Home » linux » Linux and Unix rmdir command tutorial with examples

Linux and Unix rmdir command tutorial with examples

rmdir stands for remove directory.
In the UNIX file system, we can remove directory by using rmdir command.

Syntax:

Note: In above syntax in the place of [directory name] we will specify the name of the directory to be removed.

Example:

The directory abc is removed. To confirm directory is created press “ls” command which prints the name of all files and directory.
Remove multiple directories: We can remove multiple directories with the single invocation of the command. Suppose we want to remove three directory abc1, abc2 and abc3 then the command for removing three directories shown in below.

Remove subdirectory: We can remove directory inside another directory by using a single invocation of the command.
Suppose we want to remove directory abc and subdirectory abc1 and abc2 inside the directory abc then the command is as follows.

Above command remove directory abc and subdirectory abc1 and abc2.

Note: The order of specifying argument important because we can not remove directory without removing its subdirectory. For example, we can not write

Command rmdir failed to remove directory abc because abc is not empty but it will remove two subdirectory abc1 and abc2.

Please follow and like us:
error