<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>compress folders Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/compress-folders/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Mon, 30 Sep 2019 09:37:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>Use tar command to archive/compress files/folders in Linux</title>
		<link>https://www.osradar.com/use-tar-command-to-archive-compress-files-folders-in-linux/</link>
					<comments>https://www.osradar.com/use-tar-command-to-archive-compress-files-folders-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Nabeel]]></dc:creator>
		<pubDate>Mon, 30 Sep 2019 09:37:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[compress files]]></category>
		<category><![CDATA[compress folders]]></category>
		<category><![CDATA[tar command]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=13987</guid>

					<description><![CDATA[<p>tar is a Linux utility. It is stand for tape archive. tar command is use to collect many files/directories into one archive file, often referred to as a tarball. Normally it used for distribution or backup purposes. It is most popular tool in Linux systems to create compressed archive files. In this article you will [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/use-tar-command-to-archive-compress-files-folders-in-linux/">Use tar command to archive/compress files/folders in Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>tar is a Linux utility. It is stand for tape archive. tar command is use to collect many files/directories into one archive file, often referred to as a tarball. Normally it used for distribution or backup purposes. It is most popular tool in Linux systems to create compressed archive files.</p>



<p>In this article you will learn that how to use tar command for data archive and its compression using (tar, tar.gz, tar.bz2).</p>



<p>We will use below tar tools.</p>



<p><strong>1-    Tar<br>2-    Gzip<br>3-    Bzip2</strong></p>



<h2>Create tar Archive File</h2>



<p>So, in below example we will create a tar archive file data.tar for a directory /boot in current working directory.</p>



<pre class="wp-block-preformatted">tar -cvf data.tar /boot<br>
ls</pre>



<p><strong>c </strong>– Creates a new .tar archive file.<br><strong>v</strong> – Verbosely show the .tar file progress.<br><strong>f </strong>– File name type of the archive file.</p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="614" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-1024x614.png" alt="" class="wp-image-13989" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-1024x614.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-300x180.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-768x461.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-696x418.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-1068x641.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53-700x420.png 700w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-50-53.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2>Untar (Un-Compress) Archive File</h2>



<p>Now, we will un-compress data.tar archive file in current working directory using below command.</p>



<pre class="wp-block-preformatted">tar -xf data.tar</pre>



<p><strong>x</strong> to extract archive file.</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="188" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-1024x188.png" alt="" class="wp-image-13990" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-1024x188.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-300x55.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-768x141.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-696x128.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55-1068x196.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-51-55.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>uncompress or extract an archive in current working directory.</figcaption></figure>



<p>So what if you want to Un-compress archive in different path or directory. use -C (Capital C) in command and specify your path to un-compress it, Please see below example command.</p>



<pre class="wp-block-preformatted">tar -xf data.tar -C /media<br>ls /media</pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="175" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-1024x175.png" alt="" class="wp-image-13991" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-1024x175.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-300x51.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-768x131.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-696x119.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52-1068x183.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-55-52.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>You can see in above image that <strong>boot</strong> directory is uncompressed in <strong>/media </strong>directory.</p>



<h2>Create tar.gz (gzip) Archive File</h2>



<p>If you want to compress a file/folder with gzip, then you have to use &#8220;z&#8221; in tar command and make archive extension as .tar.gz</p>



<p><strong>z</strong> &#8211; To create a compressed gzip archive file</p>



<p>Run below command</p>



<pre class="wp-block-preformatted">tar -czf data.tar.gz /boot</pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="222" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-1024x222.png" alt="" class="wp-image-13992" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-1024x222.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-300x65.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-768x167.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-696x151.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35-1068x232.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-57-35.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2>Un-compress gzip archive file</h2>



<pre class="wp-block-preformatted">tar -xf data.tar.gz</pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="203" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-1024x203.png" alt="" class="wp-image-13993" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-1024x203.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-300x60.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-768x152.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-696x138.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09-1068x212.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-58-09.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Then, you can also un-compress gzip file in your desired directory</p>



<pre class="wp-block-preformatted">tar -xf data.tar.gz -C /media</pre>



<figure class="wp-block-image"><img loading="lazy" width="1024" height="166" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-1024x166.png" alt="" class="wp-image-13994" srcset="https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-1024x166.png 1024w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-300x49.png 300w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-768x124.png 768w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-696x113.png 696w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01-1068x173.png 1068w, https://www.osradar.com/wp-content/uploads/2019/09/CentOS-8-64-bit-2019-09-26-20-59-01.png 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2>Create tar.bz2 Archive File</h2>



<p>The bz2 feature is used to highly compress and create archive. Its archive size is small then gzip archive. The bz2 compression takes more time to compress and decompress files as compared to gzip which takes less time.</p>



<p><strong>j</strong> &#8211; To create highly compressed tar file, Use following command</p>



<pre class="wp-block-preformatted">tar cj data.tar.bz2 /boot</pre>



<h2>Un-compress bz2 archive file</h2>



<pre class="wp-block-preformatted">tar -xf data.tar.bz2</pre>



<p>Now, un-compress it in another directory</p>



<pre class="wp-block-preformatted">tar -xf data.tar.bz2 -C /media</pre>



<h2>List Content of Archive File</h2>



<p><strong>t</strong> &#8211; it is used to list archive data without extract it.</p>



<p>tar -tvf data.tar<br>tar -tvf data.tar.gz<br>tar -tvf data.tar.bz2</p>



<p>That&#8217;s it.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/use-tar-command-to-archive-compress-files-folders-in-linux/">Use tar command to archive/compress files/folders in Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/use-tar-command-to-archive-compress-files-folders-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
