Linux zip命令

Linux zip命令:压缩zip文件。

Linux zip命令 功能描述

使用zip命令可以压缩zip文件。

Linux zip命令 语法

zip [选项] [压缩文件] [文件]

命令中各选项的含义如下表所示。

zip命令选项含义

Linux zip命令 示例

将/root/a文件压缩成/root/a.zip文件

[root@rhel ~]# zip /root/a.zip /root/a
adding: /root/a (stored 0%)

将/root/a文件压缩成/root/a.zip文件,并指定加密密码

[root@rhel ~]# zip -e /root/a.zip /root/a
Enter password:             //在这里输入压缩加密密码
Verify password:            //再一次输入压缩加密密码
 adding: root/a (stored 0%)

测试压缩文件/root/a.zip的完整性

[root@rhel ~]# zip -T /root/a.zip
test of /root/a.zip OK

将/root/a文件压缩成/root/a.zip文件,并且添加一行注释

[root@rhel ~]# zip -c /root/a.zip /root/a
 adding: root/a (stored 0%)
Enter comment for root/a:
zip file                 //在这里添加注释信息

更新/root/a.zip压缩文件,添加/root/b文件

[root@rhel ~]# zip -u /root/a.zip /root/b
adding: root/b (stored 0%)

压缩/root/a文件,生成的压缩文件设置成和/root/a文件一样的时间

[root@rhel ~]# zip -o /root/a.zip /root/a
adding: root/a (stored 0%)

将/home目录压缩成/root/home.zip文件

[root@rhel ~]# zip -r /root/home.zip /home

压缩/boot目录,但是排除/boot/grub/grub.conf文件

[root@rhel ~]# zip -r /root/boot.zip /boot -x /boot/grub/grub.conf
adding: boot/ (stored 0%)
adding: boot/config-2.6.32-358.el6.x86_64 (deflated 75%)
adding: boot/vmlinuz-2.6.32-358.el6.x86_64 (deflated 1%)
adding: boot/lost+found/ (stored 0%)
adding: boot/.vmlinuz-2.6.32-358.el6.x86_64.hmac (deflated 22%)
adding: boot/System.map-2.6.32-358.el6.x86_64 (deflated 79%)
adding: boot/efi/ (stored 0%)
adding: boot/efi/EFI/ (stored 0%)
adding: boot/efi/EFI/redhat/ (stored 0%)
adding: boot/efi/EFI/redhat/grub.efi (deflated 60%)
adding: boot/initramfs-2.6.32-358.el6.x86_64.img (deflated 1%)
adding: boot/symvers-2.6.32-358.el6.x86_64.gz (deflated 0%)
adding: boot/grub/ (stored 0%)
adding: boot/grub/splash.xpm.gz (deflated 88%)
adding: boot/grub/fat_stage1_5 (deflated 38%)
adding: boot/grub/ffs_stage1_5 (deflated 39%)
adding: boot/grub/stage1 (deflated 17%)
adding: boot/grub/iso9660_stage1_5 (deflated 38%)
adding: boot/grub/e2fs_stage1_5 (deflated 40%)
adding: boot/grub/jfs_stage1_5 (deflated 40%)
adding: boot/grub/device.map (deflated 5%)
adding: boot/grub/stage2 (deflated 45%)
adding: boot/grub/ufs2_stage1_5 (deflated 39%)
adding: boot/grub/vstafs_stage1_5 (deflated 39%)
adding: boot/grub/reiserfs_stage1_5 (deflated 40%)
adding: boot/grub/minix_stage1_5 (deflated 40%)
adding: boot/grub/menu.lst (deflated 36%)
adding: boot/grub/xfs_stage1_5 (deflated 39%)

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程