Creating Soft link or alias

Posted under » Linux on 30 September 2009

Hard link vs. Soft link in Linux or UNIX

Hard link makes /original/file and /new/link the same file - edit one and the other will change. The file will not be gone until both /original/file and /new/link are deleted.

Soft or symbolic links are just like shortcuts in windows. Unlike hardlinks, it allows to associate multiple filenames with a single file. However, symbolic links allows:

You can only do this with files. For folders, you must make a "soft" link. These links behave differently when the source of the link is moved or removed.

Creating hard link

$ ln resolv.conf alink.conf 
$ ln /etc/apache2/sites-available/www.taik.conf /etc/apache2/sites-enabled/www.taik.conf 

Creating soft link -s

$ ln -s resolv.conf alink.conf 

Creating soft link with the same name while in the target folder directory using the dot

$ cd /usr/lib/mozilla/plugins/
$ ln -s resolv.conf .

Note that -s makes an "empty" file pointing to the original file/folder. So if you delete the folder a symlink points to, you will be stuck with a dead symlink (just rm it).

Not to be mistaken with bash alias.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data