Home > File & Directory Management > rm

Mastering the rm Command

The rm command is used to delete files or directories. Careless use can lead to irrecoverable data loss, so it is essential to understand the meaning of each option and its safe usage.

Key Options

The `rm` command allows various ways to specify deletion targets and includes options for error prevention such as forced deletion, recursive deletion, and interactive mode.

1. Basic Options

2. Error Prevention/Confirmation Options

3. Force/Recursive/Extended Options

Generated command:

Try combining the commands.

Description:

`rm` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples and Safety Guidelines

This section summarizes precautions, safe usage methods, and option combination examples for the `rm` command.

Tips for Safe Usage

Please be sure to familiarize yourself with the following when using the rm command.

  • - Deleted files are generally unrecoverable.
  • - Commands like rm -rf / can delete the entire system, so absolutely avoid using them!
  • - Get into the habit of using -i or -I options.
  • - Be especially careful to prevent errors when using wildcards (*) in filenames.

Deleting a Regular File

rm test.txt

Delete the `test.txt` file

Recursive/Forced Deletion

rm -rf backup/

Forcibly delete the `backup` directory and all its contents

Confirm Before Deletion

rm -i important.txt

Always confirm for every deletion operation



Same category commands