3

I'm using Ubuntu 14.04 and I've accidentally moved /usr/bin to another location.

Now most of the commands don't work anymore: sudo, cp...

The OS is not booting and I can't put the directory back as I have no permissions.

I also use zsh, and I suspect there were some zsh related files and symlinks.

How can I move the directory back?

Zanna
  • 72,312

2 Answers2

6

If you simply moved the directory elsewhere (say /some/where), then move it back:

/some/where/sudo /some/where/mv /some/where /usr/bin

mv is no longer /bin/mv now that Ubuntu has completed the usrmerge.

If you don't have an open terminal in which you can run this, and have trouble opening another terminal, press AltF2 to get GNOME Shell's prompt for running commands, and then try one of these command:

/some/where/gnome-terminal.real -- /some/where/bash
/some/where/xterm /some/where/bash

Alternatively, if you have the file manager open, press CtrlL to open the address bar and go to admin:///some/where. This should prompt for you to authenticate and then open that directory in privileged mode, allowing you to move things back to /usr.

muru
  • 207,228
0

To move it back you need superuser permissions.

So navigate to the path where you moved using "cd".Yes, cd command will be available even you move the bin.

Then in the new bin directory

use:

./sudo /new/bin/path/mv new/bin/path /usr/bin/

./sudo to access sudo

./sudo /new/bin/path/mv to run mv (move command)

This should move back the folder in it's place.