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