8

This question already has an answer here:

drwxr-xr-x. 2 root root 4096 Jun 29 16:44 db
drwxr-xr-x. 2 root root 4096 Jun 29 16:44 djproject
-rwxr-xr-x. 1 root root   38 Jun 29 16:44 index.html
drwxr-xr-x. 2 root root 4096 Jun 29 16:44 jobs
-rwxr-xr-x. 1 root root  252 Jun 29 16:44 manage.py
drwxr-xr-x. 3 root root 4096 Jun 29 16:44 templates

What is the meaning of those numbers in the second column? Do they have some relation to file and folder permissions? How do I change the numbers?

marked as duplicate by Scott, PeterH, Burgi, bertieb, Ben Richards Mar 12 at 19:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Jul 2 '12 at 1:38

This question came from our site for professional and enthusiast programmers.

  • 5
    You can just man ls – VanDarg Jul 2 '12 at 1:36
  • 4
    Please accept some of the answers to your previous questions. You can do this by clicking the check mark next to the answer that you feel best answered the question. – bdonlan Jul 2 '12 at 1:37
  • 2
    info ls gives the information you need, man ls just points you to the info page. – tpg2114 Jul 2 '12 at 1:37
  • 2
    @tpg2114 Your first comment is accurate but, on at least one machine I can connect to your second is completely wrong. – mlp Mar 11 at 15:29
  • See also What do the fields in ls -l output mean? (on U&L). – Scott Mar 11 at 15:34
19

That's the number of hard links to the file or directory. For files, this will usually be 1, unless you've created additional hard links to it with ln.

For directories, it's 2 + the number of subdirectories. This is because a directory can be referred to either by its name in the parent directory, . in itself, or .. in each subdirectory.

2

This indicates the number of hard links. This article explain the output of the ls -l command in more detail.

  • 1
    The article link is broken... – Rick Mar 6 '18 at 12:32
  • @Rick Thanks for the heads-up, I just linked an alternative site to this. – Levon Mar 6 '18 at 15:43
0

The numbers in the second column is effectively the number of "links" to the file or directory. It is similar to the concept of reference count in oop.

0
drwxr-xr-x 2 matt db 4096 Jan 30 23:08 documents

-rw-r--r-- 1 matt db   49 Jan 31 01:17 sum.pl

The first character indicates the type of the file. - for normal file, d for directory, l for link file and s for socket file

The next 9 characters in the first field represent the permissions. Each 3 characters refers the read (r), write (w), execute (x) permissions on owner, group and others. - means no permission.

The second field indicates the number of links to that file.

The third field indicates the owner name.

The fourth field indicates the group name.

The fifth field represents the file size in bytes.

The sixth field represents the last modification date and time of the file.

And finally the seventh field is the name of the file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.