Skip to main content
⚑ OpenDevDocs
Linux
linuxlinux-commandsReferenceBeginner

Remove Files & Directories (rm)

Remove files and directories in Linux, with safety warnings for recursive and forced deletion (rm -rf).

Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacos
#linux#rm#deletion#files#cli

Command

rm -rf /path/to/target


Short Description

rm (Remove) deletes files or directories from the filesystem.

[!CAUTION] Deletions with rm are permanent and non-recoverable. There is no trash bin. Never run rm -rf / or commands with unexpanded variables (e.g. rm -rf $DIR/ where $DIR is empty, evaluating to rm -rf /).


Examples

1. Remove a Single File

rm temp_file.log

2. Remove Multiple Files with Wildcard

rm *.tmp

3. Remove a Directory Recursively (-r)

rm -r build/

4. Force Remove Recursively Without Confirmation Prompts (-rf)

rm -rf node_modules/ .next/

5. Interactive Confirmation Mode (-i)

rm -i important_document.pdf

On this page