The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Deleting a non-empty folder from SSH ???

Discussion in 'General Discussion' started by checked, May 5, 2004.

  1. checked

    checked Well-Known Member

    Joined:
    May 3, 2004
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    Hi guys,

    I know this is really a stupid question it's it true that I don't know.

    Please tell me how do I delete a non-empty folder from SSH with just one command ?

    Any help would be really apreciated !
     
  2. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    if you are sure you want to do this you simple type

    rm -rf foldername
     
  3. checked

    checked Well-Known Member

    Joined:
    May 3, 2004
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    Thankx asmithjr it works:)

    till now it was an haunting task for me but not it's gr8

    Thankx a lot man for your kind help :)
     
  4. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    Do know there is no recycle bin in linux...if you are wrong with the rm -rf command you can really screw stuff up. I have seen people nuke the wrong directory before, it is never pretty.
     
  5. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    I've seen it first hand. ;) :eek:

    It caused 18 hours of down time and $150 to reinstall the operating system.

    It's always safest to change to the directory you want to remove, then use rm -rf * to empty the directory, then go back 1 level and delete the now empty directory.
     
  6. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Hmmm, I've learnt to me cost that it's never a good idea to use rm -Rf *, but to always use rm -Rf /full/path/to/the/right/dir/* ;)
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Another wonderful gotcha with rm -Rf anything is accidentally putting a space in, for example:

    rm -Rf /etc /olddir/*

    Oooo, you get an error for /olddir/*, but where did /etc go :rolleyes:
     
  8. RawG

    RawG Member

    Joined:
    May 2, 2004
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    3
    I too have seen (done) bad things happen with rm.. example?

    My editor of chioce in Linux is joe. Every time you save a file, lets say it's called 'admin.php', a backup of the previous version is saved with the filename 'admin.php~'.

    After editing scripts I had been working on, I would remove the backups with the command 'rm *~'... after a while it became a habit to routinely run 'rm *~'. The evilness happened when in a jovial fashion I ran 'rm *', and hit the enter key before I realized I'd missed the ~ key... unfortunatly for me I was working in the base directory of my companies web-site, and hosed everything that wasn't in a sub-directory... 'hooray' I said, 'break out the backups'...

    The moral of the story is: be very careful with rm
     
Loading...

Share This Page