Quickly Deleting Files on Linux

Posted by Johan Cyprich on 08 Apr 2009 | Tagged as: How To

Once in a while I need to delete all of the files and folders on my Linux hosting account. This is usually due to updating an application, installing a new web application, or more often installing a clean application in my testing folder.

I would normally use WinSCP, but the problem with deleting files through this is that when there are thousands and files and folders, the process could take a long time. Deleting a Joomla installation, for example, takes more than 30 minutes to do.

A faster way to delete files is to go into your shell account (assuming your web host allows you to have one), and from the root directory, enter the following command:

rm –r folder

This will recursively delete all items in the folder and then delete the folder itself. If the folder is a subdomain, then recreate it using the rmdir command. This process takes seconds as opposed to the method used in WinSCP.

Banner



Tweet This Tweet This Post!

Related posts:
    Fixing “/var/lib/pgsql/data is missing” Error
    How to Uncompress Files in Linux
    Preventing Deletions in Attached E-mail Files
    Managing Users in phpBB

Share this post:

del.icio.us:Quickly Deleting Files on Linux digg:Quickly Deleting Files on Linux spurl:Quickly Deleting Files on Linux wists:Quickly Deleting Files on Linux simpy:Quickly Deleting Files on Linux newsvine:Quickly Deleting Files on Linux blinklist:Quickly Deleting Files on Linux furl:Quickly Deleting Files on Linux reddit:Quickly Deleting Files on Linux fark:Quickly Deleting Files on Linux blogmarks:Quickly Deleting Files on Linux Y!:Quickly Deleting Files on Linux smarking:Quickly Deleting Files on Linux magnolia:Quickly Deleting Files on Linux segnalo:Quickly Deleting Files on Linux gifttagging:Quickly Deleting Files on Linux

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


2 Responses to “Quickly Deleting Files on Linux”

  1. on 09 Apr 2009 at 12:28 pm 1.steve.lippert said …

    While this is a quick way to remove an entire directory in linux you really must take caution in using it.

    I always go with the full path to remove directories
    rm -Rf /var/www/vhost/subdomain.cyprich.com
    instead of
    rm -Rf subdomain.cyprich.com

    which may be correct if I am in /var/www/vhosts, but would be wrong if I am in say my home directory.

    I have borked a dev system by running rm -Rf in /etc instead of in /tmp like I wanted to do.

    It’s a rookie mistake I admit, but something that can also be learned from.

  2. on 09 Apr 2009 at 4:12 pm 2.Johan Cyprich said …

    Hi Steve. corykrug on Twitter said you can recursively delete all files and directories with

    rm – rf *

    Its probably a good idea giving a full path when deleting files just to be safe.

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv Enabled