What is the meaning of those numbers in the second column after typing "ls -l"?

8

8

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?

Nick Dong

Posted 2012-07-02T01:35:49.753

Reputation: 208

Question was closed 2019-03-12T19:47:35.067

2@tpg2114 Your first comment is accurate but, on at least one machine I can connect to your second is completely wrong. – mlp – 2019-03-11T15:29:23.017

See also What do the fields in ls -l output mean? (on U&L).

– Scott – 2019-03-11T15:34:58.287

@mlp That's possible, but it's also possible both were accurate in 2012 and have since changed. I'm positive I tried it on whatever systems I had access to at the time! – tpg2114 – 2019-03-11T16:51:34.060

5You can just man ls – None – 2012-07-02T01:36:58.207

4Please 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 – 2012-07-02T01:37:44.850

2info ls gives the information you need, man ls just points you to the info page. – tpg2114 – 2012-07-02T01:37:56.927

Answers

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.

bdonlan

Posted 2012-07-02T01:35:49.753

Reputation: 1 463

2

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

Levon

Posted 2012-07-02T01:35:49.753

Reputation: 740

1The article link is broken... – Rick – 2018-03-06T12:32:09.807

@Rick Thanks for the heads-up, I just linked an alternative site to this. – Levon – 2018-03-06T15:43:38.637

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.

user1006581

Posted 2012-07-02T01:35:49.753

Reputation: 1

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.

ennuikiller

Posted 2012-07-02T01:35:49.753

Reputation: 980