Kellowyn Kellowyn - 1 month ago 11
Linux Question

Explanation of the ls -l command in Linux?

I use the following command:

ls -l


As a result, I get the name of the files in the folder that I'm currently in, along with when they were last accessed, etc. On the left side, there are a string of characters and sometimes dashes. I was wondering if anyone can provide me a quick guide as to what each of the characters represent?

I can assume the first 'd' stands for directory, since that is the name of one of my folders. I'm assuming 'x' is for executable? Not sure, so can someone break it down for me?

This is what I'm referring to:

dr-xr-xr-x


Thanks for all of help.

Answer

From the man page of chmod:

read (r), write (w), execute (or access for directories) (x), execute only if the file is a directory or already has execute permis- sion for some user (X), set user or group ID on execution (s), sticky (t), the permissions granted to the user who owns the file (u), the permissions granted to other users who are members of the file's group (g), and the permissions granted to users that are in neither of the two preceding categories (o).

meaning

  user can read
  | user can execute
  | | group can not write
  | | | others can read
  | | | | others can execute
  | | | | |
 dr-xr-xr-x
 | | | | |
 | | | | others can not write
 | | | group can execute
 | | group can read
 | user can not Write  
 it is a directory