Are you losing GB of storage space because you forget to empty your recycle bin? With AutoTrash, you can tell Ubuntu to automatically empty the Trash by itself, based on the conditions you specify.
Installing AutoTrash
You will no longer find AutoTrash in the repositories of many distributions. For most users, the easiest way to install it is to use an unofficial version of snap, available in the snap store.
If you are using Ubuntu, which in its latest versions already supports snaps by default, you can find the program in Software Center by searching for “autotrash”.
Select the “autotrash-unofficial” entry that will appear and install it by clicking on the green Install button.

For those who prefer typing commands rather than clicking, you can do the same by activating your preferred terminal and using:
sudo snap install autotrash-unofficial
If the program is not available in your distribution’s repositories but you also have a loathing for snaps, there is a workaround. Since this is a Python script, you can use pip to install autotrash with:
When you install it like this, for ease of use, be sure to include its location in your PATH variable.

Define an alias
If you installed AutoTrash via the easier way of snap, you can try it out by typing autotrash-unofficial
in a terminal. You can also set up an alias for easier access.
If you prefer to type autotrash
instead of autotrash-unofficial
to run the tool, enter the following into the terminal:
sudo snap alias autotrash-unofficial autotrash

Clean your trash
AutoTrash comes with a list of settings that allow you to customize how it will clear your Trash.
Using -d
, you can set a date threshold. Anything that has been placed in the trash within the specified number of days will remain intact; AutoTrash will erase anything older. For example, to eliminate all files older than 10 days, use:
If you have enough free space, there is no point in trying to free up even more by deleting old files. Instead of checking it yourself, you can specify a free space threshold with --max-free
. Values are in megabytes.
If you want AutoTrash to wipe out anything older than ten days only if your free space has dropped below 4 GB, you would use:
autotrash -d 10 --max-free 4096
Since 1 GB = 1024 MB, the above number translates to 4 GB (4 x 1024).

You can make AutoTrash make sure you always have at least 512 megabytes of free space available with:
autotrash -d 10 --min-free 512 --keep-free 512
You can change 512 to whatever value you prefer.
It is best to always make sure that the results of any action match your original intention. You can ask AutoTrash to perform a test that does not make any real changes to your data, using the --dry-run
switch. It has no additional value. Include it as is at the end of your order to verify its result. So with this addition, the previous example would look like:
autotrash -d 10 --min-free 512 --keep-free 512 --dry-run

Automatic purge
Having to run AutoTrash to manually purge the contents of your Trash is less than optimal. Fortunately, it’s easy to run it automatically. You can set up a cron job for this, but we think the following approach is even easier.
Search for “startup” among your apps and open the startup apps preferences.

Create an empty bash script the way you prefer and enter your AutoTrash command. I created a folder called Scripts
in my home directory, then an empty Bash script named autoautotrash.sh
inside.

I entered my autotrash command, saved the changes (Ctrl + W), and left Nano (Ctrl + X).

With your command in your script, make it executable by entering the following into your preferred terminal:
In my case, this command looks like:
chmod +x autoautotrash.sh

Finally, go back to the startup apps preferences. Click the Add button at the top right to create a new entry. In the window that will appear, enter a name for your entry, your script as a command, and if you wish, a comment on what it does, which will be useful for future reference.

That’s all. From now on, every time you log into your desktop, your script will be one of the first things to run, purge files from your recycle bin, and free up valuable storage.

Now that you’ve emptied your trash, if you’re still looking for more ways to clean your Ubuntu machine, check this out.
Related:
Is this article useful?
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘400239050508508’);
fbq(‘track’, ‘PageView’);