Linux - NewbieThis 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!
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.
I made a hard link to a file.. and now I cannot delete.. I can not figure out how to remove the hardlink either?? how do I remove it.. i rtfm's but it only says how to make one
hmmm... I did not think your could just delete the two files.. I thought the purpose of a hardlink was so that the file could not be deleted without the hardlink being removed first?
either way I will try and rm the files. I did not even think to try that.
Nah. You use hardlinks (called sym [symbolic] links in *nix) to place the same file in more than one place, or even in the same directory with a different name. Deleting the original file wont delete all of the symlinks, but it will make them useless. Deleting a symlink wont touch the original file. Hope this helps.
it is my understanding that a symbolic link is a 'shortcut' pointing to the actual file whereas a hard link is the same as having another copy of the file being (hard)linked
deleting a file will render symlinks useless
deleting a file will not affect any hardlinks, any hardlinks will still point to the same data as they did before the original file was deleted
(i tested this before my initial post for accuracy just to be sure)
...it is also possible that i am confusing what is actually being asked
it is my understanding that a symbolic link is a 'shortcut' pointing to the actual file whereas a hard link is the same as having another copy of the file being (hard)linked
deleting a file will render symlinks useless
deleting a file will not affect any hardlinks, any hardlinks will still point to the same data as they did before the original file was deleted
(i tested this before my initial post for accuracy just to be sure)
...it is also possible that i am confusing what is actually being asked
You're not confusing anything, that's accurate. MikeZila is the confusing hard and symbolic links. He thinks they're synonymous... sooner or later he'll find out they're not, probably the hard way.
If you create a hard link to a regular file, what you are really doing is creating another directory entry for the file. A directory entry contains a name and a pointer to the file's inode on the filesystem.
Note the second column in the long listing. The kernel only removes the inode if all links to the inode are deleted. For file3, there is only 1. The third listing prints the inodes as well (-i). Note how the inodes for file1 and file2 are the same. A directory entry is actually a hard link. However creating another hard link to a directory is prohibited unless the -d or -F option is used by the root user, but the kernel deny this (CAP_LINK_DIR). This is to prevent infinite recursion in the filesystem.
Next I changed the group owner of the file1. The change also effects the group ownership of file2.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.