How to remove directory with all of its contents?

61,971

Solution 1

If you don't want to empty the directory first, you can use

rm -r

to recursively remove directories and their content.

Please note also that this is already explained in the documentation.

rmdir: The rmdir command will delete an empty directory. To delete a directory and all of its contents recursively, use rm -r instead.

Since you are not an expert, I suggest that you read carefully that documentation page before using more the terminal, before you do some damage to your files!

Solution 2

If you want to remove an entire directory with everything in it, you can use rm -r like dadexix said and if you really want to make sure add the f for force

rm -rf

i Always do that and it Always works

Share:
61,971

Related videos on Youtube

user3076763
Author by

user3076763

Updated on September 18, 2022

Comments

  • user3076763
    user3076763 over 1 year

    I tried to remove a directory by using command rmdir but I got this answer:

    The directory is not empty.
    

    How to deal with such problems?

  • Twinkles
    Twinkles almost 8 years
    Please be careful: not using -rf habitually has saved me several times from doing something disastrous.