六、仓库跟sed

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


[root@repo-client ~]#vim /etc/yum.repos.d/CentOS-Base.repo

[BaseOS]
name=BaseOS
baseurl=file:///misc/cd/     
        https://mirrors.aliyun.com/centos/$releasever/os/$basearch
gpgcheck=0

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch
gpgcheck=1
pgpkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch
pgpcheck=0


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

#安装前准备:关闭防火墙和SELinux
#1 安装包
[root@centos8 ~]#dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config bzip2  lsof 

#进入想要安装包的路径
[root@centos8 src]cd /usr/local/src
#下载安装包
[root@centos8 src]#wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2

#2 下载并解压缩包,-C指定安装路径
[root@centos8 ~]#tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src

#3 配置
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.43/
[root@centos8 httpd-2.4.43]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl

#4 编译并安装
[root@centos8 httpd-2.4.43]#make -j 4 && make install

#5 配置环境
[root@centos8 ~]#echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[root@centos8 ~]#. /etc/profile.d/httpd24.sh

#6运行
[root@centos8 ~]#apachectl
#如果出现端口被占用情况,找出占用端口的进程杀死
[root@Centos7 httpd-2.4.46]# lsof -i :80
[root@Centos7 httpd-2.4.46]# kill  -9 1304


#7 指定用apache用户运行
[root@centos8 ~]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
[root@centos8 ~]#vim /etc/httpd24/httpd.conf
user apache
group apache

#8生效和验证
[root@centos8 ~]#apachectl restart
#查看
[root@centos8 ~]#ps aux

验证结果:

图片.png

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

[root@Centos7 ~]# ifconfig | sed -nr '2s/(.*inet )([0-9].*)( netmask.*)/\2/p'
10.154.119.140

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

[root@Centos7 ~]# sed -n '/^#/s/^#//!p' /etc/fstab

UUID=3089f417-1bba-4347-8f21-a4581fce760a /                       xfs     defaults        0 0
UUID=71afae2d-2416-4c68-8375-e27437e32fa3 /boot                   xfs     defaults        0 0
UUID=bb537f14-b824-402e-81c3-63b87a82052a /data                   xfs     defaults        0 0
UUID=bb38c0b6-b4b3-41b8-96f9-30af2315226c swap                    swap    defaults        0 0

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

#取目录名
[root@Centos7 ~]# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/

#取基名
[root@Centos7 ~]# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、sed命令介绍: 1、含义:Stream Editor文本流编辑,sed是一个“非交互式的”面向字符流的编辑器...
    优果馥斯阅读 17,042评论 0 1
  • sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区(pattern space),同...
    ThinkerWalker阅读 3,870评论 0 0
  • 简介 sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pat...
    毛利卷卷发阅读 2,767评论 0 1
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 14,363评论 2 33
  • sed Stream EDitor, 行编辑器 sed 是一种流编辑器,它一次处理一行内容。处理时,把当前处理的...
    JevonWei阅读 3,398评论 0 0

友情链接更多精彩内容