Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-07-2012, 05:59 AM   #1
Registered: Dec 2008
Location: east anglia
Distribution: SuSE, antiX
Posts: 40

Rep: Reputation: 8
ls -l interpretation of field 2 for dir's

OK! I understand that field 1 shows the permissions et al, and that field 2 (the field full of 1's & 2's - below) the hard links. In the example below, the file 'test' is hard linked to the file 'tets'. The 2 shows that 2 files are hard linked and pointing to the same inode.

-rwxr--r-- 2 dmk-antiX dmk-antiX 133 Oct 27 12:42 test*
-rw-r--r-- 1 dmk-antiX dmk-antiX 66 Oct 1 22:00 test2
-rw-r--r-- 1 dmk-antiX dmk-antiX 83 Oct 1 20:57
-rwxr--r-- 1 dmk-antiX dmk-antiX 191 Sep 29 21:56*
-rwxr--r-- 2 dmk-antiX dmk-antiX 133 Oct 27 12:42 tets*

But, you cannot hard link directories! So what does field 2 represent in the example below?

drwx------ 3 dmk-antiX dmk-antiX 4.0K Sep 18 21:32 .adobe/
drwxr-xr-x 2 dmk-antiX dmk-antiX 4.0K Nov 2 15:57 Bash/
drwx------ 14 dmk-antiX users 4.0K Nov 7 09:44 .cache/
drwx------ 8 dmk-antiX dmk-antiX 4.0K Sep 19 22:05 .claws-mail/
drwxr-xr-x 22 dmk-antiX users 4.0K Nov 5 10:15 .config/

Anyone wanting more (and better) info might do well to look at one of these:

Thanks for any help


Last edited by TheBigMing; 11-07-2012 at 08:04 AM. Reason: spelling
Old 11-07-2012, 06:52 AM   #2
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Hi, that's because each directory contains a '.' directory which is a hardlink to itself. Also, if you create a directory inside it, ls -l will show 3 hardlinks, because the new directory contains '..' which is a hardlink to its parent directory.
2 members found this post helpful.
Old 11-07-2012, 07:54 AM   #3
Registered: Dec 2008
Location: east anglia
Distribution: SuSE, antiX
Posts: 40

Original Poster
Rep: Reputation: 8
Thanks miligates - I can't pretend to follow this entirely but I get the gist. I can now stop worrying about it!


ps. I've added your info to my notes and tagged it ln & ls.

Last edited by TheBigMing; 11-07-2012 at 08:04 AM. Reason: adding info


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sort certain field but preserve other field data akeka Programming 2 05-21-2012 04:01 PM
[SOLVED] Count occurrence of character in field and print in a new field Trd300 Linux - Newbie 5 03-21-2012 07:57 PM
[SOLVED] awk: how to print a field when field position is unknown? elfoozo Programming 12 08-18-2010 03:52 AM
awk printing from Nth field to last field sebelk Programming 2 01-08-2010 09:39 AM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration