Linux Delete Directory With rmdir Command

I‘m new to Linux and I’d like to know how to delete directory under any Linux distributions?

You need to use the command called rmdir. It remove empty directories.

rmdir command syntax

rmdir [OPTION] {directory-name}

rmdir [OPTION] {directory-name}

Delete / remove directory

To delete directory called foo, enter:
rmdir foo

Remove DIRECTORY and its ancestors

For example remove directory structure sales/99/march
rmdir -p sales/99/march

Recursive delete

Remove all directories and subdirectories, use rm command with -r option:
rm -rf /home/data/2000

Please note that rmdir command works with all Linux and Unix like operating systems. For more information read rm and rmdir command man pages:
man rm
man rmdir

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.