yum使用

第一部分yum基础
yum 参数:
search (搜索某个软件名称或是描述的重要关键字)
list(类似于rpm -qa)
info(类似于rpm -qai)
provides(类似于rpm -qf)
eg:搜索磁盘陈列raid相关的软件有哪些?
[root@centos7 yum]#yum search raid
找出mdadm这个软件的功能为何?
[root@centos7 yum]#yum info mdadm
列出yum服务器上面提供的所有软件名称?
[root@centos7 yum]#yum list
列出目前服务上可供本机进行升级的软件有哪些?
[root@centos7 yum]#yum list updates
列出提供passwd 这个文件的软件有哪些?
[root@centos7 yum]#yum provides passwd
列出以pam为开头的软件名称有哪些?
[root@centos7 yum]#yum list pam*
怎样用yum 删除软件pan-devel?
[root@centos7 yum]#yum remove pan-devel
如何使用光盘当作本地yum仓库:
(1)挂载光盘至某目录,例如/media/cdrom
#mount -r -t iso*** /dev/cdrom /media/cdrom
(2)创建配置文件
[ base] 代表容器的名字
name=
baseurl= 后 面接的就是容器的实际网址
gpgcheck=1 指定是否需要查阅RPM文件内的数字证书
enabled=1(0为不让容器启动)
mirrorlist= 列出这个容器可以使用的镜像站点
yum的命令行选项:
–nogpgcheck:禁止进行gpg check
-y:自动回答为yes
-q:静默模式
–disablerepo=reporidglob临时禁用此处指定的repo
–noplugins禁用所胡插件
yum的repo配置文件可用的变量:
$releasever :当 前os的发行版的主版本号
$arch:平台
$basearch:基础平台
$yum0-$yum9
http://mirrors.magedu.com/centos/$releasever/$basearch/os
列出目前yum server所使用的容器有哪些?
[root@centos7 yum]#yum repolist all
怎样清除掉本机上面的旧数据?
[root@centos7 yum]#yum clean [packages|headers|all]
表示将已下载的软件文件,软件文件头,所有容器数据都删除
 
yum 的软件组功能:
grouplist
groupinfo
groupinstall (可以安整组的软件)
groupremvove
怎样全系统自动升级?yum -y update
假设我每天在北京时间凌晨3:00进行自动升级?
[root@centos7 yum]#vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .—————- minute (0 – 59)
# | .————- hour (0 – 23)
# | | .———- day of month (1 – 31)
# | | | .——- month (1 – 12) OR jan,feb,mar,apr …
# | | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# * * * * * user-name command to be executed
03 ***root /usr/bin/yum -y update
情境:实际安装php,php-mysql,httpd-devel?
1.检查所需要的软件是否存在,最好直接使用rpm,因为可以直接取得rpm的数据库内容
[root@centos7 yum]#rpm -q httpd httpd-devel php php-devel php-mysql
package httpd is not installed
package httpd-devel is not installed
package php is not installed
package php-devel is not installed
package php-mysql is not installed
2。确认网络的可行性
[root@centos7 yum]#ifconfig ens33(看自己的ip是否存在)
[root@centos7 yum]#route -n (看有没有路由器设置存在)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.20.0.1 0.0.0.0 UG 100 0 0 ens33
172.20.0.0 0.0.0.0 255.255.0.0 U 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0
[root@centos7 yum]#ping -c 2 172.20.0.1看路由器设置是否正确
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
64 bytes from 172.20.0.1: icmp_seq=1 ttl=64 time=0.674 ms
64 bytes from 172.20.0.1: icmp_seq=2 ttl=64 time=0.536 ms
3.[root@centos7 yum]#dig www.goole.com
; <<>> DiG 9.9.4-RedHat-9.9.4-50.el7 <<>> www.goole.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23366
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.goole.com. IN A
;; ANSWER SECTION:
www.goole.com. 1320 IN A 87.106.83.127
;; Query time: 235 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Apr 20 16:09:30 CST 2018
网络设置妥当后,就可直接使用yum进行安装了
[root@centos7 yum]#yum install httpd httpd-devel php php-devel php-mysql
列出的都是已经装好的包
[root@centos7 yum.repos.d]#yum list installed
第二部分yum应用
1.yum-config-manager –add-repo=http:….这是一个非交互式命令,可以生成配置文件
eg:
[root@centos7 ~]#cd /etc/yum.repos.d/(yum的配置文件)
[root@centos7 yum.repos.d]#yum-config-manager –add-repo=http://172.20.0.1/centos/7/
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
adding repo from: http://172.20.0.1/centos/7/
[172.20.0.1_centos_7_]
name=added from: http://172.20.0.1/centos/7/
baseurl=http://172.20.0.1/centos/7/
enabled=1
[root@centos7 yum.repos.d]#ls
172.20.0.1_centos_7_.repo CentOS-fasttrack.repo
Centos-7.repo CentOS-Media.repo
CentOS-Base.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-Vault.repo
CentOS-Debuginfo.repo
[root@centos7 yum.repos.d]#cat 172.20.0.1_centos_7_.repo
[172.20.0.1_centos_7_]
name=added from: http://172.20.0.1/centos/7/
baseurl=http://172.20.0.1/centos/7/
enabled=1
2.[root@centos7 ~]#du -sh . (查看文件大小)
7.7M .
3。yum高级应用
[root@centos7 yum.repos.d]#yum history list(列出yum的历史动作)
[root@centos7 yum.repos.d]#yum history list 8(列出yum历史中第8个动作的具体信息)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
ID | Command line | Date and time | Action(s) | Altered
——————————————————————————-
8 | install mariadb-server | 2018-04-20 17:13 | Install | 1
history list
[root@centos7 yum.repos.d]#yum history undo 8(撤销第8个动作,也即不安装,等于卸载删除!!!!它是和指定记录中的动作执行完全相反的动作)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Undoing transaction 8, from Fri Apr 20 17:13:09 2018
Install mariadb-server-1:5.5.56-2.el7.x86_64 @172.20.0.1_centos_7_
No package matched to remove: mariadb-server-1:5.5.56-2.el7
history undo
 
[root@centos7 yum.repos.d]#yum history redo 8 (把第8个动作再重复执行一次)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repeating transaction 13, from Fri Apr 20 17:56:22 2018
Erase mariadb-1:5.5.56-2.el7.x86_64 @172.20.0.1_centos_7_
Erase perl-DBD-MySQL-4.023-5.el7.x86_64 @172.20.0.1_centos_7_
No package matched to remove: mariadb-1:5.5.56-2.el7
No package matched to remove: perl-DBD-MySQL-0:4.023-5.el7
history redo

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/96652

(1)
上一篇 2018-04-20 18:11
下一篇 2018-04-20 19:45

相关推荐

  • ansible httpd

    卸载服务ansible all -m shell -a ‘yum -y remove nginx’ 检查用户 组 uid gidansible all -m shell -a ‘getent passwd nginx’ansible all -m shell -a ‘getent group ngi…

    Linux笔记 2018-07-23
  • 学习liunx 系统笔记

    服务器按应用功能可分为:web 服务器   数据库服务器   文件服务器  中间件应用服务器  日子服务器   监控服务器   程序版本控制服务器  虚拟机服务器     邮件服务器   打印服务器   域控制服务器  多媒体服务器  通讯服务器    ERP 服务器等! 服务器按外形可分为:塔式服务器   、机架式服务器  、刀片式服务器。  

    Linux笔记 2018-04-01
  • LFS实验第一次——第一章

    环境准备:Centos6.8虚拟机 2G内存 2颗CPU 200G硬盘分区情况:/ 50G  /boot 1G  /swap 2G /data 30G 安装时吧开发工具安装上(gcc)

    2018-03-29
  • 加密和安全

    常见的加密算法和安全协议 一、对称加密:加密和解密使用同一个密钥,依赖于算法和密钥,其安全性依赖于密钥而非算法 常见的算法:DES ​ 特性: ​ 加密、解密使用同一个密钥 ​ 将明文分隔成固定的大小块逐个进行加密 ​ 缺点: ​ 密钥过多、密钥分发 二、非对称加密:采用的是公钥加密方法,密钥是成对出现的,公钥是从私钥中提取出来的 ​ 公钥:公开给所有人;p…

    Linux笔记 2018-05-10
  • Linux 中获取命令帮助

    获取命令帮助 内部命令:用 help COMMAND; 外部命令:方法一  COMMAND –help;   方法二    manual manual :文件路径为 /usr/share/man 使用方法:# man COMMAND SECTION:  NAME:功能性说明;SYNOPSIS:语法格式;DESCRIPTION:描述;       …

    Linux笔记 2018-06-24
  • Linux发行版的基础目录

    Linux发行版的基础目录名称命名法则及功用规定: FHS:Linux目录配置文件的依据         FHS的重點在于规范每个特定的目录下要放置什么样子的资料 FHS要求必須要存在的目录:/bin:在单人维护模式下还能操作的文档/boot:主要放置开机时會使用到的档案/dev:在Linux中,任何裝置与周边设备都是以档案的形态存在這個目录中的。/etc:…

    Linux笔记 2018-06-24