- 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) |