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 ‘*软件包名*’rpmdescription
rpm -Uvh packages(s).rpminstall/upgrade package file(s)
rpm -e packageemove package
rpm -qa '*spell*'show all packages whose names contain the word spell and already installed in system
rpm -q packageshow version of package installed
rpm -q -i packageshow all package metadata
rpm -q -i -p package.rpmshow all package file's metadata
rpm -q -f /path/filewhat package does file belong
rpm -q -l packagelist where files were installed
rpm -q -l -p package.rpmlist where files would be installed
rpm2cpio package.rpm | cpio -idextract package files to current directory
rpm -q --requires packagelist files/packages that package needs
rpm -q --whatrequires packagelist packages that need package (see also whatrequires)
5.2yum命令yumDescription
yum update [package list]upgrade specified packages (or all installed packages if none specified)
yum install install latest version of package(s), Yum refreshes each time it's used
yum remove 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 ‘*软件包名*’
dpkgdescription
dpkg -Gi package(s).debinstall/upgrade package file(s)
dpkg -r packageemove package
dpkg -l '*spell*'show all packages whose names contain the word spell and already installed in system
dpkg -l packageshow version of package installed
dpkg -s packageshow all package metadata
dpkg -I package.debshow all package file's metadata
dpkg -S /path/filewhat package does file belong
dpkg -L packagelist where files were installed
dpkg -c package.deblist where files would be installed
dpkg -x package.debextract package files to current directory
dpkg -s package | grep ^Depends:list files/packages that package needs
dpkg --purge --dry-run packagelist packages that need package (see also whatrequires)
6.2apt-get命令
Apt-get命令只能用于在repositories中的包,不能用于处理自己下载的deb包,要想处理自己下载的deb包,只能用dpkg命令。apt-getDescription
apt-get dist-upgradeupgrade specified packages (or all installed packages if none specified)
apt-get install install latest version of package(s)
apt-get remove remove specified packages from system
apt-cache list [package list]list available packages from repositories
7.rpm包和deb包安装命令对比:TaskRed Hat/FedoraUbuntu
Adding Removing and Upgrading Packages
Refresh list of available packagesYum refreshes each time it's usedapt-get update
Install a package from a repositoryyum install package_nameapt-get install package_name
Install a package fileyum install package.rpm或者rpm -i package.rpmdpkg --install package.deb
Remove a packagerpm -e package_nameapt-get remove package_name
Check for package upgradesyum check-updateapt-get -s upgrade或者apt-get -s dist-upgrade
Upgrade packagesyum update或者rpm -Uvh [args]apt-get dist-upgrade
Upgrade the entire systemyum upgradeapt-get dist-upgrade
Package Information
Get information about an available packageyum search package_nameapt-cache search package_name
Show available packagesyum list availableapt-cache dumpavail
List all installed packagesyum list installed或者rpm -qadpkg --list
Get information about a packageyum info package_nameapt-cache show package_name
Get information about an installed packagerpm -qi package_namedpkg --status package_name
List files in an installed packagerpm -ql package_namedpkg --listfiles package_name
List documentation files in an installed packagerpm -qd package_name-
List configuration files in an installed packagerpm -qc package_name-
Show the packages a given package depends onrpm -qR package_nameapt-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 filerpm -qpi package.rpmdpkg --info package.deb
List files in a package filerpm -qpl package.rpmdpkg --contents package.deb
List documentation files in a package filerpm -qpd package.rpm-
List configuration files in a package filerpm -qpc package.rpm-
Extract files in a packagerpm2cpio package.rpm | cpio -viddpkg-deb --extract package.deb dir-to-extract-to
Find package that installed a filerpm -qf filenamedpkg --search filename
Find package that provides a particular fileyum provides filenameapt-file search filename
Misc. Packaging System Tools
Show stats about the package cache-apt-cache stats
Verify all installed packagesrpm -Vadebsums
Remove packages from the local cache directoryyum clean packagesapt-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 headersapt-file purge
General Packaging System Information
Package file extension*.rpm*.deb
Repository location configuration/etc/yum.conf/etc/apt/sources.list