How to Delete Files and Folders via SSH


Sometimes you would need to remove a file or a folder from the system. To do so using SSH, you would need to execute the appropriate command – rm.

The command in its simpliest form looks like:

rm myFile.txt myFile1.txt myFile2.txt …etc…

You would notice however that listing all files/folders that need to be deleted can be quite time consuming. Fortunately, rm accepts several arguments which can ease us. In the above example, we could type:

rm myFile*.txt

This will match all files starting with ‘myFile’ and ending in ‘.txt’

To delete a whole folder and its content recursively, you can use:

rm -rf foldername/

To delete all files/folders in the current directory, without deleting the directory itself, you would need to use:

rm -rf *

Please be very careful when using rm command, as it might have devastating effects on your website/server, should you delete a system file or a folder.


Did you know that if you subscribe to our website, you will receive email notifications whenever content changes or new content is added.
1. Enter your e-mail address below and click the Sign Me Up button.
2. You will receive an email asking you to confirm your intention of subscribing to our site.
3. Click the link in the email to confirm. That’s all there is to it!

Enter your email address below to subscribe to Dialect Zone International.

Note: if you wish to unsubscribe from our site, click the unsubscribe link at the bottom of the email you received.
Then indicate you no longer wish to receive our emails.

Thank You
Dialect Zone International


Posted in Education, IT.

Leave a Reply