挂载光盘小技巧
确保设备状态下的两个选项已勾选如图

[root@centos7 ~]# systemctl start autofs
[root@centos7 ~]# systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[root@centos7 ~]# cd
[root@centos7 ~]# ls /misc
[root@centos7 ~]# cd /misc
[root@centos7 misc]# cd cd/  进入系统光盘
[root@centos7 cd]# ls
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
CentOS系统上使用rpm命令管理程序包:
安装、卸载、升级、查询、校验、数据库维护
安装:
rpm {-i|--install} [install-options] PACKAGE_FILE…
-v: verbose
-vv:
-h: 以#显示程序包管理执行进度
rpm -ivh PACKAGE_FILE ...
[install-options]
--test: 测试安装,但不真正执行安装,即dry run模式
--nodeps:忽略依赖关系
--replacepkgs | replacefiles
--nosignature: 不检查来源合法性
--nodigest:不检查包完整性
--noscripts:不执行程序包脚本
%pre: 安装前脚本 --nopre
%post: 安装后脚本 --nopost
%preun: 卸载前脚本 --nopreun
%postun: 卸载后脚本 --nopostun
rpm包升级
升级:
rpm {-U|--upgrade} [install-options] PACKAGE_FILE...
rpm {-F|--freshen} [install-options] PACKAGE_FILE...
upgrade:安装有旧版程序包,则“升级”
如果不存在旧版程序包,则“安装”
freshen:安装有旧版程序包,则“升级”
如果不存在旧版程序包,则不执行升级操作
rpm -Uvh PACKAGE_FILE ...
rpm -Fvh PACKAGE_FILE ...
--oldpackage:降级
--force: 强制安装
注意:
(1) 不要对内核做升级操作;Linux支持多内核版本并存,因此直接安装新版本内核
(2) 如果原程序包的配置文件安装后曾被修改,升级时,新版本提供的同一个配置文件不会直接覆盖老版本的配置文件,而把新版本文件重命名(FILENAME.rpmnew)后保留
[root@centos7 ~]# ldd /bin/cat  查看调用依赖的库
linux-vdso.so.1 =>  (0x00007ffeb6ff4000)
libc.so.6 => /lib64/libc.so.6 (0x00007f34f324a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f34f3617000)
[root@centos7 Packages]# rpm -e tree 卸载包
[root@centos7 Packages]# tree
-bash: /usr/bin/tree: No such file or directory
[root@centos7 Packages]# rpm -qpi tree-1.6.0-10.el7.x86_64.rpm  查询包信息
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: (not installed)
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, Fri 04 Jul 2014 01:36:46 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : Tue 10 Jun 2014 03:28:53 AM CST
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem http://bugs.centos.org
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.
[root@centos7 Packages]# rpm -ql tree   查询包的安装位置
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
[root@centos7 Packages]# rpm -qa "tr"  查询安装过的包 可模糊查询 支持管道正则查询
tree-1.6.0-10.el7.x86_64
traceroute-2.0.22-2.el7.x86_64
trousers-0.3.14-2.el7.x86_64
tracker-1.10.5-6.el7.x86_64
[root@centos7 Packages]# rpm -qf /usr/bin/tree 查询文件来自哪个包
tree-1.6.0-10.el7.x86_64
[root@centos7 Packages]# rpm -e --nodeps tree 不考虑依赖性直接卸载
[root@centos7 cd]# rpm --import /misc/cd/RPM-GPG-KEY-CentOS-7 导入包验证 光盘导入
[root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 系统本地导入
[root@centos7 cd]# rpm -qa "gpg-pubkey" 查看秘钥
gpg-pubkey-f4a80eb5-53a7ff4b 秘钥
[root@centos7 cd]# rpm -qi gpg-pubkey-f4a80eb5-53a7ff4b  查看秘钥信息
Name        : gpg-pubkey
Version     : f4a80eb5
Release     : 53a7ff4b
Architecture: (none)
Install Date: Thu 02 Apr 2020 05:22:08 PM CST
Group       : Public Keys
[root@centos7 data]# ls
etc  etc.tar  fstab  fstab.bak  messages  passwd  shell  tes  tree-1.6.0-10.el7.x86_64.rpm  t.sh
[root@centos7 data]# rpm -K tree-1.6.0-10.el7.x86_64.rpm
tree-1.6.0-10.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK   校验包的完整安全性
/var/lib/rpm 包数据库 必要时可备份 在包库破损时恢复
rpm -ivh -e -qi -ql -qf -qpi rpmfile  -qc -q --scripts -qa  --force --nodeps 重点熟悉命令
yum
[root@centos7localdomain cd]# cd /etc/yum.repos.d/
[root@centos7localdomain yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@centos7localdomain yum.repos.d]# mkdir bak
[root@centos7localdomain yum.repos.d]# mv *.repo bak/ 将系统自带的yum源剪切到bak文件夹中
[root@centos7localdomain yum.repos.d]# vim bash.repo
[root@centos7localdomain yum.repos.d]# cat bash.repo
[base]          基于光盘
name=cdrom base
baseurl=file:///misc/cd
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
校检包的合法性
[epel]
name=aliyun epel  基于网络  阿里云的epel
baseurl=https://mirrors.aliyun.com/epel/basearch/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
1启用 0 禁止
[root@centos7localdomain yum.repos.d]# ls /var/cache/yum//x86_64/7/
base  extras  timedhosts  timedhosts.txt  updates
[root@centos7localdomain yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@centos7localdomain yum.repos.d]# rm -rf /var/cache/yum/*   清空yum源缓存 用于更改yum源后的操作 确保旧的缓存清理干净
[root@centos7localdomain yum.repos.d]# yum repolist    下载元数据
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base                                                                                                 | 3.6 kB  00:00:00
epel                                                                                                 | 4.7 kB  00:00:00
(1/5): base/group_gz                                                                                 | 166 kB  00:00:00
(2/5): base/primary_db                                                                               | 3.1 MB  00:00:00
(3/5): epel/7/x86_64/group_gz                                                                        |  95 kB  00:00:00
(4/5): epel/7/x86_64/updateinfo                                                                      | 1.0 MB  00:00:00
(5/5): epel/7/x86_64/primary_db                                                                      | 6.8 MB  00:00:00
repo id                                                     repo name                                                 status
base                                                        cdrom base                                                 4,021
epel/7/x86_64                                               aliyun epel                                               13,246
repolist: 17,267
[root@centos7localdomain yum.repos.d]#
yum clean all 清空yum源缓存
rm -rf /var/cache/yum/* 清空yum元缓存 保持环境干净
yum repolist  下载元缓存
[root@centos7localdomain yum.repos.d]# yum remove httpd 卸载httpd包本身 不卸载依赖包
yum history undo 5 -y 卸载yum第五个
yum history redo 5 -y 重装第五个
[root@centos7localdomain yum.repos.d]# yum history info 3 查看第三个yum命令
Loaded plugins: fastestmirror, langpacks
Transaction ID : 3
Begin time     : Sat Apr 18 10:52:29 2020
Begin rpmdb    : 1364:91cf775895ed404174076e9ffc54b9a134a778a9
End time       :            10:52:44 2020 (15 seconds)
End rpmdb      : 1369:37319588d001be7f5b11d0f21eb9950c525c16c0
User           : root <root>
Return-Code    : Success
Command Line   : install httpd   yum命令
Transaction performed with:
Installed     rpm-4.11.3-32.el7.x86_64                      @anaconda
Installed     yum-3.4.3-158.el7.centos.noarch               @anaconda
Installed     yum-plugin-fastestmirror-1.1.31-45.el7.noarch @anaconda
yum install /misc/cd/Packages/下载包    可根据需求直接安装依赖包
[root@centos7localdomain html]# echo  '- - -'  > /sys/class/scsi_host/host2/scan  扫描外接设备
[root@centos7localdomain html]# lsblk
[root@centos7localdomain html]# mount /dev/sr0 centos/7/os/x86_64/ 临时挂载
mount: /dev/sr0 is write-protected, mounting read-only
编译安装
功能可定制
配好yum源后 下载安装编译器
yum install gcc
C语言源代码编译安装三步骤:
1、./configure
(1) 通过选项传递参数,指定启用特性、安装路径等;执行时会参考用户的指定以及Makefile.in文件生成Makefile
(2) 检查依赖到的外部环境,如依赖的软件包
2、make 根据Makefile文件,构建应用程序
3、make install 复制文件到相应路径