對於Window下的常見壓縮文件.zip和.rar,Linux也有相應的方法來解壓它們:
1)對於.zip
linux下提供了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.png
updating: yajiu.jpg (deflated 34%)
updating: yajiu.png (deflated 0%)
yajiu@yajiu-desktop:~/圖片$ zip yajiu.zip *.jpg
adding: 1.jpg (deflated 34%)
adding: 2.jpg (deflated 0%)
yajiu@yajiu-desktop:~/圖片$ zip -r yajiu.zip yajiu
adding: 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.zip
Archive: yajiu.zip
replace 1.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: 1.jpg;
replace 2.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: 2.jpg;
yajiu@yajiu-desktop:~/圖片$
原文鏈接:http://hi.baidu.com/zgyz/blog/item/f7ef29085c90d4d663d98665.html
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.png
RAR 3.80 beta 2Copyright (c) 1993-2008 Alexander Roshal16 Jun 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive yajiu.rar
Adding;yajiu.jpgOK
Adding;yajiu.pngOK
Done
yajiu@yajiu-desktop:~/圖片$ rar a yajiu.rar *.jpg
RAR 3.80 beta 2Copyright (c) 1993-2008 Alexander Roshal16 Jun 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive yajiu.rar
Adding;1.jpg;;;;OK
Adding;2.jpg;;;;OK
Done
yajiu@yajiu-desktop:~/圖片$ rar a yajiu.rar yajiu
RAR 3.80 beta 2Copyright (c) 1993-2008 Alexander Roshal16 Jun 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive yajiu.rar
Adding;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
Done
yajiu@yajiu-desktop:~/圖片$ unrar e yajiu.rar
UNRAR 3.80 beta 2 freeware;;;Copyright (c) 1993-2008 Alexander Roshal
Extracting from yajiu.rar
1.jpg already exists. Overwrite it ?
[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit Y
Extracting 1.jpg;;OK
7a008fc287fe680c0ff477e9.jpg already exists. Overwrite it ?
[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit Y
Extracting 2.jpg;;OK
All OK
yajiu@yajiu-desktop:~/圖片$
原文鏈接:http://hi.baidu.com/zgyz/blog/item/f7ef29085c90d4d663d98665.html
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.png
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing yajiu.jpg;;
Compressing yajiu.png;;
Everything is Ok
yajiu@yajiu-desktop:~/圖片$ 7z a yajiu.7z *.jpg
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing 1.jpg;;
Compressing 2.jpg;;
Everything is Ok
yajiu@yajiu-desktop:~/圖片$ 7z a yajiu.7z yajiu
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing yajiu/yajiu.7z;;
Compressing yajiu/yajiu.rar;;
Compressing yajiu/yajiu.zip;;
Compressing yajiu/yajiu.jpg;;
Compressing yajiu/yajiu.png;;
Everything is Ok
yajiu@yajiu-desktop:~/圖片$ 7z x yajiu.7z
7-Zip 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Processing archive: yajiu.7z
file 1.jpg
already exists. Overwrite with
1.jpg?
(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? Y
Extracting 1.jpg
file 2.jpg
already exists. Overwrite with
2.jpg?
(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? Y
Extracting 2.jpg
Everything is Ok
Files: 2
Size:;;;;112564
Compressed: 96228
yajiu@yajiu-desktop:~/圖片$