1. 程式人生 > 其它 >文字處理和編譯安裝

文字處理和編譯安裝

1、自建yum倉庫,分別為網路源和本地源

root@CentOS8 ~]\ [#vim /etc/yum.repos.d/base.repo
[BaseOS]
name=BaseOS
baseurl=file:///mnt/cdrom/BaseOS
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os
https://mirrors.huaweicloud.com/centos/$releasever/BaseOS/$basearch/os
https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/cdrom/AppStream
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os
https://mirrors.huaweicloud.com/centos/$releasever/AppStream/$basearch/os
https://mirrors.cloud.tencent.com/centos/$releasever/Appstream/$basearch/os
gpgcheck=0

[epel]
name=EPEL
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/
https://mirrors.huaweicloud.com/epel/$releasever/Everything/$basearch/
https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/
gpgcheck=0
enabled=1

[extras]
name=extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os
https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/os
https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os
gpgcheck=0
enabled=1

2、編譯安裝http2.4,實現可以正常訪問,並將編譯步驟和結果提交。

dnf install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config(下載安裝相關包)
rz -E (官網下載後拖入)
tar xvf httpd-2.4.46.tar.bz2 -c /usr/local/src (解壓縮到指定目錄)
cd /usr/local/src/httpd-2.4.46/ (進入該目錄)
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl(編譯安裝第一步)
make -j 4 && make install (編譯安裝第二步和第三步)
echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh(配置環境)
cd
. /etc/profile.d/httpd.sh
apachectl start (執行)
useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache(指定使用者執行)
vim /etc/httpd/httpd.conf (修改user和group)
apachectl restart(重啟服務生效)
ps aux(檢視程序)
history

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

[16:17:36 root@CentOS8 ~]\ [#ifconfig ens33 | sed -nr '2s/[^0-9]+([0-9.]+).*/\1/p'
10.0.0.8

4、刪除/etc/fstab檔案中所有以#開頭,後面至少跟一個空白字元的行的行首的#和空白字元

[16:36:55 root@CentOS8 ~]\ [#cat /cat /etc/fstab |sed -r 's/^#[[:space:]]+(.*$)/\1/p'
#
/etc/fstab
/etc/fstab
Created by anaconda on Fri Jun 18 06:20:46 2021
Created by anaconda on Fri Jun 18 06:20:46 2021
#
Accessible filesystems, by reference, are maintained under '/dev/disk/'.
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.
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
After editing this file, run 'systemctl daemon-reload' to update systemd
After editing this file, run 'systemctl daemon-reload' to update systemd
units generated from this file.
units generated from this file.
#
UUID=5cb25e0d-f840-4151-b233-a8693daef222 / xfs defaults 0 0
UUID=79b9811d-7519-4dd3-806b-073da9920fbd /boot ext4 defaults 1 2
UUID=09a49cd2-58b8-4f86-ab2d-db9a55cc4026 /data xfs defaults 0 0
UUID=7937620b-091b-4cbb-9df9-ceb3dc512d6c none swap defaults 0 0

5、處理/etc/fstab路徑,使用sed命令取出其目錄名和基名

<!--目錄名-->

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

<!--基名-->

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

6、列出ubuntu軟體管理工具apt的一些用法(自由總結)

apt install 安裝軟體包
apt remove 移除軟體包
apt purge 移除軟體包及配置檔案
apt update 重新整理儲存庫索引
apt upgrade 升級所有可升級的軟體包
apt autoremove 自動刪除不需要的包
apt full-upgrade 在升級軟體包時自動處理依賴關係
apt search 搜尋應用程式
apt show 顯示安裝細節
apt list 列出包含條件的包