4

so, I'm running a home server using Ubuntu Server 18.04.2 LTS and I'm currently controlling it via ssh outside home. I wanted to delete everything I had on my user's home folder so I used "sudo rm -r /home/user" and deleted everything including the user folder. now everytime I do "cd" it says "-bash: cd: /home/user: No such file or directory" I've already tried to restart the server (via ssh) but still the same. What should I do to recover my user's home folder?

2
  • 2
    There is no 'recovery' in the sense of recovering the previous user directory and any files within it. Those are gone, gone gone. You can use sudo mkdir to create a new directory with the correct username, then sudo chown to change ownership of the new home directory to the correct user. – user535733 May 7 '19 at 20:56
  • What backup strategy did you put in place? Knowing that is how you restore your removed files, and we cannot know what you chose to use. – guiverc May 7 '19 at 21:07
4

Just recreate the folder, add the default config files, and change the owner to you:

sudo mkdir /home/user
cp -a /etc/skel/* /home/user
chown -R user:user /home/user
0

Have you tried mkhomedir_helper Usage: mkhomedir_helper [ []] ?

If you are asking about recovery of the folder it was possible only before the restart.

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.