CentOS/ubuntu/Solaris软件包安装

一、CentOS/Red Hat

yum = Yellow dog Updater, Modified

(1)yum配置文件

(在CentOS下,默认安装yum,无须配置即可使用)

(Red Hat 系统可找相同版本CentOS yum源即可,写于/etc/yum.repos.d/任意名称.repo ,但要保证在/etc/yum.repos.d/ 目录下仅有一个以repo结尾文件,否则容易报错)

1) /etc/yum.conf #yum主配文件

[main]

cachedir=/var/cache/yum #yum缓存目录

keepcache=0

debuglevel=2 #debug级别

logfile=/var/log/yum.log #日志文件

exactarch=1

obsoletes=1

gpgcheck=1 #gpg校验

plugins=1

2) /etc/yum.repos.d/*.repo #yum资源库

[updates]

name=Centos updates #库名

baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ #yum源路径

enabled=1 #是否开启yum资源库,需要开启。

gpgcheck=0 #是否开启gpgcheck校验,1为开启,不开启可加快安装速度

#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #pggkey所在位置,可用rpm --import 导入

(2)yum命令

yum check-update #检查可更新软件包

yum update pkg-name #升级所有软件包

yum install pkg-name #yum包安装

yum remove pkg-name #删除包,包括与该包有倚赖性的包

yum clean packages/headers #yum清除缓存rpm包/包头文件

yum clean all #清除所有缓存信息

yum list #列出所有可用rpm包

yum list installed #列出所有已安装的rpm包

yum iist updates #列出所有可以更新的rpm包

yum info [pkg-name] #yum包信息

yum info updates/installed/available #可以更新/已安装包/可升级 包信息

yum search pkg-name #搜索包含特定字符的包

yum grouplist #列出所有组信息

yum groupinstall group-name #组安装

yum groupupdate group-name #组升级

(3)yum使用

yum -y install yum-fastestmirror #自动搜索最快镜像插件

yum -y install gcc-c++ #c++安装

yum groupinstall "X Window System" #CentOS X Window 安装

yum info gcc-c++ #查看gcc-c++详细信息

yum list | grep pcre #查看有关pcre所有包

二、Ubuntu/Debian

(1)配置文件

1) /etc/apt/sources.list #软件资源地址列表

deb [web或ftp地址] [发行版本名] [main/contrib/no-fredd]

2) /var/cache/apt/archives #默认安装软件包存放位置

(2)apt-get基本命令

apt-get update #更新软件包信息库

apt-get install pkg-name1 pkg-name2 ...

apt-get --reinstall install pkg-name[-] #重新安装软件包,包名后加减号会删除软件包

apt-get -d install pkg-name #仅下载,不安装

apt-get remove pkg-name1 pkg-name2

apt-get purge #删除包和配置文件

apt-get source pkg-name1 pkg-name2 #下载源码软件包

apt-get clean #删除/var/cache/apt/archives下所有软件包

apt-get aotoclean #删除已下载旧软件包

apt-get dselect-upgrade #根据dselect推荐功能更新系统

(3)apt-cache 软件包管理工具

apt-cache show pkg-name #显示软件信息

apt-cache search pkg-name #搜索软件包,支持正则

apt-cache showpkg pkg-name #显示软件包依赖关系

apt-cache policy pkg-name #显示安装包安装状态

apt-cache depends pkg-name #指定软件包所依赖软件包

apt-cache rdepends pkg-name #依赖于指定包的软件包

(4)apt-file 软件包查找工具,查找软件包所含文件和安装位置

apt-file update #更新软件包文件库

apt-file search file-name #查找文件所在软件包

apt-file list pkg-name #显示该软件包文件

dpkg -i unzip_6.0-4ubuntu2.5_amd64.deb

三、Solaris 10

(1)配置文件

/etc/opt/csw/pkgutil.conf

/opt/csw/etc/pkgutil.conf

http://mirror.opencsw.org/opencsw/stable/i386/5.10

两个配置文件相同:

This may seem confusing, the reason why there are two is that it is possible to run OpenCSW in a sparse root environment where /opt is not writable. In this scenario you use configurations in /opt/csw/etc for global settings and /etc/opt/csw for zone-specific setting. Both pkgutil.conf are identical on installation with all configuration options commented out, so you can just pick one for now. As a rule of thumb it is recommended to prefer the more prominent /etc/opt/csw

(2)pkgutil 安装

软件包安装

pkgadd -d http://get.opencsw.org/now

设置环境变量

PATH=$PATH:/opt/csw/bin

MANPATH=$MANPATH:/opt/csw/share/man

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/csw/lib

export PATH MANPATH LD_LIBRARY_PATH

(3) pkgutil 命令

pkgutil -a gcc #available , 查询所有与gcc有关软件包

-i #install 安装

-u #upgrade 升级软件包

-r #remove 删除软件包

-d #download only ,仅下载不安装

-U #update catalog

(4)pkgutil 加密认证

1) First you need to install cswpki

pkgutil -y -i cswpki

2) Then you need to import the public key:

/opt/csw/bin/cswpki --import

echo "pki_auto=yes" >>/etc/opt/csw/csw.conf

3) The current fingerprint looks like this:

gpg --homedir=/var/opt/csw/pki/ --fingerprint board@opencsw.org

pub 1024D/9306CC77 2011-08-31

Key fingerprint = 4DCE 3C80 AAB2 CAB1 E60C 9A3C 05F4 2D66 9306 CC77

uid OpenCSW catalog signing <board@opencsw.org>

sub 2048g/971EDE93 2011-08-31

4)You may also trust the key once you verified the fingerprint:

/opt/csw/bin/gpg --homedir=/var/opt/csw/pki --edit-key board@opencsw.org trust

5) Now everything is in place for enabling security in pkgutil. Edit the /etc/opt/csw/pkgutil.conf and uncomment the two lines withuse_gpg and use_md5 so they look like this:

vi /etc/opt/csw/pkgutil.conf

use_gpg = true

use_md5 = true

6 )You can verify that it worked with pkgutil -V:

pkgutil -V

show_current true (default: true)

stop_on_hook_soft_error not set (default: false)

use_gpg true (default: false)

use_md5 true (default: false)

wgetopts not set (default: none)

详细参数查看:

Ubuntu: man apt-get / apt-get -h

Solaris: man pkgutil /pkgutil -h

CentOS : yum -h

参考连接:

pkgutil http://www.opencsw.org/manual/for-administrators/getting-started.html#

apt-get http://man.chinaunix.net/linux/debian/debian_learning/ch03.html

http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html