{"id":1001,"date":"2021-12-17T14:12:58","date_gmt":"2021-12-17T14:12:58","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2021\/12\/17\/5822386-common-ssh-commands-at-hostinger\/"},"modified":"2026-08-18T09:41:04","modified_gmt":"2026-08-18T09:41:04","slug":"5822386-common-ssh-commands-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/5822386-common-ssh-commands-at-hostinger\/","title":{"rendered":"Common SSH commands at Hostinger"},"content":{"rendered":"<p class=\"no-margin\">After <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/1583245-how-to-connect-to-a-hosting-plan-via-ssh-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">connecting to your account via SSH<\/a><\/b>, you will require to use commands to perform all the desired actions. Check the topics below for the most commonly used ones &ndash; you can also bookmark this page to have an SSH cheat-sheet at hand.<\/p><h2 id=\"h_8004f434c8\">Manage location<\/h2><p class=\"no-margin\"><b>pwd<\/b> (print working directory) &ndash; show the full path of the directory in which you currently are:<\/p><pre><code>pwd<\/code><\/pre><p class=\"no-margin\"><b>cd <\/b>(change directory) &ndash; move from one folder to another:<\/p><pre><code>cd directory_name<\/code><\/pre><ul>\n<li>\n<p class=\"no-margin\"><code>cd directory_name<\/code> &ndash; go to this subfolder of the current folder<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>cd ..<\/code> &ndash; go one directory up<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\"><b>ls <\/b>(list) &ndash; show the list of all files and folders in the current directory:<\/p><pre><code>ls<\/code><\/pre><ul>\n<li>\n<p class=\"no-margin\"><code>ls -a<\/code> &ndash; include hidden files (which begin with a dot)<\/p>\n<\/li>\n<\/ul><h2 id=\"h_7f9a4111bb\">Manage files and folders<\/h2><p class=\"no-margin\"><b>cp <\/b>(copy) &ndash; you can copy both files and folders:<\/p><pre><code>cp copy_what copy_where<\/code><\/pre><p><strong>NOTE<\/strong><\/p><ul>\n<li class=\"no-margin\">To copy to a higher directory, insert the full path, starting from <code>home<\/code> see <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/4725353-how-to-copy-files-or-folders-using-ssh-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">How to Copy Files or Folders Using SSH<\/a><\/b><\/li>\n<\/ul><p class=\"no-margin\"><b>mv <\/b>(move) &ndash; same as cp, you may move both files and folders:<\/p><pre><code>mv move_what move_where<\/code><\/pre><p class=\"no-margin\"><b>mkdir <\/b>(make directory) &ndash; create a new empty directory:<\/p><pre><code>mkdir folder_name<\/code><\/pre><p class=\"no-margin\"><b>touch <\/b>&ndash; create a new empty file:<\/p><pre><code>touch file_name<\/code><\/pre><p class=\"no-margin\"><b>rmdir <\/b>(remove a directory) &ndash; delete the folder:<\/p><pre><code>rmdir folder_name<\/code><\/pre><p class=\"no-margin\"><b>rm <\/b>(remove) &ndash; delete a file; you can mention several files at a time:<\/p><pre><code>rm file_name<\/code><\/pre><p><strong>NOTE<\/strong><\/p><ul>\n<li class=\"no-margin\"><code>rm -r<\/code><b> <\/b>&ndash; deletes folders, their subfolders, and their content. See <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/4725430-how-to-delete-files-or-folders-using-ssh-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">How to Delete Files or Folders Using SSH<\/a><\/b><\/li>\n<\/ul><p class=\"no-margin\"><b>grep <\/b>&ndash; find a specific text inside files:<\/p><pre><code>grep -inrl 'text'<\/code><\/pre><p class=\"no-margin\"><b>find <\/b>&ndash; find files with a specific name:<\/p><pre><code>find . -type f -name 'name*.php'<\/code><\/pre><h2 id=\"h-check-file-and-folder-ownership\">Check file and folder ownership<\/h2><p>See <a href=\"https:\/\/www.hostinger.com\/support\/4726775-how-to-check-the-files-and-folders-ownership-using-ssh-at-hostinger\/\">how to check the files and folders ownership using SSH<\/a>.<\/p><h2 id=\"h_cf1f99a93c\">Manage archives<\/h2><h3 id=\"h_3d048c3f3a\">Create an archive<\/h3><ul>\n<li>\n<p class=\"no-margin\">Create an archive of <b>specific files<\/b>:<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\"><b>ZIP<\/b>: <code>zip new-archive-name.zip filename1.php filename2.php filename3.php<\/code><br>\n<b>TAR<\/b>: <code>tar -cvf new-archive-name.tar filename1.php filename2.php filename3.php<\/code><br>\n<b>TAR.GZ<\/b>: <code>tar -zcf new-archive-name.tar.gz filename1.php filename2.php filename3.php<\/code><\/p><p class=\"no-margin\">Instead of <code>new-archive-name<\/code>, type the name of the future archive and, after that, specify the exact files that should be included.<\/p><ul>\n<li>\n<p class=\"no-margin\">Create an archive of the <b>whole folder<\/b>:<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\"><b>ZIP<\/b>: <code>zip -r archive.zip DirectoryName<\/code><br>\n<b>TAR<\/b>: <code>tar -cvf archive.tar DirectoryName<\/code><br>\n<b>TAR.GZ<\/b>: <code>tar -zcf archive.tar.gz DirectoryName<\/code><\/p><h3 id=\"h_53273ebdd3\">Unpack an archive<\/h3><p class=\"no-margin\"><b>ZIP<\/b>: <code>unzip archive.zip<\/code><br>\n<b>TAR<\/b>: <code>tar -xvf archive.tar<\/code><br>\n<b>TAR.GZ<\/b>: <code>tar -zxvf archive.tar.gz<\/code><\/p><p>See <a href=\"https:\/\/www.hostinger.com\/support\/5973347-how-to-create-archives-with-ssh-at-hostinger\/\">how to create archives with SSH<\/a> for more detail.<\/p><h2 id=\"h_8023de272c\">Manage databases<\/h2><p class=\"no-margin\"><b>Import<\/b> database file.sql to the database_username database:<\/p><pre><code>mysql -u database_username -p database_name &lt; file.sql<\/code><\/pre><p><strong>NOTE<\/strong><\/p><ul>\n<li class=\"no-margin\">For this command, you should be in the folder where the <code>file.sql<\/code> is located. See <a href=\"https:\/\/www.hostinger.com\/support\/4536306-how-to-import-a-database-over-ssh-in-hostinger\/\"><b>How to Import a Database Over SSH<\/b><\/a><\/li>\n<\/ul><p class=\"no-margin\"><b>Export <\/b>of database_username database to the file.sql file:<\/p><pre><code>mysqldump -u database_username -p database_name &gt; file.sql<\/code><\/pre><p class=\"no-margin\"><strong>NOTES<\/strong><\/p><ul>\n<li class=\"no-margin\">For this command, you don&rsquo;t need to create a file beforehand. See <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/4536328-how-to-export-a-database-over-ssh-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">How to Export a Database Over SSH<\/a><\/b><\/li>\n<li>\n<p class=\"no-margin\">For both commands, in the next step, you should insert the database password<\/p>\n<\/li>\n<\/ul><h2 id=\"h_045286bdca\">Check inodes and disk usage per directory<\/h2><p class=\"no-margin\">Show the <b>inodes number <\/b>for every subdirectory of the current folder:<\/p><pre><code>find . -printf \"%hn\" | cut -d\/ -f-2 | sort | uniq -c | sort -rn<\/code><\/pre><p class=\"no-margin\">Show the<b> disk usage<\/b> per each subdirectory and file of the current folder:<\/p><pre><code>du -shc * | sort -rh<\/code><\/pre><p><strong>NOTE<\/strong><\/p><ul>\n<li>\n<p class=\"no-margin\">See <a href=\"https:\/\/www.hostinger.com\/support\/5776151-how-to-check-the-number-of-inodes-and-disk-usage-per-directory-in-hostinger\/#h_f008024049\"><b>How to Check Inodes and Disk Usage per Folder Using SSH<\/b><\/a><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">It can also be done in the <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/5776151-how-to-check-the-number-of-inodes-and-disk-usage-per-directory-in-hostinger\/#h_38933fc7f5\" target=\"_blank\" rel=\"noopener\">file manager<\/a><\/b><\/p>\n<\/li>\n<\/ul><h2 id=\"h-access-your-websites-root-directory\">Access your website&rsquo;s root directory<\/h2><p>See <a href=\"https:\/\/www.hostinger.com\/support\/5973000-how-to-open-the-website-s-root-directory-via-ssh-in-hostinger\/\">how to open the website&rsquo;s root directory via SSH.<\/a><\/p><h2 id=\"h_0abbc8b31f\">Manage WordPress websites<\/h2><h3 id=\"h_5541479e02\">Purge WordPress cache<\/h3><pre><code>wp cache flush\r\nwp litespeed-purge all<\/code><\/pre><h3 id=\"h_2c317c4179\">Replace WordPress core files<\/h3><pre><code>rm -rf wp-includes\r\nrm -rf wp-admin\r\nwp core download --skip-content --force<\/code><\/pre><p class=\"no-margin\">Or:<\/p><pre><code>backup=WP_`date +%s` &amp;&amp; mkdir $backup &amp;&amp; mv wp-admin $backup &amp;&amp; mv wp-includes $backup &amp;&amp; mv *.php $backup &amp;&amp; wget https:\/\/wordpress.org\/latest.zip &amp;&amp; unzip latest.zip &amp;&amp; rm -rf wordpress\/wp-content &amp;&amp; mv wordpress\/* . &amp;&amp; cp -rv $backup\/wp-config.php .<\/code><\/pre><h2 id=\"h-troubleshooting\">Troubleshooting<\/h2><p>If you run into errors while using SSH, see <a href=\"https:\/\/www.hostinger.com\/support\/5634587-how-to-solve-the-most-common-errors-in-ssh-at-hostinger\/\">how to solve the most common errors in SSH at Hostinger<\/a>.<\/p><p class=\"no-margin\"><b>Additional resource<\/b><\/p><ul>\n<li>\n<p class=\"no-margin\"><b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/tutorials\/ssh\/basic-ssh-commands\/\" target=\"_blank\" rel=\"noopener\">Basic SSH Commands That You Should Know About<\/a><\/b><\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Check all the most useful SSH commands in one place<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[235],"tags":[],"class_list":["post-1001","post","type-post","status-publish","format-standard","hentry","category-ssh-connection-and-ssh-keys"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/5822386-common-ssh-commands-at-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/5822386-hoja-de-trucos-de-ssh-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/5822386-antiseche-de-ssh-at-hostinger\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/5822386-cheat-sheet-ssh-at-hostinger\/","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/support\/5822386-comandos-ssh-mais-usados-na-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/5822386---ssh--hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1001"}],"version-history":[{"count":4,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1001\/revisions"}],"predecessor-version":[{"id":15938,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1001\/revisions\/15938"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}