When we delete a file or folder from our system, it moves to the Trash folder(Linux) or the Recycle Bin(Windows). Time and again, we need to get rid of these mostly useless files and folders residing in our system trash in order to vacate space for other important data.
In this article, we will describe several ways to empty your system trash, both through the UI and the command line.
We have run the procedure and commands mentioned in this article on a Ubuntu 22.04 and Ubuntu 20.04 system.
Emptying Trash Through the UI
For a person who does not like to use the command line much, the UI provides the following ways to empty your deleted files from Trash:
Method 1: Use Trash-Folder Icon context menu
Open the File Manager from the Activities bar and locate the Trash folder from the list of folders in the left panel. Right-click the Trash folder and select the Empty Trash option from the menu as follows:
All the files and folders will be removed from your trash can.
Method 2: Use Ubuntu File Manager
Another way of deleting the Trash is to open the Trash folder from the File Manager and then press the Empty button located at the top-right corner of the window.
This way your Trash will be emptied, deleting all the files and folders simultaneously.
You can also right-click an individual item and select the Delete from Trash option in order to permanently remove it from your system but deleting items one by one is a time-consuming task.
Emptying Trash Through the Command Line
Emptying the Trash through the Command Line is a lot easier and faster. Even if you are not a command line pro, the following simple methods will enable you to empty your trash can very easily:
Method 1: Delete files in the Trash folder with the rm command
Open the Linux command line application, the Terminal, through the Ubuntu Dash or through the Ctrl+Alt+T shortcut. The files and folders of a user’s trash are located in that user’s /local/share/Trash folder, files sub-folder. So we need to enter the following commands to reach there:
$ cd .local/share/Trash/
$ cd files
You can then remove all the files through the following command:
$ rm -rf *
You will see that your Trash can is completely emptied.
Method 2: Use empty-trash command
The Trash CLI utility also lets you empty your trash effectively and very easily. First, you need to install it through the following simple command as a root user:
$ sudo apt install trash-cli
You will be asked to provide the password for the root user. When you enter the correct password, the installation process will begin.
You can then enter the following command in order to delete the Trash contents:
In older versions of the utility, you could use the following command to empty the trash:
So you can try whatever works for you and you will be able to see your Trash emptied.
Among the four above-mentioned methods to empty the Trash on a Ubuntu system, you can try whichever method suits you. You will then be able to delete the unwanted files taking system resources and making space for more important files and data.