1. Home
  2. Linux

How to automatically empty the trash on Linux

The trash feature on many Linux distributions is a lot like the “Recycle bin” on Microsoft Windows, or the feature of the same name on Apple’s macOS. With it, users can send files and folders they don’t like in the “trash bin.” Effectively, getting things out of the way.

Primarily, all Linux desktop environments come with a trash bin, and when you click the “delete” button on the keyboard, files go there. Over time, the data fills up the trash bin and takes up space, which can eat up the space of your hard drive. Sadly, on Linux, the trash bin has finite space by default. Even worse, it’s not set to clear it out automatically. Luckily, with a few tricks, you can automatically empty the trash on Linux with a bit of configuration.

Installing Autotrash

Autotrash is a hands-off way you can easily set your Linux PC to empty the trash. It can be configured with a Cron job, and can even be used to purge multiple users’ trash folders, rather than just one.

To get the Autotrash application set up on your Linux distribution, open up a terminal window by pressing the Ctrl + Alt + T or Ctrl + Shift + T on the keyboard.

Once your terminal session is open, follow the installation instructions that correspond to the Linux operating system you are using.


The Autotrash tool is distributed to Ubuntu users in the central software repository. To install it, use the Apt command below.

sudo apt install autotrash


Debian users can install the Autotrash tool through Debian’s primary software sources. To get it, enter the Apt-get command below.

sudo apt-get install autotrash

Arch Linux

On Arch Linux, the Autotrash tool is not available for users in the traditional means. Instead, those looking to get it working must manually build it via the project’s Github page.

To start the building process, install the “Git” package using the Pacman package manager.

sudo pacman -S git

With the “Git” package set up on your Arch Linux PC, it’s time to download the Autotrash source code using the git clone command.

git clone https://github.com/bneijt/autotrash.git

With the code done downloading, use the CD command to move the terminal session from the home folder (~/) to the new “autotrash” directory.

cd autotrash

Inside of the “autotrash” directory, it’s time to install the program. To start the installer script, run:

sudo python setup.py install


Fedora Linux has had the Autotrash tool in their software repositories for quite a while, . To get it working, launch a terminal session and use the DNF package manager command below.

sudo dnf install autotrash -y


Are you using OpenSUSE Linux? Want to run the Autotrash application? Lucky for you, the app is available on OpenSUSE LEAP and Tumbleweed via the OSS All software repository.

To install it, ensure that you’ve got “OSS All” enabled in YaST. Then, enter the Zypper command in a terminal window to get the program working on your system.

sudo zypper install autotrash -y

Configure Autotrash

Autotrash is a tool that can be manually configured to empty the trash on your Linux PC. However, out of the box, just installing the tool does nothing. Instead, you need to set up an automatic script.

On the developer’s GitHub page it states the best way to automate the Autotrash application is with a Cron-job. To set up the job, you’ll need to be able to access Cron on your Linux PC.

Note: most Linux OSes come with the ability to use Cron right away. If you’re unable to use the Cron tool, check out our post on how to set up and use the Cron tool.

To create a new job, launch a terminal and enter:

EDITOR=nano crontab -e

Paste the following code into the Nano text editor.

@daily /usr/bin/autotrash -d 30

Save the edits to your new Cron job by pressing Ctrl + O. Then, exit by pressing Ctrl + X.

Assuming the Crontab is set up right, your trash should automatically be emptied.

Empty trash for all users

If you’d like to automatically empty the trash on Linux for all users, rather than just a single user, it is possible. To do it, you’ll need to create a Cron job.

First, open Crontab in the terminal.

EDITOR=nano crontab -e

Delete any text in the Crontab and make sure it’s blank. Then, paste this line of code into the editor.

@daily /usr/bin/autotrash -td 30

Save the job by pressing Ctrl + O on the keyboard. Then, exit the editor by using the Ctrl + X keyboard combination.

Assuming the code was set up correctly in the Cron job, Autotrash will automatically empty the trash on your Linux PC for every user.

Leave a comment