{"id":8109,"date":"2018-01-08T13:33:15","date_gmt":"2018-01-08T13:33:15","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=8109"},"modified":"2026-03-09T19:20:04","modified_gmt":"2026-03-09T19:20:04","slug":"how-to-extract-or-make-archives-via-ssh","status":"publish","type":"post","link":"\/ng\/tutorials\/how-to-extract-or-make-archives-via-ssh","title":{"rendered":"SSH compression: how to zip and unzip via SSH"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>In this article, we are going to show you how to zip and unzip via SSH. You will learn about the compression and extraction methods on your server for better archive management.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/SSH-Cheat-Sheet-EN.pdf\">Download ultimate SSH commands cheat sheet<\/a><\/p><h2 class=\"wp-block-heading\" id=\"h-zip-and-unzip-via-ssh-everything-you-need-to-know\">Zip and Unzip via SSH: Everything You Need to Know<\/h2><p>Compressing and extracting files is not only common on desktop computers. You may need to do the same things on your VPS. Zipping and unzipping files make it easy for you to download and move data around.<\/p><p>To perform these actions,&nbsp; you need to run a specific command through the SSH (Secure Shell) protocol on your server.<\/p><p>This process requires you to use an SSH client &mdash; like <a href=\"https:\/\/www.putty.org\/\">PuTTY<\/a> (Windows) or terminal shell (macOS &amp; Linux) &mdash; to access your server. If Hostinger is your <a href=\"\/ng\/vps-hosting\">VPS provider<\/a>, you can get the login credential in the <strong>Servers<\/strong> tab of the hPanel. You don&rsquo;t know how to establish the connection? Our <a href=\"\/ng\/tutorials\/how-to-use-putty-ssh\">SSH tutorial<\/a> can help you.<\/p><p>Without further delay, let&rsquo;s learn how to zip and <a href=\"\/ng\/tutorials\/how-to-unzip-files-linux\/\">unzip a file in Linux<\/a> via SSH.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-compress-and-extract-different-archive-formats\">How to Compress and Extract Different Archive Formats<\/h2><p>We will cover the compression and extraction method of popular archive formats, including <strong>.tar.gz<\/strong>, <strong>.tar<\/strong>, <strong>.zip<\/strong>, and<strong> .rar<\/strong>.<\/p><h3 class=\"wp-block-heading\" id=\"h-tar-gz-files\">.tar.gz Files<\/h3><ol class=\"wp-block-list\">\n<li>You can use the command below to compress several files into a <strong>.tar.gz <\/strong>archive: <pre>tar -czvf archive-name.tar.gz your-file.text your-file.php your-file.html<\/pre><p>If you intend to compress an entire directory, use the following method.Don&rsquo;t forget to replace &ldquo;<strong>archive-name<\/strong>&rdquo; and &ldquo;<strong>your-file<\/strong>&rdquo; with your actual file names and directories. Also, you are not limited to file formats that are used in this example.<\/p><pre>tar -czvf archive-name.tar.gz \/Directory-Name<\/pre><\/li>\n\n\n\n<li>To extract a <strong>.tar.gz<\/strong> archive, enter: <pre>tar -zxvf archive-name.tar.gz<\/pre><\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-tar-files\">.tar Files<\/h3><ol class=\"wp-block-list\">\n<li>The syntax for creating <strong>.tar<\/strong> archives is as follows: <pre>tar -zcf archive-name.tar your-file.php your-file.php your-file.html<\/pre><p>Enter the following line to move the whole directory to a <strong>.tar<\/strong> file:<\/p><pre>tar -zcf archive-name.tar.gz \/directory-name<\/pre><\/li>\n\n\n\n<li>You can extract the previous archive by typing this command: <pre>tar -xvf archive-name.tar<\/pre><\/li>\n<\/ol><p><div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p><a href=\"\/ng\/tutorials\/linux-tar-command-with-examples\/\">How to Use the tar Command: Useful Examples for Archiving and Compressing Files in Linux<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-zip-files\">.zip Files<\/h3><ol class=\"wp-block-list\">\n<li>For <strong>.zip<\/strong> files, we&rsquo;ll be using the zip command instead of tar. Here&rsquo;s how you create an archive in this format: <pre>zip archive-name.zip your-file.php your-file.php your-file.php<\/pre><p>In order to compress a directory, use this syntax:<\/p><pre>zip -r filename.zip foldername\/<\/pre><\/li>\n\n\n\n<li>This command is used for<strong> .zip<\/strong> file decompression: <pre>unzip archive-name.zip<\/pre><\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-rar-files\">.rar Files<\/h3><ol class=\"wp-block-list\">\n<li>The command for RAR compression is <strong>rar<\/strong>, as shown below: <pre>rar a archive-name.rar your-file.txt your-file.php your-file.html<\/pre><p>To put an entire folder into one <strong>.rar<\/strong> archive, you should use this syntax.<\/p><pre>rar a archive-name.rar \/directory-name<\/pre><\/li>\n\n\n\n<li>This is how you extract the<strong> .rar<\/strong> archive. <pre>unrar x archive-name.rar<\/pre><\/li>\n<\/ol><p>After you decompress any archive format, the script will output a list of all the extracted files, like this:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/01\/rar-extracting.jpg\" alt=\"The result after you unzip via SSH\"><\/figure><\/div><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/ng\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/public\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Congratulations! Now you know how to zip and unzip through SSH for easier file management.<\/p><p>There are many archive formats available, and you can choose the ones that suit you best. Keep in mind that <strong>.tar<\/strong> and <strong>.tar.gz<\/strong> formats use a similar command (<strong>tar<\/strong>) while <strong>.zip<\/strong> and <strong>.rar<\/strong> archives have their own (<strong>zip<\/strong> and <strong>rar <\/strong>respectively).<\/p><p>Therefore, make sure that you enter the appropriate line for the desired file format.<\/p><p>Let us know in the comments if you have any questions!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to show you how to zip and unzip via SSH. You will learn about the compression and extraction methods on your server for better archive management. Zip and Unzip via SSH: Everything You Need to Know Compressing and extracting files is not only common on desktop computers. You may [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/how-to-extract-or-make-archives-via-ssh\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":145349,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"SSH Compression: Zipping and Unzipping Files via SSH Explained","rank_math_description":"Read this article to learn how to zip and unzip via SSH. We'll show you how to compress and extract .tar, .tar.gz, .zip, and .rar archive format.","rank_math_focus_keyword":"ssh unzip","footnotes":""},"categories":[22644],"tags":[],"class_list":["post-8109","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-descomprimir-crear-archivos-mediante-conexion-ssh","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-extract-or-make-archives-via-ssh\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-extract-or-make-archives-via-ssh\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-descomprimir-crear-archivos-mediante-conexion-ssh","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-descomprimir-crear-archivos-mediante-conexion-ssh","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-descomprimir-crear-archivos-mediante-conexion-ssh","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-extract-or-make-archives-via-ssh","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/8109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=8109"}],"version-history":[{"count":27,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/8109\/revisions"}],"predecessor-version":[{"id":145348,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/8109\/revisions\/145348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/145349"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=8109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=8109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=8109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}