In Linux/Unix, Shortcuts are known as Links
Link are of two types: soft links (symbolic links) or hard links.
Soft Links (symbolic links)
You can make links to files and directories, and you can create links (shortcuts) on different partition and with a different inode number from original.
If the real copy is deleted, the link will not work.
Hard links are for files only; you cannot link to a file on different partition with a different inode number.
If the real copy is deleted the link will work, because it accesses the underlying data the real copy was accessing.
Question: How do I make soft link?
Answer: A soft link can be made with
ln -s; first you need to define the source and then you need to define the destination. (Keep it mind you need to define the full paths of both source and destination; otherwise it will not work.)
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib32/libGL.so.1
(----------Source-------) ( Destination )
As you can see it has a different inode and can be made on a different partition.
Question: How do I make Hard link?
Answer: A Hard link can be made with
ln; first you need to define the source and then you need to define the destination. (Keep it mind you need to define the full path of both source and destination; otherwise it will not work.)
Let's say I have a script in the
/script directory named
ls -i # Shows you the inode
ln /scripts/firefox /scripts/on-fire
( Source ) ( Destination )
As you can see, it has same inode. If I delete the original one the link will work, and it will act as the original.
Above I check that the link is working, and then delete the original firefox script.
You Question : It would be nice if someone could provide a setting where hard link might be preferable over a symbolic link.
Answer : Depending on the disk partition layout, Hard Links have the limitation that they must be on same partition ( -1 point ) and can only link to files ( -1 point ) ), but +1 point if the original is deleted the link will work and it acts like the original.
On the other hand, a soft link can point to directories or files (+1 point) and there is no partition limitation (+1 point), but (-1 point) if the source is deleted the link will not work.