Search code examples
linuxsymlink

How can I remove and recreate an existing symbolic link in one single command?


I have a symbolic link for my live server called current and I have releases in the releases directory, i.e., current -> releases/2012-05-08_15-13

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

How can I remove the symbolic link and update it to the latest release in one step?


Solution

  • The form of ln is

    ln -sf sourcefile targetlink
    

    Try

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

    to remove the current and create the new link.