-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux rmdir Guide
Mattscreative edited this page Dec 5, 2025
·
3 revisions
Complete beginner-friendly guide to rmdir on Linux, covering Arch Linux, CachyOS, and other distributions including directory removal, empty directory deletion, and directory cleanup.
Basic usage:
# Remove empty directory
rmdir mydir
# Removes directory (must be empty)Remove multiple:
# Multiple directories
rmdir dir1 dir2 dir3
# Removes all (must be empty)Empty requirement:
# Only removes empty directories
rmdir mydir
# Fails if directory contains filesNon-empty error:
# Error if not empty
rmdir mydir
# Error: "Directory not empty"Verify empty:
# Check if empty
ls mydir
# Should show nothing
# Then remove
rmdir mydirRemove tree:
# Remove empty tree
rmdir -p path/to/empty/dir
# -p = parents (removes parent dirs if empty)Parent removal:
# Remove parent directories
rmdir -p path/to/empty/dir
# -p removes parents if they become emptyIgnore failures:
# Ignore errors
rmdir --ignore-fail-on-non-empty mydir
# Doesn't error if not emptyCheck installation:
# rmdir is part of coreutils
# Usually pre-installed
# Check rmdir
which rmdirThis guide covered rmdir usage, directory removal, and empty directory deletion for Arch Linux, CachyOS, and other distributions.
- rm Guide - Remove files and directories
- mkdir Guide - Create directories
- cd Guide - Change directory
-
rmdir Documentation:
man rmdir
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.