Linux 下压缩与解压.zip和.rar及.7z文件1)对于.ziplinux下提供了zip和unzip程序,zip是压缩程序,unzip是解压程序。它们的参数选项很多,可用命令zip -help和unzip -help查看,这里只做简单介绍,举例说明一下其用法:# zip yajiu.zip yajiu.jpg yajiu.png这条命令是将yajiu.jpg和yajiu.png压缩成一个zip包# zip yajiu.zip *.jpg这条命令是将所有.jpg的文件压缩成一个zip包# zip -r yajiu.zip yajiu这条命令是将文件夹yajiu压缩成一个zip包# unzip yajiu.zip这条命令是将yajiu.zip中的所有文件解压出来yajiu@yajiu-desktop:~$ cd 图片yajiu@yajiu-desktop:~/图片zip yajiu.zip yajiu.jpg yajiu.pngupdating: yajiu.jpg (deflated 34%)updating: yajiu.png (deflated 0%)yajiu@yajiu-desktop:~/图片$ zip yajiu.zip *.jpgadding: 1.jpg (deflated 34%)adding: 2.jpg (deflated 0%)yajiu@yajiu-desktop:~/图片$ zip -r yajiu.zip yajiuadding: yajiu/ (stored 0%)adding: yajiu/yajiu.zip (stored 0%)adding: yajiu/yajiu.jpg (deflated 34%)adding: yajiu/yajiu.rar (deflated 0%)adding: yajiu/yajiu.7z (deflated 0%)adding: yajiu/yajiu.png (deflated 0%)yajiu@yajiu-desktop:~/图片$ unzip yajiu.zipArchive: yajiu.zipreplace 1.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: yinflating: 1.jpg replace 2.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: yinflating: 2.jpg yajiu@yajiu-desktop:~/图片$ 原文链接:2)对于.rar安装: sudo apt-get install rar unrar或者可从http://www.rarsoft.com/download.htm下载 RAR for Linux 编译安装# tar -xzpvf rarlinux-3.8.0.tar.gz# cd rar# make这样就安装好了,安装之后就有了rar和unrar这两个程序,rar是压缩程序,unrar是解压程序。它们的参数选项很多,可用命令rar -help和unrar -help查看,这里亦简单举例说明一下其用法:# rar a yajiu.rar yajiu.jpg yajiu.png这条命令是将yajiu.jpg和yajiu.png压缩成一个rar包# rar a yajiu.rar *.jpg这条命令是将所有.jpg的文件压缩成一个rar包# rar a yajiu.rar yajiu这条命令是将文件夹yajiu压缩成一个rar包# unrar e yajiu.rar这条命令是将yajiu.rar中的所有文件解压出来yajiu@yajiu-desktop:~$ cd 图片yajiu@yajiu-desktop:~/图片$ rar a yajiu.rar yajiu.jpg yajiu.pngRAR 3.80 beta 2 Copyright (c) 1993-2008 Alexander Roshal 16 Jun 2008Shareware version Type RAR -? for helpEvaluation copy. Please register.Creating archive yajiu.rarAdding yajiu.jpg OK Adding yajiu.png OK Doneyajiu@yajiu-desktop:~/图片$ rar a yajiu.rar *.jpgRAR 3.80 beta 2 Copyright (c) 1993-2008 Alexander Roshal 16 Jun 2008Shareware version Type RAR -? for helpEvaluation copy. Please register.Creating archive yajiu.rarAdding 1.jpg OK Adding 2.jpg OK Doneyajiu@yajiu-desktop:~/图片$ rar a yajiu.rar yajiuRAR 3.80 beta 2 Copyright (c) 1993-2008 Alexander Roshal 16 Jun 2008Shareware version Type RAR -? for helpEvaluation copy. Please register.Creating archive yajiu.rarAdding yajiu/yajiu.zip OK Adding yajiu/yajiu.jpg OK Adding yajiu/yajiu.rar OK Adding yajiu/yajiu.7z OK Adding yajiu/yajiu.png OK Adding yajiu OK Doneyajiu@yajiu-desktop:~/图片$ unrar e yajiu.rarUNRAR 3.80 beta 2 freeware Copyright (c) 1993-2008 Alexander RoshalExtracting from yajiu.rar1.jpg already exists. Overwrite it ?[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit YExtracting 1.jpg OK 7a008fc287fe680c0ff477e9.jpg already exists. Overwrite it ?[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit YExtracting 2.jpg OK All OKyajiu@yajiu-desktop:~/图片$ 原文链接:2)对于.7z支持 7Z,ZIP,Zip64,CAB,RAR,ARJ,GZIP,BZIP2,TAR,CPIO,RPM,ISO,DEB 压缩文件格式安装: sudo apt-get install p7zip p7zip-full p7zip-rar# 7z a yajiu.7z yajiu.jpg yajiu.png这条命令是将yajiu.jpg和yajiu.png压缩成一个7z包# 7z a yajiu.7z *.jpg这条命令是将所有.jpg的文件压缩成一个7z包# 7z a yajiu.7z yajiu这条命令是将文件夹yajiu压缩成一个7z包# 7z e yajiu.7z这条命令是将yajiu.7z中的所有文件解压出来,e是解压到当前路径# 7z x yajiu.7z这条命令是将yajiu.7z中的所有文件解压出来,x是解压到压缩包命名的目录下yajiu@yajiu-desktop:~$ cd 图片yajiu@yajiu-desktop:~/图片$ 7z a yajiu.7z yajiu.jpg yajiu.png7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)ScanningCreating archive yajiu.7zCompressing yajiu.jpg Compressing yajiu.png Everything is Okyajiu@yajiu-desktop:~/图片$ 7z a yajiu.7z *.jpg7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)ScanningCreating archive yajiu.7zCompressing 1.jpg Compressing 2.jpg Everything is Okyajiu@yajiu-desktop:~/图片$ 7z a yajiu.7z yajiu7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)ScanningCreating archive yajiu.7zCompressing yajiu/yajiu.7z Compressing yajiu/yajiu.rar Compressing yajiu/yajiu.zip Compressing yajiu/yajiu.jpg Compressing yajiu/yajiu.png Everything is Okyajiu@yajiu-desktop:~/图片$ 7z x yajiu.7z7-Zip 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)Processing archive: yajiu.7zfile 1.jpgalready exists. Overwrite with 1.jpg?(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? YExtracting 1.jpgfile 2.jpgalready exists. Overwrite with 2.jpg?(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? YExtracting 2.jpgEverything is OkFiles: 2Size: 112564Compressed: 96228yajiu@yajiu-desktop:~/图片$