DevOps tips & tricks - Logical rm

Scenario

In Linux, deleting files is a very sensitive operation. Once deleteted, the files are definitively lost.

Solution

The plugin trash-cli allows to have a way to undelete files if needed. In fact, the files are moved in a hidden folder (~/.local).

To install trash-cli:

sudo apt install trash-cli

To remove files:

trash file.txt

Or multiple files:

trash file1.txt file2.txt

To list the trash content:

trash-list

To restore a file from trash:

restore-trash

To remove all the files from the trash:

trash-empty

This command is the same as the rm command.

#

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×