How to Use the rmdir command on Ubuntu 16.04 | 18.04 with Examples

business 4068346 640

For new users and students learning how to use and manage Linux systems, the easiest place to start might be on Ubuntu Linux OS. Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices.

The same way one uses a mouse and keyboard to manage files and folders or perform others simple tasks on Microsoft Windows OS, Ubuntu also makes that easy for you to manage. If you think Windows is easy to use, then Ubuntu might be just what you need and for other beginners.

However, when you’re learning to use and understand Ubuntu Linux, you’ll also want to learn the comnands behind the graphics and mouse-clicking. and how to use them.  This tutorial is going to show you how..

This post shows new users and students what the rmdir command is used for and how to use it.

When you’re ready to learn how to use the rmdir commands, follow the guide below:

About rmdir command:

The rmdir command is used to remove empty directories on Linux systems. If the directory you wish to delete isn’t empty, the rmdir command will fail. It’s a same as using your mouse to right-click a directory or folder and select delete. the rmdir is the way to do it on the command line.

Only directories that have no files or other directories can be removed by using the rmdir command.


The syntax is the rule and format of how the rmdir command can be used. the systax options can be reordered. but a straight format must be followed.,.

Below is an example syntax of how to use the rmdir comamnd.



The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the commands. they are separated by spaces and followed after the commands.

Below are some options of the rmdir command:

DIRECTORY.Replace DIRECTORY.. with the dorectory you want to remove or delete.
-p, –parents
remove DIRECTORY and its ancestors. e.g., ‘rmdir -p a/b/c’ is
similar to ‘rmdir a/b/c a/b a’
-v, –verbose           Use the -v or –verbose option output a diagnostic for every directory processed
–helpUse the –help option to display this help and exit
 –versionUse the –version option to output version information and exit


Below are some examples of how to run and use the rmdir on Ubuntu Linux.

If you want to delete or remove an empty directory or folder called Confidential, you will run the commands below.

rmdir Confidential

To remove multiple empty directories or folders called Bank, Statements and Deposits, run the commands below.

rmdir Bank Statements Deposits

If you’re not logged in as a root account, you may have to use the sudo command it it.

sudo rmdir Bank Statements Deposits

To remove an empty sub directory, run the commands below.

sudo rmdir directory/sub_directory

When you run rmdir with the –help option, you’ll see the help text below:

Usage: rmdir [OPTION]. DIRECTORY.
Remove the DIRECTORY(ies), if they are empty.

                  ignore each failure that is solely because a directory
                    is non-empty
  -p, --parents   remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c' is
                    similar to 'rmdir a/b/c a/b a'
  -v, --verbose   output a diagnostic for every directory processed
      --help     display this help and exit
      --version  output version information and exit

That’s it!

Hope you like it and please come back soon for more Ubuntu Linux command!

You may also like the commands below:

1 Comment


    What about directoy and subdirectories

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.