I run
ln /a/A /b/B
I would like to see at the folder a where the file A points to by ls.
How can you see the actual hard link by ls?
feedback
|
This question came from our site for professional and enthusiast programmers.
|
You can find inode number for your file with
and
shows references count (number of hardlinks to particular inode) after you found inode number, you can search for all files with same inode:
will show filenames for inode NUM in current dir (.) | |||||||||
feedback
|
|
There isn't really a well-defined answer to your question. Unlike symlinks, hardlinks are indistinguishable from the original file. Filenames in directories are just references to an inode (which contains the file contents and file attributes). Creating a hard link creates another reference to the same inode. These references are unidirectional (in typical filesystems, at least) -- the inode only keeps a reference count. This means that the only way to find the other references to a given inode is to exhaustively search over the file system checking which files refer to the inode in question. You can use 'test A -ef B' from the shell to perform this check. | |||||
feedback
|
|
UNIX has hard links and symbolic links (made with Hard links have been around since the earliest days of UNIX (that I can remember anyway, and that's going back quite a while). They are two directory entries that reference the exact same underlying data. The data in a file is specified by its Since inodes are unique only for a given filesystem, there's a limitation that hard links must be on the same filesystem (unlike symbolic links). Note that, unlike symbolic links, there is no privileged file - they are all equal. The data area will only be released when all the files using that inode are deleted (and all processes close it as well, but that's a different issue). You can use the Here's a script which does exactly that. You invoke it with:
and it will find all files on that filesystem which are hard links for that file:
Here's the script.
| |||||||||||
feedback
|
The first column will represent permissions. The second column will be the number of sub-items (for directories) or the number of paths to the same data (hard links, including the original file) to the file. Eg:
| |||
|
feedback
|
|
Based on the 'findhardlinks' script (renamed it to: hard-links), this is what I have refactored and made it work. Output:
| |||
|
feedback
|