How to empty trash from Ubuntu terminal

Ubuntu is the widely used desktop operating system in the open-source community. The “Recycle Bin” in Windows and “Trash” in Ubuntu are both utilized to store deleted files and restore them at any time. While working in an Ubuntu, if you delete a file or directory from your system, the system moves that file to the trash folder. You can also empty your system trash to get rid of unwanted folders and files. This operation will also free up some space from your system that can store other crucial data.

Each Linux distribution has its methods for emptying the trash. This article will show you how to empty trash from Ubuntu terminal using two different methods. So let’s start!

How to empty trash from Ubuntu terminal using rm command

Deleting files from GUI trash can take a long time, or it can also cause your computer to hang up. In this situation, removing a single file will be a time-consuming process. Instead of utilizing the Ubuntu GUI, you can use the popular “rm” command for erasing all of the contents present inside the trash in a single go. In the Ubuntu terminal, the “rm” command is used for removing or deleting the files that are no longer required. If you want to empty your system trash using the rm command in the terminal, then follow the below-given procedure:

First of all, we will open up our Ubuntu terminal by pressing “CTRL+ALT+T“; you can also type “terminal” in the application’s search bar as follows:

Files and directories present in a user’s trash are stored in the “.local/share/Trash/” directory. This directory is also known as the “Ubuntu trash directory”. First of all, we will check the content of our trash directory. For that, we will switch our current working directory to the trash directory by utilizing the “cd” command. The “cd” command permits its users to move between directories. You can access the trash directory as “current working directory” by executing this command in your Ubuntu terminal:

$ cd .local/share/Trash/

Now, write out the “ls” command to list out the content of the trash directory:

$ ls

The output declares that we have two directories inside of the trash directory: info and files. Firstly, these directories perform specific background tasks which the GUI trash does not reveal. For instance, you can check out the below-given image of our GUI trash, where GUI trash is not showing “files” or “info” directories, which we retrieved during the execution of the “ls” command:

So, here comes another benefit of emptying trash using the Ubuntu terminal that you can look into what is going on inside the trash directory. The “files” directory contains the deleted files in the trash directory, while “info” contains the path of every deleted file, its permissions, and deletion date. Now, move into the “files” directory”:

$ cd files

Again, execute the “ls” command for listing the deleted files present inside the “files” directory:

$ ls

Now, the terminal will show the deleted file names, which GUI trash was displaying first hand:

In your Ubuntu terminal, empty your trash at once by executing the below-given “rm” command:

$ rm -rf *

Here, the “r” option indicates “recursive removal“, the “f” option is used to “force the action,” and “*” is used to delete all files:

To confirm that the trash is empty, list out its content:

$ ls

Now, your Ubuntu terminal will show you nothing:

You can also open up the trash directory using Ubuntu GUI to verify the performed action:

How to empty trash from Ubuntu terminal using trash-cli

Another method to empty trash from your terminal is to use the “trash-cli“. This utility offers you the option to remove the deleted files from the trash. Many popular desktop distributions, including Ubuntu, have this command-line utility in their software repositories. In your Ubuntu terminal, write out below-given command for installing “trash-cli”:

$ sudo apt install trash-cli

Enter “y/Y” to permit the installation process to continue:

For the demonstration of the working of trash-cli utility, we have deleted some unnecessary files from our system:

The “trash-cli” utility provides five commands which you can use for performing various operations through the terminal, such as:

  • trash-list” command is used to display the trash content.
  • trash-put” command is used to delete specified files or directories from the trash.
  • trash-empty” command is used to delete all files and directories from the trash at once.
  • trash-rm” command is used to delete individual files or directories.
  • restore-trash” command is used to restore a directory or file from the trash.

In our case, we will utilize the “trash-empty” command to empty trash at once:

$ trash-empty

The error-free output declares that files have been successfully removed from the trash. You can also verify that now the trash is empty or not by opening up the GUI trash:


In Ubuntu, when you delete unnecessary files or folders, it directly goes to the “trash” folder. Emptying trash can free up system space that can be utilized for other important data. If you want to empty your Ubuntu trash, then go for the command-line method because the GUI trash can get hung any time. This article showed how to empty trash from the Ubuntu terminal using the “rm” command and the “trash-cli” utility. Choose your favorite one between these simple methods and try it out on your Ubuntu!

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.