{"id":1700,"date":"2021-06-20T13:36:32","date_gmt":"2021-06-20T08:06:32","guid":{"rendered":"https:\/\/jaipurhosting.com\/blog\/?p=1700"},"modified":"2021-06-21T16:07:58","modified_gmt":"2021-06-21T10:37:58","slug":"how-to-unzip-a-zip-file-in-terminal-using-ssh","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/how-to-unzip-a-zip-file-in-terminal-using-ssh\/","title":{"rendered":"How to unzip a ZIP File in Terminal Using SSH"},"content":{"rendered":"\n<p><strong>Description :<\/strong> <\/p>\n\n\n\n<p>Restoring a backup from a ZIP file \u2013 like the ones generated by our downloadable backup feature \u2013 can sometimes be a lengthy process. <\/p>\n\n\n\n<p>If you unzip a ZIP file locally on your computer before uploading the backup with SFTP, you\u2019ll likely run into a bottleneck because SFTP can only transfer a limited number of files concurrently.<\/p>\n\n\n\n<p>There is a faster method that can reduce the backup restore time significantly.<\/p>\n\n\n\n<p>Instead of unzipping a ZIP file locally and uploading the unzipped folder, it\u2019s often faster to upload a ZIP file to the server before unzipping it.<\/p>\n\n\n\n<p>In this post, we can see how to unzip a file uploaded to a server using SSH. <\/p>\n\n\n\n<p><strong>Step 1 \u2013 Log In to Your Server with SSH<\/strong><\/p>\n\n\n\n<p>First step is to log in to your server with SSH<\/p>\n\n\n\n<p>When logging in to your server with SSH, there are two authentication methods \u2013 password and public key authentication. The password authentication method uses a plain text password.<\/p>\n\n\n\n<p>Public key authentication is widely regarded as a more secure alternative to password authentication. <\/p>\n\n\n\n<p>The public key authentication method requires you to generate a key pair \u2013 public key and private key. <\/p>\n\n\n\n<p>The public key is uploaded to the server, while the private key is stored locally on your computer. During the SSH login process, the cryptographic link between the two keys is verified to authenticate the user.<\/p>\n\n\n\n<p><strong><code>ssh username@ip-address -p port<\/code><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 2 \u2013 Install the Unzip Package (Optional)<\/strong><\/p>\n\n\n\n<p>In some Linux distributions, the unzip package is not installed by default. <\/p>\n\n\n\n<p>If you are managing a server that does not have the unzip package installed, you can use the following command to install it \u2013 note that sudo level permissions are required.<\/p>\n\n\n\n<p>Ubuntu and Debian <\/p>\n\n\n\n<p>  <strong><code>sudo apt install unzip<\/code><\/strong><\/p>\n\n\n\n<p>CentOS and Fedora <\/p>\n\n\n\n<p> <code> <strong>sudo yum install unzip<\/strong><\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 3 \u2013 Unzip the ZIP File Using Terminal<\/strong><\/p>\n\n\n\n<p>The next step is to navigate to the ZIP file and unzip it. <\/p>\n\n\n\n<p>To navigate to the correct folder, we can use the cd command, as shown below.<\/p>\n\n\n\n<p><strong><code>cd directory<\/code><\/strong><\/p>\n\n\n\n<p>We uploaded the backup.zip file to the ~\/private directory, so we\u2019ll use the command below.<\/p>\n\n\n\n<p><strong><code>cd ~\/private<\/code><\/strong><\/p>\n\n\n\n<p>Notice how our Terminal prompt shows the ~\/private directory now.<\/p>\n\n\n\n<p>We can use the ls command to list the files and folders in the current directory. <\/p>\n\n\n\n<p>There are two ways to unzip a ZIP file. You can either unzip it to the current directory or a different directory.<\/p>\n\n\n\n<p>To unzip the file to the current directory, use the command below.<\/p>\n\n\n\n<p><strong><code>unzip your-file.zip<\/code><\/strong><\/p>\n\n\n\n<p>To unzip the file to a different directory, use this command instead.<\/p>\n\n\n\n<p><strong><code>unzip your-file.zip -d directory<\/code><\/strong><\/p>\n\n\n\n<p>For the backup.zip file, we want to unzip it to our ~\/public folder, which can be done with the command below.<\/p>\n\n\n\n<p><strong><code>unzip backup.zip -d ~\/public<\/code><\/strong><\/p>\n\n\n\n<p>After running the unzip command, you should see a series of lines that start with \u201cinflating\u201d. This indicates that the unzip process was started successfully.<\/p>\n\n\n\n<p>After the unzip process is finished, navigate to the destination directory with the cd command, and list out the files with the ls command to verify the unzipped files are in the right place.<\/p>\n\n\n\n<p>If you would like to remove the original ZIP file after unzipping it, you can use the rm command like this.<\/p>\n\n\n\n<p><strong><code>rm \/path\/to\/your-file.zip<\/code><\/strong><\/p>\n\n\n\n<p>In general, if you are dealing with a ZIP file that is over 50 MB in size, unzipping it on the server instead of locally on your computer will usually be faster. But there\u2019s more to unzipping ZIP files as using SSH and Terminal is useful for a number of use cases beyond restoring backups.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description : Restoring a backup from a ZIP file \u2013 like the ones generated by our downloadable backup feature \u2013 can sometimes be a lengthy process. If you unzip a ZIP file locally on your computer before uploading the backup with SFTP, you\u2019ll likely run into a bottleneck because SFTP can only transfer a limited [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1702,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1700","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-categorized"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=1700"}],"version-history":[{"count":2,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1700\/revisions"}],"predecessor-version":[{"id":1703,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1700\/revisions\/1703"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1702"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=1700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=1700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=1700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}