Linux Command Learning Summary of RM command _linux

Source: Internet
Author: User

Introduction to Commands:

The RM command is used to remove files or directories from the Linux system. Typically 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 will only release the index point (information nodes) that points to the block, 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 are not restored, you can use the command shred. In addition, the general still should be cautious with RM-RF * such orders.

Execute permissions: All User

Instruction Path:/BIN/RM

Command syntax:

RM [OPTION] ... FILE ...

Command parameters:

Parameters

Long parameters

Description

-F

--force

Force deletes, ignoring files that do not exist, never giving a hint.

-I.

--interactive

Interactive mode deletes files and prompts before deleting files.

-R

--recursive

Recursively deletes directories under files and subdirectories.

-R

--recursive

Recursively deletes directories under files and subdirectories.

-V

--verbose

Show Run time details

--help

Show Commands online Help

--version

Display Command version information

Use examples:

1: View Help on obtaining RM commands.

[Root@db-server kerry]# man RMRM (1) User Commands rm (1) NAME rm-remove files or directories synopsis RM [OPTION] ... FILE ... DESCRIPTION This manual page documents the GNU version of RM. RM removes each specified file. By default, it does not remove directories. If a file is unwritable, the standard input is a TTY, and the-f or--force option isn't given, RM prompts the user for W Hether to remove the file. If The response is isn't affirmative, the file is skipped. The OPTIONS Remove (unlink) the FILE (s). -F,--force ignore nonexistent files, never prompt-i,--interactive prompt-before any removal--no-preserve-root does not t Reat transmission transmission? Specially (the default)--preserve-root fail to operate recursively on transmission? -R, R,--recursive remove directories and their contents recursively-v,--verbose Explain what are being done--help disp Lay this Help and exit--version output version information and exit by default, RM does not remove directories. Use the--recursive (-r or-r) option to remove EACH listed directory, too, along and all of its contents. To remove a file whose name starts with a transmission? transmission? For example transmission foo transmission? Use one of the above commands:rm---foo rm./-foo Note this if use RM to remove a file, the it is usually possible to recove R the contents of that file. If you are want more assurance that the contents are truly unrecoverable, consider using shred. AUTHOR written by Paul Rubin, David MacKenzie, Richard Stallman, and Jim meyering. REPORTING BUGS BUGS to <bug-coreutils@gnu.org>. Copyright copyright Leaks 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU general public License

[Root@db-server kerry]# rm--helpusage:rm [OPTION] ... FILE ... Remove (unlink) the FILE (s). -F,--force ignore nonexistent files, never prompt-i,--interactive prompt-before any removal--no-preserve-root does not t Reat '/' specially (the default)--preserve-root fail to operate recursively on '/'-R, R,--recursive remove directories And their contents recursively-v,--verbose Explain what is being do--help display this help and exit--version OUTPU T version information and exit by default, RM does not remove directories. Use the--recursive (-r or-r) option to remove each listed directory, too, along and all of its contents. To remove a file whose name starts with a '-', for example '-foo ', use one of the commands:rm---Foo rm./-foo Note tha T if you use RM to remove a file, it's usually possible to recoverthe contents of this file. If you are want more assurance that the contents Aretruly unrecoverable, consider using shred. The bugs to bug-coreutils@gnu.org.

2: Delete the specified file

As shown below, there are 20 files in the directory, and only 19 files are left after the specified file is deleted.

[Oracle@db-server bdump]$ LS-LRT | wc-l [Oracle@db-server bdump]$ rm gsp_lgwr_7826.trc [oracle@db-server bdump]$ LS-LRT | Wc-l 19

3: Delete files to display Run-time details

[Oracle@db-server bdump]$ rm-v gsp_lgwr_4617.trc removed ' gsp_lgwr_4617.trc '

4: Delete files in interactive mode

As shown below, entering Y will delete the file, do not want to delete the data n

[Oracle@db-server bdump]$ rm-iv gsp_lgwr_5005.trc rm:remove regular file ' Gsp_lgwr_5005.trc '? Y removed ' gsp_lgwr_5005.trc ' [oracle@db-server bdump]$ rm-iv gsp_lgwr_7826.trc rm:remove regular file ' gsp_lgwr_7826.tr C '? N

5: Recursively delete files and subdirectories in a directory

As shown below, the Kerry directory has test1.txt, test2.txt files, and subdirectory tmp, and a subdirectory with file File1, file2.

[Root@db-server ~]# tree kerrykerry|--test1.txt|--test2.txt '--tmp | file1 '--file2 1 directory, 4 Files[root@db-serv ER ~]# rm-rf kerry/

6: Delete Empty directory

[Root@db-server ~]# mkdir Kerry [root@db-server ~]# rm-r directory ' Kerry/rm:remove '?] Y

7: Deletes files of all TRC file types under the directory bdump.

[Oracle@db-server bdump]$ lsalert_gsp.log gsp_lgwr_20025.trc gsp_lgwr_5023.trc gsp_p000_4637.trc GSP_P000_5025.TRC gsp_p001_4639.trc gsp_p001_4720.trc gsp_p001_5027.trcgsp_lgwr_19915.trc gsp_lgwr_4719.trc gsp_ LGWR_5089.TRC gsp_p000_4682.trc gsp_p000_4739.trc gsp_p000_5043.trc gsp_p001_4684.trc gsp_p001_4741.trc 5045.trc[oracle@db-server bdump]$ rm-v *.trcremoved ' gsp_lgwr_19915.trc ' removed ' gsp_lgwr_20025.trc ' removed ' Lgwr_4719.trc ' removed ' gsp_lgwr_5023.trc ' removed ' gsp_lgwr_5089.trc ' removed ' gsp_p000_4637.trc ' ' removed ' 4682.trc ' removed ' gsp_p000_4718.trc ' removed ' gsp_p000_4739.trc ' removed ' gsp_p000_5025.trc ' removed '. TRC ' removed ' gsp_p001_4639.trc ' removed ' gsp_p001_4684.trc ' removed ' gsp_p001_4720.trc ' ' removed '. TRC ' removed ' gsp_p001_5027.trc ' removed ' gsp_p001_5045.trc '

The above is described in this article to introduce the Linux command to learn the summary of the RM command, I hope to help you.

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.