LinuxCommandLibrary

trash-rm

Move files and directories to the trash

TLDR

View documentation for trash-rm

$ tldr trash
copy

SYNOPSIS

trash-rm [OPTIONS] FILE...

PARAMETERS

--force, -f
    Ignore non-existent files and arguments, never prompt.

--interactive, -i
    Prompt before every removal.

--recursive, -R, -r
    Remove directories and their contents recursively.

--verbose, -v
    Explain what is being done.

--help
    Display a help message and exit.

--version
    Output version information and exit.

DESCRIPTION

trash-rm is a command-line utility that acts as a safer alternative to the standard rm command.
Instead of permanently deleting files and directories, trash-rm moves them to the user's trash bin, typically located at ~/.local/share/Trash, adhering to the Freedesktop.org Trash Specification. This allows for easy recovery of accidentally deleted items, providing a crucial safety net for command-line users. It's particularly useful when dealing with sensitive data or when you want to avoid immediate, irreversible deletion.
The command supports recursive removal of directories and common options similar to rm, making it a familiar and secure replacement for everyday file management tasks. Files moved to the trash can be restored later using trash-restore or permanently removed using trash-empty.

CAVEATS

While trash-rm provides a safety net by moving files to the trash, it does not guarantee permanent deletion. Users must explicitly empty the trash to free up disk space or permanently remove files. The trash bin is typically stored on the same filesystem as the user's home directory; moving very large files across filesystems might be slower as it may involve a copy operation.
Files on read-only filesystems cannot be trashed. The command relies on the Freedesktop.org Trash specification; environments not adhering to this might not fully integrate with graphical trash bins.

FREEDESKTOP.ORG TRASH SPECIFICATION

trash-rm adheres to the Freedesktop.org Trash Specification, meaning files are moved to a standardized location (typically ~/.local/share/Trash) along with metadata about their original path and deletion date. This allows compatibility with graphical desktop environments' trash bins and easy restoration.

DISK SPACE MANAGEMENT

Since trash-rm moves files rather than deleting them, trashed files continue to consume disk space. Users must periodically empty their trash (e.g., using trash-empty) to reclaim storage. Unmanaged trash can potentially fill up a disk over time.

HISTORY

trash-rm is part of the trash-cli project, a set of command-line tools designed to interact with the Freedesktop.org Trash specification. This specification defines a standardized way for applications to move files to a trash folder, enabling consistency across desktop environments.
trash-cli was developed to bring this standardized trash functionality to the command line, providing a safer alternative to the traditional rm command, which permanently deletes files without a recovery option. The project aims to integrate seamlessly with the user's existing desktop trash bin.

SEE ALSO

Copied to clipboard