trash-cli is a client to manage the recycle bin from the command line. If you block rm or create an alias so that when you use rm you are actually using trash-cli, it is a good way to prevent data loss. Many times you delete certain files that you really did not want to delete or you do it carelessly and then you can no longer recover them. In this way, when you delete something with trash-cli, it will be left in the trash.
If you want to get them back it can be done easily. In addition, trash-cli will remember the date a certain file was deleted, its permissions, the path where it was located before it was deleted, and so you can recover them as they were in a very simple way. Something that with rm you will not be able to do, and in case of accidentally deleting them you would have to use forensic tools to try to recover them if possible ...
Installing trash-cli is very easy if you use your package manager from your favorite distro. For example, you can use apt-get install trash-cli for DEB distros. Once the package is installed, it gives you these commands:
- trash-put: remove files and directories
- trash-empty: empty the trash
- trash-list: list the files in the trash
- trash-restore: restore files that are in the trash
- trash-rm: individually delete a specific file that is in the trash
La trash-cli tool is Python based, and you can also install it from sources. The procedure is common for all distros and you can do it by following these simple steps:
git clone https://github.com/andreafrancia/trash-cli.git cd trash-cli sudo python setup.py install python setup.py install --user
Once installed, you can use the available commands from the terminal in a very simple way. For example, to send something to the trash, instead of using rm (which would be, in principle, unrecoverable), you can use this alternative: