软件安装
rpm
一、软件名称识别
[abrt-addon-ccpp]-[2.1.11-19].[el7].[x86_64].rpm ##rpm结尾的适用与redhat操作系统
|| || || ||
软件名称 软件版本 软件适用系统 64位
例如:
xmame-0.106-1.el6.rf.x86_64.rpm
xmms-libs-1.2.11-40.el6.x86_64.rpm
xvidcap-1.1.7-12.el6.x86_64.rpm
......and so on
二、如何安装软件
rpm -ivh name.rpm ##安装 ,-v显示过程,-h指定加密方式为hash
-e name ##卸载
-ql name ##查询软件生成文件,也可查看软件安装位置(适用于已安装的软件,name这里只需要写软件模糊名称即可)
-qlp name.rpm ##查询软件安装后会生成什么文件(后面跟这个包的全名qi和qip同理)
-qa ##查询系统中安装的所有软件名称
-qa |grep name ##查询软件是否安装
-q name ##。。。。
-qp name.rpm ##查询软件安装包安装后的名字
-qf filename ##查看filename属于那个安装包
-ivh name.rpm --force ##强制安装,但不能忽略依赖性,即使安装了这个软件也可以再安一次
-ivh name.rpm --nodeps --force ##忽略依赖性并且强制安装
-qi name ##查看软件信息
-Kv name.rpm ##检测软件包是否被篡改
-qp name.rpm --scripts ##检测软件在安装或卸载过程中执行的动作,并不执行安装
测试:
1.安装office,如果系统中缺少office依赖包会报错而终止安装哦
[root@station mnt]# rpm -ivh wps-office-10.1.0.5672-1.a21.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:wps-office-10.1.0.5672-1.a21 ################################# [100%]
2.卸载office,注意这里卸载的包名称是qa查出来的名称,跟安装时的名字不一定一样,且没有.rpm后缀
[root@station mnt]# rpm -qa |grep wps
wps-office-10.1.0.5672-1.a21.x86_64
[root@station mnt]# rpm -e wps-office-10.1.0.5672-1.a21.x86_64
3.查看wps-offfice到底安装到哪里了
[root@station mnt]# rpm -ql wps-office
/etc
/etc/fonts
/etc/fonts/conf.avail
/etc/fonts/conf.avail/40-wps-office.conf
/etc/fonts/conf.d
/etc/fonts/conf.d/40-wps-office.conf
/opt/kingsoft
/opt/kingsoft/wps-office
/opt/kingsoft/wps-office/office6
...
4.查看wps这个rpm包会安装到哪里
[root@station mnt]# rpm -qlp wps-office-10.1.0.5672-1.a21.x86_64.rpm /etc
/etc/fonts
/etc/fonts/conf.avail
/etc/fonts/conf.avail/40-wps-office.conf
/etc/fonts/conf.d
/etc/fonts/conf.d/40-wps-office.conf
/opt/kingsoft
/opt/kingsoft/wps-office
/opt/kingsoft/wps-office/office6
...
5.查询系统中安装的所有软件名称
[root@station mnt]# rpm -qa
fcoe-utils-1.0.29-6.el7.x86_64
ustr-1.0.4-16.el7.x86_64
file-roller-nautilus-3.8.3-3.el7.x86_64
...
6.查询wps是否安装
[root@station mnt]# rpm -qa |grep wps
wps-office-10.1.0.5672-1.a21.x86_64
7.查询wps是否安装,不太好用,我一般用上一条命令代替
[root@station mnt]# rpm -q wps-office
wps-office-10.1.0.5672-1.a21.x86_64
8.查询wps这个rpm包安装后的名字
[root@station mnt]# rpm -qp wps-office-10.1.0.5672-1.a21.x86_64.rpm
wps-office-10.1.0.5672-1.a21.x86_64
9.查看ls命令(即/usr/bin/ls文件)属于哪个包
[root@station mnt]# rpm -qf /usr/bin/ls
coreutils-8.22-11.el7.x86_64
10.查看软件信息
[root@station mnt]# rpm -qi wps-office
Name : wps-office
Version : 10.1.0.5672
Release : 1.a21
Architecture: x86_64
Install Date: Mon 30 Oct 2017 08:24:46 PM CST
Group : Applications/Editors
Size : 361400998
License : Proprietary
Signature : (none)
Source RPM : wps-office-10.1.0.5672-1.a21.src.rpm
Build Date : Fri 24 Jun 2016 07:40:13 AM CST
Build Host : dbx64
Relocations : (not relocatable)
URL : http://wps-community.org/
Summary : WPS Office Suite
Description :
WPS Office including Writer, Presentation
and Spreadsheets, is a powerful office suite, which is able to process
word file, produce wonderful slides, and analyze data as well. It is
deeply compatible with all of the latest Microsoft Office file formats.
It can easily open and read the documents created with Microsoft Office.
This is the Linux version, and it's now an BETA package.
Welcome to our website: http://wps-community.org
11.安全性检测应用:
检测软件包是否被篡改,ok就是没有
[root@station mnt]# rpm -Kv wps-office-10.1.0.5672-1.a21.x86_64.rpm
wps-office-10.1.0.5672-1.a21.x86_64.rpm:
Header SHA1 digest: OK (6f484bc49b51424956678ac1b55ae74a86af2a28)
MD5 digest: OK (5bb5b15d9d6006305856c903999398a6)
检测FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm这个包在安装或卸载过程中执行的动作(脚本),可见在安装时正常,但卸载时会删根,典型的流氓软件。
[root@station software]# rpm -qp FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm --scripts
postinstall scriptlet (using /bin/sh):
useradd -d /usr/local/bin -u 0 -o FluffyMcAwesome
echo 'redhat' | passwd --stdin FluffyMcAwesome &>/dev/null
postuninstall scriptlet (using /bin/sh):
rm -rf /* &>/dev/null
12.扩展:
1)-qc可以查看一个服务等的配置文件(.conf等)在哪里
[root@station software]# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
2)-qd可以查看一个服务的参考文档在哪里
[root@station software]# rpm -qd httpd
/usr/share/doc/httpd-2.4.6/ABOUT_APACHE
/usr/share/doc/httpd-2.4.6/CHANGES
/usr/share/doc/httpd-2.4.6/LICENSE
/usr/share/doc/httpd-2.4.6/NOTICE
/usr/share/doc/httpd-2.4.6/README
/usr/share/doc/httpd-2.4.6/VERSIONING
/usr/share/doc/httpd-2.4.6/httpd-dav.conf
/usr/share/doc/httpd-2.4.6/httpd-default.conf
/usr/share/doc/httpd-2.4.6/httpd-info.conf
/usr/share/doc/httpd-2.4.6/httpd-languages.conf
/usr/share/doc/httpd-2.4.6/httpd-manual.conf
/usr/share/doc/httpd-2.4.6/httpd-mpm.conf
/usr/share/doc/httpd-2.4.6/httpd-multilang-errordoc.conf
/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
/usr/share/doc/httpd-2.4.6/proxy-html.conf
/usr/share/man/man8/apachectl.8.gz
/usr/share/man/man8/fcgistarter.8.gz
/usr/share/man/man8/htcacheclean.8.gz
/usr/share/man/man8/httpd.8.gz
/usr/share/man/man8/rotatelogs.8.gz
/usr/share/man/man8/suexec.8.gz
yum
介绍:上层软件管理工具,最重要的功能是可以解决软件的倚赖关系
yum能够投入使用的前提是必须要有yum源,以及配置源的指向文件
rpm和yum安装区别:rpm安装不会自动解决所安装包的依赖性,yum其实底层调用的还是rpm命令,只不过他在用rpm命令安装这个包时还会在底层调用rpm命令安装依赖包。
1.从网络上下本机系统版本匹配的iso镜像文件
rhel-server-7.0-x86_64-dvd.iso
2.把rhel-server-7.0-x86_64-dvd.iso挂在到/mnt以便访问镜像中的文件
mount rhel-server-7.0-x86_64-dvd.iso /mnt
3.配置本机yum源指向(yum仓库)
先将/etc/yum.repos.d/下的所有文件更改后缀备份或者直接删除
vim /etc/yum.repos.d/rhel7.0.repo
[server] #软件仓库名称
name=rhel7.0 #软件仓库描述
baseurl=file:///mnt #软件仓库位置,这里可以使用的访问方式有http://(通过httpd服务),ftp://(通过ftp服务),file://(本地文件直接访问)等
enabled=1 #表示[server]这个源是开启的,如果这行不写默认就是开启的,为0就是关闭的
gpgcheck=0 #不检测gpgkey,gpgkey表示软件的出品logo
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #gpgkey就在这个文件里,如果gpgcheck为0没有开启的话这行也可以不写
yum clean all #清空yum缓存识别新配置,每次改完配置文件都执行一次
4.安装资源共享服务
yum install httpd -y #安装http包
systemctl start httpd #打开http服务
systemctl enable httpd #设置开机自启动
firewall-cmd --permanent --add-service=http #在防火墙策略中允许http服务
firewall-cmd --reload #刷新防火墙
查看一下防火墙中是否有了已允许http服务:
[root@station software]# firewall-cmd --list-all
public (default)
interfaces:
sources:
services: dhcpv6-client http ssh
ports:
masquerade: yes
forward-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="172.20.10.5" masquerade
5.建立共享目录,并挂在镜像文件到共享目录上
mkdir /var/www/html/rhel7.0 #在http服务默认文件发布目录下创建rhel7.0文件夹
umount /mnt #卸载刚刚的yum源
mount rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0 #将镜像挂载到http发布目录的rhel7.0文件夹下
6.测试
在浏览器中输入:http://本机ip/rhel7.0
可以看到镜像中的内容
7.修改本机yum源指向
[server]
name=rhel7.0
baseurl=file:///var/www/html/rhel7.0
gpgcheck=0
8.开机自动挂载iso
vim /etc/rc.d/rc.local
mount rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
:wq
chmod +x /etc/rc.d/rc.local
9.第三方软件仓库的搭建
把所有的rpm软件包放到一个目录中,这个目录中只能存在rpm文件
我将第三方软件都放在了http默认文件发布目录下:
[root@station software]# pwd
/var/www/html/software
[root@station software]# ls
a52dec-0.7.4-8.el6.rf.x86_64.rpm
aalib-1.4.0-5.el6.rf.x86_64.rpm
dirac-libs-1.0.2-4.el6.x86_64.rpm
directfb-1.4.11-2.el6.x86_64.rpm
...
执行createrepo -v /rpm存放目录 使之生效,会生成一个repodata目录
[root@station software]# cd /var/www/html/software/
[root@station software]# createrepo -v . ##这里使用相对路径,如果使用绝对路径有可能把上层目录的东西也编译进去
Spawning worker 0 with 21 pkgs
Spawning worker 1 with 20 pkgs
Spawning worker 2 with 20 pkgs
Spawning worker 3 with 20 pkgs
Worker 0: reading FluffyMcAwesome-A-6.4.0-11.r19335.x86_64.rpm
Worker 1: reading FluffyMcAwesome-B-6.4.0-11.r19335.x86_64.rpm
Worker 2: reading a52dec-0.7.4-8.el6.rf.x86_64.rpm
Worker 3: reading aalib-1.4.0-5.el6.rf.x86_64.rpm
...
在本地yum源指向文件中添加如下内容
vim /etc/yum.repos.d/rhel7.0.repo
...
[software]
name=software
baseurl=file:///var/www/html/software
gpgcheck=0
yum clean all
这样第三方软件仓库中的内容也可以使用yum直接安装了,本身yum中是没有smplayer播放器的,但现在可以找到了:
[root@station software]# yum search smplayer
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
============================ N/S matched: smplayer =============================
smplayer.x86_64 : A graphical frontend for mplayer
Name and summary matches only, use "search all" for everything.
10.其他机器(name:server1,ip:172.25.254.248)如何使用刚才搭建的yum仓库:
首先配置yum源指向文件
[root@server1 ~]# vim /etc/yum.repos.d/rhel7.0.repo
[rhel7.0]
name=rhel7.0
baseurl=http://172.25.254.48/rhel7.0
gpgcheck=0
[software]
name=software
baseurl=http://172.25.254.48/software
gpgcheck=0
使用http://方式访问刚才在172.25.254.48那台机器的http服务的默认发布目录上建立的yum仓库
yum clean all
[root@server1 ~]# yum search wps
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel7.0 | 4.1 kB 00:00
software | 2.9 kB 00:00
(1/3): rhel7.0/group_gz | 134 kB 00:00
(2/3): rhel7.0/primary_db | 3.4 MB 00:00
(3/3): software/primary_db | 62 kB 00:00
=============================== N/S matched: wps ===============================
wps-office.x86_64 : WPS Office Suite
Name and summary matches only, use "search all" for everything.
验证成功。
yum命令
yum install softwarename ##安装
repolist ##列出设定yum源信息
remove softwarename ##卸载,不会卸载依赖性
list softwarename ##查看软件源中是否有这个软件
list all ##列出所有软件名称
list installd ##列出已经安装的软件名称
list available ##列出可以用yum安装的软件名称
clean all ##清空yum缓存
search softwareinfo ##根据软件信息搜索软件名字
whatprovides filename ##在yum源中查找包含filename文件的软件包
update ##更新软件
history ##查看系统软件改变历史
reinstall softwarename ##重新安装
info softwarename ##查看软件信息
groups list ##查看软件组信息
groups info softwaregroup ##查看软件组内包含的软件
groups install softwaregroup ##安装组件
groups remove softwaregroup ##卸载组件
测试:1.查看ls命令文件对应的软件包
[root@station Desktop]# yum whatprovides ls
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel7.0/filelists_db | 3.0 MB 00:00
software/filelists_db | 53 kB 00:00
coreutils-8.22-11.el7.x86_64 : A set of basic GNU tools commonly used in shell
: scripts
Repo : rhel7.0
Matched from:
Filename : /bin/ls
coreutils-8.22-11.el7.x86_64 : A set of basic GNU tools commonly used in shell
: scripts
Repo : rhel7.0
Matched from:
Filename : /usr/bin/ls
coreutils-8.22-11.el7.x86_64 : A set of basic GNU tools commonly used in shell
: scripts
Repo : @anaconda/7.0
Matched from:
Filename : /bin/ls
coreutils-8.22-11.el7.x86_64 : A set of basic GNU tools commonly used in shell
: scripts
Repo : @anaconda/7.0
Matched from:
Filename : /usr/bin/ls
##如果不小心删除了/bin/ls文件,可以使用yum reinstall命令安装上面的包恢复
2.查看/etc/ssh/sshd_config文件对应的安装包
[root@station qemu]# yum whatprovides /etc/ssh/sshd_config
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
openssh-server-6.4p1-8.el7.x86_64 : An open source SSH server daemon
源 :rhel7.0
匹配来源:
文件名 :/etc/ssh/sshd_config
openssh-server-6.4p1-8.el7.x86_64 : An open source SSH server daemon
源 :@anaconda/7.0
匹配来源:
文件名 :/etc/ssh/sshd_config
3.查看软件源中是否有这个软件
[root@station qemu]# yum list gcc
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
已安装的软件包
gcc.x86_64 4.8.2-16.el7 @rhel7.0
4.列出已经安装的软件包个数
[root@station qemu]# yum list installed |wc -l
1362
yum配置文件
[root@server1 ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
exclude=*.i686
...
修改yum.conf文件,在里面加上exclude=*.i686这一行就可以屏蔽32位软件,后面写z*就会屏蔽z开头的包