linux压缩解压命令



转载注明转载地址:http://blog.csdn.net/oyhb_1992/article/details/77102667

解压命令

        linux中有众多的解压命令,首先要明确压缩文件的扩展名有哪些

        .tar tape archive打包文件,但是不压缩

        .tar.gz     先打包再压缩

        .gz   gzip命令压缩的文件后缀是.gz

        .bz2.bzip2命令压缩的文件后缀是.bz2

下面介绍各个命令的用法

gzip命令

        压缩        #gzip /root/anaconda-ks.cfg

        解压缩    #gzip –d /root/anaconda-ks.cfg.gz

       注意gzip命令不能用来压缩整个路径,需要先用tar命令打包路径后才可以用gzip压缩

bzip命令

        压缩        #bzip2 /root/anaconda-ks.cfg

        解压缩    #bzip2 –d /root/anaconda-ks.cfg.bz2

        bzip2命令也不能用来压缩整个路径

tar命令  

        tar命令只能打包文件或路径却不能压缩

        打包        #tar cvf tmp.tar /tmp     c表示compless压缩,vview显示打包过程ffile备份文件

        解压打包文件        #tar xvf tmp.tar xextract提取的意思

        先打包再压缩        #tar cvzf tmp.tar.gz /tmp      z表示gzip压缩

        解压缩和打包        #tar xvzf tmp.tar.gz

总结:bzip2,gzip命令都是压缩不压缩用-d区分,tar则用x/c/z来区别.

 

各用法

[root@ouyanghaibin lesson6]# gzip --help
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.

  -c, --stdout      write on standard output, keep original files unchanged
  -d, --decompress  decompress
  -f, --force       force overwrite of output file and compress links
  -h, --help        give this help
  -l, --list        list compressed file contents
  -L, --license     display software license
  -n, --no-name     do not save or restore the original name and time stamp
  -N, --name        save or restore the original name and time stamp
  -q, --quiet       suppress all warnings
  -r, --recursive   operate recursively on directories
  -S, --suffix=SUF  use suffix SUF on compressed files
  -t, --test        test compressed file integrity
  -v, --verbose     verbose mode
  -V, --version     display version number
  -1, --fast        compress faster
  -9, --best        compress better
    --rsyncable   Make rsync-friendly archive
[root@ouyanghaibin lesson6]# gzip --help
Usage: gzip [OPTION]... [FILE]...

 

 

[root@ouyanghaibin lesson6]# bzip2 --help
bzip2, a block-sorting file compressor.  Version 1.0.5, 10-Dec-2007.

   usage: bzip2 [flags and input files in any order]

   -h --help           print this message
   -d --decompress     force decompression
   -z --compress       force compression
   -k --keep           keep (don't delete) input files
   -f --force          overwrite existing output files
   -t --test           test compressed file integrity
   -c --stdout         output to standard out
   -q --quiet          suppress noncritical error messages
   -v --verbose        be verbose (a 2nd -v gives more)
   -L --license        display software version & license
   -V --version        display software version & license
   -s --small          use less memory (at most 2500k)
   -1 .. -9            set block size to 100k .. 900k
   --fast              alias for -1
   --best              alias for -9

   If invoked as `bzip2', default action is to compress.
              as `bunzip2',  default action is to decompress.
              as `bzcat', default action is to decompress to stdout.

   If no file names are given, bzip2 compresses or decompresses
   from standard input to standard output.  You can combine
   short flags, so `-v -4' means the same as -v4 or -4v, &c.

 

 

 

[root@ouyanghaibin lesson6]# tar --help
用法: tar [选项...] [FILE]...
 GNU ‘tar’
将许多文件一起保存至一个单独的磁带或磁盘归档,并能从归档中单独还原所需文件。

示例
  tar -cf archive.tar foo bar  # 从文件 foo 和 bar 创建归档文件
archive.tar。
  tar -tvf archive.tar         # 详细列举归档文件 archive.tar
中的所有文件。
  tar -xf archive.tar          # 展开归档文件 archive.tar
中的所有文件。


 

 

 

 

 




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值