linux how to remove directory

Answer

To remove an empty directory use the command:

rmdir directory/

To remove a directory which contains files or sub-directories use this way:

rm -r not-emty-directory/

If you want to ignore a nonexistent files and never prompt, use the option "f":

rm -rf not-empty-directory/

Command rm has option "v" which explains what is being done.

rm -rv directory

If you don't have permision to delete folder add sudo at the beginning:

sudo rm -rv directory

If you are not 100 % sure if you want remove all the files in directory, use -i option:

rm -rvi directory

Shell will ask you before remove each file.

Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.