What is the difference between Tar and Gzip ? Details with example

I too had this doubt! what is the difference between “tar” and “zip”. The answer is quit simple rather than the confusion. We all are very familiar about the word “.tar.gz”, it’s very common when we download something from internet. The extension “.tar.gz” is not a single file extension, it’s a combination of commonly using two technologies to combine and compress files together. That means “.tar.gz” is simply the combination of “.tar” and “.gz”.

The “tar” is a file archiving technique which combine multiple file into single file archive. It’s very useful when you want to transfer some files from one server/machine to another. Combining multiple files using the “tar” is helpful to upload and transfer files simply. We already discussed the usage and possibilities of tar command in Unix.

Gzip is file compression technique used to compress files which has large size. By using this file compression technique, we can simply reduce the file size before sending/transferring it from source to destination. We can also decompress the compressed file at the destination.

How to compress files using Gzip?

As a Unix admin, you can use the command “zip” and “gunzip” to compress and decompress files respectively. Here I am illustrating a simple example of the same.

Test file name is test.txt
To compress file to smaller:

# zip test.txt

After executing this command, the file size will reduce and will add the extension .gz to the file. Use the command “guzip” to decompress the file.

# gunzip test.txt.gz

File extension will come back to its original 

See the file size and format variations in the above attached example.

How to create an archive using tar?

We have already discussed this in detail in one of our previous post, here I list the basic commands to create an archive and extract it. >> tar command in Linux with example <<

Create an archive using tar.

# tar -cvf archive.tar file1.txt file3.txt

Here the files file1 and file2 will combine together and formed the file archive.tar, you can use the tar command with switch -x to extract file from the archive created.

# tar -xvf archive.tar

Here we goes to the extension “.tar.gz”. Yes, there is an option in tar command to compress the files by using additional switches like “-z”, “-j” for Gzip and Bzip respectively.
Examples:
For gzip,

# tar -zcf file.tar.gz file2.txt file1.txt

For bzip,

# tar -jcf file.tar.bz file2.txt file1.txt

We can conclude as:
>> Tar is a file archiving technology which combine multiple files to a single file archive.
>> Gzip is a compression methord to redusethe file size.
>> .tar.gz means the combination of tar and gzip to compress and combine files.

That’s it.

Related Links:
1, Differences between POP3 and IMAP protocol
2, tar command usages with examples

时间: 2024-10-12 04:53:33

What is the difference between Tar and Gzip ? Details with example的相关文章

find 命令 tar 命令 gzip 命令

find ./ -name test.sh 查找当前目录下所有名为test.sh的文件 find ./ -name '*.sh' 查找当前目录下所有后缀为.sh的文件 find ./ -name "[A-Z]*" 查找当前目录下所有以大写字母开头的文件 find /tmp -size 2M 查找在/tmp 目录下等于2M的文件 find /tmp -size +2M 查找在/tmp 目录下大于2M的文件 find /tmp -size -2M 查找在/tmp 目录下小于2M的文件 fi

Linux打包压缩解压缩tar、gzip、bzip2

压缩与解压 1 gzip gzip test.py     #压缩后为test.py.gz gzip -d test.py.gz   #解压文件 2 bzip2 bzip2 test.py     #压缩后为test.py.bz2 bzip2 -d test.py.gz   #解压文件 3 tar 选项内容 -c     创建打包文件 -r     追加文件到打包文档 -t     列出打包内容 -f     指定打包名 -j     打包后通过bzip2格式压缩 -z     打包后通过gzi

Linux的压缩命令(tar,gzip,zip)

打包和压缩.打包是指将一大堆文件或目录变成一个总的文件:压缩则是将一个大的文件通过一些压缩算法变成一个小文件. 这源于Linux中很多压缩程序只能针对一个文件进行压缩,这样当你想要压缩一大堆文件时,你得先将这一大堆文件先打成一个包(tar命令),然后再用压缩程序进行压缩. 1.tar (针对tar包)参考:http://blog.csdn.net/eroswang/article/details/5555415/ tar 参数 被打包的包 参数:-c 创建打包 -x解包  -t 查看(必选,而且

[Z]Linux tar和gzip命令

tar命令 通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具.linux中最流行的tar是麻雀虽小,五脏俱全,功能强大. tar命令可以为linux的文件和目录创建档案.利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件.tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案.利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为

Difference Between ZIP and GZIP

From: http://www.differencebetween.net/technology/difference-between-zip-and-gzip/ Summary: 1. GZIP can achieve better compression compared to ZIP. 2. ZIP is capable of archiving and compressing multiple files, while GZIP is only capable of compressi

Linux下的压缩文件剖析 (tar/gzip的区别)

Linux下的压缩文件剖析 对于刚刚接触Linux的人来说,一定会给Linux下一大堆各式各样的文件名给搞晕.别个不说,单单就压缩文件为例,我们知道在Windows下最常见的压缩文件就只有两种,一是,zip,另一个是.rap.可是Linux就不同了,它有.gz..tar.gz.tgz.bz2..Z..tar等众多的压缩文件名,此外windows下的.zip和.rar也可以在Linux下使用,不过在Linux使用.zip和.rar的人就太少了.本文就来对这些常见的压缩文件进行一番小结,希望你下次遇

加压压缩文件报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

压缩包是直接weget 后面加官网上的tar包地址获取的 [[email protected] ~]# tar -zxvf /home/hadoop/hadoop-2.6.5-src.tar.gz gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exiting now[[email protected] ~]# tar -xvf /home/hadoop/hadoo

Linux CentOS 7 中打包压缩工具gzip、bzip2、xz、zip、tar

一. 压缩打包介绍 常见压缩文件 windows .rar  .zip  .7z linux: .rar .zip .gz .bz2 .xz .tar.gz .tar.bz2  .tar.xz 二. gzip压缩工具 gzip压缩文件: gzip 只能压缩文件不能压缩目录.**gzip 1.txt 压缩完成原文件删除**生成1.txt文件: find /etc/ -type f -name  "*.conf" -exec cat {} >> /tmp/fxq/1.txt \

解压.tar.gz出错gzip: stdin: not in gzip format tar: /Child returned status 1 tar: Error is not recoverable: exiting now

先查看文件真正的属性是什么? [[email protected] ~]# tar -zxvf tcl8.4.16-src.tar.gz gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now [[email protected] ~]# file tcl8.4.16-src.tar.gz tcl8.4.16-src.tar.gz: HTML d