Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command rm

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of the Linux basic command rm". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command rm".

Rm

Delete files and directories, and directories are not deleted by default. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Rm [options] file

2. List of options

Option

Description

-- help

Show help documentation

-- version

Display version information

-f |-- force

Enforce, do not interact

-I

Interactive mode, asking for each file deleted

-I

Prompt once before deleting more than three files, or before deleting recursively. "- I" is not as intrusive as "- I", but it is still immune to most errors.

-- interactive [= WHEN]

According to the time tip: never (never), once (- I), or always (- I). No WHEN specified, always prompted

-- one-file-system

When you recursively delete a hierarchy, skip any directory on the file system that is different from the corresponding command line argument.

-- no-preserve-root

Delete the root directory

-- preserve-root

Do not delete the root directory, the default

-r |-R |-- recursive

Delete subdirectories recursively

-v |-- verbose

Show detailed execution process

3. Description

By default, rm does not delete directories. You can also delete each listed directory and all its contents using the-- recursive (- r or-R) option. To delete a file whose name begins with "-", such as "- foo", use one of the following commands:

Rm-foo

Rm. /-foo

Note that if you delete a file using rm, you can usually restore the contents of the file. If you want more assurance that the content is truly unrecoverable, consider using shred.

4. Examples

1) Delete files at the beginning of te

[root@localhost weijie] # ls

11.c 1.c 1.c ~ 2.c 3.c 4.c 4.c ~ 5.c 6.c te000 te001 test

[root@localhost weijie] # rm te*

Rm: do you want to delete the normal file "te000"? Y

Rm: do you want to delete the normal file "te001"? Y

Rm: cannot delete "test": it is a directory / / cannot delete a directory

2) Delete the directory

[root@localhost weijie] # rm-rf test/ forcibly delete directories

[root@localhost weijie] # ls

11.c 1.c 1.c ~ 2.c 3.c 4.c 4.c ~ 5.c 6.c

Thank you for your reading, the above is the content of "the usage of the Linux basic command rm". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command rm, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report