I am logged into a remote ubuntu server, and I accidentally erased the entire /home/username/
directory for the current user. The only thing left is a hidden directory called .gvfs
. I don't need anything of the Documents/Music/etc.
Now it is not letting me cd into the /var/www/
directory, which has permissions 666 and it is owned by the current user.
I am afraid to disconnect from my ssh session because I don't know if I will be able to get back on. Have I permanently created a problem? Is there a way I can replace the most important files to the /home/username/ directory?
Thanks!
** EDIT **
Thanks everyone for the help. I figured the problem with cd
into the /var/www/
was actually my permissions in the /var/www/
directory. It was set to 666, changed it to 755 and everything was good again. It doesn't look like anything systematic was ruined by deleting the contents of the user folder.
The system should continue to be completely usable in itself with files in a user's home directory all deleted. You certainly shouldn't have any problem cd'ing to
/var/www
.But directories need to have execute permission for users to be able to traverse to them. You said
/var/www
was666
, which doesn't include any execute bits, so it sounds like you have a separate problem. Try:sudo chmod 755 /var/www
to set/var/www
back to reasonable permissions.You may also find it useful to copy the contents of
/etc/skel
to the home directory where you have deleted everything. If you do, make sure the files you copy end up having the owner and group of the user. This is done when you create a new user and provides a set of sane defaults for new users to start with.You also said you were ssh'd in as this user. To make sure you can do so again, you'll need to restore the
~/.ssh
directory with700
permissions, and make sure that~/.ssh/authorized_keys
contains your public key. You can test this with a different ssh session before you log out of your original one.If you log into ssh with a password, you need not worry about your ssh session. However, if you login without a password, ie with an ssh key, then the most important file to restore now is the one allowing your ssh access. For this, you need to find the contents of the file
~/.ssh/id_rsa.pub
on your LOCAL computer, and put it in the file
~/.ssh/authorized_keys
on your REMOTE computer.
Use a second, simultaneous ssh session in another terminal window to see whether you can still login.
try pressing Ctrl + Alt + T to launch Terminal
Next, type in
to run the file manager and try to undelete
If this doesn't work, you could try manually adding the required folders either in nautilus if it will let you, or in Terminal using the
mkdir
command, create a Home folder then folder which is your username so that you can get to ~ or /home/username then you'll need to create:Hopefully this will get you back and running
I HAVE NOT TRIED THIS AND IT MAY NOT WORK
You could try out http://extundelete.sourceforge.net/ to see if you're able to recover the directory and files. If possible, make sure nothing more is written to the disk before you have tried to get the old files back.