How To Empty Trash From Terminal in Ubuntu

Hello Guys, As you and I always say and we will continue to say. “The command line is power” yes the command line is really power even more.

Today am going to share with you a command line skill of emptying Trash in Ubuntu. I have not tried it on other distros. If it works, good.

Launch Terminal (ctrl + alt + t).

In your home directory from the time. Run the command below:

$ cd /.local/share/Trash

trash_terminalIn the Trash directory type the ls command to list its contents.

enock@enock-pc:~/.local/share/Trash$ ls

trash_lsNow from the image above you can see that there three other directories located in Trash. (Am not sure you ever seen this before. Not even in GUI Trash too)

First of all all these directories perform a special function in the background which GUI Trash doesn’t show you.

Now assuming I have deleted a file or folder it will currently be located in files.

ls_filesInfo gives you summary or list of all the files that have passed through Trash file directory or are currently located there since you logged on.

ls_infoFor the final directory expunged is still in the research. I don’t know what it actually does. If you know kindly share with us and anyone reading this article by commenting its function. Thanks.

Now since we know all that are in Trash now is what we want remove, we can quickly run the command below to remove everything (including all those three directories)

enock@enock-pc:~/.local/share/Trash$ rm -rf *

rm_allAlso, you can also run a single command to save you the time of changing directories by combining all the above commands:

enock@enock-pc:~$ rm -rf ~/.local/share/Trash/files/*

OR

enock@enock-pc:~$ rm -rf ~/.local/share/Trash/*

empty_trash_terminalBut Note: These three directories are system directories so they will always be available anytime you push something to Trash. You can verify by repeating the steps treated earlier after moving something to Trash.