What is the trash-cli tool?

0703

trash-cli is a command-line interface for managing the trash or recycle bin in Unix-like operating systems. It allows users to move files and directories to the trash instead of permanently deleting them with the rm command. This provides a safety net, as files can be easily restored from the trash if needed.

Key Features of trash-cli:

  1. Move to Trash: Instead of deleting files permanently, trash-cli moves them to the trash, allowing for easy recovery.

    trash file_name
  2. List Trash Contents: You can view the contents of the trash with:

    trash-list
  3. Restore Files: You can restore files from the trash back to their original location.

    trash-restore
  4. Empty Trash: To permanently delete all files in the trash, you can use:

    trash-empty
  5. Cross-Platform: trash-cli works on various Unix-like systems, including Linux and macOS.

Installation:

You can install trash-cli using your package manager. Here are some examples:

  • Debian/Ubuntu:

    sudo apt install trash-cli
  • Fedora:

    sudo dnf install trash-cli
  • macOS (using Homebrew):

    brew install trash

Example Usage:

  1. Move a File to Trash:

    trash myfile.txt
  2. List Files in Trash:

    trash-list
  3. Restore a File:

    trash-restore
  4. Empty the Trash:

    trash-empty

Using trash-cli can help prevent accidental data loss by providing a way to recover deleted files easily. If you have any further questions or need assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!