17
5
Can any one explain -rw-rw-r--. 1
and give some "detailed" information on ls -lart command.
Specifically, what does the number 1
after the file permissions mean?
Why does it change or why is it different for different files?
17
5
Can any one explain -rw-rw-r--. 1
and give some "detailed" information on ls -lart command.
Specifically, what does the number 1
after the file permissions mean?
Why does it change or why is it different for different files?
15
Some examples:
-rwxrw-r-- 1
is a file with read, write and execute privileges for the owner. The group has read and write, and others have only read. There are no links to this data.
drwxr-xr-x 10
is a directory with 8 files. The extra 2 are .
and ..
. Only the owner can create files in this directory, others can access which files are in the directory, and read the contents of those files if the privileges allow.
-r-------- 2
is a file which only the owner can read, but cannot execute or modify. It has a link, which means there is another file reference on disk somewhere that accesses the same data. So the actual "file content" on disk has 2 "files" referencing it. These links are often created using ln
without supplying -s
.
So:
-
or d
indicating file or directory.r
ead, w
rite, and ex
ecute for the owner.See chapter The Long Format of man ls
.
My distro (Linux Mint 18.3) doesn’t have such a chapter in ls
’s man page. None of the fields are explained there. I think it’s the same for Ubuntu. – bleistift2 – 2020-02-20T16:42:32.010
As @sapht said the number(for a directory) at the end implies the number of files in a directory is wrong I guess. Because I have thousands of files in directory and it is still showing 2 – VAR121 – 2012-09-21T12:08:28.927
I've never seen an ls that doesn't print directory subnode count using long format. Which OS/distribution are you on? Gnu ls, , busybox and darwin all print the node count. Is it really a directory and not another node type? – sapht – 2012-09-21T15:17:20.027
5
For files it is the number of hard-links to the contents of the file. 1 means no hard-links (the typical case), a number N above 1 means this and another N-1 filenames share the same contents.
For directories most but not all filesystems report a link count of 2+N where N is the number of sub-directories.
1
[max@localhost ~]$ ll
total 4
drwxrwxr-x 2 max max 4096 Sep 25 17:11 zzz
Here 2 means number of link count
now I will create 3 directories inside zzz
now value changes to 5
[max@localhost ~]$ cd zzz [max@localhost zzz]$ mkdir a b c drwxrwxr-x 5 max max 4096 Sep 25 17:16 . drwx------ 5 max max 4096 Sep 25 17:12 .. drwxrwxr-x 2 max max 4096 Sep 25 17:16 a drwxrwxr-x 2 max max 4096 Sep 25 17:16 b drwxrwxr-x 2 max max 4096 Sep 25 17:16 c
[max@localhost zzz]$ cd
[max@localhost ~]$ ll
total 4
drwxrwxr-x 5 max max 4096 Sep 25 17:16 zzz
That is because now 5 directories are present inside zzz 3 are a
b
c
and 2 are hidden directories .
..
if I create file then nothing will happen to link count
[max@localhost zzz]$ touch 1 2 3 [max@localhost zzz]$ ls -al total 20 drwxrwxr-x 5 max max 4096 Sep 25 17:26 . ------> current directory link count drwx------ 5 max max 4096 Sep 25 17:12 .. ------> parent directory link count -rw-rw-r-- 1 max max 0 Sep 25 17:26 1 -rw-rw-r-- 1 max max 0 Sep 25 17:26 2 -rw-rw-r-- 1 max max 0 Sep 25 17:26 3 drwxrwxr-x 2 max max 4096 Sep 25 17:16 a drwxrwxr-x 2 max max 4096 Sep 25 17:16 b drwxrwxr-x 2 max max 4096 Sep 25 17:16 c [max@localhost zzz]$ cd [max@localhost ~]$ ll total 4 drwxrwxr-x 5 max max 4096 Sep 25 17:26 zzz
but if I delete any directory then link count will change
[max@localhost zzz]$ rmdir b c [max@localhost zzz]$ cd [max@localhost ~]$ ll total 4 drwxrwxr-x 3 max max 4096 Sep 25 17:28 zzz
Much (maybe too much) detail for dirs not a word for files. – ndemou – 2019-01-16T16:26:40.597
4http://en.wikipedia.org/wiki/Filesystem_permissions#Notation_of_traditional_Unix_permissions – Karoly Horvath – 2012-09-21T10:03:00.777
2Have you tried finding information yourself (manual pages, etc.)? Was the information unclear? – Daniel Andersson – 2012-09-21T10:14:00.487
1@yi_H, I don't see any information on the number after the permissions. – Shahbaz – 2012-09-21T10:25:46.250
1I was sure user1688102's question had already been asked and answered but can't find it. @Shahbaz: it;s the number of references to the same inode, i.e. the number of hard-links, i.e. the number of different names for the same file (excluding soft-links). – RedGrittyBrick – 2012-09-21T10:40:53.303
1I've seen the man ls page. The information was not clear and no information was provided regarding permissions in man ls @Daniel – VAR121 – 2012-09-21T12:03:42.427