In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How do I delete a file from the Linux command line? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Rm command
The rm command is a command that most people use when deleting a file. It is used to delete a file or directory.
The syntax of the rm command is:
Rm / path/to/file
You can also delete all files in folders and subfolders, as follows:
Rm-R / path/to/folder
Once the file is deleted by the rm command, it cannot be recovered, so the command must be used with great care. However, we can prevent accidental deletion of files to some extent by using various methods. For example, if you want to delete multiple files, you can be prompted before deleting each file to ensure that the correct file is deleted.
Rm-I / path/to/file
Whenever you run the above command, a message is displayed asking if you are sure you want to delete the file.
But if you delete dozens of files and each file receives a prompt, we need to press "y" repeatedly to confirm, which will be troublesome.
We can use the following command, which prompts us only when we need to delete more than 3 files or delete them recursively.
Rm-I / path/to/file
Trash-cli tool
Trash-cli is a command-line tool for the Recycle Bin that provides the command-line recycle bin. We can use the trash-cli tool to move files to the Recycle Bin or restore deleted files.
By default, trash-cli is not usually installed on Linux, and we need to install it before we can use it.
Install (using package Manager)
If you are using a Debian-based system, such as Ubuntu or Mint, you need to use the apt-get command:
Sudo apt-get install trash-cli
If you are using a centos-based system, you need to use the yum command:
Sudo yum install-y trash-cli
How do I move files to the Recycle Bin?
To move a file to the Recycle Bin, use the following command:
Trash / path/to/file
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 sends the folder and all files in the folder to the Recycle Bin.
How do I list files in the Recycle Bin?
To list the files in the Recycle Bin, run the following command:
Trash-list
The returned results include the original path of the file, the date and time the file was moved to the Recycle Bin.
How do I recover files from the Recycle Bin?
The man page of the trash command indicates that to restore files, you should use the following command:
Trash-restore
However, if you run this command, you may receive a command not found error.
The alternative to file restore is to use the restore-trash command, as follows:
Restore-trash
The restore-trash command lists all files in the Recycle Bin, each with a number next to it. To restore the file, simply enter the number next to the file.
How to empty the Recycle Bin?
The main problem with the Recycle Bin is that files still take up valuable drive space. If you really don't need everything in the Recycle Bin, you can run the following command to empty the Recycle Bin.
Trash-empty
If you want to delete all files that already exist in the Recycle Bin for a specific number of days, simply use the trash-empty command to specify that number. Example:
Trash-empty 7
Delete all files that have existed in the Recycle Bin for 7 days.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
After reading the above, have you learned how to delete files from the Linux command line? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.