Linux Delete directory is very simple, many people are still accustomed to use rmdir, but once the directory is not empty, it fell into deep distress, now use the RM-RF command.
Direct RM is available, but add two parameters-rf that is: RM-RF directory name
Delete directory, file rm (remove)
Feature Description: Delete files or directories.
Syntax: RM [-dfirv][--help][--version][file or directory ...]
Additional Note: The Execute RM instruction can delete the file or directory, if you want to delete the directory must add the parameter "-r", otherwise the default will only delete the file.
Parameters:
-D or –directory delete the hard connection data for the directory that you want to delete directly by deleting the directory by 0.
-F or –force forces the deletion of files or directories.
-I or –interactive to ask the user before deleting both files or directories.
-R or-R or –recursive recursively handles all files and subdirectories under the specified directory.
-V or –verbose shows the instruction execution process.
1 Deleting 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
To be reminded: Use this RM-RF with extreme caution, Linux does not have a recycle Bin
2 Deleting files
De>rm-f filenamede>
Use RM-RF with extreme caution, Linux does not have a recycle Bin
Delete files other than the specified file
First, delete files and folders under Linux Common commands are as follows:
Delete Files: RM file
Delete folder: Rm-rf dir
It is important to note that rmdir can only delete empty folders.
Ii. Delete all documents other than the development document (folder)?
1, Method 1, the more troublesome practice is:
Copy the files that you want to keep to a different folder, and then delete the directory, and then move it back to what you want to keep.
MV Keep. /#保留文件 (clip) Keep
RM-RF * #删除当前文件夹里的所有文件
Mv.. /keep./#将原来的东西移动回来
2, Method 2, you need to do in the current folder:
Rm-rf! (keep) #删除keep文件之外的所有文件
Rm-rf! (Keep1 | keep2) #删除keep1和keep2文件之外的所有文件
Completely remove files from Linux
Shred how to delete files completely:
$ shred-u File
Shred will overwrite the node and data block where the file resides with some random content, and delete the file (-u parameter).
If you want to clear a bit more thoroughly you can add the-z parameter, which means to fill with random data, and then fill it with 0.
$ shred-u-Z File
In addition shred can also clear the entire partition or disk, such as to completely clear the contents of the/DEV/SDB1 partition can be:
$ SHRED/DEV/SDB1 (note do not add-u parameter)
Detailed parameters of the shred:
-F,--force Change permissions allow write (if necessary)
-N,--iterations=n rewrite n times, default is 3 times
--random-source=file reading data from a specified file
-S,--size=n the file to a fixed size (suffixes such as K, M, C, etc. can be used)
-U,--remove truncate and remove files after rewriting
-V,--verbose show progress
-Z,--zero-add with 0 coverage data
Help Display Help
–version displaying version information
Linux Delete operations