YUM

国内机器请先修改安装源

基础命令

  1. # 安装
  2. yum install name
  3. # 卸载
  4. yum remove name
  5. # 搜索
  6. yum list name
  7. # 显示已安装的
  8. yum list
  9. # 显示依赖包
  10. yum deplist tomcat
  11. # 查看基础信息
  12. yum info tomcat
  13. # 升级
  14. yum update # 升级所有
  15. yum update tomcat # 升级tomcat
  16. yum check-update # 检测可升级

修改安装源

  1. # 备份
  2. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
  3. # 修改163安装源
  4. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
  5. # 更新缓存即可
  6. yum makecache

其他安装源

163源

目前还没有出现过问题

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

阿里源

偶尔不太稳定

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清华源

参考:https://mirror.tuna.tsinghua.edu.cn/help/centos/

  1. vim /etc/yum.repos.d/CentOS-Base.repo
  2. # CentOS-Base.repo
  3. #
  4. # The mirror system uses the connecting IP address of the client and the
  5. # update status of each mirror to pick mirrors that are updated to and
  6. # geographically close to the client. You should use this for CentOS updates
  7. # unless you are manually picking other mirrors.
  8. #
  9. # If the mirrorlist= does not work for you, as a fall back you can try the
  10. # remarked out baseurl= line instead.
  11. #
  12. #
  13. [base]
  14. name=CentOS-$releasever - Base
  15. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
  16. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  17. gpgcheck=1
  18. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  19. #released updates
  20. [updates]
  21. name=CentOS-$releasever - Updates
  22. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
  23. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  24. gpgcheck=1
  25. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  26. #additional packages that may be useful
  27. [extras]
  28. name=CentOS-$releasever - Extras
  29. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
  30. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  31. gpgcheck=1
  32. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  33. #additional packages that extend functionality of existing packages
  34. [centosplus]
  35. name=CentOS-$releasever - Plus
  36. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
  37. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  38. gpgcheck=1
  39. enabled=0
  40. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

中科大源

  1. wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3

RPM

安装

  1. rpm -ivh rpm

查找

  1. rpm -qa | grep -i mysql

卸载

  1. rpm -e --nodeps 软件名

升级

  1. rpm -Uvh rpm