Linux Step---RM command

Source: Internet
Author: User

1 command function (brief description):

This command is used to remove files or directories from a Linux system. Normally RM does not delete the directory, you must delete the directory by specifying the parameter-R or-R. In addition, RM can usually restore the file or directory (note that the RM Delete file is just the index point to the data block (information nodes) released, as long as it is not overwritten, the data is actually on the hard disk. If you want to ensure that the contents of the file cannot be restored, you can use the command shred. In addition, it is generally prudent to use RM-RF/* such commands.

2 Command syntax:

RM "Options" ... File ... #注: the content in "" is not a required option

3 command options (only common command parameters are described):

Use the help command: Man RM or Rm-help

-F,--force forcibly removed. Ignore files that do not exist, do not prompt for confirmation
-I need to confirm before deleting
-I (capital I) requires confirmation before deleting more than three files or recursively deleting them. This option is less than the-I hint content, but can also prevent most errors from occurring
--interactive[=when] The confirmation prompt according to the specified when: never,once (-i), or always (-i). Always prompt if this parameter is not added
--one-file-system recursively deletes a hierarchy, skips all files on the file system that do not conform to the command line arguments
--no-preserve-roo No special treatment "/"
--preserve-root not allowed to delete "/" (default)
-R,-R,--recursive recursively delete directories and their contents
-V,--verbose detailed display of the steps performed
--HELP Display this help message and exit
--version display version information and exit

4 Usage Examples:

  (1) RM directory (file name)------------Note that the default RM command is an alias (alias rm= ' Rm-i ') and cannot be overridden, even if you cannot force overwriting the file with the-f parameter, you can use \RM to execute the RM command without walking alias.

#Delete the specified file[[email protected] command_test]#lsCanglaoshi.txt[root@localhost Command_test]#RM canglaoshi.txtRM: Delete normal empty files"Canglaoshi.txt"? Y[root@localhost Command_test]#ls[[email protected] command_test]#Touch Xiaocang.txt[[email protected] command_test]#lsXiaocang.txt[root@localhost Command_test]#\rm xiaocang.txt[[email protected] command_test]#ls[[email protected] command_test]# 

(2) Rm-rf directory (file name)

#Create a multi-level directory, regardless of whether the directory is empty enough to force the deletion of directories, subdirectories in the future directory. [[email protected] command_test]#mkdir-p DIR1/{DIR2,DIR3/{DIR4,DIR5}}[[email protected] command_test]#lsDir1[root@localhost Command_test]#CD Dir1[[email protected] dir1]#lsDir2 Dir3[root@localhost Dir1]#CD..[[email protected] command_test]#RM Dir1RM: Cannot delete"Dir1": is a directory [root@localhost Command_test]#RM-RF Dir1[[email protected] command_test]#ls[[email protected] command_test]# 

(3) Rm-v A class of files and displays the command execution process in detail

#Create two new types of files and delete only those files at the end of the TXT[[email protected] command_test]#Touch canglaoshi.txt xiaocang.txt av.log[[email protected] command_test]#lsav.log canglaoshi.txt xiaocang.txt[root@localhost Command_test]#rm-v *.txtRM: Delete normal empty files"Canglaoshi.txt"? Y has been removed"Canglaoshi.txt"RM: Delete normal empty files"Xiaocang.txt"? Y has been removed"Xiaocang.txt"[Root@localhost Command_test]#lsAv.log[root@localhost Command_test]# 

Linux Step---RM command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.