Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It's known that a soft link can be distinguished by the 'l' in the o/p of ls -l. But is there any way to distinguish a hard link from the original file ?
Regards
Last edited by techie_san778; 05-31-2016 at 02:58 AM.
yes descendant_command, i actually meant the original file-name. Sorry for using the phrase "File". Let's say /abc/text is to be linked. $ ln /abc/text /def/note
How to differentiate note from text ?
But is there any way to distinguish a hard link from the original file ?
No, you will not be able to tell which one was the "original" and which one is the link, because both of them are just entries in different directories pointing to the same content/file/inode. So there are no two files stored, just one, and that is the original one.
One has the name 'note', the other has the name'text' and they are both the same file.
What do you mean by "differentiate"?
I suspect that the OP considers one directory entry to be the "original" and one just to be a hard link to the original, and wants to differentiate between them.
In reality, of course, both directory entries point to the same inode ("file" so to speak), they are both hard links to the "original" file.
@ descendant_command I meant that just as the 'l' in the o/p of ls -l means it is a soft link, is there any notation that denotes the file is a hard link ?
by default every entry in a directory is a hardlink to an inode (especially a directory itself is a file, just handled differently)
using ls -l you will see a number after the access rights, that will tell you how many directory entries (filenames) uses the given inode:
ls -l /bin/bzip2 (if that works for you)
-rwxr-xr-x 3 root root 31152 okt 21 2013 bzip2
If you put an apple on a table, leave the room, and view it from outside the window and from outside the open door, which is the 'original' view of the apple?
It's known that a soft link can be distinguished by the 'l' in the o/p of ls -l. But is there any way to distinguish a hard link from the original file ?
Regards
You could try hard-linking an existing file, and then try changing properties like permissions, mtime, or owner. When I tried this, the original and the link always showed the same.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.