In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to delete files completely under Linux". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to delete files thoroughly under Linux".
Linux is easy to delete directories, and many people are still used to using rmdir, but once the directory is not empty, they are in deep trouble. Now you can use the rm-rf command.
Rm is fine, but you need to add two parameters-rf: rm-rf directory name
Delete directories, files rm (remove)
Function description: delete files or directories.
Syntax: rm [- dfirv] [--help] [--version] [file or directory.]
Add: execute rm directive to delete files or directories, if you want to delete directories, you must add the parameter "- r", otherwise the default will only delete files.
Parameters:
-d or-directory delete the hard connection data of the directory you want to delete directly to 0, and delete the directory.
-f or-force forces the deletion of a file or directory.
-I or-interactive asks the user before deleting an existing file or directory.
Recursive processing of-r or-R or-recursive, processing all files and subdirectories under the specified directory together.
-v or-verbose displays the instruction execution process.
1 Delete a folder
De > rm-rf fileNamede >
-Delete a folder instance:
Rm-rf / var/log/httpd/access
The / var/log/httpd/access directory and all files and folders under it will be deleted
Need to be reminded: you must be very careful when using this rm-rf. Linux does not have a Recycle Bin.
2 delete files
De > rm-f fileNamede >
Be careful when using rm-rf. Linux does not have a Recycle Bin.
Delete files other than the specified file
1. Common commands for deleting files and folders under Linux are as follows:
Delete files: rm file
Delete folder: rm-rf dir
It should be noted that rmdir can only delete empty folders.
Second, delete all documents except the formulation document (folder)?
1. Method 1, the more troublesome approach is:
Copy the files that need to be retained to another folder, then delete the directory, and then move the files that need to be retained back.
Mv keep.. / # keep files (folders) keep
Rm-rf * # Delete all files in the current folder
Mv.. / keep. / # move the original things back
2. Method 2, which needs to be done in the current folder:
Rm-rf! (keep) # Delete all files except the keep file
Rm-rf! (keep1 | keep2) # Delete all files except keep1 and keep2 files
Completely delete files in Linux
Shred's method of deleting files completely:
$shred-u file
Shred overwrites the node and data block where the file is located with some random content and deletes the file (the-u parameter).
If you want to clear it more thoroughly, you can add the-z parameter, which means to fill it with random data first and then with 0 at last.
$shred-u-z file
In addition, shred can also clear the entire partition or disk, for example, if you want to completely clear the contents of the / dev/sdb1 partition, you can do this:
$shred / dev/sdb1 (do not add the-u parameter)
Detailed parameters of shred:
-f,-- force changes permissions to allow writes (if necessary)
-n,-- iterations=N is rewritten N times. Default is 3 times.
-- random-source=FILE reads data from the specified file
-s,-- size=N shredded the file to a fixed size (suffixes such as K, M, C, etc.)
-u,-- remove truncates and removes files after rewriting
-v,-- verbose shows progress
-z,-- zero-add overwrites data with 0
-help display help
-version displays version information
Thank you for your reading, the above is the content of "how to delete files thoroughly under Linux". After the study of this article, I believe you have a deeper understanding of how to delete files thoroughly under Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.