{"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-03-16T12:12:09","modified_gmt":"2026-03-16T12:12:09","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 href=\"\/support\/1583245-how-can-i-log-in-to-my-account-via-ssh\" target=\"_blank\" class=\"intercom-content-link\">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 &#128521; <\/p><p class=\"no-margin\">\n<\/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\">\n<\/p><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><p class=\"no-margin\">\n<\/p><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><ul>\n<li>\n<p class=\"no-margin\">To copy to a higher directory, insert the full path, starting from <code>home<\/code><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/4725353-how-to-copy-files-or-folders-using-ssh\" target=\"_blank\" class=\"intercom-content-link\">How to Copy Files or Folders Using SSH<\/a><\/b><\/p>\n<\/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\">\n<\/p><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\">\n<\/p><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\">\n<\/p><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\">\n<\/p><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><ul>\n<li>\n<p class=\"no-margin\"><code>rm -r<\/code><b> <\/b>&ndash; deletes folders, their subfolders, and their content<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/4725430-how-to-delete-files-or-folders-using-ssh\" target=\"_blank\" class=\"intercom-content-link\">How to Delete Files or Folders Using SSH<\/a><\/b><\/p>\n<\/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\">\n<\/p><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><p class=\"no-margin\">\n<\/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><b>TAR<\/b>: <code>tar -cvf new-archive-name.tar filename1.php filename2.php filename3.php<\/code><br><b>TAR.GZ<\/b>: <code>tar -zcf new-archive-name.tar.gz filename1.php filename2.php filename3.php<\/code><\/p><p class=\"no-margin\">\n<\/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><b>TAR<\/b>: <code>tar -cvf archive.tar DirectoryName<\/code> <br><b>TAR.GZ<\/b>: <code>tar -zcf archive.tar.gz DirectoryName<\/code><\/p><p class=\"no-margin\">\n<\/p><h3 id=\"h_53273ebdd3\">Unpack an Archive<\/h3><p class=\"no-margin\"><b>ZIP<\/b>: <code>unzip archive.zip<\/code> <br><b>TAR<\/b>: <code>tar -xvf archive.tar<\/code> <br><b>TAR.GZ<\/b>: <code>tar -zxvf archive.tar.gz<\/code><\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">\n<\/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><ul>\n<li>\n<p class=\"no-margin\">For this command, you should be in the folder where the <code>file.sql<\/code> is located<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/4536306-how-do-i-import-a-database-over-ssh\" target=\"_blank\" class=\"intercom-content-link\">How to Import a Database Over SSH<\/a><\/b><\/p>\n<\/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><ul>\n<li>\n<p class=\"no-margin\">For this command, you don&rsquo;t need to create a file beforehand<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/4536328-how-do-i-export-a-database-over-ssh\" target=\"_blank\" class=\"intercom-content-link\">How to Export a Database Over SSH<\/a><\/b><\/p>\n<\/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><p class=\"no-margin\">\n<\/p><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\">\n<\/p><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><ul>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/5776151-how-to-check-inodes-and-disk-usage-per-directory#h_f008024049\" target=\"_blank\" class=\"intercom-content-link\">How to Check Inodes and Disk Usage per Folder Using SSH<\/a><\/b><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">It can also be done in the <b><a href=\"\/support\/5776151-how-to-check-inodes-and-disk-usage-per-directory#h_32ba235ce9\" target=\"_blank\" class=\"intercom-content-link\">file manager<\/a><\/b><\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">\n<\/p><h2 id=\"h_0abbc8b31f\">Manage WordPress Websites<\/h2><h3 id=\"h_5541479e02\">Purge WordPress Cache<\/h3><pre><code>wp cache flush<br>wp litespeed-purge all<\/code><\/pre><p class=\"no-margin\">\n<\/p><h3 id=\"h_2c317c4179\">Replace WordPress Core Files<\/h3><pre><code>rm -rf wp-includes<br>rm -rf wp-admin<br>wp 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><p class=\"no-margin\">\n<\/p><p class=\"no-margin\"><b>Additional Resources<\/b><\/p><ul>\n<li>\n<p class=\"no-margin\"><b><a href=\"https:\/\/www.hostinger.com\/tutorials\/ssh\/basic-ssh-commands\" target=\"_blank\" class=\"intercom-content-link\">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-PT","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":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1001\/revisions"}],"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}]}}