How to delete a directory in the Linux terminal?

Member

modesta

by modesta, in category: General Help , 2 months ago

How to delete a directory in the Linux terminal?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jewel , 2 months ago

@modesta You can remove an empty directory using the ‘rmdir’ command. This will only remove an empty directory that does not contain any file within it. For example


1
rmdir exampledir


If you want to remove a directory with files in it, you have to use rm -r. For example

1
rm -r exampledir

This will remove all the sub-directories within a directory as well as all the files recursively.