Chinaunix首页 | 论坛 | 博客
  • 博客访问: 265241
  • 博文数量: 74
  • 博客积分: 1470
  • 博客等级: 上尉
  • 技术积分: 793
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-25 21:01
文章分类

全部博文(74)

文章存档

2011年(1)

2010年(32)

2009年(32)

2008年(9)

我的朋友

分类: LINUX

2009-10-07 21:51:58


  • 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: <

阅读(1385) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~