Linking is akin to making shortcuts in Windows, in that it enables quick access to a file which is in a different directory. There are two different kinds of links that can be created:
- Hard Links
- These are special links, which create a new pointer to an existing file. This allows you to access the same file on disk from two different "files on system" (ie files as shown by ls). If one of the "files on system" is deleted, that pointer is removed and that "file on system" is also removed, but the "file on disk" and the "file on system" at the other location are still there. Note that it is impossible to hard link directories.
- Soft Links
- Soft links are the actual windows shortcuts, which point the OS to a different file when you try to access it. But if the target file is removed, your link is now sitting there pointing at nothing and essentially useless. Conversely, removing a soft link does nothing to the target file.
To create a link:
ln -options Path/to/target LinkName
where -s
is the most common option, asking to create a soft link.