{"id":227,"date":"2026-06-03T23:07:03","date_gmt":"2026-06-04T06:07:03","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/"},"modified":"2026-06-03T23:07:03","modified_gmt":"2026-06-04T06:07:03","slug":"compress-extract-files-linux-tar-gzip","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/","title":{"rendered":"How to Compress and Extract Files on Linux Using tar and gzip"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><code class=\"\" data-line=\"\">tar<\/code> and <code class=\"\" data-line=\"\">gzip<\/code> are the standard tools for file compression on Linux. <strong>tar<\/strong> bundles files and directories into a single archive. <strong>gzip<\/strong> compresses that archive to reduce its size. Most of the time you&#8217;ll use them together, which is why you&#8217;ll see the <code class=\"\" data-line=\"\">.tar.gz<\/code> extension everywhere in Linux hosting environments.<\/p>\n<p>You&#8217;ll need this if you&#8217;re downloading a site backup from your VPS, packaging up a WordPress installation before migrating it, compressing log files that are bloating your disk, or extracting software tarballs. These are all daily tasks in server management.<\/p>\n<p>This article covers the most common <code class=\"\" data-line=\"\">tar<\/code> and <code class=\"\" data-line=\"\">gzip<\/code> operations on Linux \u2014 compression, extraction, listing archive contents, and a few combinations that save time. All commands below are tested on Ubuntu 22.04, Debian 12, AlmaLinux 8\/9, and Rocky Linux 8\/9, which cover the vast majority of <a href=\"https:\/\/www.hostandtech.com\/vps-ssd-servers\">VPS SSD Hosting<\/a> environments at Host &amp; Tech.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>SSH access to your Linux server (root or a sudo-capable user)<\/li>\n<li><code class=\"\" data-line=\"\">tar<\/code> installed \u2014 it&#8217;s included by default on virtually every Linux distribution<\/li>\n<li><code class=\"\" data-line=\"\">gzip<\/code> and <code class=\"\" data-line=\"\">bzip2<\/code> installed (also included by default on most distros)<\/li>\n<li>Enough free disk space to hold the compressed archive \u2014 check with <code class=\"\" data-line=\"\">df -h<\/code><\/li>\n<li>Basic familiarity with navigating directories using <code class=\"\" data-line=\"\">cd<\/code> and <code class=\"\" data-line=\"\">ls<\/code><\/li>\n<\/ul>\n<h2>Step-by-Step Instructions<\/h2>\n<h3>Step 1: Create a Compressed tar Archive (.tar.gz)<\/h3>\n<p>This is the command you&#8217;ll use most. It creates a <code class=\"\" data-line=\"\">.tar.gz<\/code> file from a directory or set of files.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-1\"><code class=\"\" data-line=\"\">tar -czvf archive-name.tar.gz \/path\/to\/directory<\/code><\/pre>\n<\/div>\n<p>Here&#8217;s what each flag does:<\/p>\n<ul>\n<li><code class=\"\" data-line=\"\">-c<\/code> \u2014 create a new archive<\/li>\n<li><code class=\"\" data-line=\"\">-z<\/code> \u2014 compress it using gzip<\/li>\n<li><code class=\"\" data-line=\"\">-v<\/code> \u2014 verbose output (lists files as they&#8217;re added \u2014 useful for verification)<\/li>\n<li><code class=\"\" data-line=\"\">-f<\/code> \u2014 specifies the archive filename (must come last, immediately before the filename)<\/li>\n<\/ul>\n<p><strong>Real example:<\/strong> Compressing a WordPress site directory before migration:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-2\"><code class=\"\" data-line=\"\">tar -czvf wordpress-backup-2026-01-15.tar.gz \/var\/www\/html\/wordpress<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: The <code class=\"\" data-line=\"\">-v<\/code> flag is optional. Leave it out if you&#8217;re archiving thousands of files \u2014 printing every filename to the terminal slows things down noticeably on large directories.<\/p>\n<h3>Step 2: Extract a .tar.gz Archive<\/h3>\n<p>To extract the contents of a <code class=\"\" data-line=\"\">.tar.gz<\/code> file into the current directory:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-3\"><code class=\"\" data-line=\"\">tar -xzvf archive-name.tar.gz<\/code><\/pre>\n<\/div>\n<p>To extract into a specific directory instead:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-4\"><code class=\"\" data-line=\"\">tar -xzvf archive-name.tar.gz -C \/path\/to\/destination\/<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: <code class=\"\" data-line=\"\">tar<\/code> will overwrite existing files without asking. If you&#8217;re extracting into a live web directory, make sure you&#8217;re not about to clobber files you need. Either extract to a temp directory first, or verify the archive contents with Step 3 before extracting.<\/p>\n<h3>Step 3: List Archive Contents Without Extracting<\/h3>\n<p>Before extracting, it&#8217;s good practice to see what&#8217;s inside the archive. This is especially true when extracting someone else&#8217;s archive \u2014 some tarballs dump everything into the current directory with no containing folder, which creates a mess.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-5\"><code class=\"\" data-line=\"\">tar -tzvf archive-name.tar.gz<\/code><\/pre>\n<\/div>\n<p>If the output shows paths starting with <code class=\"\" data-line=\"\">.\/<\/code> or a directory name, you&#8217;re fine. If you see individual files at the root with no wrapping directory, extract to a dedicated folder using <code class=\"\" data-line=\"\">-C<\/code> as shown in Step 2.<\/p>\n<h3>Step 4: Compress a Single File with gzip<\/h3>\n<p>If you just need to compress a single file (not a directory), you can use <code class=\"\" data-line=\"\">gzip<\/code> directly:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-6\"><code class=\"\" data-line=\"\">gzip filename.log<\/code><\/pre>\n<\/div>\n<p>This replaces <code class=\"\" data-line=\"\">filename.log<\/code> with <code class=\"\" data-line=\"\">filename.log.gz<\/code>. The original is deleted automatically.<\/p>\n<p>\ud83d\udcdd Note: If you want to keep the original file, use <code class=\"\" data-line=\"\">gzip -k filename.log<\/code>. The <code class=\"\" data-line=\"\">-k<\/code> (keep) flag is available in gzip 1.6 and later, which is standard on all modern distros.<\/p>\n<p>To decompress a <code class=\"\" data-line=\"\">.gz<\/code> file:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-7\"><code class=\"\" data-line=\"\">gunzip filename.log.gz<\/code><\/pre>\n<\/div>\n<h3>Step 5: Create a .tar.bz2 Archive (Better Compression Ratio)<\/h3>\n<p>If disk space or transfer size matters more than speed, <code class=\"\" data-line=\"\">bzip2<\/code> compression typically produces smaller files than <code class=\"\" data-line=\"\">gzip<\/code>, though it&#8217;s slower. Swap the <code class=\"\" data-line=\"\">-z<\/code> flag for <code class=\"\" data-line=\"\">-j<\/code>:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-8\"><code class=\"\" data-line=\"\">tar -cjvf archive-name.tar.bz2 \/path\/to\/directory<\/code><\/pre>\n<\/div>\n<p>To extract a <code class=\"\" data-line=\"\">.tar.bz2<\/code>:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-9\"><code class=\"\" data-line=\"\">tar -xjvf archive-name.tar.bz2<\/code><\/pre>\n<\/div>\n<p>In my experience, <code class=\"\" data-line=\"\">.tar.gz<\/code> is the right default for most hosting tasks \u2014 it&#8217;s faster and universally supported. Use <code class=\"\" data-line=\"\">.tar.bz2<\/code> only when you&#8217;re storing archives long-term and the size difference is meaningful.<\/p>\n<h3>Step 6: Exclude Files or Directories from an Archive<\/h3>\n<p>This one comes up constantly when backing up a CMS installation. You often want to exclude the <code class=\"\" data-line=\"\">node_modules<\/code> folder, cache directories, or large upload folders that don&#8217;t need to be in a code backup.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-10\"><code class=\"\" data-line=\"\">tar -czvf backup.tar.gz \/var\/www\/html\/mysite \n  --exclude=&#039;\/var\/www\/html\/mysite\/wp-content\/uploads&#039; \n  --exclude=&#039;\/var\/www\/html\/mysite\/node_modules&#039;<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: The path in <code class=\"\" data-line=\"\">--exclude<\/code> must match exactly how <code class=\"\" data-line=\"\">tar<\/code> sees it internally. A common gotcha \u2014 if your source path has a trailing slash, the internal paths differ. Test with <code class=\"\" data-line=\"\">-t<\/code> (list) first if you&#8217;re unsure the exclusion worked.<\/p>\n<h3>Step 7: Extract a Single File from an Archive<\/h3>\n<p>You don&#8217;t have to extract an entire archive to retrieve one file. Specify the internal path directly:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-11\"><code class=\"\" data-line=\"\">tar -xzvf archive-name.tar.gz var\/www\/html\/mysite\/wp-config.php<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: Don&#8217;t include a leading slash in the internal path when extracting individual files \u2014 <code class=\"\" data-line=\"\">tar<\/code> strips the leading slash when archiving, so <code class=\"\" data-line=\"\">\/var\/www\/html\/...<\/code> is stored as <code class=\"\" data-line=\"\">var\/www\/html\/...<\/code> internally. The path you specify here must match what <code class=\"\" data-line=\"\">tar -t<\/code> shows.<\/p>\n<h2>Common Issues &amp; Troubleshooting<\/h2>\n<h3>&#8220;tar: Removing leading &#8216;\/&#8217; from member names&#8221;<\/h3>\n<p><strong>Cause:<\/strong> This is informational, not an error. When you specify absolute paths (starting with <code class=\"\" data-line=\"\">\/<\/code>), <code class=\"\" data-line=\"\">tar<\/code> strips the leading slash before storing the file. This is actually intentional safety behaviour \u2014 it prevents extraction from overwriting system files at arbitrary absolute paths.<\/p>\n<p><strong>Fix:<\/strong> Nothing to fix. Your archive is fine. If you want to suppress the message, add <code class=\"\" data-line=\"\">--warning=no-leading-slash<\/code> to your command.<\/p>\n<h3>&#8220;gzip: stdin: not in gzip format&#8221; or &#8220;tar: This does not look like a tar archive&#8221;<\/h3>\n<p><strong>Cause:<\/strong> The file extension doesn&#8217;t match the actual format. This happens with incomplete downloads, corrupted transfers, or files that were renamed. A <code class=\"\" data-line=\"\">.tar.gz<\/code> file that&#8217;s actually just a <code class=\"\" data-line=\"\">.tar<\/code> (uncompressed) will trigger this.<\/p>\n<p><strong>Fix:<\/strong> Run <code class=\"\" data-line=\"\">file archive-name.tar.gz<\/code> to see what the file actually is. Then use the appropriate flags \u2014 drop <code class=\"\" data-line=\"\">-z<\/code> if it&#8217;s an uncompressed tar, or use <code class=\"\" data-line=\"\">-j<\/code> if it&#8217;s actually bzip2-compressed.<\/p>\n<h3>&#8220;No space left on device&#8221; During Compression<\/h3>\n<p><strong>Cause:<\/strong> You&#8217;re trying to compress into the same filesystem that&#8217;s full, or the compressed output is going onto a partition without enough room.<\/p>\n<p><strong>Fix:<\/strong> Check available space first with <code class=\"\" data-line=\"\">df -h<\/code>. If your <code class=\"\" data-line=\"\">\/home<\/code> partition is full, write the archive to a different mount point \u2014 for example, <code class=\"\" data-line=\"\">\/tmp<\/code> or a mounted backup volume. On a Host &amp; Tech VPS you can also expand your storage or attach a block storage volume.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-12\"><code class=\"\" data-line=\"\">df -h\ntar -czvf \/tmp\/backup.tar.gz \/var\/www\/html\/mysite<\/code><\/pre>\n<\/div>\n<h3>Extraction Is Extremely Slow<\/h3>\n<p><strong>Cause:<\/strong> Usually one of two things \u2014 either the archive is very large and disk I\/O is the bottleneck, or you&#8217;re running <code class=\"\" data-line=\"\">-v<\/code> (verbose) on an archive with tens of thousands of small files. Printing each filename to the terminal has real overhead.<\/p>\n<p><strong>Fix:<\/strong> Drop the <code class=\"\" data-line=\"\">-v<\/code> flag. If you need to verify integrity without full extraction, use <code class=\"\" data-line=\"\">tar -tzf archive.tar.gz | wc -l<\/code> to count files, or <code class=\"\" data-line=\"\">tar -tzf archive.tar.gz | head -20<\/code> to spot-check the contents.<\/p>\n<h3>Permission Denied When Extracting<\/h3>\n<p><strong>Cause:<\/strong> The archive was created by root and you&#8217;re extracting as a non-root user, or the destination directory has restrictive permissions.<\/p>\n<p><strong>Fix:<\/strong> Either use <code class=\"\" data-line=\"\">sudo tar -xzvf archive.tar.gz -C \/destination\/<\/code>, or change ownership of the destination directory first. If you&#8217;re extracting a cPanel backup that was created as root, you&#8217;ll almost always need <code class=\"\" data-line=\"\">sudo<\/code>.<\/p>\n<h2>FAQ<\/h2>\n<div class=\"ht-faq-section\">\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">What&#039;s the difference between .tar, .tar.gz, and .tar.bz2?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>A <code class=\"\" data-line=\"\">.tar<\/code> file is just a bundle \u2014 multiple files and folders packed into one, with no compression. A <code class=\"\" data-line=\"\">.tar.gz<\/code> is that same bundle compressed with gzip, which is faster to create and widely supported. A <code class=\"\" data-line=\"\">.tar.bz2<\/code> uses bzip2 compression, which is slower but usually produces a smaller file. For most hosting tasks, <code class=\"\" data-line=\"\">.tar.gz<\/code> is the right choice.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I compress a directory without including the full absolute path?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Change into the parent directory first, then reference the target by its relative name. For example, <code class=\"\" data-line=\"\">cd \/var\/www\/html &amp;&amp; tar -czvf ~\/backup.tar.gz mysite\/<\/code> \u2014 this archives <code class=\"\" data-line=\"\">mysite\/<\/code> with a relative path, so extraction won&#8217;t try to recreate the full <code class=\"\" data-line=\"\">\/var\/www\/html\/<\/code> structure at the destination.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Can I compress files on Linux without using the command line?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>If you&#8217;re on shared hosting or managed WordPress hosting with cPanel, yes \u2014 cPanel&#8217;s File Manager has a built-in Compress tool under the toolbar. Select your files or folder, click Compress, and choose the archive format. Extraction works the same way via the Extract button. For VPS or dedicated servers without a control panel, the command line is the practical option.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I see the size of a tar.gz file before and after compression?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Use <code class=\"\" data-line=\"\">du -sh \/path\/to\/directory<\/code> to check the original size, then <code class=\"\" data-line=\"\">ls -lh archive.tar.gz<\/code> after compression to see the archive size. For a quick ratio, <code class=\"\" data-line=\"\">gzip<\/code> prints compression statistics if you use the <code class=\"\" data-line=\"\">-v<\/code> flag: <code class=\"\" data-line=\"\">gzip -v filename<\/code> shows the original size, compressed size, and percentage saved.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Compressing and extracting files from the Linux command line is something you&#8217;ll need constantly \u2014 whether you&#8217;re backing up a site, moving files between servers, or troubleshooting a cPanel environment. This guide covers the commands that actually matter, with real examples from hosting scenarios.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[49],"tags":[646,623,645,643,644,642,647,448],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-linux","tag-bash","tag-command-line","tag-file-archiving","tag-gzip","tag-linux-compression","tag-tar","tag-tar-gzip-linux-compression","tag-vps-management"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Compress and Extract Files on Linux Using tar and gzip<\/title>\n<meta name=\"description\" content=\"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Compress and Extract Files on Linux Using tar and gzip\" \/>\n<meta property=\"og:description\" content=\"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-04T06:07:03+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"How to Compress and Extract Files on Linux Using tar and gzip\",\"datePublished\":\"2026-06-04T06:07:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/\"},\"wordCount\":1339,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"bash\",\"command line\",\"file archiving\",\"gzip\",\"linux compression\",\"tar\",\"tar gzip Linux compression\",\"VPS management\"],\"articleSection\":[\"Linux Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/\",\"name\":\"How to Compress and Extract Files on Linux Using tar and gzip\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-06-04T06:07:03+00:00\",\"description\":\"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/linux\\\/compress-extract-files-linux-tar-gzip\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Compress and Extract Files on Linux Using tar and gzip\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Compress and Extract Files on Linux Using tar and gzip","description":"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/","og_locale":"en_US","og_type":"article","og_title":"How to Compress and Extract Files on Linux Using tar and gzip","og_description":"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.","og_url":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-06-04T06:07:03+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"How to Compress and Extract Files on Linux Using tar and gzip","datePublished":"2026-06-04T06:07:03+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/"},"wordCount":1339,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["bash","command line","file archiving","gzip","linux compression","tar","tar gzip Linux compression","VPS management"],"articleSection":["Linux Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/","url":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/","name":"How to Compress and Extract Files on Linux Using tar and gzip","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-06-04T06:07:03+00:00","description":"Learn how to compress and extract files on Linux using tar and gzip. Step-by-step commands for VPS, dedicated servers, and shared hosting environments.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/linux\/compress-extract-files-linux-tar-gzip\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Compress and Extract Files on Linux Using tar and gzip"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}