LinuxCommandLibrary

trash-restore

Restore files from the trash/recycle bin

TLDR

View documentation for trash-restore

$ tldr trash
copy

SYNOPSIS

trash-restore [options] [pattern]

PARAMETERS

-h, --help
    Displays a help message and exits, providing information on command usage and available options.

-v, --version
    Shows the program's version number and exits.

[pattern]
    An optional argument used to filter the list of trashed items. It accepts a regular expression or shell glob pattern to narrow down the results displayed for interactive selection.

DESCRIPTION

trash-restore is a command-line utility from the trash-cli suite, designed to help users recover files that have been moved to the trash according to the FreeDesktop.org Trash specification. Unlike permanent deletion with rm, files "trashed" using commands like trash-put are moved to a special directory, typically ~/.local/share/Trash, providing a safety net. This command allows you to browse an interactive list of trashed items, including their original path, deletion date, and size. Users can then select specific items or ranges of items to restore them, by default, to their original location. This functionality is crucial for recovering accidentally deleted files, offering a terminal-based equivalent of a graphical desktop environment's trash can. It ensures a safer file management workflow from the command line.

CAVEATS

Caveats include potential issues if the original restoration path no longer exists, or during name collisions at the restore location, where the command might prompt for resolution or append suffixes. trash-restore exclusively manages files adhering to the FreeDesktop.org Trash specification and is not a substitute for a comprehensive data backup solution. Users should also be aware that file permissions might be affected during the trash and restoration process.

INTERACTIVE RESTORATION

When invoked without a specific pattern, trash-restore presents a numbered, interactive list of all trashed files. Users can then select one or more items to restore by entering their corresponding numbers, ranges (e.g., '1-5'), or combinations. This interactive nature makes it user-friendly.

FREEDESKTOP.ORG TRASH SPECIFICATION

The core of trash-cli's functionality, including trash-restore, relies on the FreeDesktop.org Trash Specification. This ensures that files trashed by graphical file managers (like Nautilus, Dolphin, Thunar) can be restored via the command line, and vice-versa, promoting seamless interoperability between GUI and CLI environments.

RESTORATION LOCATION

By default, files are restored to their exact original path from which they were deleted, preserving the directory structure. If the original directory no longer exists, the command might attempt to recreate it during the restoration process, though user confirmation might be required depending on the scenario.

HISTORY

The trash-cli project, which includes trash-restore, was developed to provide a robust command-line interface adhering to the FreeDesktop.org Trash specification. This specification standardizes how files are moved to 'trash' across different Linux desktop environments. Its inception provided a safer and more user-friendly alternative to permanent deletion with rm, mirroring the functionality of graphical trash cans directly from the terminal. Over time, it has become a widely adopted utility for managing trashed files in command-line environments, focusing on compatibility and user experience across various desktop setups.

SEE ALSO

trash(1), trash-put(1), trash-list(1), trash-empty(1), rm(1), mv(1)

Copied to clipboard