How to Remove a Directory in Linux

January 27, 2023 / How-to Guide

This article explains how to remove a directory in Linux. In the Linux/Unix operating system, everything including directories, files, and hardware such as a mouse, keyboard, and printer is a file.

To remove a directory, follow the steps:

  1. To remove empty directories, execute the following command:
    rmdir or rm -d 
  2. To remove non-empty directories, execute the following command:
    rm -r 
  3. It is very important to know the name of the directory, to be removed. To know the files and directories, use the command:
  4. To know about the directory you are in, execute the following command:
  5. Some of the options added with the rm command are listed below:
    rm –d, rm –r, rm –f, rm –rf, rm –I, rm –I, rm *, rm ?, rmdir –p, rmdir –v

Hope you liked our guide and that it was very helpful to you. If you wish to know more about web hosting, do visit our WHUK’s knowledge base articles regularly.

Dominos Search