Linux knowledge Point, RM of one day

Source: Internet
Author: User

features : RM command to delete one or more files or directories (folders) in a directory.

    • It can also delete a directory and all of its files and subdirectories.
    • For linked files, only the links are deleted and the original files remain unchanged.
    • Once the file is deleted, it cannot be restored.

The warning is: Use this RM-RF must be extra careful, Linux no Recycle Bin, once deleted will never find back. Especially for novices, 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, exactly what to delete, and keep a high level of sanity in the operation.

Syntax:rm[Options]  file
Short options Long options Meaning
- F --force Ignore non-existent files, force Delete, no prompt.
- I. --interactive For interactive deletion
- R --recursive Recursively delete (in this directory) all files and directories
- v --verbose Detailed display of the steps performed

Common Parameters

Format: RM file
Delete file, the system will first ask whether to delete.

Format: Rm-f file
Forcibly deleting file, the system no longer prompts.

Format: Rm-rf dir
Forcibly delete all files and directories under directory dir, and delete dir itself.

Format: Rm-f *. log*
Delete the log file.

RM file nameDelete the file, the system will first ask whether to delete. [[email protected] test1]# ls-l total 4-rw-r--r--1 root root * 10-26 14:31 log.log [email protected] test1] #rm log.logrm: Do you want to delete the generic file "Log.log"? y [email protected] test1]# ls-l total 0[[email protected] test1]# Description: After entering the RM log.log command, the system will ask whether to delete, enter Y will delete the file, do not want to delete the data n.rm-f file nameForcibly delete the file, the system no longer prompts. [Email protected] test1]# ls-l total 4-rw-r--r--1 root root at 10-26 14:40 log1.log [[email protected] test1] #rm-f log1. Log[[email protected] test1]# ls-l total 0[[email protected] test1]#rm-i file nameDelete any files, delete the previous one by asking for confirmation [[email protected] test1]# ls-l total 8-rw-r--r--1 root root one 10-26 14:45 log1.log-rw-r--r--1 root ro OT 10-26 14:45 log2.log [[email protected] test1] #rm-I *.logrm: Do you want to delete the generic file "Log1.log"? Y RM: Do you want to delete the generic file "Log2.log"? y [[email protected] test1]# ls-l total 0[[email protected] test1]#rm-r Directory NameDelete all files in subdirectories and subdirectories [[email protected] test]# Ls-l total 24drwxr-xr-x 7 root root 4096 10-25 18:07 scf drwxr-xr-x 2 root root 40 10-26 14:51 test1 drwxr-xr-x 3 root root 4096 10-25 17:44 test2 drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr- x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 test5 [[email protected] test] #rm-R TEST1RM: Do you want to enter the directory "Test1"? Y RM: Do you want to delete the generic file "Test1/log3.log"? Y RM: Do you want to delete the directory "Test1"?  y [[e-mail protected] test]# ls-l total 20drwxr-xr-x 7 root root 4096 10-25 18:07 scf drwxr-xr-x 3 root root 4096 10-25 17:44 Test2 drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr-x 3 root root 4096 10-25 17:56 TEST5 [[email protected] test]#RM-RF Directory NameDelete all files in directory and subdirectory without one by one confirmation [[email protected] test] #rm-rf test2[[email protected] test]# ls-l total 16drwxr-xr-x 7 root root 4096 10-25 18:07 scf drwxrwxrwx 2 root root 4096 10-25 17:46 test3 drwxr-xr-x 2 root root 4096 10-25 17:56 test4 drwxr-xr- X 3 root root 4096 10-25 17:56 test5 [[email protected] test]#RM---FDelete files beginning with-f [[email protected] test]# touch---f [[email protected] test]# ls---f-f[[email protected] test] #rm---fr M: Do you want to delete the general empty file "-F"? y [[email protected] test]# ls---f ls:-F: There is no file or directory [[email protected] test]# can also use the following procedure: [[email protected] test]# T Ouch./-f [[email protected] test]# ls./-f./-f[[email protected] test] #rm./-FRM: Delete the generic empty file "./-f"? y [[email protected] test]#

Linux knowledge Point, RM of one day

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.