Linux RM Command

Source: Internet
Author: User

RM command

rmdirCommands are limited, only non-empty directories can be deleted, and files cannot be deleted. rm The command is more than good, you can delete any directory and files. Need some awesome options!

RM-RF/   this command never knocks!!!!

RM-RF/   this command never knocks!!!!

rm -rf / This command must never be knocked!!!!

1. deleting files
[Email protected] ~]# rm/tmp/allin/2/3/1.txt RM: Do you want to delete the plain empty file "/tmp/allin/2/3/1.txt"? Y[[email protected] ~]# tree/tmp/allin/tmp/allin├──1│└──2└──2└──34 directories, 0 files
    • Delete a non-empty directory

[[email protected] ~]# rm /tmp/allin/2/3rm:  Unable to delete "/TMP/ALLIN/2/3":  is a directory [[email  protected] ~]# rm /tmp/allin/2/3/1.txt  2.txt  [[email protected ] ~]# rm /tmp/allin/2/3/1.txt  2.txt  [[email protected] ~]#  RM /TMP/ALLIN/2/3/*.TXTRM: Do you want to delete the normal empty file   "/tmp/allin/2/3/1.txt"? NRM: Do you want to delete the normal empty file   "/tmp/allin/2/3/2.txt"? N 
    • Every time you ask for more files, it can be troublesome.   -f option is forced to delete without asking.

[Email protected] ~]# TREE/TMP/ALLIN//TMP/ALLIN/├──1│└──2└──2└──3├──1.TXT└──2.TXT4 Director IES, 2 files[[email protected] ~]# rm-f/tmp/allin/2/3/*.txt[[email protected] ~]# tree/tmp/allin//tmp/allin/├──1│└─ ─2└──2└──34 directories, 0 files
2. Deleting a directory
[[email protected] ~]# rm/tmp/allin/2/3/rm: Cannot delete '/tmp/allin/2/3/': is a directory

There will be an error. Because it is a non-empty directory.

    • Requires     options

[[EMAIL PROTECTED] ~]# RM -R /TMP/ALLIN/2/3/RM: Do you want to delete the directory   "/tmp/allin/2/3/"? y[[email protected] ~]# !treetree /tmp/allin//tmp/allin/├── 1│   └──  2└── 23 directories, 0 files 
    • Don't want to ask, plus -f options

[Email protected] ~]# rm-rf/tmp/allin/2[[email protected] ~]#!treetree/tmp/allin//tmp/allin/└──1└──22 Directori ES, 0 files
    • Visualization, plus -v options

[[EMAIL PROTECTED] ~]# RM -RFV /TMP/ALLIN/1 deleted directory: "/TMP/ALLIN/1/2" deleted directory: "/TMP/ALLIN/1 "[[Email protected] ~]# ls /tmp/allin/[[email protected] ~]# !treetree  /tmp/allin//tmp/allin/0 directories, 0 files 

-f options are awesome, but be sure to use them with caution.

-fSome of the disadvantages of the options

    • Delete the directory that does not exist, also will not error, easy to cause confusion.

[[email protected] ~]# tree/tmp/allin/tmp/allin0 directories, 0 files[[email protected] ~]# rm-f/TMP/ALLIN/2
Expand your knowledge
    1. historycommand, the user views the history of previously used commands.

650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706052225_662.png "style=" border-style:none; "/>

    1. !+ command to quickly use the last command.

[[email protected] ~]#!treetree/tmp/allin/tmp/allin0 directories, 0 files[[email protected] ~]#!lsls/tmp/allin/[[emai L protected] ~]#!historyhistory 1 ls 2 ls/tmp 3 ls/boot 4 LS/5 dhclient


This article is from the "Linux Road" blog, make sure to keep this source http://allin28.blog.51cto.com/12931477/1933846

Linux 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.