I accidentally deleted something on my Linux command line using the rm command. Can I set up a recycle bin for the command line?
I accidentally deleted something via rm on my Linux command line because I was careless. Is there any way to use a recycle bin on the command line?
Yes, there are different ways to do this, but not via rm. The "trash-cli" project is relatively well known. It provides the trash-put command to put files and folders in the trash. Further commands allow the basket to be inspected, emptied and so on.
trash-cli adheres to the FreeDesktop.org trash specification, so it uses the same trash bin as common GUI programs. Don't give in to the temptation to alias the rm command to trash-put. The author advises against this because the commands do not behave in the same way. It is better to deactivate rm via alias so that things are no longer accidentally deleted directly:
If something should be deleted directly, you can bypass the alias with a backslash: \ rm. As an alternative, there are wrapper scripts such as "rmtrash", which adapt the behavior of trash-put to rm.