Understand long format of ls command in Linux

Share this post to your friends !

This entry is part 5 of 6 in the series Linux commands: Part 3 - Exploring the system

WriteBash - This article will help you understand the long format of ls command. You may already know the ls command in Linux is used to display content in a directory.

Understanding long format will help you in some work situations. For example, you need to check the permissions of the files contained in a directory, or you want to check the timestamps of files in the directory.

“-l” option of ls command

If you remember in the previous article, the ls command when using the -l option (ie long format) will display the list result in the form of long format.

Now, see the example below. I use the ls command to display the content in the writebash.com directory.

understand-long-format-of-ls-command-in-linux Understand long format of ls command in Linux
“ls” command with “-l” option to display results in long format.

I use ls with 2 ways, ls command does not have any options and ls command with -l option. You see the results displayed in different terminal windows very clearly.

Understand long format of ls command

Now we will explore each column of information in the long format of the ls command. What does that column mean?

drwxr-xr-x : show file or directory permissions.

  • First character: the first character in this column indicates the type of file. This character is in 1 of 3 values.
    • - : the first character is - then the type is the file.
    • d : value is d then the type is the directory.
    • l : value is l then the type is the link. You can read more about links in Linux.
  • The next 3 characters rwx: show file owner permissions.
    • r : shows file read permission.
    • w : write permission of file.
    • x : show execute permission of file.
  • Next 3 characters r-x : show file group permissions.
  • The last 3 characters r-x : displays the permission of the user other for the file.

So now that you look at the image above, you can understand that hello_world is a file and the pathname is a directory.

2 : file’s number of hard links.

trungdung : this is username of the file’s owner. In this case, my username is trungdung.

trungdung : the name of the group which owns the file. My username and group has the same name.

4096 : this display size of the file in bytes.

Jan 19 11:44 : show data and time of the files last modification.

pathname : name of the file or name of the directory.

Conclusion

For this article, you can understand what information columns mean when displaying the long format of the ls command. Believe me, it’s quite useful in some work requirements.

Continue reading the series«« Previous part: Create links with ln commandNext part: Understand system directories on Linux systems »»
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.