Every Linux distribution provides a certain way to empty the trash. 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.
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.
Empty trash using Linux command line
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.
Open a terminal and use the following command:
rm -rf ~/.local/share/Trash/*
Now be careful in what you type. 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.
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.
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.