12

What do the following numbers represent?

Tim
  • 32,274
  • 27
  • 118
  • 177
LearningIsFun
  • 137
  • 1
  • 1
  • 3
  • 3
    they are file permissions and properties. perhaps you should have a good readin here https://wiki.archlinux.org/index.php/File_permissions_and_attributes – ostendali Dec 18 '15 at 14:32
  • 2
    How many time did you read `man ls`? – Ken Sharp Dec 18 '15 at 22:28
  • @KenSharp The copy of the `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". – AJM Aug 17 '22 at 13:20
  • Though I admit I don't know of any situation in which it's been, say, another timestamp like the status change or creation date. – AJM Aug 17 '22 at 13:20

2 Answers2

20

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 use k, M, G, T etc. for human readable. (See man ls or run ls --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.

Byte Commander
  • 105,631
  • 46
  • 284
  • 425
Maythux
  • 82,867
  • 54
  • 239
  • 271
  • 3
    The first field could also be `b` for a *block device special file*, `c` for a *character device special file*, `s` for a *socket*, or `p` 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 be `s` or `S`, the third character in field 4 can also be `t` or `T`. – Jörg W Mittag Dec 18 '15 at 17:53
  • @JörgWMittag right you are. you can edit that in, if you like – cat Dec 18 '15 at 18:44
  • 3
    field5 = 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 then `ls -l foo bar` (both will have 1 inode pointing them). then `ln 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 – Olivier Dulac Dec 18 '15 at 19:13
  • Script to calculate permissions: https://github.com/crushedice2000/ext4-imc – 0x2b3bfa0 Dec 18 '15 at 19:58
4

The numbers represents:

1 is the number of hard links

7160 the file size in bytes.

heemayl
  • 90,425
  • 20
  • 200
  • 267
LilloX
  • 1,987
  • 11
  • 16