Linux How to Remove Directory

Linux How to Remove Directory

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 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 won’t remove all the files in directory, use -i option:

rm -rvi directory

Shell will ask you before removing each file.

Leave a Comment