Possible Duplicate:
UNDO LINUX Trash Command
Hi,
Is there any simple way to undo an rm
command?
The question is purely theoretical; I have NEVER deleted the log of a benchmark queue who took a whole lunchtime to run.
Possible Duplicate:
UNDO LINUX Trash Command
Hi,
Is there any simple way to undo an rm
command?
The question is purely theoretical; I have NEVER deleted the log of a benchmark queue who took a whole lunchtime to run.
On ubuntu or similar:
$ sudo apt-get install trash-cli
$ alias rm=trash
Then put that alias in .bashrc or the appropriate login script for your shell of choice.
The trash-cli
package is a command-line interface to the same trash can that GNOME and KDE and other use. So anything you delete via the trash
command can be restored by GNOME/KDE and vice-versa.
The other commands in the trash-cli
package are trash-list
, trash-empty
, and restore-trash
.
rm
? I like having an undo button for my accidental deletions, even on the command line. Also, trash-cli
explicitly facilitates this by accepting (and ignoring) many GNU rm
options. Besides, the OP asked for a way to undo rm. This solution doesn't answer the question correctly without the alias.
Feb 19, 2010 at 23:21
rm
and then hypnotize yourself into forgetting that you did. That way you can still keep using rm
as though it's final.... but if you slip up and go "oh noes!!" you're not completely screwed. (i.e. don't rely on it's "recoverable" functionality)
trash
is the way. I use an alias reminder instead, e.g.: alias rm='echo "tip: use trash next time"; rm'
, that way I retain functionality and the choice.
The traditional answer is:
You recover the file from the latest backup. You do have a recent backup, don't you?
because on many unix filesystems this simple isn't possible, or is very difficult.
As others have noted this is not the end-all and be-all of the issue any more, but not making mistakes of this kind is still the preferred approach.
rm -fr *(1)*
... every file wen away. So having backups is not always the solution. Trash-cli sounds cools.
To prevent hypopthetical future mistakes, you might want to alias rm='rm -i'
...
ls
with the same parameters before so I can see what's going to go.
Aug 30, 2009 at 15:40