Home > File & Directory Management > rm

Mastering the rm Command

The `rm` command is used to delete files or directories. Using it carelessly can lead to data loss that is difficult to recover, so it's essential to understand the meaning of each option and how to use it safely.

Main Options

The `rm` command allows you to specify various targets for deletion, with options available to prevent mistakes such as forced deletion, recursive deletion, and interactive mode.

1. Basic Options

2. 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 when using the `rm` command, how to use it safely, and examples of option combinations.

Tips for Safe Usage

Make sure to understand the following points when using the rm command.

  • - Deleted files are generally irrecoverable.
  • - Commands like `rm -rf /` can delete the entire system, so never use it!
  • - Habitually use the `-i` or `-I` options.
  • - Be particularly careful when using wildcards (*) in file names.

Deleting a Regular File

rm test.txt

Deleting the `test.txt` file

Recursive/Forced Deletion

rm -rf backup/

Forcefully deleting the `backup` directory and all its files

Confirm Before Deletion

rm -i important.txt

Must confirm before every deletion operation


Same category commands