第四周-2021-12-06

1、自建yum仓库,分别为网络源和本地源

配置光盘自动挂载
rpm -q autofs || yum -y install autofs
systemctl enable --now autofs

备份repo文件
cd /etc/yum.repos.d/;mkdir bak;mv *.repo bak

创建本地源:

配置光盘自动挂载
rpm -q autofs || yum -y install autofs
systemctl enable --now autofs

编辑/etc/yum.repos.d/CentOS.repo

[base]
name=CentOS
baseurl=file:///misc/cd
enabled=1
gpgcheck=0
创建网络源

阿里云镜像站:https://mirrors.aliyun.com
阿里云源创建命令:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
阿里云epel源创建命令:
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

> yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                                              repo name                                                                                           status
base/7/x86_64                                                        CentOS-7 - Base - mirrors.aliyun.com                                                                   446
epel/x86_64                                                          Extra Packages for Enterprise Linux 7 - x86_64                                                      13,689
extras/7/x86_64                                                      CentOS-7 - Extras - mirrors.aliyun.com                                                                 500
updates/7/x86_64                                                     CentOS-7 - Updates - mirrors.aliyun.com                                                              3,175
repolist: 17,810

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

下载httpd安装包:
https://httpd.apache.org/

解压:
tar jxf httpd-2.4.51.tar.bz2

cd httpd-2.4.51

安装依赖包
yum -y install gcc apr-devel apr-util-devel pcre-devel openssl-devel

生成Makefile文件
./configure --prefix=/usr/local/httpd --enable-ssl

编译安装
make && make install

配置环境变量
echo 'export PATH=/usr/local/httpd/bin:$PATH' >> /etc/profile
source /etc/profile

查看启动命令
apachectl -h

启动httpd服务
apachectl -k start


3、利用sed 取出ifconfig命令中本机的IPv4地址

> ifconfig |sed -nr 's/.*inet ([0-9.]{1,4}{4}).*/\1/p'
192.168.184.147
127.0.0.1

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

> cat /etc/fstab |sed -r 's/^# ?(.*)/\1/' |sed '/^$/d'
/etc/fstab
Created by anaconda on Mon Mar  8 11:45:48 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=db331537-55ba-4dd8-a8a8-67966977944f /boot                   xfs     defaults        0 0
UUID=d57a87fc-f47c-4a10-86bd-cb7ea9c3247d swap                    swap    defaults        0 0

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

目录名:

> ls /etc/fstab |sed -nr 's@(.*)/([^/]+)@\1@p'
/etc

基名:

> ls /etc/fstab |sed -nr 's@(.*)/([^/]+)@\2@p'
fstab

6、列出ubuntu软件管理工具apt的一些用法(自由总结)

apt install #安装软件包
pt install nginx=1.14.0-0ubuntu1.6 #安装软件包的时候指定安装具体的版本
apt update #刷新存储库索引
apt upgrade #升级所有可升级的软件包
apt full-upgrade #升级整个系统,必要时可以移除旧软件包
apt remove apache2 #只删除程序,不删配置文件
apt autoremove apache2 #删除安装包并解决依赖关系
apt purge apache2 #彻底删除,包含配置文件
apt list #列出仓库中所有包
apt-file search 'string' #搜索仓库种包含该字符串的文件
apt-file search -x '/sl$' #搜索仓库中以sl结尾的文件,-x后加正则表达式
apt-file search -F /sbin/ifconfig #搜索文件文件来自于哪个包
apt show nginx #查看仓库中包详细信息
apt-cache madison docker-ce #查看仓库中的指定软件的所有版本
apt edit-sources #编辑source源⽂件

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容