1.通常Linux應用軟件的安裝包有三種:
1) tar包,如software-1.2.3-1.tar.gz。它是使用UNIX系統的打包工具tar打包的。
2) rpm包,如software-1.2.3-1.i386.rpm。它是Redhat Linux提供的一種包封裝格式。安裝rpm包的命令是"rpm -參數,包管理工具 yum 。"
3) deb包,如software-1.2.3-1.deb。它是Debain Linux提供的一種包封裝格式。安裝deb包的命令是"dpkg -參數",包管理工具 apt-get。
2.包命名規則:
大多數Linux應用軟件包的命名也有一定的規律,它遵循:名稱-版本-修正版-類型
例如:
1) software-1.2.3-1.tar.gz 意味着:
軟件名稱:software
版本號:1.2.3
修正版本:1
類型:tar.gz,說明是一個tar包。
2) sfotware-1.2.3-1.i386.rpm
軟件名稱:software
版本號:1.2.3
修正版本:1
可用平台:i386,適用於Intel 80x86平台。
類型:rpm,說明是一個rpm包。
注:由於rpm格式的通常是已編譯的程序,所以需指明平台。
3.包里的內容:
一個Linux應用程序的軟件包中可以包含兩種不同的內容:
1) 一種就是可執行文件,也就是解開包后就可以直接運行的。在Windows中所 有的軟件包都是這種類型。安裝完這個程序后,你就可以使用,但你看不到源程序。而且下載時要注意這個軟件是否是你所使用的平台,否則將無法正常安裝。
2) 另一種則是源程序,也就解開包后,你還需要使用編譯器將其編譯成為可執行文件。這在Windows系統中是幾乎沒有的,因為Windows的思想是不開放源程序的。
通常,用tar打包的,都是源程序;而用rpm、dpkg打包的則常是可執行程序。一般一個軟件總會提供多種打包格式的安裝程序的。你可以根據自己的情況來選擇。
4.tar包:
整個安裝過程可以分為以下幾步:
1) 取得應用軟件:通過下載、購買光盤的方法獲得;
2) 解壓縮文件:一般tar包,都會再做一次壓縮,如gzip、bz2等,所以你需要先解壓。如果是最常見的gz格式,則可以執行:“tar –xvzf軟件包名”,就可以一步完成解壓與解包工作。如果不是,則先用解壓軟件,再執行“tar –xvf 解壓后的tar包”進行解包;
閱讀附帶的INSTALL文件、README文件;
3) 執行“./configure”命令為編譯做好准備;
4) 執行“make”命令進行軟件編譯;
5) 執行“makeinstall”完成安裝;
6) 執行“makeclean”刪除安裝時產生的臨時文件。
7) 運行應用程序:一般來說,Linux的應用軟件的可執行文件會存放在/usr/local/bin目錄下!不過這並不是“放四海皆准”的真理,最可靠的還是看這個軟件的 INSTALL和README文件,一般都會有說明。
8) 卸載:通常軟件的開發者很少考慮到如何卸載自己的軟件,而tar又僅是完成打包的工作,所以並沒有提供良好的卸載方法。有兩個軟件能夠解決這個問題,那就是Kinstall和Kife,它們是tar包安裝、卸載的黃金搭檔
5.rpm包:
1) 操作系統:RedHat(Red Hat/Fedora)
2) 常見的安裝包格式 rpm包,安裝rpm包的命令是“rpm -參數”
3) 包管理工具 yum
4) 支持tar包
5.1rpm命令
安裝: rpm –ivh 軟件包名.rpm( -I 安裝軟件,-t測試安裝,不是真的安裝,-p顯示安裝進度,-f忽略任何錯誤,-U升級安裝,-v檢測套件是否正確安裝)
卸載: rpm –e 軟件名(注意使用的是軟件名,而不是軟件包名)
查詢:查詢當前系統安裝的軟件包: rpm –qa ‘*軟件包名*’
rpm |
description |
rpm -Uvh packages(s).rpm |
install/upgrade package file(s) |
rpm -e package |
emove package |
rpm -qa '*spell*' |
show all packages whose names contain the word spell and already installed in system |
rpm -q package |
show version of package installed |
rpm -q -i package |
show all package metadata |
rpm -q -i -p package.rpm |
show all package file's metadata |
rpm -q -f /path/file |
what package does file belong |
rpm -q -l package |
list where files were installed |
rpm -q -l -p package.rpm |
list where files would be installed |
rpm2cpio package.rpm | cpio -id |
extract package files to current directory |
rpm -q --requires package |
list files/packages that package needs |
rpm -q --whatrequires package |
list packages that need package (see also whatrequires) |
5.2yum命令
yum |
Description |
yum update [package list] |
upgrade specified packages (or all installed packages if none specified) |
yum install <package list> |
install latest version of package(s), Yum refreshes each time it's used |
yum remove <package list> |
remove specified packages from system |
yum list [package list] |
list available packages from repositories |
6.deb包:
1) 操作系統:Debian系列(Ubuntu)
2) 常見的安裝包格式 deb包,安裝deb包的命令是“dpkg -參數”
3) 包管理工具apt-get
4) 支持tar包
6.1dpkg命令
安裝: dpkg –i 軟件包名.deb
卸載: dpkg –e 軟件名
查詢:查詢當前系統安裝的軟件包: dpkg –l ‘*軟件包名*’
dpkg |
description |
dpkg -Gi package(s).deb |
install/upgrade package file(s) |
dpkg -r package |
emove package |
dpkg -l '*spell*' |
show all packages whose names contain the word spell and already installed in system |
dpkg -l package |
show version of package installed |
dpkg -s package |
show all package metadata |
dpkg -I package.deb |
show all package file's metadata |
dpkg -S /path/file |
what package does file belong |
dpkg -L package |
list where files were installed |
dpkg -c package.deb |
list where files would be installed |
dpkg -x package.deb |
extract package files to current directory |
dpkg -s package | grep ^Depends: |
list files/packages that package needs |
dpkg --purge --dry-run package |
list packages that need package (see also whatrequires) |
6.2apt-get命令
Apt-get命令只能用於在repositories中的包,不能用於處理自己下載的deb包,要想處理自己下載的deb包,只能用dpkg命令。
apt-get |
Description |
apt-get dist-upgrade |
upgrade specified packages (or all installed packages if none specified) |
apt-get install <package list> |
install latest version of package(s) |
apt-get remove <package list> |
remove specified packages from system |
apt-cache list [package list] |
list available packages from repositories |
7.rpm包和deb包安裝命令對比:
Task |
Red Hat/Fedora |
Ubuntu |
Adding Removing and Upgrading Packages |
||
Refresh list of available packages |
Yum refreshes each time it's used |
apt-get update |
Install a package from a repository |
yum install package_name |
apt-get install package_name |
Install a package file |
yum install package.rpm或者rpm -i package.rpm |
dpkg --install package.deb |
Remove a package |
rpm -e package_name |
apt-get remove package_name |
Check for package upgrades |
yum check-update |
apt-get -s upgrade或者apt-get -s dist-upgrade |
Upgrade packages |
yum update或者rpm -Uvh [args] |
apt-get dist-upgrade |
Upgrade the entire system |
yum upgrade |
apt-get dist-upgrade |
Package Information |
||
Get information about an available package |
yum search package_name |
apt-cache search package_name |
Show available packages |
yum list available |
apt-cache dumpavail |
List all installed packages |
yum list installed或者rpm -qa |
dpkg --list |
Get information about a package |
yum info package_name |
apt-cache show package_name |
Get information about an installed package |
rpm -qi package_name |
dpkg --status package_name |
List files in an installed package |
rpm -ql package_name |
dpkg --listfiles package_name |
List documentation files in an installed package |
rpm -qd package_name |
- |
List configuration files in an installed package |
rpm -qc package_name |
- |
Show the packages a given package depends on |
rpm -qR package_name |
apt-cache depends |
Show other packages that depend on a given package (reverse dependency) |
rpm -q -whatrequires [args] |
apt-cache rdepends |
Package File Information |
||
Get information about a package file |
rpm -qpi package.rpm |
dpkg --info package.deb |
List files in a package file |
rpm -qpl package.rpm |
dpkg --contents package.deb |
List documentation files in a package file |
rpm -qpd package.rpm |
- |
List configuration files in a package file |
rpm -qpc package.rpm |
- |
Extract files in a package |
rpm2cpio package.rpm | cpio -vid |
dpkg-deb --extract package.deb dir-to-extract-to |
Find package that installed a file |
rpm -qf filename |
dpkg --search filename |
Find package that provides a particular file |
yum provides filename |
apt-file search filename |
Misc. Packaging System Tools |
||
Show stats about the package cache |
- |
apt-cache stats |
Verify all installed packages |
rpm -Va |
debsums |
Remove packages from the local cache directory |
yum clean packages |
apt-get clean |
Remove only obsolete packages from the local cache directory |
- |
apt-get autoclean |
Remove header files from the local cache directory(forcing a new download of same on next use) |
yum clean headers |
apt-file purge |
General Packaging System Information |
||
Package file extension |
*.rpm |
*.deb |
Repository location configuration |
/etc/yum.conf |
/etc/apt/sources.list |