e

How-To create Symlinks and Hardlinks

Symbolic Links (Symlinks)

A symlink is a “pointer” to another file or directory, often referred to as a “shortcut” in the Windows world. If you delete the link, the target (original file) will not be deleted. If you want to create a symlink of a file or directory to somewhere else, you have to do that with the following command in a terminal:

ln -s <source> <target>

If you have, for example, moved your movies from your home partition or folder to another partition (that is mounted here at /mnt/movies), but you want to be able to access the movies-folder in your home folder, the command would look like that:

ln -s /mnt/movies /home/<user>/movies

<user> would be replaced by your username.

Hardlinks

From a user's perspective a hardlink is another copy of the same file in a different location. Technically speaking, that is not correct; in reality they are the same file which just appears to be in 2 places. This is important to know, because if you delete the link, the target will be deleted, too! So be careful with those. Usually a file has only one hardlink, though it is possible to have more.

To create a hardlink use the same syntax as for a symlink without the -s argument.

ln <source> <target>

More information

The manual page for ln can be accessed using the command

man ln

However, the complete and authoritative documentation is available by:

info ln

—-

User Feedback

links_-_symlinks_and_hardlinks
Did you find this article helpful?
Yes, right on the money!
 
100%(5)
Somewhat. Needs work.
0%(0)
Not really
0%(0)
Not at all.
0%(0)

If you would like to comment or make further suggestions, please leave a note on our Comments page (you will have to Create an Account if you haven't already).

 
links_-_symlinks_and_hardlinks.txt · Last modified: 2011/05/25 07:27 by ottermaton · [Old revisions]


© Copyright Bodhi Linux 2012. All Rights Reserved - Hosted by vaultnetworks