I believe everyone is familiar with the trashcan, because it is very common for Linux users, Windows users, or Mac users. When you delete a file or directory, it will be moved to the Recycle Bin. It should be noted that after moving a file to the Recycle Bin, the file system space is not released unless the Recycle Bin is emptied. If you do not want to permanently delete the files (empty the Recycle Bin), you can use the Recycle Bin to temporarily store the deleted files, which can help us recover the deleted files when necessary. However, if you use the rm command to delete files in the command line, you will not be able to find any deleted files or directories in the Recycle Bin. Therefore, please think twice before executing the rm command. If you make a mistake (execute the rm command), the file is permanently deleted and cannot be recovered because the metadata stored on the disk is no longer there. According to the freedesktop.org specification, trash is a feature provided by desktop managers such as GNOME, KDE, and XFCE. When you delete a file or directory through the file manager, the file or directory will become trash and then be moved to the Recycle Bin. The directory corresponding to the Recycle Bin is $HOME/.local/share/Trash The Recycle Bin directory contains two subdirectories: files and info. The files directory stores the actual deleted files and directories, and the info directory contains information about the deleted files and directories, such as the file path, deletion date and time, with each file stored separately. You may ask, since there is already a graphical user interface (GUI) recycle bin, why do we need a command line tool? Because most of the guys who use *NIX systems (including me) prefer using the command line rather than a GUI, even if they are using a GUI-based system. So, if anyone is looking for a command line recycle bin tool, then here is a good option. What is Trash-Cli trash-cli is a command-line trash utility that complies with the FreeDesktop.org trash specification. It can store the name, original path, deletion date and permissions of each junk file. How to Install Trash-Cli on Linux Most of the Linux distributions provide Trash-Cli installation packages in their official repositories, so you can run the following commands to install it. For RHEL/CentOS users, use the yum command to install Trash-Cli: For Fedora users, use the dnf command to install Trash-Cli: For Arch Linux users, use pacman command to install Trash-Cli: For openSUSE users, use zypper Command to install Trash-Cli: If your distribution does not provide Trash-Cli installation package, you can also use pip to install it. To be able to install python packages, you should have pip package manager in your system. $ sudo pip install trash-cli Collecting trash-cli Downloading trash-cli-0.17.1.14.tar.gz Installing collected packages: trash-cli Running setup.py bdist_wheel for trash-cli ... done Successfully installed trash-cli-0.17.1.14 How to Use Trash-Cli Trash-Cli is not difficult to use as it provides a very simple syntax. Trash-Cli provides the following commands:
Next, let's try it out with some examples. 1) Deleting Files and Directories: In this example, we move the 2g.txt file and magi folder to the Recycle Bin by running the following command. 2) List Deleted Files and Directories: In order to view the deleted files and directories, you need to run the following command. After that, you can see the detailed information of deleted files and directories in the output, such as name, deletion date and time, and file path. $ trash-list 2017-10-01 01:40:50 /home/magi/magi/2g.txt 2017-10-01 01:40:50 /home/magi/magi/magi 3) Restore Files or Directories from Recycle Bin: At any time, you can restore files and directories by running the following command. It will ask you to select the files or directories you want to recover. In this example, I am going to restore the 2g.txt file, so my selection is 0. $ trash-restore 0 2017-10-01 01:40:50 /home/magi/magi/2g.txt 1 2017-10-01 01:40:50 /home/magi/magi/magi What file to restore [0..1]: 0 4) Delete Files from Recycle Bin: If you want to delete specific files from Recycle Bin, then you can run the following command. In this example, I will delete the magi directory. 5) Empty Recycle Bin: If you want to delete all the files and directories in Recycle Bin, you can run the following command. 6) Delete Trash Files Older Than X Days: Alternatively, you can delete files older than X days from the Recycle Bin by running the following command. In this example, I will delete items in the Recycle Bin that are older than 10 days. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Detailed explanation of the difference between Oracle10 partitions and MySQL partitions
>>: Node uses koa2 to implement a simple JWT authentication method
Problem description: The following error message ...
Table of contents 1. Installation of JDK1.8 under...
If you have a choice, you should use UTF-8 In fac...
Table of contents Overview Build Process Related ...
A transaction is a logical group of operations. E...
Use Javascript to achieve the countdown effect, f...
1: Installation command pip install docker-compos...
Preface To be honest, I've been feeling very ...
State Hooks Examples: import { useState } from ...
First, let's take a look at the relative leng...
This article records the detailed process of down...
Table of contents 1. Repeated declaration 1.1 var...
Table of contents 1. Overview 1. Explain statemen...
Today I saw a little trick for HTML text escaping ...
tomcat server configuration When everyone is lear...