1、自建yum仓库,分别为网络源和本地源
# 启用misc [root@CentOS8 ~]# rpm -q autofs || yum install -y autofs [root@CentOS8 ~]# systemctl enable --now autofs # 移除原有的仓库配置文件 [root@CentOS8 ~]# cd /etc/yum.repos.d/ [root@CentOS8 yum.repos.d]# mkdir backup; mv *.repo backup # 编辑配置文件 [root@CentOS8 yum.repos.d]# cat >base.repo<[baseOS] > name=baseOS > baseurl=file:///misc/cd/baseOS > enabled=1 > gpgcheck=1 > gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial > > [AppStream] > name=AppStream > baseurl=file:///misc/cd/AppStream > enabled=1 > gpgcheck=1 > gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial > > [extras] > name=extras > baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/ > https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/os/ > https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/ > enabled=1 > gpgcheck=1 > gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial > > [epel] > name=epel > baseurl=https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/ > https://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/ > https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/ > enabled=1 > gpgcheck=1 > gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-8 > EOF [root@CentOS8 yum.repos.d]# cat base.repo [baseOS] name=baseOS baseurl=file:///misc/cd/baseOS enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [AppStream] name=AppStream baseurl=file:///misc/cd/AppStream enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [extras] name=extras baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/ https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/os/ https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [epel] name=epel baseurl=https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/ https://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/ enabled=1 gpgcheck=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-8 [root@CentOS8 yum.repos.d]# yum repolist all repo id repo name status AppStream AppStream enabled baseOS baseOS enabled epel epel enabled extras extras enabled [root@CentOS8 yum.repos.d]# [root@CentOS8 yum.repos.d]# ifconfig ens33 -bash: ifconfig: command not found [root@CentOS8 yum.repos.d]# [root@CentOS8 yum.repos.d]# dnf install -y net-tools [root@CentOS8 yum.repos.d]# rpm -qf `which ifconfig` net-tools-2.0-0.52.20160912git.el8.x86_64 [root@CentOS8 yum.repos.d]# rpm -q net-tools net-tools-2.0-0.52.20160912git.el8.x86_64
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
# 关闭防火墙和seLinux [root@CentOS8 ~]# systemctl stop firewalld [root@CentOS8 ~]# systemctl disable firewalld [root@CentOS8 ~]# sed -i "s/(SELINUX=).*/1disabled/" /etc/selinux/config [root@CentOS8 ~]# reboot # 下载安装包 [root@CentOS8 ~]# wget -P /usr/local/src https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz [root@CentOS8 ~]# cd /usr/local/src/ [root@CentOS8 src]# ls httpd-2.4.52.tar.gz # 解压文件 [root@CentOS8 src]# tar -xvf httpd-2.4.52.tar.gz -C /usr/local/src # 安装包 [root@CentOS8 httpd-2.4.52]# yum install -y gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config # 配置 [root@CentOS8 src]# cd httpd-2.4.52 [root@CentOS8 httpd-2.4.52]# ./configure --prefix=/application/httpd --sysconfdir=/etc/httpd --enable-ssl # 编译并安装 [root@CentOS8 httpd-2.4.52]# make && make install # 创建用户和组 [root@CentOS8 httpd-2.4.52]# getent group apache || groupadd -r -g 48 apache [root@CentOS8 httpd-2.4.52]# getent passwd apache || useradd -r -u 48 -g apache -s /sbin/nologin -M apache # 编辑配置文件 [root@CentOS8 httpd]# sed -i -e "s/^(User +).*/1apache/" -e "s/^(Group +).*/1apache/" /etc/httpd/httpd.conf # 启动服务 [root@CentOS8 httpd]# cd /application/httpd/bin/ [root@CentOS8 bin]# ./apachectl start [root@CentOS8 bin]# ps aux |grep apache apache 41648 0.0 0.7 1339632 7660 ? Sl 18:26 0:00 ./httpd -k start apache 41649 0.0 0.7 1339632 7656 ? Sl 18:26 0:00 ./httpd -k start apache 41650 0.0 0.7 1339632 7660 ? Sl 18:26 0:00 ./httpd -k start root 41740 0.0 0.1 12136 1112 pts/0 S+ 18:29 0:00 grep --color=auto apache
验证结果:
3. 利用sed 取出ifconfig命令中本机的IPv4地址
[root@CentOS8 yum.repos.d]# ifconfig ens33 ens33: flags=4163mtu 1500 inet 10.10.0.153 netmask 255.255.255.0 broadcast 10.10.0.255 inet6 fe80::20c:29ff:febc:10a6 prefixlen 64 scopeid 0x20 ether 00:0c:29:bc:10:a6 txqueuelen 1000 (Ethernet) RX packets 15071 bytes 12793036 (12.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10503 bytes 3703779 (3.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@CentOS8 yum.repos.d]# ifconfig ens33|sed -n "s/.*inet +([0-9.]+).*/1/p" 10.10.0.153
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@CentOS8 ~]# cat -A /etc/fstab $ #$ # /etc/fstab$ # /etc/fstab$ # Created by anaconda on Fri Dec 10 07:56:44 2021$ # Created by anaconda on Fri Dec 10 07:56:44 2021$ #$ # Accessible filesystems, by reference, are maintained under '/dev/disk/'.$ # Accessible filesystems, by reference, are maintained under '/dev/disk/'.$ # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$ # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$ #$ # After editing this file, run 'systemctl daemon-reload' to update systemd$ # After editing this file, run 'systemctl daemon-reload' to update systemd$ # units generated from this file.$ # units generated from this file.$ #$ UUID=b9eae324-0632-43b8-86ab-2f7d879c4e99 / xfs defaults 0 0$ UUID=74e4a264-93d2-43f1-8601-4acd2d0af0a6 /boot xfs defaults 0 0$ UUID=095caf33-bd53-4fc2-970a-0b6d0db4264a /data xfs defaults 0 0$ UUID=2854a60b-c536-4a23-a76a-d80fdb7a6d6c none swap defaults 0 0$ [root@CentOS8 ~]# sed -i.bak "/^# +/s/^# +//" /etc/fstab [root@CentOS8 ~]# cat -A /etc/fstab $ #$ /etc/fstab$ /etc/fstab$ Created by anaconda on Fri Dec 10 07:56:44 2021$ Created by anaconda on Fri Dec 10 07:56:44 2021$ #$ Accessible filesystems, by reference, are maintained under '/dev/disk/'.$ Accessible filesystems, by reference, are maintained under '/dev/disk/'.$ See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$ See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.$ #$ After editing this file, run 'systemctl daemon-reload' to update systemd$ After editing this file, run 'systemctl daemon-reload' to update systemd$ units generated from this file.$ units generated from this file.$ #$ UUID=b9eae324-0632-43b8-86ab-2f7d879c4e99 / xfs defaults 0 0$ UUID=74e4a264-93d2-43f1-8601-4acd2d0af0a6 /boot xfs defaults 0 0$ UUID=095caf33-bd53-4fc2-970a-0b6d0db4264a /data xfs defaults 0 0$ UUID=2854a60b-c536-4a23-a76a-d80fdb7a6d6c none swap defaults 0 0$
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
# 取/etc/fstab基名 # 方式一 [root@CentOS8 ~]# basename /etc/fstab fstab # 方式二 [root@CentOS8 ~]# echo /etc/fstab|sed -n "s#(.*)/(.*)#2#p" fstab # 取/etc/fstab目录名 # 方式一 [root@CentOS8 ~]# dirname /etc/fstab /etc # 方式二 [root@CentOS8 ~]# echo /etc/fstab|sed -n "s#(.*)/(.*)#1#p" /etc



