Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 6
    ln -snf is not atomic: it unlinks the destination, then creates the desired symlink. Commented Aug 13, 2011 at 12:37
  • 2
    Given that the OP was interested in getting "as close as possib[e]" to atomically changing a symlink, this is a perfectly reasonable answer. If there is a better one that can get closer (or be) atomic, that one can be accepted. I don't think there's a need to downvote. Commented Oct 29, 2013 at 18:51
  • 2
    Not sure for busybox, but I have confirmed by strace that on modern linux distribution such as Ubuntu Bionic, the ln -snf works atomically, it does not call unlink, it will do actually "ln -s source a_tmp_file && mv -T a_tmp_file symlink" Commented Feb 12, 2022 at 7:30