cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Linux Trash can (With Keyboard Shortcuts)

BenGarrison
JumpCloud Alumni
JumpCloud Alumni

I know, this is a very simple thing, but I am learning and you're just going to have to deal with it!

One thing I like with Mac is the ability to delete and empty trash from keyboard shortcuts out of the box. Something very satisfying with pressing Cmd+Shift+Delete and then watching things go bye-bye.

With Linux, by default when you do a standard delete of a file, it stays in the trash can and won't go away. They just sit there, staring at you, wondering why you deleted them. Are you sure you want me to go away?.. YES! Go, now!

Sorry, got a little dark there for a moment. Where was I? Oh yeah, back to deleting files. There are two ways to delete files on Linux. First, you press the Delete button. I know, I was impressed too. The second way is to press Shift+Del. This will just zap those files like a bug swatter on the porch.

Using Trash CLI

Just remember to always Shift+Del and you're good to go. But what if you forget and you end up with over 1GB of unused, forgotten about files? #savethefiles. You can install trash-cli and then create a keyboard shortcut to create that satisfying experience you receive on Mac!

Install trash-cli in the terminal by running:
sudo apt install trash-cli
Let all the stuff install and press Y at some point, or don't.

Now that the highly technical installation is complete you now have access to the trash-cli. To empty your trash, just type trash-empty.

Take that a step further and create a keyboard shortcut. One of the amazing things about Linux is that everything can be done in the terminal. This means we can create keyboard shortcuts and map those to commands.

  1. Open Settings and find Keyboard shortcut
    Screenshot from 2022-03-11 05-24-22.png

2. Scroll down to the bottom and press the little + sign
Give your launcher a name, and enter the command trash-empty in the command field. Then create your shortcut, I used Ctrl+Shft+Del

Screenshot from 2022-03-11 05-25-40.png

Use your shortcut whenever you want to obliterate your pesky trash can goblins and take control of your life again!

0 REPLIES 0
You Might Like

New to the site? Take a look at these additional resources:

Community created scripts

Keep up with Product News

Read our community guidelines

Ready to join us? You can register here.