How to create & delete symlink
How to create and delete a symlink?
=>I] How to create symlink :=>
# cd /
# ln -s /home/user/example example
You would be creating a symbolic link called "example" in the root directory, and it would be a reference to the /home/user/example file.
To see this, you would:
# cd /
# ls -l
And the ls output would show you the standard directory listing with symbolic links maked with arrows, like this:
lrwxrwxrwx 1 user user 13 Aug 30 2006 example -> ../home/user/example
-----------------------------------------------------------
II] How to delete a symlink?
You can delete either by rm command or unlink command :
$ unlink symbolic_link
or
$ rm symbolic_link
NOTE :
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.
|