{"id":6932,"date":"2023-10-07T10:02:18","date_gmt":"2023-10-07T10:02:18","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=6932"},"modified":"2024-10-15T15:18:26","modified_gmt":"2024-10-15T15:18:26","slug":"how-to-use-tar-in-linux-ubuntu-centos-redhat-debian","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/","title":{"rendered":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat)"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en.jpg\" alt=\"Use Tar in Linux Ubuntu 18.04 \/ 20.04 \/ 22.04, Debian CentOS 7 \/ 8 or Red Hat 7\" class=\"wp-image-6946\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p><strong>Tar<\/strong> is a utility for archiving and compressing files in Linux and UNIX-like operating systems. It allows you to bundle multiple files and directories into a single .tar archive file, while preserving permissions and directory structures.<\/p>\n\n\n\n<p>Tar is extremely useful for backing up data, moving groups of files between systems, and preparing source code distributions. In this comprehensive guide, we will cover the basics of using tar, as well as some more advanced features and examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"an-overview-of-tar\">An Overview of Tar<\/h2>\n\n\n\n<p>Tar stands for Tape ARchive. It was originally used to archive data onto tape drives for long-term storage. While tar can still write archives to tape drives, it is more commonly used with regular files and pipes today.<\/p>\n\n\n\n<p>Some key facts about tar:<\/p>\n\n\n\n<ul>\n<li>Tar archives bundle multiple files and directories into a single .tar file.<\/li>\n\n\n\n<li>Archives can be compressed using gzip or bzip2 to save space.<\/li>\n\n\n\n<li>Tar preserves permissions, ownership, file modification times, etc.<\/li>\n\n\n\n<li>Archives can span multiple tapes\/volumes (for backing up to tape drives).<\/li>\n\n\n\n<li>Tar is standardized &#8211; archives created on one UNIX system can be extracted on any other compatible UNIX system.<\/li>\n\n\n\n<li>Tar is a very old utility that exists on every Linux and UNIX platform. It has decades of widespread use which makes it very stable and reliable.<\/li>\n<\/ul>\n\n\n\n<p>Let&#8217;s go over some common tar terminology:<\/p>\n\n\n\n<ul>\n<li><strong>Archive<\/strong>&nbsp;&#8211; The .tar file created by bundling files using tar. This file contains the archived content. Archives can be compressed using gzip\/bzip2 which are signified by .tar.gz or .tar.bz2 file extensions.<\/li>\n\n\n\n<li><strong>Bundle<\/strong>&nbsp;&#8211; Synonym for archive.<\/li>\n\n\n\n<li><strong>Tarball<\/strong>&nbsp;&#8211; A tarball is also just another way to refer to a .tar.gz or .tar.bz2 archive file.<\/li>\n\n\n\n<li><strong>Extract<\/strong>&nbsp;&#8211; The process of unbundling an archive and writing the extracted files to disk.<\/li>\n\n\n\n<li><strong>Compression<\/strong>&nbsp;&#8211; Tar supports optional compression with gzip or bzip2 to save space. The compressed archives have .tar.gz or .tar.bz2 extensions.<\/li>\n\n\n\n<li><strong>Append<\/strong>&nbsp;&#8211; Adding files to an existing archive. Does not affect existing content.<\/li>\n\n\n\n<li><strong>Concatenation<\/strong>&nbsp;&#8211; Combining two archives end-to-end.<\/li>\n<\/ul>\n\n\n\n<p>Now that we understand tar terminology and basics, let&#8217;s move on to some usage examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-archives\">Creating Archives<\/h2>\n\n\n\n<p>To create a new tar archive, use the&nbsp;<code>tar -cvf<\/code>&nbsp;command. This breaks down as:<\/p>\n\n\n\n<ul>\n<li><code>-c<\/code>&nbsp;&#8211; Creates a new archive.<\/li>\n\n\n\n<li><code>-v<\/code>&nbsp;&#8211; Verbose output. Lists files processed.<\/li>\n\n\n\n<li><code>-f &lt;archive-name&gt;<\/code>&nbsp;&#8211; Output filename.<\/li>\n<\/ul>\n\n\n\n<p>For example :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf archive.tar \/path\/to\/folder<\/code><\/pre>\n\n\n\n<p>This will archive the given folder recursively into&nbsp;<code>archive.tar<\/code>. You can give multiple file\/folder paths to add multiple entries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf archive.tar \/path\/one \/path\/two \/path\/three<\/code><\/pre>\n\n\n\n<p>To compress the archive using gzip, use&nbsp;<code>-czvf<\/code>&nbsp;instead of just&nbsp;<code>-cvf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -czvf archive.tar.gz \/path\/to\/folder<\/code><\/pre>\n\n\n\n<p>For bzip2 compression, use&nbsp;<code>-cjvf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cjvf archive.tar.bz2 \/path\/to\/folder<\/code><\/pre>\n\n\n\n<p>You can control the verbose output using&nbsp;<code>-v<\/code>. Omit it to hide the file listings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cf archive.tar \/path\/to\/folder<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"viewing-archive-contents\">Viewing Archive Contents<\/h2>\n\n\n\n<p>To view files contained within a tar archive without extracting it, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -tf archive.tar<\/code><\/pre>\n\n\n\n<p>The&nbsp;<code>-t<\/code>&nbsp;lists the contents.<\/p>\n\n\n\n<p>For compressed archives, you need to add the compression flag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -tzf archive.tar.gz\n$ tar -tjf archive.tar.bz2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"extracting-archives\">Extracting Archives<\/h2>\n\n\n\n<p>To extract an archive, use&nbsp;<code>-xf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -xf archive.tar<\/code><\/pre>\n\n\n\n<p>This will extract the contents of&nbsp;<code>archive.tar<\/code>&nbsp;in the current directory while preserving permissions and attributes.<\/p>\n\n\n\n<p>For compressed archives:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -xzf archive.tar.gz\n$ tar -xjf archive.tar.bz2 <\/code><\/pre>\n\n\n\n<p>You can extract to a specific directory using&nbsp;<code>-C<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -xf archive.tar -C \/tmp\/extract-here<\/code><\/pre>\n\n\n\n<p>This will extract the archive into&nbsp;<code>\/tmp\/extract-here<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"appending-to-archives\">Appending to Archives<\/h2>\n\n\n\n<p>You can append files\/directories to an existing tar archive using&nbsp;<code>-rvf<\/code>&nbsp;instead of&nbsp;<code>-cvf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -rvf archive.tar \/new\/folder<\/code><\/pre>\n\n\n\n<p>This will add&nbsp;<code>\/new\/folder<\/code>&nbsp;recursively to&nbsp;<code>archive.tar<\/code>&nbsp;without affecting existing contents.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"updating-archives\">Updating Archives<\/h2>\n\n\n\n<p>To update existing files in an archive or add new files, use&nbsp;<code>-uvf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -uvf archive.tar \/path\/to\/update<\/code><\/pre>\n\n\n\n<p>This will add any new files under&nbsp;<code>\/path\/to\/update<\/code>, and replace any existing files in the archive with the updated versions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"deleting-from-archives\">Deleting from Archives<\/h2>\n\n\n\n<p>Deleting files from tar archives involves creating a new archive without those files.<\/p>\n\n\n\n<p>First, extract the archive contents to a temporary location:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ mkdir \/tmp\/archive-temp\n$ tar -xf archive.tar -C \/tmp\/archive-temp<\/code><\/pre>\n\n\n\n<p>Then delete the file you want removed from the temporary folder.<\/p>\n\n\n\n<p>Finally, create a new archive from the temporary folder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cf new-archive.tar \/tmp\/archive-temp<\/code><\/pre>\n\n\n\n<p><code>new-archive.tar<\/code>&nbsp;will now contain the archive contents minus the deleted file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"excluding-filespaths\">Excluding Files\/Paths<\/h2>\n\n\n\n<p>To exclude certain files\/paths when creating an archive, use&nbsp;<code>--exclude<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf archive.tar \/path --exclude=\/path\/to\/exclude<\/code><\/pre>\n\n\n\n<p>This will prevent&nbsp;<code>\/path\/to\/exclude<\/code>&nbsp;from being added to&nbsp;<code>archive.tar<\/code>.<\/p>\n\n\n\n<p>You can have multiple&nbsp;<code>--exclude<\/code>&nbsp;options. For example, to exclude all .log files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf archive.tar \/path --exclude=*.log<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"including-only-matched-paths\">Including Only Matched Paths<\/h2>\n\n\n\n<p>Instead of excluding certain paths, you can choose to only include matches using&nbsp;<code>-T<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf archive.tar -T include-list.txt<\/code><\/pre>\n\n\n\n<p>Where&nbsp;<code>include-list.txt<\/code>&nbsp;containsPatterns like&nbsp;<code>*.py<\/code>&nbsp;can be used to only match certain extensions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"compression-options\">Compression Options<\/h2>\n\n\n\n<p>By default, tar uses gzip for compression. You can specify different algorithms:<\/p>\n\n\n\n<ul>\n<li>For gz (gzip):&nbsp;<code>-z<\/code><\/li>\n\n\n\n<li>For bz2 (bzip2):&nbsp;<code>-j<\/code><\/li>\n\n\n\n<li>For lzma:&nbsp;<code>-J<\/code><\/li>\n\n\n\n<li>For lzop:&nbsp;<code>-Z<\/code><\/li>\n<\/ul>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cjf archive.tar.bz2 \/path <em># bzip2 compression<\/em><\/code><\/pre>\n\n\n\n<p>You can also set the compression level, which usually ranges from 1 to 9 (higher = better compression but slower):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -czf -9 archive.tar.gz \/path <em># gzip level 9<\/em><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"archive-verification\">Archive Verification<\/h2>\n\n\n\n<p>Once an archive is created, you can verify it has not been corrupted or altered using&nbsp;<code>-W<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -Wvf archive.tar<\/code><\/pre>\n\n\n\n<p>This will check the integrity of the archive.<\/p>\n\n\n\n<p>For compressed archives, add the compression flag as usual:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -Wzvf archive.tar.gz<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tar-over-pipes-and-remote-access\">Tar Over Pipes and Remote Access<\/h2>\n\n\n\n<p>Tar can read\/write archives locally or remotely via stdin\/stdout pipes.<\/p>\n\n\n\n<p>For example, to create a tar over SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ ssh user@host 'tar -cf - \/path\/to\/archive' | tar -xvf -<\/code><\/pre>\n\n\n\n<p>This pipes the tar output over SSH to extract locally.<\/p>\n\n\n\n<p>You can also extract an archive and pipe it over SSH for remote extraction:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cf - \/path\/to\/archive | ssh user@host 'tar -xvf -'<\/code><\/pre>\n\n\n\n<p>Piping tar through SSH compressing\/decompressing can significantly speed up transfers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar czf - \/path\/to\/archive | ssh user@host 'tar xvzf -'<\/code><\/pre>\n\n\n\n<p>These are just some examples &#8211; tar gives you a lot of flexibility with pipes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"splittingspanning-archives\">Splitting\/Spanning Archives<\/h2>\n\n\n\n<p>If your archive does not fit onto a single volume like a tape drive or disk, you can split tar archives into multiple chunks.<\/p>\n\n\n\n<p>To split by size:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf - --tape-length=1G \/path | split -b 1G - archive.tar.<\/code><\/pre>\n\n\n\n<p>This will split&nbsp;<code>archive.tar<\/code>&nbsp;into 1GB chunks named&nbsp;<code>archive.tar.01<\/code>,&nbsp;<code>archive.tar.02<\/code>, etc.<\/p>\n\n\n\n<p>You can also split by number of chunks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -cvf - \/path | split -b 100m -d -a 5 - archive.tar.<\/code><\/pre>\n\n\n\n<p>This splits the archive into 5 parts (-a 5) named&nbsp;<code>archive.tar.01<\/code>,&nbsp;<code>archive.tar.02<\/code>, &#8230;&nbsp;<code>archive.tar.05<\/code>.<\/p>\n\n\n\n<p>To reconstruct the archive from the chunks, use&nbsp;<code>cat<\/code>&nbsp;to concatenate them back in order:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat archive.tar.0* &gt; archive.tar<\/code><\/pre>\n\n\n\n<p>Then extract as usual with&nbsp;<code>tar -xf archive.tar<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"archiving-special-files\">Archiving Special Files<\/h2>\n\n\n\n<ul>\n<li>To archive device files like&nbsp;<code>\/dev\/sdb<\/code>, use the&nbsp;<code>--preserve-devices<\/code>&nbsp;option in GNU tar or&nbsp;<code>--formats=v7<\/code>&nbsp;in BSD\/Solaris tar.<\/li>\n\n\n\n<li>For tracking file hardlinks accurately and archiving them properly, use&nbsp;<code>--hard-dereference<\/code>.<\/li>\n\n\n\n<li>For archiving system extended attributes (SELinux, ACLs, etc), use&nbsp;<code>--xattrs<\/code>.<\/li>\n\n\n\n<li>To keep empty directories in the archive, use&nbsp;<code>--keep-directory-symlinks<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Refer to the tar documentation for details on these and other specialty archiving options.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"useful-tar-flagsexamples\">Useful Tar Flags\/Examples<\/h2>\n\n\n\n<p>Here is a quick reference of some useful tar flags and operations:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"><em># Create archive<\/em>\n$ tar -cf archive.tar \/path\/to\/files\n\n<em># Compressed archive <\/em>\n$ tar -czf archive.tar.gz \/path\/to\/files\n\n<em># View archive contents<\/em>\n$ tar -tf archive.tar\n\n<em># Extract archive <\/em>\n$ tar -xf archive.tar\n\n<em># Extract to specific folder<\/em>\n$ tar -xf archive.tar -C \/tmp \n\n<em># Append files to archive<\/em>\n$ tar -rvf archive.tar file1 file2\n\n<em># Update files in archive<\/em>\n$ tar -uvf archive.tar file1\n\n<em># Delete file from archive<\/em>\n$ tar --delete -f archive.tar file_to_delete \n\n<em># Archive a remote folder over SSH<\/em>\n$ ssh user@host 'tar -cf - \/path\/to\/archive' | tar -xvf -\n\n<em># Verify archive integrity  <\/em>\n$ tar -Wvf archive.tar\n\n<em># Compression levels 1-9<\/em>\n$ tar -czf -9 archive.tar.gz \/path  \n\n<em># Split archive into chunks <\/em>\n$ tar -cf - \/path | split -b 100m -d -a 5 - archive.tar.<\/code><\/pre>\n\n\n\n<p>This covers a wide range of tar usage examples. Be sure to refer to the man pages for your specific tar implementation for more details and supported flags.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Tar is an essential tool for working with groups of files on Linux\/UNIX systems. It allows you to bundle any number of files, directories, and special files into a single portable archive that preserves permissions and attributes, and has many everyday uses for file backups, transfers, Docker and CI\/CD workflows, and software distribution. It is a standardized UNIX utility guaranteed to be available on Linux and macOS systems.<\/p>\n\n\n\n<p>Hopefully this guide gave you a broad overview of tar and how to use it effectively for managing archives on a Linux system like Debian, Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7.<\/p>\n\n\n\n<p>If you have any questions or would like to know more about this article, please post your question in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tar is a utility for archiving and compressing files in Linux and UNIX-like operating systems. It allows you to bundle multiple files and directories into a single .tar archive file, while preserving permissions and directory structures. Tar is extremely useful for backing up data, moving groups of files between systems, and preparing source code distributions. ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,279],"tags":[],"yoast_head":"\n<title>How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-07T10:02:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-15T15:18:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\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\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat)\",\"datePublished\":\"2023-10-07T10:02:18+00:00\",\"dateModified\":\"2024-10-15T15:18:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\"},\"wordCount\":1203,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Linux system administration\",\"Softwares and Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\",\"name\":\"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2023-10-07T10:02:18+00:00\",\"dateModified\":\"2024-10-15T15:18:26+00:00\",\"description\":\"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations","description":"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.","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:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations","og_description":"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.","og_url":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2023-10-07T10:02:18+00:00","article_modified_time":"2024-10-15T15:18:26+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/10\/tar_config_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat)","datePublished":"2023-10-07T10:02:18+00:00","dateModified":"2024-10-15T15:18:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/"},"wordCount":1203,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Linux system administration","Softwares and Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/","url":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/","name":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat) - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2023-10-07T10:02:18+00:00","dateModified":"2024-10-15T15:18:26+00:00","description":"Learn how to use tar on Linux (Ubuntu 18.04 \/ 20.04 \/ 22.04, CentOS 7 \/ 8 or Red Hat 7) to create and extract archives, compress files, backup data, transfer files between systems, and more. Includes tar command examples.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-tar-in-linux-ubuntu-centos-redhat-debian\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"How to Use Tar in Linux (Ubuntu, CentOS, Red Hat)"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6932"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=6932"}],"version-history":[{"count":9,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6932\/revisions"}],"predecessor-version":[{"id":9530,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/6932\/revisions\/9530"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=6932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=6932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=6932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}