Sunday, November 11, 2007

Symbolic link

ln -s [target] [from]

Example:
You don't have simulation folder in your home directory yet now. But you DO have a simulaion directory in another hard drive/ partition. You want to set up a link in your home folder ( /home/joying/simulaion) to a different partition/hard drive ( /media/_home/simulation).
SO the command would be:
ln -s /media/_home/simulation /home/joying/simulation

If you want to remove the link,
cd /home/joying
unlink simulation


########################################

When using the rm or unlink command to remove a symbolic link to a directory, make sure you don’t end the target with a ‘/’ character because it will create an error. Example:

$ mkdir dirfoo
$ ln -s dirfoo lnfoo
$ rm lnfoo/
rm cannot remove directory ‘lnfoo/’ : Is a directory
$ unlink lnfoo/
unlink: cannot unlink ‘lnfoo/’: Not a directory
$ unlink lnfoo
$

Notice how one complains it “Is a directory”, but the other complains it is “Not a directory”, which I found confusing. This is a problem if you have a tendency to use tab completion a lot, because it will stick a ‘/’ at the end.

No comments: