显示系统中可更新的包

[root@qls ~]# yum list updates
更新一个软件包
[root@qls ~]# yum update hostname
更新系统中所有可更新的包,包括内核,刚刚装完系统进行更新
[root@qls ~]# yum update -y
显示系统中所有已安装的包
[root@qls ~]# yum list installed
系统中包组的安装
[root@qls ~]# yum groups install Python -y
包组的卸载
[root@qls ~]# yum groups remove Python -y
yum的历史记录
[root@qls ~]# yum history
回滚操作
[root@qls ~]# yum history undo 14 -y
yum仓库管理 ,仓库的启用和禁用
[root@qls ~]# yum install -y yum-utils

关闭指定的仓库

enabled = 0 表示不启用
[root@qls ~]# yum-config-manager --disable epel

开启指定的仓库

enabled = 1 表示启用
[root@qls ~]# yum-config-manager --enable epel

软件包缓存

命令行中实现

直下载不安装,指定下载路径

[root@qls ~]# yum install --downloadonly --downloaddir=/opt tree
[root@qls ~]# ll /opt/
-rw-r--r--. 1 root root 47508 Jul 4 2014 tree-1.6.0-10.el7.x86_64.rpm

yum本地进行安装软件包

[root@qls ~]# yum localinstall /opt/tree-1.6.0-10.el7.x86_64.rpm -y

配置文件中,启用缓存

[root@qls ~]# vim /etc/yum.conf keepcache=1

清空软件包缓存

[root@qls ~]# yum clean packages

清空所有缓存

[root@qls ~]# yum clean all

缓存测试

[root@qls ~]# yum install -y tree
[root@qls ~]# find / -name "tree*.rpm" /var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm

yum本地仓库

第一步,挂载镜像  
[root@qls ~]# mount  /dev/cdrom   /mnt
mount: /dev/sr0 is write-protected, mounting read-only  
#将所有的仓库地址禁用              
[root@qls ~]# gzip  /etc/yum.repos.d/*  
编辑一个repo仓库文件            
[root@qls ~]# vim  /etc/yum.repos.d/local.repo            
[qls]
name=this is a local  Base  repo
baseurl=file:///mnt
enabled=1
gpgcheck=0            
#生成缓存        
[root@qls ~]# yum  makecache            
#查看仓库列表            
[root@qls ~]# yum repolist

共享给其他的主机

10.0.0.200
10.0.0.100
#第一步 
克隆一台主机  
修改ip地址 
[root@qls ~]# sed -i  's#100#99#g'   /etc/sysconfig/network-scripts/ifcfg-eth0
[root@qls ~]# systemctl  restart  network   
[root@qls ~]# ip  a  s eth0  
#修改主机名,重新登录生效 
[root@qls ~]# hostnamectl   set-hostname  web01
[root@qls ~]# bash
[root@web01 ~]# 
#第二步,下载vsftp
[root@qls ~]# yum  install  -y  vsftpd
#第三步,启动
[root@qls ~]# systemctl  start  vsftpd
#检查启动  active (running)  运行
[root@qls ~]# systemctl  status  vsftpd
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-11-18 11:40:09 CST; 15s ago
  Process: 1262 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 1263 (vsftpd)
   CGroup: /system.slice/vsftpd.service
           └─1263 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Nov 18 11:40:09 qls systemd[1]: Starting Vsftpd ftp daemon...
Nov 18 11:40:09 qls systemd[1]: Started Vsftpd ftp daemon.
#第四步,创建仓库 
[root@qls ~]# mkdir  /var/ftp/centos7
#第五步,将rpm包复制到仓库地址
[root@qls ~]# cp  -rp  /mnt/Packages/*   /var/ftp/centos7
#第六步,让这个目录成为yum仓库
[root@qls ~]# yum install -y  createrepo            
[root@qls ~]# createrepo   /var/ftp/centos7/
Spawning worker 0 with 4021 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
#第七步,检测结果 
#停止防火墙
[root@qls ~]# systemctl   stop  firewalld
[root@qls ~]# systemctl   disable   firewalld
#查看selinux的状态            
[root@qls ~]# getenforce 
Enforcing
#临时关闭            
[root@qls ~]# setenforce  
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@qls ~]# setenforce  0
[root@qls ~]# getenforce 
Permissive
#永久关闭
[root@qls ~]# sed  -i  '/^SELINUX=/cSELINUX=disabled'  /etc/sysconfig/selinux
[root@qls ~]# sed  -i  '/^SELINUX=/s#enforing#disabled#g'  /etc/sysconfig/selinux
#浏览器测试
ftp://10.0.0.100/
#客户端操作
#第一步,把之前的yum源禁用
[root@web01 ~]# gzip  /etc/yum.repos.d/*
#第二步,编写本地仓库文件
[root@web01 ~]# cat /etc/yum.repos.d/local.repo
[local_base]
name= this  is a local  base  repo
baseurl=ftp://10.0.0.100/centos7
enabled=1
gpgcheck=0
#第三步,生成缓存  
[root@web01 ~]# yum  makecache
#第四步,测试 
[root@web01 ~]# yum repolist

yum总结

yum            软件包管理工具 

            install       安装   -y 免交互
            reinstall    重新安装
            remove        卸载
            erase        卸载
            info        显示软件包本身信息  
            list        显示所有可安装的包

                updates    显示所有可更新的包
                installed    显示已经安装的包
            provides    查看命令属于哪一个软件包
            search        查看软件包相关信息
            repolist    显示所有可用的仓库
                enabled    可用的
                disabled 不可用的
                all         显示所有             

            check-update    检查可更新的包

            update             更新指定的包,不加包名,更新所有

            history            yum命令的;历史记录 
                info  id     显示具体的操作信息
                undo  id    回滚id对应的操作

            groups            针对组操作 
                install        安装 
                remove        卸载  

            clean            清空缓存 
                all         所有 
                packages     清空包缓存

            --downloadonly     只下载不安装
            --downloaddir=    指定下载路径  
            localinstall    指定本地的包进行安装
            makecache        生成本地缓存
    yum-config-manager        yum仓库管理  
            --enable         开启指定的仓库  
            --disable        关闭指定的仓库
Copyright © 高程程 all right reserved,powered by Gitbook修订于: 2021-05-18 21:14:13

results matching ""

    No results matching ""