INFORMATION!!!!! rm will move deleted data to Trash.........For future recover
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
INFORMATION!!!!! rm will move deleted data to Trash.........For future recover
As far as how to make stuff go to the trash instead of deleted, run this as root:
Code:
mv /usr/bin/rm /usr/bin/rm.bak
Now copy this script and save it as /usr/bin/rm:
Code:
#!/bin/bash
mkdir ~/.Trash &> /dev/null
while [ ! -z "$1" ]; do
mv "$1" ~/.Trash/
shift
done
---------------------------------------------------
This will, instead of deleting files, move them to the .Trash directory in your home directory, and you can delete them for real later.
If there are any comments aor any other soltion to get rid of accidently deleted file,please disucess here...
Note that 'rm' can also be "/bin/rm", you don't use error detection ("&&") or switch termination (try moving a file called "--help"), backgrounding commands like that could lead to problems when a system is under a high load, you don't use force (should you?) and a while loop like that slows things down. All in all it's a nice try but unfortunately comes nowhere near for instance syscall-intercepting methods like say LD_PRELOAD'ed thrashcan solutions offer.
It doesn't support rm command-line switches, so it's not a good idea to use that.
Code:
OPTIONS
Remove (unlink) the FILE(s).
-f, --force
ignore nonexistent files, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or when
removing recursively. Less intrusive than -i, while still giv-
ing protection against most mistakes
--interactive[=WHEN]
prompt according to WHEN: never, once (-I), or always (-i).
Without WHEN, prompt always
--one-file-system
when removing a hierarchy recursively, skip any directory that
is on a file system different from that of the corresponding
command line argument
--no-preserve-root
do not treat `/' specially
--preserve-root
do not remove `/' (default)
-r, -R, --recursive
remove directories and their contents recursively
-v, --verbose
explain what is being done
--help display this help and exit
--version
output version information and exit
Another problem is that identically named files will overwrite each other in trash directory, so files STILL will be deleted accidentally.
Please discuess if any of you have the right script that will make getrid of rm -rf comamnd if accidently used.
Waiting----------------
I recommend being *VERY* careful when using that command. Don't get rid of it... just don't use it unless you are absolutely *SURE* that is what you want to do.
I have an alias that is rm='rm -i' but that does nothing if you throw in the rm -rf.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.