Restore Manjaro to a working state after bad command wiped out large amount of / folder

Hi. So I was an idiot and ran the command sudo find . -maxdepth 1 -type d -exec rm -r {} \; in my / folder. I thought I was in another folder and I was getting rid of some files that had root permission on them, files that I made but made wrong. After I realized where I just executed the command I stopped it, freaked out, and calmed down as I realized my important files were on my NAS or on another drive. Now I need to get my PC back to a workable state. How would I do this? Is there a way I can repair it link how Windows has it or is it just going to be a total reinstall? Any and all help would be great as I don’t really know where to go from here.

It depends.
What state is the system in? Does it work mostly? Can you log in and execute commands?
Do you have timeshift/btrfs backups?
I’m pretty sure all official versions come with that by default since a little while.

I am not sure. I don’t think I set anything like that up. How can I check?

I am still logged in and can execute commands and can still generally move around but most of the customization I did is gone. I’ve made my peace with that but I am not sure about stuff I don’t know about. I ran that command in the / directory so it could have done a LOT more damage than I know.

This from when it happened if it helps at all.

BTRFS stuff is all contained at this wiki page, with this link pointing to the rollback instructions:

…but given the example of what you actually did…

It appears you didnt affect the root fileystem at all.
You did start to thrash your $HOME though while using sudo.

( . is equal to ‘here’, and your current working directory was $HOME [/home/username/] )

So really you just need to get back your $HOME files and permissions.
Possibly the easiest might just be create a new user and then place important stuff there, remove old user.

I opened timeshift up and it didn’t have any snapshots for me, I’ll be sure to set that up when this is all fixed though. Without a backup there wouldn’t be any way to recover them, correct? No magic undo?

Could you point me in the direction of how to make a new user and then remove the old one?

You can try methods like photorec or some other form of data recovery.

You can likely just use your Desktop Environment’s “System Settings” or similar to add/remove users.

Or see here: Users and groups - ArchWiki

Here are also some valuable tips if you still intend to recover some of the deleted files:

By default timeshift does protect only “/”, but not “/home”

So you need to set it up, so that it also protects(snapshots) /home

There also is snapper

I prefer snapper because snapper adheres more closely to the btrfs developers’ specifications than timeshift.
However, timeshift is easier to set up and use.

As far as i know there is no kind of “photorec” for btrfs yet.

But there are programs to additionally save snapshots of btrfs externally.

1 Like