Whenever you delete a file or directory in Linux by default it doesn’t get permanently deleted instead it is moved to the Trash. The trash in Linux is the same as Recycle Bin which is used in Windows operating system. Later if you require a deleted file or directory you can simply find and restore it from Trash.
The files or directories that are in Trash still occupy space on your system so most of the time you may want to delete them even from the Trash.
So In this article, I will discuss how to clear trash using GUI and terminal in Linux.
Empty Trash using GUI
Using the GUI you can easily clear the Trash on your Linux system but sometimes when there is a large number of files and directories you may feel that it takes a comparatively longer time which can cause problems like system hang.
First press Windows Key + E to open my computer.
On the left-hand side right-click on the Trash and then click on Empty Trash.
Next, it will display a confirmation dialog again click on Empty Trash.
Now all the items from Trash will get permanently deleted.
Empty Trash by using Terminal
The location of trash in Linux is
.local/share/Trash/ in your home directory. You can empty the Trash by deleting files and directories from your terminal.
To clear Trash from your terminal first open your terminal by pressing ctrl+alt+t and then use the given command –
rm -rf ~/.local/share/Trash/*
This will remove all the files and directories that are in the trash. Alternatively, you can move to this location and then run the rm command to delete all the files and directories.
Please think twice before deleting all the files and directories from the Trash else the recovery of these is a very painful process.
Ok, that’s all for now I hope the methods to empty the trash are useful to you. Now if you have a query then write us in the comments below.