This simple tutorial shows how to automatically remove trash / temporary files after given days in Linux with most desktop environments, such as Cinnamon, XFCE, KDE, MATE.
Trash and temporary files can sometimes contain personal and sensitive information. So, it’s useful to let your system to automatically empty them which can also free up your disk spaces.
In GNOME, the default desktop for Ubuntu, Fedora Workstation and optional in many other Linux, user can go to “Settings -> Privacy -> File History & Trash” to enable this function. And, here’s a step by step tutorial talking about it.
For other Linux Desktop Environments, here are the how to tips.
Automatically Empty Trash/Temporary files in Linux Mint Cinnamon
For Linux Mint and other Linux with Cinnamon desktop, there’s hidden option to do the job. User can choose to configure it either via command or graphical tool.
Option 1: Use gsettings command
First, search for and open “terminal” from start menu. Then, user can enable this feature by running the commands below one by one:
To automatically remove old trash files:
gsettings set org.cinnamon.desktop.privacy remove-old-trash-files true
To automatically remove old temporary files:
gsettings set org.cinnamon.desktop.privacy remove-old-temp-files true
And specify how many days old files to remove automatically (15 days for example):
gsettings set org.cinnamon.desktop.privacy old-files-age 15
Option 2: Use Dconf Editor (graphical)
For choice, user can use “Dconf Editor” configuration tool do the job.
- First, search for and launch “Dconf Editor” from start menu. Install it from software manager if you don’t have it.
- Then, navigate to ‘
- Finally, turn on ‘
remove-old-temp-files‘ and ‘
- And, change the value number for ‘
Automatically Empty Trash in KDE Plasma 5
For KUbuntu, Ubuntu Studio and other Linux with KDE desktop environment, simply open ‘Dolphin‘ file manager.
Then go to ‘☰’ menu -> ‘configure Dolphin’. In pop-up dialog, you’ll see the option to “Delete files older give days” under Trash settings page.
Auto Empty Trash in XFCE4, MATE and other Linux Desktops
If you don’t find out the option in other Linux desktops, there’s a command line tool to do the job in universal way.
1. First, open “terminal” from system app launcher and run command to install
- For Debian and Ubuntu based systems, run command:
sudo apt install trash-cli
- For Fedora, RHEL, based systems, run:
sudo dnf install trash-cli
- Arch Linux and its based systems can install it via:
sudo pacman -S trash-cli
(crontab -l ; echo "@daily $(which trash-empty) 30") | crontab -
It creates a crontab job, that automatically run
/usr/bin/trash-empty 30 everyday in the background, to remove trash files older than 30 days. Change number 30 as you prefer.
In this tutorial I taught how to automatically empty trash and/or temporary files in most Linux desktops. For Gnome, there’s graphical option in ‘Privacy’ settings. And, KDE has the option in its Dolphin file manager’s configuration page.
Linux Mint Cinnamon has hidden option to do the job, user can choose either
gsettings command or ‘Dconf Editor’ to configure it. And, for most other Linux Desktops, there are a few 3rd party tool can do the job. Here’s I chose to use
trash-cli by creating crontab job to automatically run it in the background.