rm Command The rm command is a command that most people often use when deleting files. It is used to delete a file or directory. The syntax of the rm command is as follows:
You can also delete all files in a folder and subfolders as follows:
Once a file is deleted using the rm command, it cannot be restored, so you must use this command with extreme caution. However, we can prevent accidental deletion of files to some extent by using various methods. For example, if you are deleting multiple files, you can be prompted before deleting each file so that you can ensure that you are deleting the correct files.
Whenever you run the above command, a message will be displayed asking if you are sure you want to delete the file. But if we delete dozens of files, each file will be prompted and we need to press "y" repeatedly to confirm, which will be very troublesome. We can use the following command, which will prompt only when more than 3 files need to be deleted or when recursive deletion is required.
trash-cli tool trash-cli is a command line tool that provides a command line trash bin. We can move files to the recycle bin or restore deleted files by using the trash-cli tool. By default, trash-cli is usually not installed on Linux, so we need to install it before we can use it. Installation (using package manager) If you are using a Debian-based system such as Ubuntu or Mint, you need to use the apt-get command:
If you are using a centos-based system, you need to use the yum command:
How do I move files to the Recycle Bin? To move a file to the Recycle Bin, you can use the following command:
The file is not completely deleted, but is moved to the Recycle Bin in the same way as the Windows Recycle Bin. If you provide a folder name to the trash command, it will send the folder and all the files in the folder to the Recycle Bin. How to list files in the Recycle Bin? To list the files in the Recycle Bin, you can run the following command:
The returned results include: the original path of the file, the date and time when the file was moved to the Recycle Bin. How to recover files from Recycle Bin? The man page for the trash command states that to restore files you should use the following command:
However, if you run this command, you may receive a "command not found" error. An alternative to file restoration is to use the restore-trash command as follows:
The restore-trash command will list all the files in your Recycle Bin with a number next to each file. To restore a file, just enter the number next to the file. How do I empty the Recycle Bin? The main problem with the Recycle Bin is that the files still take up valuable drive space. If you really don't need all the contents in the Recycle Bin, you can run the following command to empty the Recycle Bin.
If you want to delete all files that have been in the Recycle Bin for a certain number of days, just specify that number with the trash-empty command. example:
Delete all files in the Recycle Bin that are older than 7 days. You may also be interested in:
|
<<: Vue custom v-has instruction to implement button permission judgment
>>: Detailed installation tutorial of Mysql5.7.19 under Centos7
After installing MySQL, you will find that the ro...
The specific code is as follows: <style> #t...
Application scenario: It is necessary to count th...
HTML stands for Hypertext Markup Language. Nowada...
1. In Windows system, many software installations...
1. Check the currently installed PHP packages yum...
This article example shares the specific code of ...
Importing data with incorrect MySQL character set...
Table of contents 1. Tool Introduction 2. Workflo...
Crontab is a command used to set up periodic exec...
This article shares the specific code of Vue3 man...
Table of contents 1. Background 2. Verification p...
In order to facilitate the storage and access of ...
I am writing a small program recently. Because th...
Environmental preparation: VMware+CentOS, jdk 1. ...