• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Holy God - Help Now Pleeeeeeease!!!

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Stoanhart

Member
Joined
Dec 16, 2001
Location
VIctoria, BC, Canada
I just made the worst typo in the history of linux.

instead of: sudo rm -rf /tmp/*
I did: sudo rm -rf * /tmp/

I KILLED MY ROOT DIRECTORY!!!! I KILLED ALL MY DIRECTORIES!!! The computer is still on, and in a somewhat functinal state. Please tell me there is a way to undo this?
 

su root

Senior Member, --, I teach people how to read your
Joined
Aug 25, 2001
Location
Ontario, Canada
There are ways to recover the data, but it is terribly painful. It's a lot easier to just reinstall.

If you play with root too much, the tree will wither and die.

My personal favorite is:
sudo rm -rf /tmp/sess<tab>*
If the tab actually completes the filename instead of a partial match, it will put a space after the file, so it ends up being "/tmp/session_0038478302" AND "*" instead of "/tmp/session_*"
 

MRD

Senior Member
Joined
Feb 14, 2003
If you have critical data, you can recover some of it, but you will have to reinstall. Recovering every file would take days or weeks. Also, not all filesystems have good recovery tools. ext2 has the best. ext3 is possible. Stuff like reiser, xfs, jfs, etc. don't have any that I know of.
 

jnev_89

Member
Joined
Sep 2, 2004
wow, if that didn't suck so much it would actually be pretty funny. hope you didn't lose too much important data!
 
OP
Stoanhart

Stoanhart

Member
Joined
Dec 16, 2001
Location
VIctoria, BC, Canada
no critical data, so its not that big a deal.

also, i found out the rm command died when it deleted itself, so i still have alot of stuff! extracting a stage 3 tarball and reemerging should fix it!

Thanks though!
 

telexen

Member
Joined
Jun 29, 2003
I didn't think using a wildcard like that would automatically assume from the root. I've used it like that when copying or moving stuff ([email protected] ~/somestuff $ mv * ../otherstuff) and I've had no problems
 
OP
Stoanhart

Stoanhart

Member
Joined
Dec 16, 2001
Location
VIctoria, BC, Canada
telexen said:
I didn't think using a wildcard like that would automatically assume from the root. I've used it like that when copying or moving stuff ([email protected] ~/somestuff $ mv * ../otherstuff) and I've had no problems

I was in the root:

[email protected] /# sudo rm -rf * /tmp/

basically, be root, delete everything, in every subdirectory, and don't bother confirming with me, then delete /tmp/ too.
 

su root

Senior Member, --, I teach people how to read your
Joined
Aug 25, 2001
Location
Ontario, Canada
Hmm... it shouldn't have stopped unless you hit CTRL-C. You can delete or override running programs, and the version of it in memory will continue working.. that's how most application upgrades work... once you restart the application, it loads the new version from disk, and runs that.. if you upgrade a piece of software but don't restart it, it's still running the old version.
 
OP
Stoanhart

Stoanhart

Member
Joined
Dec 16, 2001
Location
VIctoria, BC, Canada
I hit CTRL+C, but this was after it had already frozen. I think rm probably calls a new version of itself everytime if finishes a directory. It cleared out /bin, went to change directory, and stopped.

or maybe it cleared out bin, went to change directory, but couldn't find cd. Who knows, but it stopped.
 

Elif Tymes

Member
Joined
Dec 8, 2004
Ouchhhh :( that hurts :(.
I work through the command line alot at work for editing. VI is my favorite... Anyways ci apparently deletes the contents of a file.

Guess where c and v are on the keyboard?
 

Arkaine23

Captain Random Senior Evil
Joined
Nov 8, 2001
rm, cp, and mv all have a -i switch for interactive mode. You can put this as 3 different aliases in root's .bash_profile or /etc/profile (and source it for all users) or wherever equivalent for whatever shell you use as root. I tend to drop a -i on systems where it's not already aliased when I need to do an rm -rf. you never know when you might type the directory path and accidentally put a space after the first /....
 

Arkaine23

Captain Random Senior Evil
Joined
Nov 8, 2001
Indeed it does. Nevertheless, tossing in that -i can save you a lot of hassle from a disastrous mistype.
 

funnyperson1

Senior Member
Joined
Jun 16, 2001
MRD said:
If you have critical data, you can recover some of it, but you will have to reinstall. Recovering every file would take days or weeks. Also, not all filesystems have good recovery tools. ext2 has the best. ext3 is possible. Stuff like reiser, xfs, jfs, etc. don't have any that I know of.
I actually rmed an important C++ project while using reiserfs (well actually I rmed the backup swap file, and mistyped the tar command to tar over my program when trying to submit :(). Then I tried using the trick below:

http://www.antrix.net/journal/techtalk/reiserfs_data_recovery_howto.comments

Then I think I cancelled halfway because I though I made some stupid mistake, and that screwed most of my filesystem.

Luckily following that tutorial again allowed me to recover the file through the gnome search feature (or at least 60% of it), although the install itself was pretty much hosed.
 

MRD

Senior Member
Joined
Feb 14, 2003
ext2 isn't the best filesystem for most things, but it does have the advantage of compatibility. Lots of programs can work with it easily, including partitioners and unerase utils.
 
OP
Stoanhart

Stoanhart

Member
Joined
Dec 16, 2001
Location
VIctoria, BC, Canada
I'm using ext2 because the system is a laptop. The problem I had with reiser was I couldn't spin down the HDD, since it would write to it every 10 seconds.

I am just going to restart from scratch. It was my first real linux install that I had actually started using as opposed to windows. All previous distros just sat there ignored in the boot manager. I definaley like the gentoo build your own approach. Second time should go much faster.