免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 969 | 回复: 0
打印 上一主题 下一主题

Advanced compression using zip command [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-07 21:51 |只看该作者 |倒序浏览

               
  • There are 10 levels of compression provided by zip command.
o Level 0 is the lowest level, where it just archives the file without any compression.
o Level 1 will perform little compression. But, will be very fast.
o Level 6 is the default level of compression.
o Level 9 is the maximum compression. This will be slower when compared to default level. In my opinion, unless you are compressing a huge file, you should always use level 9.
In the example below, I used Level 0, default Level 6, and Level 9 compression on a same directory. See the compressed file size yourself.
# zip var-log-files-default.zip /var/log/*
# zip -0 var-log-files-0.zip /var/log/*
# zip -9 var-log-files-9.zip /var/log/*
# ls -ltr

-rw-r--r-- 1 root root 2817248 Jan 1 13:05 var-log-files-default.zip

-rw-r--r-- 1 root root 41415301 Jan 1 13:05 var-log-files-0.zip

-rw-r--r-- 1 root root 2582610 Jan 1 13:06 var-log-files-9.zip
  • Pass the option –P to the zip command to assign a password to the zip file

# zip -P mysecurepwd var-log-protected.zip /var/log/*
The above option is good if you are using the command inside a shell-script for background jobs. However, when you are performing the compression interactively on the command-line, you don’t want the password to be visible in the history. So, use the option –e as shown below to assign the password
# zip -e var-log-protected.zip /var/log/*
Enter password:
Verify password:
updating: var/log/acpid (deflated 81%)
updating: var/log/anaconda.log (deflated 79%)
When you are uncompressing a password protected file, it will ask for the password as shown below.
# unzip var-log-protected.zip
Archive: var-log-protected.zip
[var-log-protected.zip] var/log/acpid password:
reference: > 
http://www.thegeekstuff.com


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/86590/showart_2065403.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP