 |
|
 |
|
|
 |
second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 12:24 PM
Hi,
It's said that the second column of ls -l shows the number of hard links
to the file. The file under investigation has 15 links. But when I run
find / -samefile ./myfile -print, it shows only one. After all, I don't
think that I had created all these hard links, or soft ones. So what
exactly does the second column mean?
Thanks.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 06:20 PM
On Aug 17, 5:47 am, Jerry Fleming <jerry.flem...@saybot.com> wrote:
> Hi,
>
> It's said that the second column of ls -l shows the number of hard links
> to the file. The file under investigation has 15 links. But when I run
> find / -samefile ./myfile -print, it shows only one. After all, I don't
> think that I had created all these hard links, or soft ones. So what
> exactly does the second column mean?
The second column should be the number of links. Is the file in
question a directory?
Robert Gamble
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 06:20 PM
Jerry Fleming <jerry.fleming@saybot.com> writes:
> Hi,
>
> It's said that the second column of ls -l shows the number of hard
> links to the file. The file under investigation has 15 links. But when
> I run find / -samefile ./myfile -print, it shows only one. After all,
> I don't think that I had created all these hard links, or soft
> ones. So what exactly does the second column mean?
OK, first check that myfile is not a directory with 13
sub-directories. If is it all is as it should be, but I doubt you
would have posted in that case! Next...
I'd check with another program such as stat (if you have it) just to
get a second opinion. You might be using an odd version of ls (or
maybe even one whose behaviour has been customised by environment
variable settings). Check also what ls is running (I've seen distros
that have it as an alias by default).
If stat confirms the multiple links, and find does not find them, your
file system may be messed up -- un-mount it and fsck it.
--
Ben.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 06:20 PM
Ben Bacarisse wrote:
> Jerry Fleming <jerry.fleming@saybot.com> writes:
[vbcol=seagreen]
> If stat confirms the multiple links, and find does not find them, your
> file system may be messed up -- un-mount it and fsck it.
There are other possibilities. For instance, the other links may be
obscured by a filesystem mounted on top of the directory that contains
them:
touch a
mkdir b
for i in 1 2 3 4 5
do
ln a b/"$i"
done
mount /dev/whatever `pwd`/b
Now when you do the 'find', you will not find the files '1' through '5',
but the link count on 'a' should still reflect them.
Or, to put it another way, 'find' and 'ls' reflect what you see at the
vfs layer, but the link count is something that exists at the layer of
the individual filesystem.
- Logan
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 06:20 PM
Logan Shaw <lshaw-usenet@austin.rr.com> writes:
> Ben Bacarisse wrote:
>
>
>
> There are other possibilities. For instance, the other links may be
> obscured by a filesystem mounted on top of the directory that contains
> them:
Yes, that is a good point (I said "may" because I was pretty sure
there could be other reasons for the discrepancy).
To the OP: does the filesystem containing "myfile" have other FSs
mounted within it? If so, unmount these, and check find again.
The links reported by stat can only be from withing the same
filesystem, so you only need to unmount those that might be "on top"
of it. If in doubt, post the output of mount.
--
Ben.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-17-07 06:20 PM
Jerry Fleming <jerry.fleming@saybot.com> wrote:
# Hi,
#
# It's said that the second column of ls -l shows the number of hard links
# to the file. The file under investigation has 15 links. But when I run
# find / -samefile ./myfile -print, it shows only one. After all, I don't
# think that I had created all these hard links, or soft ones. So what
# exactly does the second column mean?
Do you mean find -print or find -ls (or find -print | xargs ls -l)?
find -ls is a slightly different format from ls -l.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
GERBILS
GERBILS
GERBILS
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-22-07 06:23 AM
SM Ryan wrote On 2007年08月18日 01:19, :
> Jerry Fleming <jerry.fleming@saybot.com> wrote:
> # Hi,
> #
> # It's said that the second column of ls -l shows the number of hard links
> # to the file. The file under investigation has 15 links. But when I run
> # find / -samefile ./myfile -print, it shows only one. After all, I don't
> # think that I had created all these hard links, or soft ones. So what
> # exactly does the second column mean?
>
> Do you mean find -print or find -ls (or find -print | xargs ls -l)?
> find -ls is a slightly different format from ls -l.
>
> --
> SM Ryan http://www.rawbw.com/~wyrmwif/
> GERBILS
> GERBILS
> GERBILS
No, I use exactly find / -samefile ./myfile -print.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-22-07 06:23 AM
Ben Bacarisse wrote On 2007年08月17日 21:16, :
> Jerry Fleming <jerry.fleming@saybot.com> writes:
>
>
> OK, first check that myfile is not a directory with 13
> sub-directories. If is it all is as it should be, but I doubt you
> would have posted in that case! Next...
>
> I'd check with another program such as stat (if you have it) just to
> get a second opinion. You might be using an odd version of ls (or
> maybe even one whose behaviour has been customised by environment
> variable settings). Check also what ls is running (I've seen distros
> that have it as an alias by default).
>
> If stat confirms the multiple links, and find does not find them, your
> file system may be messed up -- un-mount it and fsck it.
>
Yes, it is a directory, but there are no 13 sub-directories -- even
there are, I was wondering that the sub-dir are not hard links to the
parent directory.
I did a `stat`, and it is consistent with ls.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-22-07 06:23 AM
Ben Bacarisse wrote On 2007年08月17日 21:16, :
> Jerry Fleming <jerry.fleming@saybot.com> writes:
>
>
> OK, first check that myfile is not a directory with 13
> sub-directories. If is it all is as it should be, but I doubt you
> would have posted in that case! Next...
>
> I'd check with another program such as stat (if you have it) just to
> get a second opinion. You might be using an odd version of ls (or
> maybe even one whose behaviour has been customised by environment
> variable settings). Check also what ls is running (I've seen distros
> that have it as an alias by default).
>
> If stat confirms the multiple links, and find does not find them, your
> file system may be messed up -- un-mount it and fsck it.
>
No, there are no 13 sub-dir, no is my ls old -- I am working on Ubuntu
Feisty, which is very new. No mysterious alias, no unknown mounts, no
anything uncertain, because the system is newly installed.
I tried with other systems (i.e, gentoo linux), and get the same
confusing result. So I am sure no fsck is needed, but my understanding
of ls and hard links will have to be reformed
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: second column of ls -l doesn't show number of hard links |
 |
 |
|
|
08-22-07 06:23 AM
In article <faga5c$fdm$1@news.cn99.com>,
Jerry Fleming <jerry.fleming@saybot.com> wrote:
> Ben Bacarisse wrote On 2007年08月17日 21:16, :
>
> Yes, it is a directory, but there are no 13 sub-directories -- even
> there are, I was wondering that the sub-dir are not hard links to the
> parent directory.
The ".." entry in each subdirectory is a hard link to the original
directory. The link count of a directory is 2+subdirectories, because
each subdirectory has a ".." link, the directory itself has a "." link,
and its parent directory has a link to the directory.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
[ Post a follow-up to this message ]
|
|
|
 |
|
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 03:09 AM. |
 |
|
|
 |
|
 |
|
|
 |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
|
|
|
|
Medical and Health forum | Computer Games Reviews | Graphics design forum
|
 |
|
 |
|