Linux: Use trash instead of rm
Why use trash instead of rm ?
If you wrongly rm sth, it can’t recovered.
While if you just move sth to trash, it could be recovered.
Use trash in your Linux
-
Install trash command.
In Ubuntu 14.04, run:sudo apt-get install trash - Add following lines into ~/.bashrc.
alias trash="trash" alias th="trash" alias del="trash" alias rm="echo Use 'del' to move to trash, or the full path i.e. '/bin/rm'" alias trash-restore="restore-trash" # since trash-restore is easy to use than original restore-trash. - Let it take effect, run:
source .bashrc
Examples
- To delete sth
touch foo del fooor
touch foo th foo - View all deleted files:
trash-list - How to restore?
-
First way: run
trash-restore, and input index of file you want to restore. -
Second way: Go to /home/$username/.local/share/Trash/files and save your file.
-
Leave a Comment
Your email address will not be published. Required fields are marked *