How to delete or replace an already created symbolic link?
I am working on my project using network simulator2. I installed it and everything is fine. I attempted to create a symbolic link between this installation and /usr/bin
, so I could invoke the software by running ns
from the command-line. Namely, I ran:
sudo ln -s /home/vinaychalluru/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns
which generated the following output:
ln: creating symbolic link '/usr/bin/ns': File exists
How can I delete the already created symlink or can I replace it with any other commands?
ln
has -f
switch that 'forces' a symlink to be created whether it exists or not.
sudo ln -sf /home/vinaychalluru/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns
sudo rm -r /usr/bin/ns
sudo ln -s /home/vinaychalluru/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns
I tried ln -sf
while replacing but it didn't work for me, but doing ln -sfn directory link_name
as root
worked.