trash-empty
Empty the trash can
TLDR
View documentation for trash-empty
SYNOPSIS
trash-empty [OPTION...] [DAYS]
PARAMETERS
[DAYS]
Empties items that have been in the trash for longer than the specified number of days. If not provided, all items in the trash are permanently deleted.
--days DAYS
Equivalent to specifying DAYS directly. Empties items older than DAYS.
-f, --force
Do not ask for confirmation before emptying the trash. Use with caution as this action is irreversible.
-v, --verbose
Display a list of each file and directory as it is being permanently deleted from the trash.
DESCRIPTION
trash-empty is a command-line utility used to permanently delete files and directories that have been moved to the trash according to the freedesktop.org Trash Specification. It is part of the trash-cli package, which provides a suite of tools for managing the user's trash from the terminal. Unlike the rm command, which deletes files immediately, trash-put moves files to a designated trash directory, allowing for later recovery. trash-empty then serves as the final step, removing these trashed items to free up disk space.
When executed without any arguments, trash-empty will delete all items currently in the trash. Users can also specify a number of DAYS to empty only those items that are older than the specified duration, providing a way to manage trash retention policies. This command is particularly useful for users who prefer to manage their system from the terminal but still wish to utilize the safety net of a trash bin, similar to what graphical file managers provide.
CAVEATS
- Irreversible Action: Once trash-empty is executed, the files are permanently deleted and cannot be recovered through the trash system. There is no "undo" for this command.
- User-Specific Trash: trash-empty manages the trash for the current user session. It does not affect trash bins of other users or the root user.
- Adherence to Standard: It only empties files placed in the trash according to the freedesktop.org Trash Specification (typically located in ~/.local/share/Trash). Files deleted via rm or other non-trash-aware methods are not affected.
TRASH LOCATION
The standard location for a user's trash directory on Linux systems, adhering to the freedesktop.org Trash Specification, is typically ~/.local/share/Trash/. This directory contains two subdirectories: files/ (where the actual deleted items reside) and info/ (which stores metadata like original path and deletion date). trash-empty operates by removing entries from both these locations.
INTEGRATION WITH DESKTOP ENVIRONMENTS
Because trash-empty follows the freedesktop.org standard, it seamlessly integrates with most modern Linux desktop environments (e.g., GNOME, KDE, XFCE). Files moved to trash via the file manager (e.g., Nautilus, Dolphin) can be emptied using trash-empty, and vice-versa.
HISTORY
The trash-cli project, which includes trash-empty, was developed to bring the convenience and safety of the freedesktop.org trash bin to the command line. Before trash-cli, users had to choose between the permanent deletion of rm or manually navigating to the trash directory. trash-cli aimed to bridge this gap, allowing terminal users to utilize the same trash mechanism as their graphical desktop environments. trash-empty specifically provides the necessary command to finally clear out accumulated trashed items, completing the trash management workflow.
SEE ALSO
trash-put(1), trash-list(1), trash-restore(1), rm(1), mv(1)