How to change where a symlink points

John Doe ·

1210 Views

files is a symbolic link to /media/files/tb-prod/files. When you access files or anything inside it, you'll really access the path under /media. Symbolic links are made and updated using the ln command. This link could have been made with:

ln -s /media/files/tb-prod/files files

-s means to make a symbolic link. To update a link, either delete the link and create it as above, or use the -f option to ln as well. If you are linking to a folder, you should include the -n option:

ln -sfn /a/new/path files

This will replace the link with a new one pointing at /a/new/path.

The -n option is necessary when linking to a different target folder to avoid creating a sub-folder inside that symbolic link and instead replace the symbolic link completely.

e.g.

contact@me:/mnt/webdav$ ls
a1  a2  a3  a4  a5  a6
contact@me:/mnt/webdav$ ln -sfn /mnt/a2/XYZ a2
contact@me:/mnt/webdav$ ls
a1  a2  a3  a4  a5  a6
contact@me:/mnt/webdav$

https://unix.stackexchange.com/questions/151999/how-to-change-where-a-symlink-points

Ubuntu linux