第四周作業(yè)

1、自建yum倉庫,分別為網(wǎng)絡(luò)源和本地源
網(wǎng)絡(luò)源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,實現(xiàn)可以正常訪問,并將編譯步驟和結(jié)果提交。

下載并解壓安裝包
[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

配置環(huán)境(配置后無須進入軟件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地址后,出現(xiàn)“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的一些用法(自由總結(jié))

apt 相當(dāng)于 apt-get、apt-cache 和 apt-config 中最常用命令選項的集合
apt 具有更精減但足夠的命令選項,而且參數(shù)選項的組織方式更為有效。此外,啟用的幾個特性也非常有幫助。

例如:可以在使用 apt 命令安裝或刪除程序時看到進度條,apt 還會在更新存儲庫數(shù)據(jù)庫時提示用戶可升級的軟件包個數(shù)
apt 與 apt-get 有一些類似的命令選項,但它并不能完全向下兼容 apt-get 命令,也即可用 apt 替換部分apt-get 系列命令,但不是全部。

用法:

apt install         安裝軟件包
apt remove          移除軟件包
apt purge           移除軟件包及配置文件
apt update          刷新存儲庫索引
apt upgrade         升級所有可升級的軟件包
apt autoremove      自動刪除不需要的包
apt full-upgrade    在升級軟件包時自動處理依賴關(guān)系
apt search          搜索應(yīng)用程序
apt show            顯示安裝細節(jié)
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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、查找/var目錄下不屬于root、lp、gdm的所有文件 find /var! \( -user root -...
    hl大寶閱讀 212評論 0 0
  • 1、打包/etc/目錄下面所有conf結(jié)尾的文件,壓縮包名稱為當(dāng)天的時間,并拷貝到/usr/local/src目錄...
    馬暉閱讀 118評論 0 0
  • 1、查找/var目錄下不屬于root、lp、gdm的所有文件 find /var -not \( -user ro...
    lomg213閱讀 160評論 0 0
  • 1. 查找/var目錄下不屬于root、lp、gdm的所有文件 find /var -not ( -user ro...
    ritch閱讀 129評論 0 0
  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險厭惡者,不喜歡去冒險,但是人生放棄了冒險,也就放棄了無數(shù)的可能。 ...
    yichen大刀閱讀 7,681評論 0 4

友情鏈接更多精彩內(nèi)容