How to identify a hard link from a soft link?
I know the difference between a hard link and a soft link. Basically a hard link is another file name to the same physical file on disk. A soft link is a special file containing the path to a regular file. If I use ls -l, I am able to see the l at the beginning of the permissions for soft links. But for hard links I do not see any such special mark except that they share the same inode if I use ls -i. How do I find out all the filenames which point to a single inode? Thanks in advance. -- Tux #395953 resides at http://samvit.org playing with KDE 3.51 on SUSE Linux 10.0 $ date [] CCE +2006-02-24 W08-5 UTC+0530
Am Freitag, 24. Februar 2006 14:17 schrieb Shriramana Sharma:
I know the difference between a hard link and a soft link. Basically a hard link is another file name to the same physical file on disk. A soft link is a special file containing the path to a regular file.
If I use ls -l, I am able to see the l at the beginning of the permissions for soft links. But for hard links I do not see any such special mark except that they share the same inode if I use ls -i.
How do I find out all the filenames which point to a single inode?
find is your friend :-) from the info page: <snip> -- Test: -samefile NAME File is a hard link to the same inode as NAME. If the `-L' option is in effect, symbolic links to the same file as NAME points to are also matched. -- Test: -inum n File has inode number N. The `+' and `-' qualifiers also work, though these are rarely useful. </snip> Oliver
On Fri, Feb 24, 2006 at 06:47:17PM +0530, Shriramana Sharma wrote:
I know the difference between a hard link and a soft link. Basically a hard link is another file name to the same physical file on disk. A soft link is a special file containing the path to a regular file.
If I use ls -l, I am able to see the l at the beginning of the permissions for soft links. But for hard links I do not see any such special mark except that they share the same inode if I use ls -i.
'man ls': -l, --format=long, --format=verbose In addition to the name of each file, print the file type, per- missions, number of hard links, owner name, group name, size in bytes, and timestamp (the modification time unless other times are selected).
How do I find out all the filenames which point to a single inode?
If they're not all in the same directory, you're probably best off using a 'find' command. HTH... -- David Smith Work Email: Dave.Smith@st.com STMicroelectronics Home Email: David.Smith@ds-electronics.co.uk Bristol, England GPG Key: 0xF13192F2
Shriramana Sharma wrote:
I know the difference between a hard link and a soft link. Basically a hard link is another file name to the same physical file on disk. A soft link is a special file containing the path to a regular file.
If I use ls -l, I am able to see the l at the beginning of the permissions for soft links. But for hard links I do not see any such special mark except that they share the same inode if I use ls -i.
Every item in a directory is a hard link, unless it's a soft link. That is when you create a file, you are in fact creating a hard link to it that appears with ls. When you delete all hard links to a file, that file is then "deleted".
participants (4)
-
David SMITH
-
James Knott
-
Oliver Wittenburg
-
Shriramana Sharma