Quantcast
Channel: Replace important symbolic link ‘safely’ - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Replace important symbolic link ‘safely’

$
0
0

I would like to change the target of symbolic link from within a bash script. The problem is that the symlink is quite important (it's /bin/sh, namely) and I would to do it in fashion that:

  1. New target will be available immediately after removing old, i.e. there will be no possibility that something will notice disappearing of it,
  2. There will be no possibility that the change will fail in the middle, i.e. leaving user with symlink removed and no new one.

I thought about two methods. Either using plain ln:

ln -fs /bin/bash /bin/sh

or using mv:

ln -s /bin/bash /bin/sh.newmv /bin/sh.new /bin/sh

Which one will suit my needs better? Is there any possibility that one of them would try to replace the symlink target instead of symlink itself?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images