LINUX下安装软件方法命令方法
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 80×86平台。
类型: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 |