This is a discussion on O/P of ls -l command within the Linux software forums, part of the Linux Getting Started category; Hi All: I am having small query regarding ls -l command. Have a look at the following o/p dr-xr-xr-x 181 ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Hi All:
I am having small query regarding ls -l command. Have a look at the following o/p dr-xr-xr-x 181 root root 12288 Nov 23 18:39 a drwxr-xr-x 2 root root 4096 Dec 29 04:45 bin drwxrwxr-x 4 94 141 3072 Dec 5 18:56 boot drwxr-xr-x 10 root root 6460 Dec 28 16:06 dev drwxr-xr-x 126 94 141 12288 Dec 29 12:14 etc drwxr-xr-x 8 root root 4096 Nov 4 17:33 home drwxr-xr-x 2 root root 4096 Aug 12 2004 initrd drwxrwxr-x 10 94 141 12288 Dec 28 12:22 lib drwx------ 2 root root 16384 Mar 23 2005 lost+found drwxr-xr-x 4 root root 4096 Dec 28 16:06 media drwxr-xr-x 2 root root 4096 Mar 24 2005 misc drwxr-xr-x 2 root root 0 Dec 28 16:06 mnt drwxr-xr-x 10 root root 4096 Dec 27 11:30 opt dr-xr-xr-x 151 root root 0 Dec 28 21:35 proc drwxr-x--- 80 root root 12288 Dec 29 11:25 root drwxr-xr-x 2 root root 12288 Dec 29 04:52 sbin I just wanted to know the meaning of "126" in drwxr-xr-x 126 94 141 12288 Dec 29 12:14 etc or meaning of "80" in drwxr-x--- 80 root root 12288 Dec 29 11:25 root Thanks! Ashish |
| Sponsored Links | ||
|
|
|
|||
|
Well, I also thought those numbers are links, but now, I don't think that those numbers indicates links.
To test this I have crated directory at / [root@SwiftLinux /]# mkdir ashish [root@SwiftLinux /]# ls -l total 204 dr-xr-xr-x 181 root root 12288 Nov 23 18:39 a drwxr-xr-x 2 root root 4096 Dec 30 11:01 ashish drwxr-xr-x 2 root root 4096 Dec 30 04:02 bin drwxrwxr-x 4 94 141 3072 Dec 30 10:57 boot As per your comment ashish directory is having 2 links now.. drwxr-xr-x 2 root root 4096 Dec 30 11:01 ashish Now I changed my directory to /root and created one link for same directory [root@SwiftLinux ~]# ln -s /ashish/ . [root@SwiftLinux ~]# ls -l total 142984 drwxr-xr-x 2 root root 4096 Oct 25 18:10 drwxr-xr-x 2 root root 4096 Dec 12 12:02 aaa lrwxrwxrwx 1 root root 8 Dec 30 11:02 ashish -> /ashish/ -rw-r--r-- 1 root root 78875256 Dec 29 20:06 attachment.part drwxr-xr-x 2 root root 4096 Jul 11 18:51 bbb and again have a look at ls -l o/p at / [root@SwiftLinux ~]# cd / [root@SwiftLinux /]# ls -l total 204 dr-xr-xr-x 181 root root 12288 Nov 23 18:39 a drwxr-xr-x 2 root root 4096 Dec 30 11:01 ashish It is still showing 2, by considering those numbers are for links, it should have shown 3 but it showing 2. |
|
|||
|
I am not sure but I think the links in the ls -l o/p refer to the relative and absolute links with respect to the current directory and not a symbolic link or hardlink.
I think it is insane to have 126 symbolic links to a dir or file. Lets compare. As per your example, if you have created ashih under /, and create another directory under ashish named test, the o/p od ls -l will show 3 for the dir ashish now. but test will show 2 links like below : Code:
rc@quark:~/public_html> ls -la total 6 drwxr-xr-x 3 quark users 104 2005-12-30 15:15 . drwxr-xr-x 30 quark users 1912 2005-12-18 10:07 .. -rw-r--r-- 1 quark users 48 2005-07-18 15:23 .directory drwxr-xr-x 3 quark users 72 2005-12-30 15:29 rc rc@quark:~/public_html> ls -la total 6 drwxr-xr-x 3 quark users 104 2005-12-30 15:15 . drwxr-xr-x 30 quark users 1912 2005-12-18 10:07 .. -rw-r--r-- 1 quark users 48 2005-07-18 15:23 .directory drwxr-xr-x 3 quark users 72 2005-12-30 15:29 rc ricc |
|
||||
|
Yes it indicates the number of links to file /ashish
Let us start with an example Code:
cd /tmp mkdir demo ls -l This is an empty directory still you see 2 links, how? Because all directories have at least 2 links. Every directory contains two subdirectories "." and ".." The first is a link to itself, and the second is a link to the parent directory. Thus, there are two links to the directory file "demo" Now type command to make a subdirectory of one: Code:
mkdir demo/one ls -ld demo/ Now it is updated to 3. These subdirectories links which are automatically created for you, you cannot manually create links to directories. Now create a soft link inside demo Code:
cd demo ln -s one one-soft ls -l lrwxrwxrwx 1 root root 3 2005-12-30 15:22 one-soft -> one Now see demo directory: Code:
cd .. ls -ld demo/ It is still 3 why? Creation of a soft link to "one" (inside demo dir) doesn't update the link field of demo inode or directory. Hope this helps. |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|