linux学习(4)

Q1:自建yum仓库,分别为网络源和本地源-

A1:网络源:

   [root@CentOS7 ~]# cd /etc/yum.repos.d/

   [root@CentOS7 yum.repos.d]# vi CentOS-Base.repo.bak

   [bash]

   name=Base Repo

   baseurl=https://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/

   gpgcheck=0

   enabled=1

   [epel]
   name=epel 7 Release 7
   baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
   gpgcheck=0
   enabled=1

 

 

   本地源:

   [root@CentOS7 ~]# cd /media/cdrom/

   [root@CentOS7 cdrom]# -ls

   CentOS_BuildTag EULA images liveOS repodata RPM-GPG-KEY-Centos-Testing-7

   EFI GPL isolinux Packages RPM-GPG-KEY-Centos-Testing-7 TRANS.TBL

   [root@CentOS7 ~]# vi /etc/yum.repos.d/CentOS-local.repo

   [CentOS7]

   name=CentOS 7 Release 7.4

   baseurl=file:///misc/cd

   enabled=1

   gpgcheck=0

 

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

A2:[root@CentOS7 ~]# yum install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config

   [root@CentOS7 ~]# tar xvf httpd-2.4.41.tar.gz -C /usr/local/src

   [root@CentOS7 ~]# cd /usr/local/src/httpd-2.4.41

   [root@CentOS7 httpd-2-4.41]# make -j 2 && install

   [root@CentOS7 httpd-2-4.41]# echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh  【这段是参考,还没明白意思】 

   [root@CentOS7 httpd-2-4.41]# . /etc/profile.d/httpd24.sh

   [root@CentOS7 httpd-2-4.41]# apachectl

   [root@CentOS7 ~]# curl 192.168.31.122

   <html>>body><h1> It works! <h1><body><html>

   

 

Q3:利用sed 取出ifconfig命令中本机的IPv4地址

A3:[root@CentOS7 ~]# ifconfig enp0s3 | sed -rn '2s/^[^0-9]+([0-9.]+) .*$/\1/p'

   192.168.31.122

 

Q4:删除/etc/fstab文件中所有以#开头,后面至少跟一个

A4:[root@CentOS7 ~]# sed -ri.bak '/^#\s+/s/^#\s+//' /etc/fstab

   [root@CentOS7 ~]# cat /etc/fstab

   #

   /etc/fstab

   Created by anaconda on Sun Nov 21 19:00:47 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

  #

   UUID=52bf5cf9-bcc1-486c-bf66-651ad5014e45 /      ext4    defaults  1  1

   UUID=0f04baa9-b607-4aef-a04e-d8b6efcf3906 /boot    xfs      defaults  0  0

   UUID=d097a5c2-8801-41cc-a9be-44e728faf678 /data     xfs      defaults  0  0

   UUID=57473913-326e-4258-8736-ac6e8711ab66 swap     swap     defaults  0  0

 

 

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

A5:[root@CentOS7 ~]# echo /etc/fstab | sed -rn 's#(.*)/([^/]+)/?#\1#p'

   /etc

   [root@CentOS7 ~]# echo /etc/fstab | sed -rn 's#(.*)/([^/]+)/?#\2#p'

   fstab

 

Q6:列出ubuntu软件管理工具apt的一些用法

A6:一、安装软件包

   [root@localhost ~]# apt install tree

   二、删除软件包

   [root@localhost ~]# apt remove tree

   三、列出仓库软件包

   [root@localhost ~]# apt list

   四、搜索软件包

   [root@localhost ~]# apt search nginx

   五、查看某个软件包的详细信息

   [root@localhost ~]# apt show nginx

   六、更新包索引

   [root@localhost ~]# apt update

posted @ 2021-12-14 22:03  Leveling  阅读(64)  评论(0)    收藏  举报