Delete Files And Folders From Linux Mint Command Line Without Using rm

If the rm command when using Linux Mint Terminal is something that is scary (quite rightly so because of rm -rf), then there is a safer alternative to deleting files and folders without worrying about messing up the system.

This is by using trash command. It works similar to recycle bin although from the command line.

First, install it from Terminal in Linux Mint/Ubuntu :

sudo apt install trash-cli

installing trash-cli in Linux Mint

Once installed, it is time to try it out.

Deleting files and folders :

To delete any file or folder, simply type :

trash filename or trash directoryname

deleting files using trash command in Linux Mint

It also supports wild cards and so you can delete multiple files and folders as needed.

using wildcards to delete multiple files and folders using trash command

You can also delete specific sub directories using trash.

deleting sub directories using trash command

Listing deleted items :

To know what is deleted but not emptied yet, simply give the following command :


listing the deleted files that can be restored using trash command

Restoring deleted items :

Also, you can restore deleted files and folders before they are permanently deleted, to do that the command is :


restoring deleted files and folders using trash command

You will then be prompted to enter the number corresponding to the deleted entries that need to be restored.

The items will now be restored back to their original location.

Emptying trash :

To permanently remove the deleted files and folders, use :


permanently emptying deleted files and folders using trash

All done.

Comments are closed.