Every Linux distribution provides a certain way to empty the trash. You can even empty trash from the terminal. I’ll show you both ways in this quick tutorial.
Method 1: Empty trash using GUI
Some Linux distributions (or more accurately desktop environments) have the trash bin aka the recycle bin on the desktop itself. You can empty the trash from here by right-clicking on it.
In other desktop environments, you can empty the trash from the file manager. Just look for ‘Trash’ icon and right click on it and empty the trash.
That’s how I clean the recycle bin in Ubuntu.
But the other day I ran in to an issue while emptying trash in Ubuntu. I right clicked on the trash icon and chose Empty Trash option, like I always do. It took some time with a progress bar showing that it was in the process of deleting the files in trash. But it just got stuck at it and I got ended with a frozen Nautilus File manager. I had to kill the process terminal.
But this was painful because the files in trash were still there. And my repeated attempts to delete the trash resulted in same frozen window.
Method 2: Empty trash from terminal in Linux
Honestly, I do not know what caused this issue in the first place. But I do have a solution for you if you too are facing issue in deleting the trash via GUI in Ubuntu.
The location of the trash in Ubuntu (and other Linux) is .local/share/Trash/ in your home directory. To empty trash, you can delete the contents of this directory.
Open a terminal and use the following command:
rm -rf ~/.local/share/Trash/*
Now, be careful in what you type with rm -rf. You are using the remove command. I trust you that you won’t be deleting any other files or directory. Otherwise recovering deleted files in Linux is a painful job.
You could cd into trash first and then remove the content of the directory.
The above mentioned command is deleting all the files in Trash directory. In other words, it is emptying the trash in command line way. Once you use that command, you’ll see that the Trash has been emptied. If you delete any new files, you should not be having the same freezing Nautilus issue again.
Keep in mind that if you delete files in Linux using the rm command, it doesn’t go to the recycle bin.
Worked for you?
I hope this little tip worked for you and you can empty the trash without any further issue in Ubuntu or any other Linux distribution. Do let me know if you face any issue.