How To Delete Files And Folders Via SSH - SiteGround Tutorials

Tutorials

  • SSH Tutorials menu
    • Enable SSH in Site Tools
    • How to Use PuTTY
    • List Files and Directories
    • Create/Edit Files and Folders
    • Move and Copy Files
    • Delete Files and Folders
    • Create and Extract Archives
    • Search for Files and Folders
    • Permissions and Ownership
    • Environment Variables

Get Expert Website Hosting

Choose website reliability and expertise with SiteGround!

Start now Home / SSH Tutorials / How to Delete Files and Folders via SSH How to Delete Files and Folders via SSH Summarize this article with: Last update: Oct 13, 2021
  • SSH Tutorials menu
    • Enable SSH in Site Tools
    • How to Use PuTTY
    • List Files and Directories
    • Create/Edit Files and Folders
    • Move and Copy Files
    • Delete Files and Folders
    • Create and Extract Archives
    • Search for Files and Folders
    • Permissions and Ownership
    • Environment Variables

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 simplest form looks like:

rm myFile.txt myFile1.txt myFile2.txt

However, listing all files/folders that need to be deleted can be quite time-consuming. Fortunately, rm accepts several arguments which can ease your task. In the above example, you could type:

rm myFile*.txt

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

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 *

Share this article

  • Copied

SiteGround Chat

CHAT WITH US

Have questions? Chat with a team member, we're happy to help!

Chat now 1

Từ khóa » Xoa Ssh