mmrs151 mmrs151 - 1 year ago 81
Linux Question

How to remove and re-create an existing symlink in one single command?

I have a symlink for my live server called

and I have releases in the
directory, i.e
current -> releases/2012-05-08_15-13

If I want to update the symlink of my
directory, I have to unlink/rm it and re ln -s it.

My question is: How can I remove the symlink and update it to the latest release in one step.

Answer Source

The form of ln is

ln -sf sourcefile targetlink


ln -sf releases/2012-05-08_15-13 current

to remove the current and create the new link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download