READHAT7 RHCSA学习笔记 压缩归档

21 篇文章 0 订阅

linux下不能直接对于文件夹进行压缩,需要进行打包后进行压缩

tar打包

tar -cvf 目标文件名  源文件名    :创建打包,查看详细过程

[root@localhost tmp]# tar -cvf testacl.tar testacl
testacl/
testacl/cat
testacl/cron
testacl/cron1
testacl/crontab.log
[root@localhost tmp]# ls -la | grep testacl
drwxrwx---+  2 root  root     61 Apr 17 16:03 testacl
-rw-r--r--.  1 root  root  61440 Apr 17 16:04 testacl.tar

tar解包

tar -jxvf 文件名 【-C 指定路径】

[root@localhost tmp]# tar -xvf testacl.tar 
testacl/
testacl/cat
testacl/cron
testacl/cron1
testacl/crontab.log

gzip压缩

gzip 文件名

[root@localhost tmp]# gzip cron
[root@localhost tmp]# ls -la | grep cron
-rw-------.  1 root  root  2505 Apr 17 15:52 cron.gz
-rw-r--r--.  1 root  root  5148 Apr 17 15:53 crontab.log

gzip解压缩

gzip -d 文件名

[root@localhost tmp]# gzip -d cron.gz 
[root@localhost tmp]# ls -la | grep cron
-rw-------.  1 root  root  24809 Apr 17 15:52 cron
-rw-r--r--.  1 root  root   5177 Apr 17 15:54 crontab.log

bzip2压缩

bzip2 -z 压缩

bzip2 -s 最小化压缩

bzip2 -k 保存原文件

[root@localhost tmp]# ls -la | grep cron
-rw-------.  1 root  root  24809 Apr 17 15:52 cron
-rw-------.  1 root  root   2115 Apr 17 15:52 cron.bz2
-rw-r--r--.  1 root  root   5264 Apr 17 15:57 crontab.log

bzip2解压缩

bzip2 -d 解压缩

[root@localhost tmp]# bzip2 -d cron.bz2 
[root@localhost tmp]# ls -la | grep cron
-rw-------.  1 root  root  24809 Apr 17 15:52 cron
-rw-------.  1 root  root  24809 Apr 17 15:52 cron1
-rw-r--r--.  1 root  root   5322 Apr 17 15:59 crontab.log

查看文件大小du

du 文件名

[root@localhost tmp]# du -h testacl
64K     testacl
[root@localhost tmp]# du -h testacl.tar 
60K     testacl.tar

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值