13

I was hiding some of the folders on my Ubuntu machine. By mistake, I have hidden bin folder too by using

cd /
mv bin .bin

Now I could cd to .bin, but I am not able to unhide the bin directory. Can someone help? I was trying the following command:

mv .bin bin

I am getting the following error

bash: /bin/mv: No such file or directory

I tried to login as root, but my machine is asking me to install login. On doing apt-get install login, I am getting a message login is currently the latest version.

  • 5
    To help others in similar cases, the first rule is don't panic. Then read below's top answer. But to get even more ideas of what is possible : lug.wsu.edu/node/414 (different system, different os, but the ideas are still relevant, and unix's reliability is (almost, if distribs remember to keep it sane) still shining) – Olivier Dulac Dec 4 '17 at 10:02
35

If you still have a root shell open, run

cd /
/.bin/mv .bin bin

Your shell can’t find mv because it’s no longer on the path; giving the full path to it will allow it to run.

(As a general rule, it’s best not to rename directories outside of your home directory — they are managed by the package manager, and you are likely to confuse it and prevent updates from being applied in the future.)

  • 3
    @Apricot No need to panic. Even if you could not have been able to restore the directory names from within your running (and broken) system, you could have still used a live system for rescuing it. – Richard Neumann Dec 4 '17 at 9:05
  • 9
    @Apricot: well, that's good, but backup should be taken before something bad happens ;) Continue taking backups regularly from now on. – Olivier Dulac Dec 4 '17 at 9:49
  • 1
    Yes, making backups is always good, even if they turn out to be not necessary for the current situation. – Mr Lister Dec 4 '17 at 11:21
  • 3
    @user3490 it moves itself without complaint; see Overwriting a running executable or .so for details. – Stephen Kitt Dec 4 '17 at 13:27
  • 2
    Abstractly, renaming /.bin to /bin changes neither any file within the renamed directory, nor the directory itself; the only thing that is changed is the name of one entry in the root directory! – zwol Dec 4 '17 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.