A soft link, or more common, a symlink, is link a shortcut to the targeted file or directory. So when is removed the original target stays present. This is the opposite of a hard link which is a reference to the target and so, if the hard link is removed, so is the target.
A symlink can be created like:
ln -s /path/ linkname
from the ln man pages:
ln [OPTION]… [-T] TARGET LINK_NAME (1st form)
-s, –symbolic
make symbolic links instead of hard links
to remove a symlink
rm linkname
What is important here is to note that the command doesn’t have the trailing slash
$ rm linkname/
will output the error:
rm: cannot remove `linkname/': Is a directory
$ rmdir linkname/
will output:
rmdir: linkname/: Not a directory
So it’s a directory or not?? i guess different tools have different ways of looking at this. Isn’t GNU/Linux great?! :D
[...] Nerdica wrote an interesting post today onHere’s a quick excerptA soft link, or more common, a symlink, is link a shortcut to the targeted file or directory. So when is removed the original target stays present. This is the opposite of a hard link which is a reference to the target and so, if the hard link is removed, so is the target. A symlink can be created like: ln -s /path/ linkname from the ln man pages: ln [OPTION]… [-T] TARGET LINK_NAME (1st form) -s, –symbolic make symbolic links instead of hard links [...]
Pingback by Linux Code and More » Blog Archive » How to create and remove a soft link, symlink or symbolic link — November 15, 2007 @ 10:47 pm
[...] see in this post how to create a symlink so, everytime you change this file you don’t need to copy it to the [...]
Pingback by How to start a new X server with Quake wars to work as a minimizer « The GNU of Life, the Universe and Everything — November 15, 2007 @ 11:10 pm
What is important here is to note that i doesn’t have the trailing slash
what is i?
Comment by Whose name — April 22, 2008 @ 12:29 pm
Thanks “Whose name” for the heads up.
“i” should be “it” which is “the command”.
hope it makes sense :)
Comment by Pedro Carvalho — April 22, 2008 @ 1:15 pm
[...] under your dropbox folder. Solution, symbolic links. SymbolicLinker is a cool plugin for creating symbolic links using Finder from the right click menu. Place the links in your Dropbox folder to backup the [...]
Pingback by Dropbox with symbolic links in finder | digiculturetravelexpatasia — September 15, 2008 @ 7:31 am
hey buddy use unlink instead of rm command
unlink linkname
Badi Ul Zaman
MCSE,RHCE,JNCIS
bnhashmi@yahoo.com
Comment by Badi Ul Zaman — December 4, 2008 @ 8:31 am
hei there buddy!
thanks for the tip but in most GNU Linux Systems rm uses unlink to remove files so unlink will run into the same problems.
Comment by Pedro Carvalho — December 4, 2008 @ 8:56 am
Your problem is that you’re using tab completion, which automatically appends a ‘/’ to the end of your symlink. Syntactically, this appears to be a directory to rm. If you simply say “rm linkname” (without any trailing slash), the command will work.
Comment by Brian Stempin — April 10, 2009 @ 8:41 pm
Thank you so much
Comment by kalpana — March 13, 2012 @ 7:59 pm
Thank you very much! I was having an awful job trying to remove the the symlink and it was as simple as getting rid of the trailing slash. You’ve saved me some hair-pulling. Thanks again.
Comment by sislii — May 20, 2009 @ 1:14 am
# this works
rm linkname
# versus
rm linkname/
Basically you need to tell it its a file not a dir (/)
Comment by Brian — June 17, 2009 @ 9:40 pm
try “rm linkname” instead of “rm linkname/”
Comment by a2j — July 5, 2009 @ 2:37 am
hai
Comment by ghg — February 3, 2011 @ 11:11 am
I was trying to get apache2 to identify a folder at a location. Since by default apache looks under /var/www/ for what to open, I wanted to create a symbolic link there to point to the folder where I wanted my browser to open a .php file. So when I searched for how to create a symbolic link, I found your great post on it. :) Thanks a lot! :)
Comment by Haris Ibrahim K. V. — September 14, 2011 @ 3:18 pm
:) Well done!
Comment by Pedro Carvalho — October 23, 2011 @ 1:36 am
wonderful post. saved me lot of time :)
Comment by Murali — June 3, 2013 @ 6:22 pm