nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

O/P of ls -l command

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 ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 12-29-2005, 01:46 PM
Member
User
 
Join Date: Jan 2005
Location: Pune, India.
Posts: 47
Rep Power: 0
Ashish Pathak
Send a message via MSN to Ashish Pathak Send a message via Yahoo to Ashish Pathak
Default O/P of ls -l command

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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-29-2005, 07:25 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

126 or 80 are number of links. The ls -l output format can be explain as follows for entry:
Code:
drwxr-xr-x  112 root root 8192 2005-12-29 19:16 /etc
file mode: drwxr-xr-x
number of links: 112
owner name: root
group name: root
number of bytes in the file: 8192
date (last modified): 2005-12-29
time (last modified): 19:16
filename/path: /etc

Hope this helps
Reply With Quote
  #3 (permalink)  
Old 12-30-2005, 11:21 AM
Member
User
 
Join Date: Jan 2005
Location: Pune, India.
Posts: 47
Rep Power: 0
Ashish Pathak
Send a message via MSN to Ashish Pathak Send a message via Yahoo to Ashish Pathak
Default

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.
Reply With Quote
  #4 (permalink)  
Old 12-30-2005, 03:23 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

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
Elders....!!! Please correct me if I am wrong.

ricc
Reply With Quote
  #5 (permalink)  
Old 12-30-2005, 03:28 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Yes it indicates the number of links to file /ashish

Let us start with an example

Code:
cd /tmp
mkdir demo
ls -l
drwxr-xr-x 2 root root 4096 2005-12-30 15:13 demo/

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/
drwxr-xr-x 3 root root 4096 2005-12-30 15:17 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
drwxr-xr-x 2 root root 4096 2005-12-30 15:21 one
lrwxrwxrwx 1 root root 3 2005-12-30 15:22 one-soft -> one

Now see demo directory:
Code:
cd ..
ls -ld demo/
drwxr-xr-x 3 root root 4096 2005-12-30 15:22 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.
Reply With Quote
  #6 (permalink)  
Old 12-30-2005, 04:19 PM
Member
User
 
Join Date: Jan 2005
Location: Pune, India.
Posts: 47
Rep Power: 0
Ashish Pathak
Send a message via MSN to Ashish Pathak Send a message via Yahoo to Ashish Pathak
Default

Okie.. Cool..
I got it. Now, Can we say that, these numbers indicates the addition of all subdirectoris and files (not link in given directory?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 08:47 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36