What do the following numbers represent?
2 Answers
Let’s take this one to analyse:
-rwxrw-r-- 1 root root 4096 Dec 18 16:41 somefile.txt
We will split the output for better understanding.
Field1 Field2 Field3 Field4 Field5 Field6 Field7 Field8 Field9 Field10
- rwx rw- r-- 1 root root 4096 Dec 18 16:41 somefile.txt
First field:
-
for regular file,d
for Directory,l
for symlink
Second: The owner can read, write and execute this file
Third: The owner's group can read and write this file
Fourth: Other users can read, but not write or execute this file.
Fifth: The number of hard links to this file or directories inside this directory.
Sixth: The object's owner
Seventh: The object's owner's group. All of the users in this group (for example,
root
,user
,www-data
, etc.) are affected by the permissions in field 3.Eighth field is the object's size in bytes. Note:
ls -lh
will usek
,M
,G
,T
etc. for human readable. (Seeman ls
or runls --help
.)Ninth field: The object's last modified time; for directories this is not inheritive.
Tenth field: The object's name as stored in the filesystem's table of contents
See understanding the Unix permission model, man chmod
and apropos permissions
for more information.
Note: Some versions of ls(1)
also display the octal permissions, which are a simple way of using a number to display and store the first through fourth fields.
-
3The first field could also be
b
for a block device special file,c
for a character device special file,s
for a socket, orp
for a fifo special file (aka named pipe). You are also missing a field in between the fourth and fifth, where a single character may be appended to the permissions string, indicating Extended Attributes (@
) or Extended Security Information such as Access Control Lists (+
). The third character in field 2/3 can also bes
orS
, the third character in field 4 can also bet
orT
. Dec 18, 2015 at 17:53 -
-
3field5 = the number of hard links to this file. symlinks to a file don't add 1 to this file's 5th field. Try :
touch foo bar
and thenls -l foo bar
(both will have 1 inode pointing them). thenln foo baz
;ls -l foo bar baz
will show both foo and baz, 2 entries pointing to the same inode (pointing to the content of foo), both have "2" as their hard link number. Then add a symlink:ln -s foo toto
and still only foo & baz have 2 inodes pointing the same file, toto has 1. In the end, foo & baz will have 2, and bar & toto will have 1 in their 5th field, as both have no hardlinks to them Dec 18, 2015 at 19:13 -
Script to calculate permissions: github.com/crushedice2000/ext4-imc Dec 18, 2015 at 19:58
The numbers represents:
1
is the number of hard links
7160
the file size in bytes.
man ls
?ls
manpage on linux.die.net doesn't actually give all the relevant information. For example, it doesn't state what the timestamp is that's shown, and GNU coreutils documentation says only that it is "normally the modification timestamp".