Cannot overwrite Symbolic Link RedHat Linux

Chuck Burgess picture Chuck Burgess · Mar 9, 2011 · Viewed 13.7k times · Source

I have created a symbolic link:

sudo ln -s /some/dir new_dir

Now I want to overwrite the symbolic link to point to a new location and it will not overwrite. I have tried:

sudo ln -f -s /other/dir new_dir

I can always sudo rm new_dir, but I would rather have it overwrite accordingly if possible. Any ideas?

Answer

ire_and_curses picture ire_and_curses · Mar 9, 2011
ln -sfn /other/dir new_dir

works for me. The -n doesn't dereference the destination symlink.