Skip to content

Rmdir command on Linux (remove directory)

The rmdir command on Linux removes one or more empty directories from the system.

The most common options are:

  • -p Remove a directory and its subdirectories
  • —ignore-fail-on-non-empty Ignore the error if the directory is not empty

Examples:

Remove the favorites directory:

$ rmdir favorites

Remove the a/b/c/d subdirectories:

$ rmdir -p a/b/c/d

Try to remove the music directory, but it’s not empty:

$ rmdir songs rmdir: failed to remove “songs”: Directory not empty

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share