rm

file managementLinux/Unix
The rm command is one of the most frequently used commands in Linux/Unix-like operating systems. rm Sample fallback description for rm

Quick Reference

Command Name:

rm

Category:

file management

Platform:

Linux/Unix

Basic Usage:

rm filename.txt

Common Use Cases

  • 1

    File removal

    Permanently delete files from the filesystem

  • 2

    Cleanup

    Remove unnecessary or temporary files

  • 3

    Security

    Securely erase sensitive data from disks

  • 4

    Scripting

    Use in shell scripts to remove files programmatically

Syntax

rm [OPTION]... [FILE]...

Options

Option Description
-l Use a long listing format
-a Show hidden entries starting with .
-h Human-readable sizes
-R List subdirectories recursively

Examples

How to Use These Examples

The examples below show common ways to use the rm command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

ls
List files in the current directory.
ls -l
List files in long format with details.
ls -a
List all files including hidden ones.

Advanced Examples:

ls -lah Detailed list with human-readable sizes. ls -R List directories recursively.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

These are sample notes for the rm command.

Tips & Tricks

1

Use the -r option to remove directories and their contents recursively

2

Use the -f option to force the removal without prompting for confirmation

3

Use the -i option to prompt before removing each file

4

Use the -v option to display a message for each removed file

5

Use the --one-file-system option to stay on the current file system

Common Use Cases

File removal

Permanently delete files from the filesystem

Cleanup

Remove unnecessary or temporary files

Security

Securely erase sensitive data from disks

Scripting

Use in shell scripts to remove files programmatically

Data management

Manage files and directories in the filesystem

Related Commands

These commands are frequently used alongside rm or serve similar purposes:

Use Cases

1

File removal

Permanently delete files from the filesystem

2

Cleanup

Remove unnecessary or temporary files

3

Security

Securely erase sensitive data from disks

4

Scripting

Use in shell scripts to remove files programmatically

5

Data management

Manage files and directories in the filesystem

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the rm command works in different scenarios.

$ rm
View All Commands