what does terminal command: ls -l show?

mharris7190 picture mharris7190 · Jul 10, 2013 · Viewed 65.7k times · Source

I know that it outputs the "long" version but what do each of the sections mean?

On my mac, when I type in

ls -l /Users 

I get

total 0
drwxr-xr-x+ 33 MaxHarris  staff  1122 Jul  1 14:06 MaxHarris
drwxrwxrwt   8 root       wheel   272 May 20 13:26 Shared
drwxr-xr-x+ 14 admin      staff   476 May 17 11:25 admin
drwxr-xr-x+ 44 hugger     staff  1496 Mar 17 21:13 hugger

I know that the first line it the permissions, although I don't know what the order is. It would be great if that could be explained too. Then whats the number after it?

Basically, what do each one of these things mean? Why are the usernames written twice sometimes and don't match other times?

Answer

rodelarivera picture rodelarivera · Jul 10, 2013

The option '-l' tells the command to use a long list format. It gives back several columns wich correspond to:

  • Permissions
  • Number of hardlinks
  • File owner
  • File group
  • File size
  • Modification time
  • Filename

The first letter in the permissions column show the file's type. A 'd' means a directory and a '-' means a normal file (there are other characters, but those are the basic ones). The next nine characters are divided into 3 groups, each one a permission. Each letter in a group correspond to the read, write and execute permission, and each group correspond to the owner of the file, the group of the file and then for everyone else.

  • [ File type ][ Owner permissions ][ Group permissions ][ Everyone permissions ]

The characters can be one of four options:

  • r = read permission
  • w = write permission
  • x = execute permission
  • - = no permission

Finally, the "+" at the end means some extended permissions.