Creating Soft link or alias
Posted under » Linux on 30 September 2009
Hard link vs. Soft link in Linux or UNIX
- Hard links cannot links directories
- Cannot cross file system boundaries
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 hard links. It allows to associate multiple filenames with a single file. However, symbolic links allows:
- To create links between directories
- Can cross file system boundaries
- smaller in size
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.
- Symbolic links are not updated.
- Hard links always refer to the source, even if moved or removed.
Creating hard link
$ ln resolv.conf alink.conf $ ln /etc/apache2/sites-available/wwwinterfil /etc/apache2/sites-enabled/www.interfil.org
Creating soft link -s
$ ln -s resolv.conf alink.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).
