Data Recovery – Accidentally Moved Directories Under Root

data-recoverymvrootssh

I've accidentally run this command

sudo mv /* /applications/minced/

instead of

sudo mv ./* /applications/minced/

This is all that's left in the root directory

$ /
applications/ dev/          proc/         run/          sys/          tmp/       

I still have an active ssh connection to the server. I've tried calling mv, sudo and chmod… directly from /applications/minced/bin/ or /applications/minced/usr/bin/, but nothing works, though I can locate them there using path autocompletion.

$ /applications/minced/bin/ls
-bash: /applications/minced/bin/ls: No such file or directory

I've read Revert moving root directory recursively, but mounting the system under LiveCD is not an option for me since it's a VPS, not a physical machine. Any ideas?

Update

I figured out this is due to library linkage problems, so I did this

$ export LD_LIBRARY_PATH=/applications/minced/lib/x86_64-linux-gnu/
$ /applications/minced/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /applications/minced/bin/mv /applications/minced/* /

Obviously I ran into permission problems. Calling sudo with the linker throws this error

$ /applications/minced/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /applications/minced/usr/bin/sudo ...
sudo: effective uid is not 0, is /applications/minced/usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

As suggested by Barafu Albino, I've tried calling su with busybox (.../bin/busybox su -), but it throws su: must be suid to work properly. I guess this happens because su can't locate /etc/passwd and /etc/shadow. Seems like I've screwed up the system completely.

Best Answer

Your applications can not run because they want to find libraries and those are misplaced too. Try using busybox directly.

bin/busybox ls

should work as ls and so on.

Related Question