Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

How to remove a directory recursively?

Discussion in 'Command Line' started by carbon333, Feb 16, 2012.

  1. carbon333

    carbon333 Guest

    By typing in the terminal:



    rm -rf /path/to/the/directory
     
  2. rpatt

    rpatt Guest

    You do need to make sure that you have write permissions to remove the directory, sub directories. If you run into permission problems, you can do

    chmod -R +w directory-name

    and then

    rm -rf directory-name
     
  3. forestplay

    forestplay Guest

    Be aware that 'rm -rf directory-name' is powerful. As in, dangerous. Use with caution.

    -Bob "Know from experience"
     
  4. ehansen

    ehansen Guest

    The meanest prank to pull on a Linux beginner is getting them into root and telling them to run "rm -rf /".

    Also, this works too:
    find . -exec "rm -rf {}"\;

    I believe that's the command anywho. Been a while since I used find's exec switch.
     
  5. Rob

    Rob Guest

    I have a rule that I always type in the full path to whatever i'm using 'rm -rf' on.. I'll also preach it to anyone i'm teaching..

    IE: if you're root and you are in /home/rob/Downloads/ and want to remove the /home/rob/Downloads/etc/ directory, type in the full path to it.. you don't want to accidently wipe out /etc/ :)

    (also, don't run around as root unless you have to!)
     

Share This Page