Linux: Recover files

Nithin

Senior member
Dec 31, 2002
961
0
76
Accidentally did an rm -rf in my home dir instead of a sub dir.
any way to recover data?

Thanks,
N.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Restore from backups.

You can try some of the forensics software out there, but that would be a hell of a lot more trouble than just restoring from backups.
 

Nithin

Senior member
Dec 31, 2002
961
0
76
Originally posted by: n0cmonkey
Restore from backups.

You can try some of the forensics software out there, but that would be a hell of a lot more trouble than just restoring from backups.

ya, i googled and found out its not easy. why isn't undelete included in linux?
im sure it would be useful


N.
 

Cheetah8799

Diamond Member
Apr 12, 2001
4,508
0
76
sorry, rm -rf = gone forever.

You can setup your own undelete option. Simply replace "rm" with a wrapper script that moves the file to a trash bin of some sort. Check some more of your google results, there are documented ways to set this up. I know, I've done what you did and had to research it too....
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nithin
Originally posted by: n0cmonkey
Restore from backups.

You can try some of the forensics software out there, but that would be a hell of a lot more trouble than just restoring from backups.

ya, i googled and found out its not easy. why isn't undelete included in linux?
im sure it would be useful


N.

It should be up to the user to not do stupid things. If you really want an undelete, you can alias the rm command to move your files to a predetermined location instead of deleting them. Then you can delete them later, have them deleted when they reach a certain age, etc.
 

Nithin

Senior member
Dec 31, 2002
961
0
76
Originally posted by: n0cmonkey
Originally posted by: Nithin
Originally posted by: n0cmonkey
Restore from backups.

You can try some of the forensics software out there, but that would be a hell of a lot more trouble than just restoring from backups.

ya, i googled and found out its not easy. why isn't undelete included in linux?
im sure it would be useful


N.

It should be up to the user to not do stupid things. If you really want an undelete, you can alias the rm command to move your files to a predetermined location instead of deleting them. Then you can delete them later, have them deleted when they reach a certain age, etc.

ok but that is not a reason not to include it. why have any safety features?
is there any technical reason? maybe if its a huge resource hog, or performance hit or something.

just because users are stupid, why should linux punish them? thats just elitism.
at least give the user an option to turn undelete off.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nithin
ok but that is not a reason not to include it. why have any safety features?
is there any technical reason? maybe if its a huge resource hog, or performance hit or something.

It treats you like an adult. It doesn't coddle you or make you suck at its teat. It gives you the gun and lets you do as you will. If you shoot yourself in the foot, it's your fault.

just because users are stupid, why should linux punish them? thats just elitism.
at least give the user an option to turn undelete off.

They give you the option to create one. Use it.
 

Nithin

Senior member
Dec 31, 2002
961
0
76
Originally posted by: n0cmonkey
Originally posted by: Nithin
ok but that is not a reason not to include it. why have any safety features?
is there any technical reason? maybe if its a huge resource hog, or performance hit or something.

It treats you like an adult. It doesn't coddle you or make you suck at its teat. It gives you the gun and lets you do as you will. If you shoot yourself in the foot, it's your fault.

just because users are stupid, why should linux punish them? thats just elitism.
at least give the user an option to turn undelete off.

They give you the option to create one. Use it.

i don't want to argue with you noc. you know a lot more about this stuff.

i'm just saying it would be better to include this if there is no compelling reason
to leave it out. what do you experts lose? it will help those who are no knowledgeable.

and thats my question why make it a gun with safety turned off? if there is an option, why not include it? make it a gun with the option for experts to turn safety off?

thats all IMHO.

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nithin
i don't want to argue with you noc. you know a lot more about this stuff.

i'm just saying it would be better to include this if there is no compelling reason
to leave it out. what do you experts lose? it will help those who are no knowledgeable.

They lose time explaining to people why their hard drive is filling up even though they're deleting a bunch of stuff. They spend time telling experienced users why the results they expect (that have worked for 30 years) aren't the results they are seeing. They spend time documenting the system and testing the system. They spend time designing a system that works for both desktop and server users, that works for single user systems and multi-user systems. All of this when a user can do it themselves in 10 minutes (if you had to look something up like I did).

It's not your OS's job to tell you how to do things, it's your job to tell it. Everyone is different and likes different things working in different ways. Apparently no one made this "feature" because they didn't think it was important enough to spend time on. If you do, make it. Preach it to the world. If you want a distribution to include it by default, start your own distribution.

and thats my question why make it a gun with safety turned off? if there is an option, why not include it? make it a gun with the option for experts to turn safety off?

thats all IMHO.

Knobs are bad. They lead to mistakes and problems. This knob isn't necessary, it isn't expected, and would cause plenty of problems. You can solve the issue for yourself in no time. Instead of wondering why you're given powerful tools, use them.

Here's how you can fix this:
mkdir ~/.trash
unalias rm
function rm() { mv $* ~/.trash/; }
alias bammo=rm


Add the last 3 lines to your bash profile also, so they stick through logouts. The function will move everything to ~/.trash instead of deleting them. To delete something, use the command "bammo".
 

Nithin

Senior member
Dec 31, 2002
961
0
76
ok. that makes sense. not entirely convinced but thanks for the script. :)

[edit] and i suppose complete newbies use the gui so its a non issue.
at least in ubuntu it puts it in trash.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nithin
ok. that makes sense. not entirely convinced but thanks for the script. :)

[edit] and i suppose complete newbies use the gui so its a non issue.
at least in ubuntu it puts it in trash.

I think both KDE and Gnome do that.

From a few little google searches, it looks like anything more complicated than I posted would require quite a bit of kernel level filesystem work. Filesystems are the type of thing you want to be hacking in if you can help it. If one little change corrupts one little bit, you could lose a lot of important data, and not find out until your backups aren't even worthwhile as coasters. ;)
 

Hersh

Senior member
Oct 14, 1999
331
0
0
Well, and deleting things via X (gui) is different than doing a 'rm -rf' command line; there is a reason why it's necessary to type in the extra '-f' flag.

Sorry you lost data you needed... on the upside, this is a good lesson for all, never use the '-f' flag unless you are 120% sure you know the command is correct. All other times, just leave the '-f' off.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
ok but that is not a reason not to include it. why have any safety features?
is there any technical reason? maybe if its a huge resource hog, or performance hit or something.

The filesystem drivers would have to be rewritten to not reuse space for a certain amount of time and I'm sure for some of them this would be really difficult if not impossible. And it's not like it's included in Windows or OS X either.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: alphaz
Well, and deleting things via X (gui) is different than doing a 'rm -rf' command line; there is a reason why it's necessary to type in the extra '-f' flag.

Because some idiot keeps aliasing rm to "rm -i". :p