Tuesday 15 October 2013

Create a symbolic link in linux

Well I was working on this project and so happens my development directory and deployment directory (where i compile the code) are different. Now its not possible every time to go back and forth and copy my development one into deployment. So i will create a symbolic link between them. For those who are new to term symbolic link; its a file which has the reference( an address to reach to original file) of linked file.Yes something what windows calls a shortcut file.
To create a symbolic link, just say

ln -s [source; in my case development dir]  [target; deployment dir]

Note: Linux will not create hard link between directories. So if you have created a directory as target; simply delete it and give just the name instead.

Adding some more point.There are two types of links - Symbolic link and Hard link. Hard link actually points to the physical data i.e. location where it is stored on disk. Symbolic links refer to just path of the file. So if you delete the original file symbolic link will go, but hard links will stay as it is.

To create hard link just say 'ln' no '-s' in option.

1 comment: