Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    156
    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:
    506
    Likes Received:
    4
    Trophy Points:
    168
    if you are sure you want to do this you simple type

    rm -rf foldername
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. checked

    checked Well-Known Member

    Joined:
    May 3, 2004
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    156
    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:
    168
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    4
    Trophy Points:
    343
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    21
    Trophy Points:
    463
    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/* ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    21
    Trophy Points:
    463
    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:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. RawG

    RawG Member

    Joined:
    May 2, 2004
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    153
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice