LinuxCommandLibrary

trash-put

Move files/directories to the trash

TLDR

View documentation for the original command

$ tldr trash
copy

SYNOPSIS

trash-put [OPTIONS] FILE...

PARAMETERS

-h, --help
    Displays the help message and exits.

-v, --verbose
    Shows verbose output, explaining what is being done during the operation.

--debug
    Shows detailed debug output, primarily useful for development or troubleshooting.

--force-autodelete
    Forces automatic deletion of the oldest files in the trash if the trash bin becomes full during the operation.

DESCRIPTION

trash-put is a command-line utility from the trash-cli package that safely moves specified files and directories into the user's trash bin. Unlike rm, which permanently deletes files, trash-put allows for recovery of trashed items. It adheres to the FreeDesktop.org Trash specification, meaning files are moved to a specific trash directory (usually ~/.local/share/Trash) along with metadata about their original location and deletion time. This makes it a safer alternative to rm for everyday file management on the command line.

CAVEATS

trash-put moves files to the user's trash directory, typically ~/.local/share/Trash, not necessarily to an external drive's trash.
Files are not permanently deleted until the trash is emptied, either manually or if the trash fills up and --force-autodelete is active.
This command relies on the trash-cli package being installed.

FREEDESKTOP.ORG TRASH SPECIFICATION

trash-put strictly adheres to the FreeDesktop.org Trash Specification. This ensures that files moved to the trash via the command line are fully compatible with graphical desktop environments like GNOME, KDE, and XFCE. Items trashed using trash-put will appear in the GUI's trash bin and can be restored or permanently deleted from there.

TRASH LOCATION

By default, the user's trash directory is located at ~/.local/share/Trash.
Inside this directory, trashed items are stored in the files/ subdirectory, while metadata (original path, deletion date) for each item is kept in corresponding files within the info/ subdirectory.

HISTORY

The trash-cli project, which includes trash-put, was developed to provide a robust command-line interface that complies with the FreeDesktop.org Trash Specification. This initiative aimed to standardize trash management across various Linux desktop environments, allowing users to safely "delete" files to a recoverable state from the terminal. Its development started around 2008-2009, bringing GUI-like trash functionality to the command line.

SEE ALSO

Copied to clipboard