-1

This question already has an answer here:

I screwed up my AWS instance.

I created a new directory demo inside my /var/www/html

Then in navigated to the html directory and ran this command:

sudo mv /* demo

And all the files and folders from the server root appeared in the demo directory.

How do I move it back?

Also, my intention was to move all the files/folders inside the html directory to the demo folder.

marked as duplicate by muru, Kiwy, Jeff Schaller, telcoM, Rui F Ribeiro Mar 13 '18 at 10:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please comment why vote down :) – Saurabh Mar 13 '18 at 9:21
1

I saw this happen two or three years ago, and I'm aware there are different AWS setups, so this might be doable or might not be.

The machine could no longer be reached through SSH (it did allow login, but the shell would not start). There was no "hardware" terminal available as there is on other services.

If your machine can fire up a root shell, then the commands

LD_LIBRARY_PATH=/var/www/html/demo/lib /var/www/html/demo/lib/ld-linux.so.2 /var/www/html/demo/bin/mv /var/www/html/demo/usr /
LD_LIBRARY_PATH=/var/www/html/demo/lib /var/www/html/demo/lib/ld-linux.so.2 /var/www/html/demo/bin/mv /var/www/html/demo/var /
LD_LIBRARY_PATH=/var/www/html/demo/lib /var/www/html/demo/lib/ld-linux.so.2 /var/www/html/demo/bin/mv /var/www/html/demo/lib /
LD_LIBRARY_PATH=/lib /lib/ld-linux.so.2 /var/www/html/demo/bin/mv /var/www/html/demo/bin /

should bring you to a sufficiently recoverable state.

If there is a terminal allowing login through VNC, Remote Desktop or whatever, same thing.

In our case neither worked.

What the then-administrator did was fire up another temporary AWS instance, force dirty shutdown of the damaged instance, detach its disk, and attach it to the new instance as secondary disk.

Then he did the equivalent of

mount /mnt /dev/sdb1
cd /mnt/var/www/html/demo
mv * /mnt/
sync
shutdown -h now

and detached the disk, reattaching to the old instance, which apart from a lenghty fsck due to the dirty shutdown booted with no problems.

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