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.
If I create a link to a file; for instance, so that its icon is shown on the Desktop. If I then delete the link by rm <file> or by sending it to trash does the actual file get deleted.
I just sent a link to my whole windows hard disk to trash and then I realised it might cause a problem and unlinked it.
I had assumed that if I dragged aWould that be wrong. file from Konquerer to my desktop and created a link that I was just making a Windows-like shortcut. Is that wrong?
Deleting a link should not remove the file. If your unsure, create a backup of the file, then link the actual file. Then remove the link and see if your file is still there.
Originally posted by mysterio If it's a soft or symlink it won't, but if it's a hard link I think it will delete the file.
That is correct, forgot to mention that. Best thing to do though if in doubt, just make a backup copy of the linked file.. always play it safe, cause you never know right..
Hi all,
I am trying to get and add more information about linking file.
I tried myself linking a file in hard and symbolic way. I found that we can not make a hard link to another partition, no matter what file system used in. By making a hard link we actually making another name (new file) of the same data that the first name (old file) refer to. The data stored in hard disk, whose certain range of address, is one, but the file name that refer to it can be more than one (by making a hard link). So then, if we delete one file, we will still have another.
Differ than hard link, symbolic link can be made to another partition which uses native linux file system. What the symbolic link actually does is only link a new file name to the old (real) file name, without knowing of its data. This means the sym link (new file) does not know in which area the data reside in the hard disk. Thus, if we delete the sym link, the real file name with its data will still remain. On the other hand, if we delete the real file, the sym link will become a broken link.
I hope that is correct, pls remind me if im wrong.
Distribution: Mandrake as base, most software hand rolled
Posts: 80
Rep:
Quote:
Originally posted by mysterio If it's a soft or symlink it won't, but if it's a hard link I think it will delete the file.
Actually, it won't It will just decrease the ref count of the original inode by one. But as there is still the directory entry for the original file referencing it, the ref count goes down to 1, not zero (assuming there was only one ref to the file), so the file remains happily alive.
Distribution: Mandrake as base, most software hand rolled
Posts: 80
Rep:
Quote:
Originally posted by levian Hi all,
I am trying to get and add more information about linking file.
I tried myself linking a file in hard and symbolic way. I found that we can not make a hard link to another partition, no matter what file system used in.
Cheers
Hard links (or just links) are actually directory entries which point to the same inode as the original file. Thus if you do:
Code:
ln a b
b is now a directory entry whose inode is the same as that of file a. This means that they point to the same data. That is why you cannot cross filesystem boundaries with hard links, as inode are file system specific.
Symlinking:
Code:
ln -s a b
creates a second file, with its own inode, with a special type that causes it to refer to the first file. It is effectively a different file - just one that points to the first one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.