What are symbolic link good for?
Why do we need them? both types?
I familiar with creating them ..etc but why do we need them??? Regards |
In simple words, they are like shortcuts. Suppose you've some application installed somewhere and you everytime need to follow it's full path to launch it, so in order to avoid using full path, you create a symbolic link of it on your desktop for ease of access. Similarly, you create symlink to a file which is deep inside the directory tree, so you create a symlink in your home folder or on desktop to easily access it. Also, whatever changes you make in symlink original file, gets reflected in other one.
|
Seems the OP is asking why you need "Soft links" and "Hard links"
Which is explained in great detail on websites that can be found through Google. https://www.google.com/search?q=hard+links+soft+links Turned up 13,000 results if you'd like to research it further. |
Quote:
|
If you are familiar with creating them and ... etc then you know what they are for and why they are needed. And if you DO NOT know this, then you should research the subject on the internet. It is not difficult at all to find thousands of examples and howtos and documentation on the subject.
Doing the legwork yourself will ensure a much greater understanding. Also: http://www.linuxquestions.org/questi...ymlink-799528/ http://www.linuxquestions.org/questi...-links-531463/ Don't be afraid to search LQ before posting a question. |
Assuming you know why you want links in the first place, and are only asking regarding the differences between hard links and symbolic links, for one, symbolic links can cross filesystems, hard links can't. Symbolic links can be created before the file they use as their target even exists. You can't create a hard link to a non-existant file. With a hard link, if you delete the original file, you can still access its contents via the hard link. With a symbolic link, once the original file has been deleted, you cannot access the original files contents anymore. I use symbolic links far more than hard links personally.
|
If you are indeed asking why you want links, any link type, in the first place, think of it this way:
If you want to show a friend in a different state what your house looks like, do you go up there and build a duplicate of your house (a "copy")? Or do you sent them a photograph of your existing house (a "link" - well not exactly, but for purposes of this discussion it's close enough). You don't want the resource usage (cost) of creating a duplicate "copy" of your house, you just want to "refer" to the existing house. |
Quote:
So when you create a hard link to an existing file, you're actually, and literally, giving it another name, i.e. every single one of a file's hard links literally IS that file (which is why they all have to be on the same partition). If you remove one hard link, the file will still exist under its other hard links, if any. Only when you remove the last hard link do you actually delete the file (i.e. you unlink the inode completely and make that space available for new use). A soft link, on the other hand, is a completely different beast. It's just a special kind of file that, when accessed, tells the system to jump to another location on the file tree and continue the processing there. Unlike hard links, they can cross partition boundaries, and the file location it's pointing to doesn't have to actually exist. |
Quote:
|
Don't sweat it. You basically had it right. But yeah, it could give the wrong impression, so I just thought I'd clarify it a bit more.
|
One thing not mentioned is that hard links are only valid within a single filesystem. Softlinks/symbolic links have the path to the file, so that the link can point to a file not in the same filesystem as the link itself.
Another thing not mentioned (though this is true for both hard and soft links), is that it is possible to use the name of an executable as a parameter. This has been done for things requiring a root password -- the utility that asks for the password has a symbolic name pointing to it that identifies the function. After the utility gets a proper password, it then looks up the name it was invoked by in its table to identify the specific program to run. |
All times are GMT -5. The time now is 03:49 PM. |