trash-rm
Move files and directories to the trash
TLDR
View documentation for trash-rm
SYNOPSIS
trash-rm [OPTION]... FILE...
PARAMETERS
-f, --force
Ignore nonexistent files and arguments, never prompt.
-i, --interactive
Prompt before every removal.
-I, --interactive[=WHEN]
Prompt once before removing more than three files, or when removing recursively; WHEN may be 'never', 'once' (-I), or 'always' (-i); if no WHEN, prompt only when removing more than three files, or when removing recursively.
--one-file-system
When removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument.
--no-preserve-root
Do not treat '/' specially.
--preserve-root
Fail to operate recursively on '/', the default behavior.
-r, -R, --recursive
Remove directories and their contents recursively.
-d, --dir
Remove empty directories.
-v, --verbose
Explain what is being done.
--help
Display this help and exit.
--version
Output version information and exit.
DESCRIPTION
The trash-rm command provides a safer alternative to the standard rm command by moving files and directories to the system's trash or recycle bin instead of permanently deleting them. This allows users to recover accidentally deleted files. It integrates with various desktop environments like GNOME, KDE, and XFCE, respecting their trash management protocols.
The command relies on the 'trash-cli' utilities package, which needs to be installed separately. It checks the system's XDG configuration to determine the location of the trash directory, typically located within the user's home directory (e.g., ~/.local/share/Trash). When a file or directory is 'trashed', it's moved to the 'files' subdirectory of the trash directory, and a corresponding '.trashinfo' file is created in the 'info' subdirectory, storing information like the original path and deletion time.
Trash-rm will also respect the filesystem. It will refuse to work across filesystems and throw an error.
trash-rm provides a safety net against accidental data loss, but it's important to regularly empty the trash to reclaim disk space.
CAVEATS
Files in the trash bin still take up disk space. Regularly empty the trash to free up space. The trash-rm command relies on the 'trash-cli' package being installed.
EXIT STATUS
The trash-rm command exits with a status of 0 if successful, and a non-zero value if an error occurs. Common errors include insufficient permissions, inability to access files or directories, or failure to move the file to the trash directory.
HISTORY
trash-rm is part of the 'trash-cli' utilities, designed to provide a command-line interface to the freedesktop.org trash specification. It was developed to offer a safer alternative to the standard rm command, reducing the risk of accidental data loss. The 'trash-cli' package has been widely adopted across various Linux distributions due to its ease of use and integration with desktop environments.
SEE ALSO
rm(1), trash-put(1), trash-list(1), trash-restore(1), trash-empty(1)