How to delete files or folders using SSH at Hostinger

Delete files or folders using SSH at Hostinger with the rm command: remove single files, multiple files, whole folders, or all directory contents.

Updated 6 days ago

Delete files or folders using SSH at Hostinger with the rm command, after connecting to your hosting plan and opening the folder that contains them. The rm command removes single files, multiple files, a whole folder, or all contents of a directory, and deleted files can’t be recovered from the terminal.

Deleting files and folders is possible using Hostinger File Manager:

If you would like to delete files and folders with SSH, all you need to do is:

Step 1 – Connection

First, enable SSH access and connect to your account using SSH. Open the directory, where the files and folders, which you want to delete, are located. For that:

  1. Open your website’s root directory

  2. Run ls command. If you see the needed files and folders, then you can go to Step 2

  3. If the needed content is in a subdirectory, reach it by running:

cd path/to/files

where “path/to/files” is changed by an actual path to your files. For example, if your files are located in public_html/new/version1, then the command should be “cd new/version1”.

Step 2 – Deleting

You only need 1 command to delete files or folders, just chose the option the most suitable for you:

  • To delete a file or files:

rm filename.php

rm filename1.php filename2.php filename3.php
  • To delete a whole folder and its contents:

rm -r foldername/
  • To delete all files in a directory including files and folders inside of it:

rm -r *

The selected files and folders are now removed from your hosting plan.

More SSH file management guides at Hostinger