1

I am running Ubuntu 24.04.1 LTS on my HP 250 Laptop, and I accidentally deleted my entire home directory while trying to remove an old VirtualBox VM folder.

What Happened?

I was trying to delete an old VM folder and ran the following command:

sudo rm -rf /home/my-username/VMBOX \ Machines*machine-name*

Initially, I ran it without sudo, but I got a "Permission denied" error mentioning /home/my-username. Instead of stopping to check, I assumed it was a permission issue and reran the command with sudo.

Unfortunately, this ended up deleting my entire home directory (/home/my-username), including all my personal files and configuration files.

What Happened Next?

I manually recreated my home folder and subdirectories (Documents, Downloads, etc.), but I did not restore any hidden/system files. After recreating the folders, I noticed: My terminal was opening in / instead of /home/my-username. pwd showed the correct path inside /home/my-username, but some apps were behaving strangely. Google Chrome couldn’t download files, showing "permission required" errors. I decided to reboot the system to see if that would fix anything.

Current Problem: Can't Log In

After restarting:

I enter my password at the login screen, see a brief animation (as if it’s logging in), but then I get sent back to the login screen. No error messages appear, and I am not redirected to a terminal—just back to the login prompt.

What Should I Do?

I haven’t tried any fixes yet because I want to ask for advice before making things worse.

How can I properly restore my home directory so I can log in again? What system files/configurations are needed for login and apps to work properly? Is there any way to recover settings for apps like Chrome and GNOME that were stored in my home folder?

I’d really appreciate any help—thank you in advance!

stumblebee
  • 4,379

1 Answers1

0

At this point, you'd save a lot of time and energy just doing a full reinstall. All of your personal info, your documents, and local app settings will have been deleted, so unless you've been installing some servers which might have put data in /var/lib or /opt or /etc, there's probably not much left to worry about.

Whether you want to reinstall or try and recover the deleted files, you will need to start off with a bootable Ubuntu (or other Linux flavoured) USB drive. Set that up using another PC, or use the one you might have from your original restore.

Once you've booted in using a USB, check out this tutorial here on undeleting if that's the path you want to go: https://itsfoss.com/recover-deleted-files-linux/

If for some reason you can't make a bootable USB, and you want to get to the command line and your GUI is broken, you can hit ctrl-alt-F1. (Or F2, F3... all the way up to F7 - the last of which should take you back to the GUI login.) These open up different TTYs, or terminals if you prefer. You should be able to login and muck about from there. (Also useful if you mess up your X server.)

Good luck!