Linux compression and decompression

1. zip format

zip is probably the most used document compression format today. Its biggest advantage is that it can be used on different operating system platforms, such as Linux , Windows and Mac OS . The downside is that the supported compression ratios are not very high, while tar.gz and tar.gz2 do very well in terms of compression ratios.
We can compress a directory with the following command:
# zip -r archive_name.zip directory_to_compress
Here's how to unzip a zip archive:
# unzip archive_name.zip
#unzip archive_name.zip –d new_dir

2. rar format

RAR is a private format for file compression and archiving. It is used for data compression and archiving packaging. Simply put, it is the file format suffix name of the original file data saved after compression processing. Usually Windows users are more common compression software WinRAR , by using WinRAR to compress the file data, the default file format saved is RAR format.

 The rar command uses methods a             to add files to the archive  c             to add comments to the archive ( the maximum size of the comments cannot exceed 62000 bytes )  cf            to add file comments ( when the 'v' parameter is used to display the file comments, the maximum cannot exceed 32767 bytes)  ch            Change the compressed archive parameter  cw            write archive remarks to the specified file  d             delete the file from the archive  e             unzip the file to the current directory ( do not create any subdirectories )  f             refresh the files in the archive ( update the changes of these files since they were packed , not in the archive







 

  new in the case )   i[par]=  Find specific characters in archives  k             to lock archives ( any commands that try to change the contents of compressed archives will be ignored )  l[t,b]        list archives [technical, bare]  m[ f]          move into archive [ file only ]   p             print file to stdout  r             patch archive






rc            rebuild lost volume  rn            rename file in archive  rr[N]         add data recovery record  rv[N]         create recovery Conversion between volume  s[name|-]     archive and SFX ( self-extracting archive )  t             test archive  u              





update files in zip archive  v[t,b]        list zip archive details [technical,bare]  x             unzip to full path


 zip command using rar
rar a anaconda-ks.cfg.rar anaconda-ks.cfg
Use of unzip command unrar :

$unrar --help

Usage : unrar - -               <@listfiles...> < command >  e             extract files to the current directory   l[t,b]        list archive information [technical, bare]  p             print files to standard output  t             test zip i rust  v [t,b]        List the details of the compressed file [technical,bare]  x             Extract the file to the full path [root@localhost ~]# unrar e anaconda-ks.cfg.rar /home/ 
 







 

3. tar format

Tar是在Linux中使用得非常广泛的文档打包格式。它的好处就是它只消耗非常少的CPU以及时间去打包文件,他仅仅只是一个打包工具,并不负责压缩。下面是如何打包一个目录:

# tar -cvf archive_name.tar directory_to_compress
如何解包:
# tar -xvf archive_name.tar.gz
上面这个解包命令将会将文档解开在当前目录下面。当然,你也可以用这个命令来捏住解包的路径:
# tar -xvf archive_name.tar -C /tmp/extract_here/

 

四、tar.gz格式

这种格式是我使用得最多的压缩格式。它在压缩时不会占用太多CPU的,而且可以得到一个非常理想的压缩率。
压缩:
# tar -zcvf archive_name.tar.gz directory_to_compress
解压缩:
# tar -zxvf archive_name.tar.gz
上面这个解包命令将会将文档解开在当前目录下面。当然,你也可以用这个命令来创建解包的路径:
# tar -zxvf archive_name.tar.gz -C /tmp/extract_here/

 

五、tar.bz2格式

这种压缩格式是我们提到的所有方式中压缩率最好的。当然,这也就意味着,它比前面的方式要占用更多的CPU与时间。

压缩:
# tar -jcvf archive_name.tar.bz2 directory_to_compress
上面这个解包命令将会将文档解开在当前目录下面。当然,你也可以用这个命令来创建解包的路径:
# tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/

 
一杯敬故乡,一杯敬远方

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324518244&siteId=291194637