How to delete/remove directory in Linux?

Deleting a directory in Linux

To delete a directory in Linux, you can use the following command:

rm -rf directory_name

If the directory you want to delete is called “abc” in the path /path/to/folder/abc. You should navigate to the /path/to/folder and execute the command like this:

cd /path/to/folder
rm -rf abc

Or you can do this directly using the following command:

rm -rf /path/to/folder/abc

The option “-r” is to remove directories and their contents recursively, and the option “-f” is to ignore nonexistent files and arguments, never prompt, if you have many files to delete and you are sure you want to delete it, you can use the rm command with option “-f” to save yourself sometime

Leave a Comment