Alias rm to other command, never delete wrong files
At the leap year 29 Feb. I wrote the post to remember my unforgettable experience about Linux command rm
(remove).
we should not use rm
command, to instead, we need use trash-put
from trash-cli
package.
Just Edit your .bashrc now!
dnf install -y trash-cli
echo "alias rm='trash-put'" >> ~/.bashrc
source ~/.bashrc
The whole story began with my auto-rename script, I wrote it to rename pictures. After added some new features to this script, the program had move all pictures from Pictures folder to root directory. I didn’t check if the renamed pictures are in the Pictures folder and deleted them which in the root directory. In the end, I lost all picutures.
Try to restore them is a tough task.
First, I installed testdisk
, and using photorec
to restore pictures.
This tool has many drawbacks, it will give you all the deleted pictures without a user friendly filename and modified date.
It is difficult to use it find only few files(50+) in a million restore files.
Then, I use another tool, namely EasyCovery, it gave me the correct files.
The whole lesson I learned is never use rm
again.