Skip to content

Wednesday, December 2nd, 2009

New Linux User

HOWTO: Remove Directories in GNU/Linux

April 19, 2006 by Jon  
Filed under How To

There are two options at your disposal to remove directories depending on whether you want to remove a single directory or an entire tree: rm -d or rmdir -p.

rm -d foo will remove the foo directory even if it is not empty. However, you must be root to use this command.

rmdir -p foo will remove the foo directory and ALL it’s subdirectories whether empty or not. You do not have to be root to do this, but you must own all the files and directories that will be effected.

  • StumbleUpon
  • Digg
  • Facebook
  • Mixx
  • Google
  • TwitThis
  • Reddit
  • Yahoo! Buzz
  • Slashdot
  • E-mail this story to a friend!

Comments

8 Responses to “HOWTO: Remove Directories in GNU/Linux”
  1. daveb says:

    rm -r foo

    or rm -rf foo

    if you’d rather not be prompted for every file in the directory.

  2. Jon says:

    Thanks Dave! You’re right – I’d rather not be prompted :)

  3. Geoff says:

    Not to mention, you don’t have to be root to use them.

  4. Jon says:

    You only need to be root for the rm -d command.

  5. Eric says:

    I did not know rm -d and rmdir -p
    I use rm -rf all the time

  6. DOG says:

    RM-D AND RMDIR-P DONT WORK
    THANKS ERIC

  7. Kyle says:

    @Dog: Try rm -R that stands for remove directory recursively and it will remove the directory and its entire contents.

  8. Ben says:

    rmdir -p foo will _only_ remove foo and any subdirectories if they are _empty_ (http://www.linfo.org/rmdir.html). What is written above is incorrect.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!


About Us | Advertise with us | Blog for EveryJoe | Privacy Policy | Terms of Use
Get This Theme | Sitemap


All content is Copyright © 2005-2009 b5media. All rights reserved.