常用归档压缩命令

1. 打包tar

打包表示把一堆文件变成一个

tar ####打包工具

-f ####指定生成包的名字

-c ####创建包

-v ####显示创建过程

-t ####查看包中内容

-x ####解包

-r ####添加文件到包中

--delete filename ##删除包中指定文件

--get filename  ##取出包中指定文件

         cf

         fr

         cvf    等组合使用


2. 压缩

gzip

gzip xxxx.tar =====> xxxx.tar.gz ##压缩

gunzip xxxx.tar.gz =====> xxxx.tar ##解压

tar zcvf xxxx.tar.gz 目标文件 ##打包压缩文件

tar zxvf xxxx.tar.gz ###xxxx.tar.gz===>xxxx


bz2

bzip2 xxxx.tar =====> xxxx.tar.bz2 ##压缩

bunzip2 xxxx.tar.bz2 =====> xxxx.tar ##解压

tar jcvf xxxx.tar.bz2 目标文件 ##打包压缩文件

tar jxvf xxxx.tar.bz2 ###xxxx.tar.bz2===>xxxx


xz

xz xxxx.tar =====> xxxx.tar.xz      ##压缩

unxz xxxx.tar.xz =====> xxxx.tar    ##解压

tar Jcvf xxxx.tar.xz 目标文件    ##打包压缩文件

tar Jxvf xxxx.tar.xz                ###xxxx.tar.xz===>xxxx


zip

zip -r xxx.tar.zip xxx.tar    ###压缩

unzip xxx.tar.zip    ###解压


例:

1.打包文件

[root@localhost test]# touch file{1..10}

[root@localhost test]# tar -cf test.tar  *

[root@localhost test]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  test.tar


2.解压文件

[root@localhost test]# mkdir test1

[root@localhost test]# cd test1

[root@localhost test1]# tar xf ../test.tar 

[root@localhost test1]# ls


3.gzip打包压缩

[root@localhost test]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9

[root@localhost test]# tar -zcvf test.tar *

file1

file10

file2

file3

file4

file5

file6

file7

file8

file9

[root@localhost test]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  test.tar


4.解gzip压缩包

[root@localhost test]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  test.tar

[root@localhost test]# mkdir test2

[root@localhost test]# cd test2/

[root@localhost test2]# tar -zxvf ../test.tar 

file1

file10

file2

file3

file4

file5

file6

file7

file8

file9

[root@localhost test2]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9




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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值