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 PackagesRPM-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