Linux RM command details and how to use the actual combat "beginner"

Source: Internet
Author: User

RM: Delete command preface:

Delete command in Windows Everyone is not unfamiliar, the removal command in Linux and Windows have a common feature, that is dangerous, the first two Linux mkdir command detailed and use the actual combat "beginner" we mentioned the RM command, Now let's take a detailed look at the commands for deleting files and directories in Linux,

RM Command, RM is a commonly used command that removes one or more files or directories from a directory, and it can delete all files and subdirectories under a directory. for linked files, only the links are deleted and the original files remain unchanged.

Name

Rm-remove files or directories deleting a file or directory

How to use

RM [Options ] File or directory ...  

RM followed by parameters in the file or directory, delete one or more files or directories in a directory, if the Delete folder must be used with the-R parameter. The -f parameter is mandatory and must be used sparingly!

Describe

-F,--force ignores nonexistent files and never gives hints. Novice Please use this parameter Strictly, Hazard index: ★★★★★

-I,--interactive for interactive deletion

-R,-R,--recursive instructs RM to delete all directories and subdirectories listed in the parameters recursively.

-V,--verbose detailed display of the steps performed

Demo: Use default delete (no parameters, prompt when deleting)Risk Index: ★
1 [[email protected] vanos]# Touch Lcp.txt We create a new file in the directory to use as a test, a lcp.txt document is used here (of course, this is the suffix in Windows)2 [email protected] vanos]# ll take a look at the current Lcp.txt file, where touch, new , is new and will be explained further in the future. 3Total0 Touch is used to create files that do not exist 4-rw-r--r--.1Root root0Jan5  A: theLcp.txt shows the results. 5 [[email protected] vanos]# RM lcp.txt use RM command directly with the file name (lcp.txt) Note the space, Linux focus on symbols and capitalization, must be cautious 6Rm:remove regular empty file ' Lcp.txt'? y at this point, you will be prompted to delete, you need to type a Y to confirm, if you want to delete the type Y and then enter, otherwise type n cancel the deletion. 7 [email protected] vanos]# ll8Total0 The result after deletion, this is the default RM command, which is more secure 
Use default delete (no parameters, prompt when deleting)Risk Index: ★★★★★
1 [[email protected] vanos]# Touch Lcp.exe also create a new file to test, in order to differentiate us from creating a Lcp.exe file (and Linux does not recognize EXE suffix)2 [email protected] vanos]# ll look at the new results. 3Total04-rw-r--r--.1Root root0Jan6  +: WuLcp.exe Show the results5[Email protected] vanos]# RM-F Lcp.exe We use the Rm-f parameter here (Force Delete does not remind), here we see and not like the default delete, there will be a prompt to ask whether to delete,6 [email protected] vanos]# llThere's no warning here.
7Total0
To delete a folder by using the RM command
[email protected] vanos]# CD. This is our test environment, the path is/lcp/abc/vanos, we use the RM correlation parameter (-r) to delete the folder first back to the ABC folder [[email protected] abc]# ll see what's in the current folder. Total4drwxr-xr-x.2Root root4096Jan6  +: WuVanos display [[email protected] abc]# RM-R vanos/We use the Rm-r command followed by the name of the folder.rm:remove directory ' Vanos'? y prompts whether to delete, type Y here to confirm the deletion, if you want to omit this step use the-RF command to cancel the reminder. Use CAUTION!!! [[email protected] abc]# ll look at the results after the deletion. Total0

It is mentioned here that the deletion of folders and a command is to delete the empty directory (folder), the new directory is known as mkdir, the deletion of the directory is rmdir note that this command can only delete the empty directory, the content has a file directory does not take effect. This is an understanding only and will be explained in detail later.

  RM is a dangerous command, especially when used, especially for novices, or the entire system will be destroyed in this command (e.g., RM *-rf under/(root directory)). So, before we execute RM, it's a good idea to check in which directory (PWD), exactly what to delete (ll or LS), and maintain a high level of sanity when operating.

Linux RM command details and how to use the actual combat "beginner"

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.