1、自建yum仓库,分别为网络源和本地源
网络源repo配置(centos7):
[CentOS7]
name=CentOS7
baseurl=file:///data/centos7
https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[CentOS7-Updates]
name=CentOS7-Updates
baseurl=https://mirrors.aliyun.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras7]
name=extras7
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[EPEL7]
name=EPEL7
baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64
https://mirrors.cloud.tencent.com/epel/$releasever/x86_64
https://repo.huaweicloud.com/epel/$releasever/x86_64
https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/x86_64
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591
本地源repo配置(centos7):
repo配置:
[base]
name=CentOS
baseurl=http://10.10.10.8/centos/CentOS7/Packages/
gpgcheck=1
gpgkey=http://10.10.10.8/centos/CentOS7/RPM-GPG-KEY-CentOS-7
[base-updates]
name=base-updates
baseurl=http://10.10.10.8/centos/CentOS7/CentOS7-Updates/
gpgcheck=1
gpgkey=http://10.10.10.8/centos/CentOS7/RPM-GPG-KEY-CentOS-7
[extras7]
name=extras7
baseurl=http://10.10.10.8/centos/CentOS7/extras7/
gpgcheck=1
gpgkey=http://10.10.10.8/centos/CentOS7/RPM-GPG-KEY-CentOS-7
[EPEL7]
name=EPEL7
baseurl=http://10.10.10.8/centos/CentOS7/EPEL7/
gpgcheck=1
gpgkey=http://10.10.10.8/centos/CenTOS/EPEL7/RPM-GPG-KEY-EPEL-7
[zabbix]
name=zabbix
baseurl=http://10.10.10.8/zabbix/5.0/centos/7/
gpgcheck=1
gpgkey=http://10.10.10.8/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
下载并解压安装包
[root@centos8 ~]#wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
[root@centos8 ~]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src
进入解压目录
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.43/
编译
[root@centos8 httpd-2.4.46]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
PS:
--prefix为指定安装目录
--sysconfdir为指定配置文件安装位置
--enable-ssl为指定软件特性
安装
[root@centos8 httpd-2.4.46]#make && make install
配置环境(配置后无须进入软件bin目录下启动)
[root@centos8 ~]#echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@centos8 ~]#. /etc/profile.d/httpd.sh
运行
[root@centos8 ~]#apachectl start
打开浏览器输入IP地址后,出现“It works!”,安装成功
image.png
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@test ~]$ifconfig | sed -nE '2s/.* ([0-9.]+[0-9]{1,3}).*mask.*/\1/p'
10.10.10.222
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@test ~]$cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Jun 11 15:36:33 2021
#
# 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
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=3a7da216-cb2a-40a7-a41d-93f9c162f2a0 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-var /var xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
[root@test ~]$sed -nE '/^#[[:blank:]]+(.*)/p' /etc/fstab
# /etc/fstab
# Created by anaconda on Fri Jun 11 15:36:33 2021
# 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
[root@test ~]$sed -nE 's/^#[[:blank:]]+(.*)/\1/p' /etc/fstab
/etc/fstab
Created by anaconda on Fri Jun 11 15:36:33 2021
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
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
目录名:
[root@test ~]$echo /etc/fstab | sed -nE 's@(^/.*/)([[:alpha:]]+$)@\1@p'
/etc/
基名:
[root@test ~]$echo /etc/fstab | sed -nE 's@(^/.*/)([[:alpha:]]+$)@\2@p'
fstab
6、列出ubuntu软件管理工具apt的一些用法(自由总结)
apt 相当于 apt-get、apt-cache 和 apt-config 中最常用命令选项的集合
apt 具有更精减但足够的命令选项,而且参数选项的组织方式更为有效。此外,启用的几个特性也非常有帮助。
例如:可以在使用 apt 命令安装或删除程序时看到进度条,apt 还会在更新存储库数据库时提示用户可升级的软件包个数
apt 与 apt-get 有一些类似的命令选项,但它并不能完全向下兼容 apt-get 命令,也即可用 apt 替换部分apt-get 系列命令,但不是全部。
用法:
apt install 安装软件包
apt remove 移除软件包
apt purge 移除软件包及配置文件
apt update 刷新存储库索引
apt upgrade 升级所有可升级的软件包
apt autoremove 自动删除不需要的包
apt full-upgrade 在升级软件包时自动处理依赖关系
apt search 搜索应用程序
apt show 显示安装细节
apt list 列出包含条件的包(已安装,可升级等)
apt edit-sources 编辑源列表
APT包索引配置文件:
/etc/apt/sources.list
/etc/apt/sources.list.d
apt命令操作(如安装和删除软件包)日志文件:
/var/log/dpkg.log
例: 修改阿里云的APT源为清华源
root@ubuntu2004:~# sed -i 's/mirrors.aliyun.com/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list