Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Command Line

How to Automatically Empty Trash in Ubuntu: Desktop and Terminal Steps

By Freedom251 Team · · 12 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ubuntu’s GNOME desktop can delete Trash contents automatically. Open Settings → Privacy & Security → File History & Trash, enable Automatically Delete Trash Content, and choose the Automatically Delete Period shown on your system. The separate temporary-file switch is optional and does not control Trash.

For an immediate purge, use Empty Trash… in the same panel or run a documented command such as gio trash --empty. Automatic deletion is destructive, so inspect anything you might need before the selected period expires.

As an Amazon Associate I earn from qualifying purchases.

What Ubuntu’s automatic Trash setting does

Moving a file to Trash is not the same as deleting it permanently. The item remains in a Trash location until Ubuntu empties it. Ubuntu’s official help describes both manual cleanup and an option to have the computer do it automatically. The automatic control applies to Trash contents only when Automatically Delete Trash Content is enabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The cleanup interval is selected through Automatically Delete Period. Ubuntu’s help confirms that the period is configurable, but it does not publish a universal list of interval choices or specify the exact moment a background cleanup job runs. The available choices can therefore vary with the Ubuntu release, desktop build, or language. Select the interval actually displayed by your installation rather than assuming a particular default.

Temporary files use a different control. Automatically Delete Temporary Files can be left off if your goal is only to manage Trash. Enabling it adds a separate cleanup policy and should be treated as an independent decision.

Before you turn on automatic deletion

Understand the irreversible step

Trash is the safety net that lets you inspect or restore a file. Emptying Trash removes those discarded items and releases the space they occupy. After the purge, normal desktop recovery is no longer available, so check the Trash first for documents, photos, project folders, or downloaded files that may have been discarded accidentally.

Decide how long you need a recovery window

A short period reclaims space sooner but leaves less time to notice a mistake. A longer period preserves a larger recovery window while allowing more deleted data to accumulate. Choose a period based on how often you review deleted files and how tight your storage is; Ubuntu does not prescribe one interval for every user.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know that Trash is storage-location dependent

Trash can be stored differently depending on where an item resides. The gio documentation notes that not every filesystem supports the Trash concept. A file deleted from a removable drive, network mount, or unusual filesystem may therefore behave differently from a file deleted from your home directory. If a device has its own Trash folder or does not implement Trash, the desktop setting may not govern it in the same way.

Check the account and volume before automating

Trash is associated with the user and, in some cases, with the volume that contained the original file. A command run as one account does not automatically empty another account’s Trash. Likewise, a scheduled job cannot remove items on a drive that is disconnected when it runs. If you regularly use USB disks, network mounts, or multiple user accounts, include those limits in your policy instead of assuming one setting covers every discarded item.

Set up automatic Trash cleanup in Ubuntu’s desktop Settings

These steps describe the GNOME-based Ubuntu desktop help. Labels and available intervals can differ by release, so follow the wording shown in your installation.

  1. Open the Activities overview. Press the Super key or move the pointer to the hot corner, then search for Privacy & Security.
  2. Open the settings panel. Select Settings → Privacy & Security.
  3. Open the Trash controls. Choose File History & Trash.
  4. Enable Trash cleanup. Turn on Automatically Delete Trash Content. This is the switch that governs deleted files in Trash.
  5. Choose the retention period. Set Automatically Delete Period to one of the intervals offered on your system. The official help does not guarantee a fixed list of choices or a precise execution time across releases.
  6. Leave temporary-file cleanup unchanged unless wanted. Keep Automatically Delete Temporary Files off if you do not also want Ubuntu to remove temporary data under its separate policy.
  7. Close Settings. The preference is now configured; Ubuntu will apply its own cleanup mechanism according to the selected period.

The setting is a policy, not a countdown displayed for each file. Ubuntu’s documentation establishes that a configurable period exists, but it does not state exactly when the cleanup task runs after an item reaches that age. Do not treat the displayed interval as a guaranteed minute-by-minute schedule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to change or pause the policy

Return to the same File History & Trash panel whenever you need to change the interval. Turn Automatically Delete Trash Content off to pause automatic purging while you sort a large batch of files or investigate a mistaken deletion. Pausing the toggle does not restore files that were already emptied; it only stops the policy from removing future contents until you enable it again.

Empty Trash immediately from the graphical interface

If you need the disk space now, you do not have to wait for the automatic period.

  1. Return to Settings → Privacy & Security → File History & Trash.
  2. Review the items in Trash using the desktop file manager before proceeding.
  3. Select Empty Trash….
  4. Confirm the action when Ubuntu asks.

Emptying is the operation that frees the space occupied by trashed files. Merely moving another file into Trash does not reclaim that space.

Restore an item instead of emptying it

Open Trash in the file manager, select the file or folder, and use the restore action supplied by that file manager. Restoring returns the item to its original location when that location is available. If the original removable or network volume is disconnected, reconnect it before attempting the restore. Copy important content elsewhere if you are unsure whether the original path still exists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect and empty Trash from a terminal

Terminal commands are useful when you administer a machine remotely, prefer scripts, or want a repeatable manual action. Review the target first; a purge command is not a substitute for checking what is present.

List trashed files with gio

Ubuntu 22.04 LTS (Jammy) documents this command:

gio trash --list

The output lists trashed files and their original locations. Use it to identify an item before emptying the Trash. The command reflects the Trash implementation available to the current user and mounted locations; it is not a universal inventory for filesystems that do not support Trash.

Empty Trash with gio

Jammy’s gio manual documents:

gio trash --empty

This performs an immediate empty operation for the Trash handled by gio. Because it is destructive, run gio trash --list first when there is any chance you will need a discarded item.

Use trash-empty on Ubuntu 24.04 LTS

Ubuntu 24.04 LTS (Noble) documents the trash-empty utility from package trash-cli, version 0.23.11.10-1. If the command is not installed, install the trash-cli package from the repositories configured for your Noble system, then invoke the utility as follows.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
trash-empty

With no argument, trash-empty removes all items handled by the utility. To remove items older than a specified number of days, pass the number as an argument:

trash-empty N

Replace N with the age threshold you intend to use. The documented behavior is “older than N days,” not “exactly N days old,” so an item is retained until it exceeds the threshold. This command is an action you start yourself; it is not, by itself, a background scheduler.

Do not confuse a purge command with scheduling

gio trash --empty and trash-empty execute when called. To run one on a recurring basis, you must arrange a scheduler such as a user-level timer or cron and decide which account and Trash location it should affect. A scheduler can also run while a removable or network volume is unavailable, so test the command manually and account for the storage locations you actually use.

Plan a safe scheduled command

Use the same user account for testing and recurring execution. Start with a listing or dry test where the utility supports one, confirm the expected paths, and only then permit deletion. Record which volumes must be mounted and what happens when they are absent. Avoid putting an unconditional purge in a system-wide job if several users share the computer; that can target a different Trash scope from the one you intended. A conservative schedule should also leave enough time for you to notice accidental deletions before the age threshold is reached.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Desktop setting or terminal command?

Approach Configuration effort Policy available Scheduling Release evidence Main risk
Settings → Privacy & Security → File History & Trash Low; uses Ubuntu’s graphical controls Configurable Trash period; interval choices are whatever the system displays Built into the desktop policy; exact execution timing is not specified in the cited help Current stable Ubuntu desktop help A period that is too short can remove an item before you notice the mistake
gio trash --empty Low for a one-time command Immediate empty only Must be supplied separately Ubuntu 22.04 LTS Jammy gio manual Immediate, destructive purge if run without reviewing the list
trash-empty Low for manual use; suitable for scripts All items, or an age cutoff with N days Must be supplied separately Ubuntu 24.04 LTS Noble; trash-cli 0.23.11.10-1 An age rule can delete files as soon as they exceed the chosen threshold
autotrash More involved; policy and scheduler setup required Historical manual describes age and free-space thresholds plus dry-run support Historical Trusty page includes a cron example Ubuntu Trusty manpage, package 0.1.5-1; current compatibility not established Following an old example on a newer release without verifying package availability or behavior

For most desktop users, the built-in Settings control is the simplest and most directly supported choice. A terminal user who wants an immediate purge or an age argument can use the command documented for the Ubuntu release in question.

Which policy fits common situations?

Choose the desktop period when you want a simple recovery window and do not need storage-based rules. Choose gio trash --empty when a Jammy machine needs a one-time purge and you have already inspected the list. Choose Noble’s trash-empty N when age, rather than an immediate all-or-nothing purge, is the important rule. A free-space threshold can be useful on a constrained server, but it adds complexity and should not be adopted from an old example without confirming that the current package behaves as expected.

About the older autotrash utility

An Ubuntu Trusty manpage for autotrash (package version 0.1.5-1) describes more elaborate rules: purge by age, remove files when free space falls below or above a threshold, perform a --dry-run, and schedule the utility from cron. Those features can be useful in a controlled environment, but the cited documentation is for Trusty, an old Ubuntu release.

Do not assume that the Trusty package, command-line options, or cron example work unchanged on a current Ubuntu installation. Verify that a package exists for your release, read its local manual, and run a dry test before enabling a recurring job. If you cannot verify compatibility, use the current desktop setting or the release-specific gio and trash-empty documentation instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting automatic cleanup

The toggle is missing

Confirm that you are using Ubuntu’s GNOME-based desktop and that you opened Privacy & Security, not a similarly named privacy page from another desktop environment. Ubuntu flavors can expose different settings applications and labels. If File History & Trash is absent, use the file manager to inspect Trash and the command-line tools documented for your release.

Trash still contains files after the period has passed

The official help does not promise an exact cleanup timestamp. The period is a retention policy, while the actual cleanup task may run later. Check that Automatically Delete Trash Content remains enabled and that you selected the intended interval. Also consider whether the file came from a location whose filesystem does not implement the Trash concept in the same way.

Disk space did not increase

Space is not released merely by moving an item to Trash. Use Empty Trash…, gio trash --empty, or the appropriate trash-empty action, then check the filesystem where the original file lived. A separate mounted volume can retain its own Trash data, and a filesystem without Trash support may have deleted the file through a different path.

gio or trash-empty reports no items

Commands operate within the Trash locations they understand for the current user and supported filesystems. Check the command spelling, run the listing command first, and verify that the file was deleted under the same user account. Inspect removable or network storage separately when applicable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A command is not found

gio is part of the desktop’s GLib tooling, while trash-empty belongs to the trash-cli package documented for Noble. Install the package appropriate to your release using its configured Ubuntu repositories, or use the graphical Empty Trash control when you do not need a terminal workflow.

The setting changed but old files remain

Enabling the toggle does not necessarily empty existing contents immediately. Existing items are evaluated by the desktop’s cleanup mechanism according to its policy. If you need space now, use Empty Trash… or a documented purge command after reviewing the list. Do not repeatedly toggle the setting as a substitute for an explicit empty operation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Safe operating checklist

  • Open Trash in the file manager before the first automatic purge.
  • Restore or copy out anything that must remain recoverable.
  • Choose a retention period that matches your review habits, not just your available disk space.
  • Keep temporary-file deletion off unless you have separately decided to manage temporary data.
  • Use gio trash --list before a command-line purge when the contents are uncertain.
  • Test any scheduled command manually under the same user account and with the same mounted volumes that the scheduler will see.
  • Do not apply the old Trusty autotrash instructions to a current release without checking package and option compatibility.
  • Keep backups for important files; Trash is not a backup system and an emptied item is not normally restorable through the desktop.

Release and version boundaries

The graphical route comes from Ubuntu’s stable desktop help and is intended for the GNOME-based Ubuntu desktop. Settings names and interval choices can change between releases.

The gio behavior described here comes from the Ubuntu 22.04 LTS Jammy manual. The trash-empty details come from Ubuntu 24.04 LTS Noble and identify trash-cli version 0.23.11.10-1. The autotrash information is specifically an Ubuntu Trusty manual page for version 0.1.5-1; it is historical reference material, not confirmation of current-release support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which method should you use?

Choose the graphical setting if you want Ubuntu to manage a retention period without maintaining a script. Choose gio trash --empty for a straightforward, immediate terminal purge on a Jammy system, or use Noble’s trash-empty when an immediate or age-based command fits your workflow. Use an external scheduler only after deciding which user, filesystems, and age policy it should cover. In every case, inspect important discarded files before the purge because emptying Trash is the point at which recovery through Trash ends.

Frequently Asked Questions

How do I automatically empty the Trash in Ubuntu?

Open Activities and search for Privacy & Security. Go to File History & Trash, enable Automatically Delete Trash Content, and select the Automatically Delete Period offered by your installation. The interval choices and exact cleanup time can vary by Ubuntu release.

Does moving a file to Trash free disk space?

No. Moving a file only places it in a Trash location. Space is released when you use Empty Trash…, gio trash –empty, or another supported purge action.

Can I empty Ubuntu Trash immediately?

Yes. Review the contents in the file manager, then choose Empty Trash… in Settings → Privacy & Security → File History & Trash. On Jammy, gio trash –empty is the documented terminal alternative.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I delete Trash files older than a certain number of days?

On Ubuntu 24.04 LTS, the documented trash-empty utility accepts an age argument: trash-empty N. It removes items older than N days. It performs the action when called; it does not create a recurring schedule by itself.

Is automatic deletion of temporary files the same as automatic Trash deletion?

No. Automatically Delete Temporary Files is a separate setting. Leave it disabled if you only want to control discarded files in Trash.

Why does automatic cleanup not affect a USB or network drive?

Trash handling depends on the storage location and filesystem. Some volumes maintain separate Trash data, some are unavailable when a scheduled job runs, and not every filesystem supports the Trash concept. Check the volume while it is mounted and use the account that deleted the files.

Is autotrash safe to use on current Ubuntu?

The cited autotrash documentation is an Ubuntu Trusty manpage for version 0.1.5-1. It describes age and free-space rules, dry-run support, and a cron example, but it does not establish current-release compatibility. Verify package availability and options locally before using it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I recover a file after emptying Trash?

Normal desktop restore works only while the item remains in Trash. Once Trash is emptied, recovery through Ubuntu’s file manager is no longer available, so inspect and restore important files beforehand and rely on backups for longer-term protection.

The Bottom Line

For most Ubuntu desktop users, enable Automatically Delete Trash Content under Settings → Privacy & Security → File History & Trash, then choose the interval shown on your system. Empty Trash manually when space is urgent. For terminal workflows, inspect with gio trash --list, use gio trash --empty on Jammy, or use Noble’s trash-empty with an optional age threshold. Every purge is destructive, so verify the account, volume, and contents first.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Command LineGNOMELinuxTrashUbuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.