目录
1、yum配置多个网络源
2、yum配置本地局域网私有源仓库
3、编译安装http2.4版本
3、利用sed 取出ifconfig命令中本机的IPv4地址
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
6、列出ubuntu软件管理工具apt的一些用法
7、ubuntu建议安装的常用包
a、首先切换到/etc/yum.repos.d/
[root@Centos8 ~]# cd /etc/yum.repos.d/
[root@Centos8 yum.repos.d]# ls
CentOS-Linux-AppStream.repo CentOS-Linux-FastTrack.repo
CentOS-Linux-BaseOS.repo CentOS-Linux-HighAvailability.repo
CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Media.repo
CentOS-Linux-Debuginfo.repo CentOS-Linux-Plus.repo
CentOS-Linux-Devel.repo CentOS-Linux-PowerTools.repo
CentOS-Linux-Extras.repo CentOS-Linux-Sources.repo
[root@Centos8 yum.repos.d]# mkdir bak
[root@Centos8 yum.repos.d]# mv *.repo ./bak/
[root@Centos8 yum.repos.d]# ls
bak
[root@Centos8 yum.repos.d]# vi base.repo
[BaseOS]
name=BaseOS
#baseurl=file:///misc/cd/BaseOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
https://repo.huaweicloud.com/centos/$releasever/BaseOS/$basearch/os/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=0
[AppStream]
name=AppStream
#baseurl=file:///misc/cd/AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
https://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
https://repo.huaweicloud.com/centos/$releasever/AppStream/$basearch/os/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
gpgcheck=0
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/
https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/os/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
gpgcheck=0
enabled=1
[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
https://mirrors.cloud.tencent.com/epel/$releasever/Everything/$basearch/
https://repo.huaweicloud.com/epel/$releasever/Everything/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/Everything/$basearch/
gpgcheck=0
enabled=1
[PowerTools]
name=CentOS - PowerTools - mirrors.aliyum.com
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
https://mirrors.cloud.tencent.com/centos/$releasever/PowerTools/$basearch/os/
https://repo.huaweicloud.com/centos/$releasever/PowerTools/$basearch/os/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=0
enabled=1
输入完毕之后,按ESC键,输入英文冒号: 再输入小写wq 在按enter回车即可保存
enabled=1 #开机自启
gpgcheck=0 #是否检测 0不检测 1检测
yum clean all && yum makecache #清理缓存并重新建立元数据
yum list #查看列表,如果出现红色的说明有问题
b、神奇的光盘挂载目录:
[root@Centos8 yum.repos.d]# rpm -q autofs
autofs-5.1.4-74.el8.x86_64
[root@Centos8 yum.repos.d]# yum install -y autofs
Failed to set locale, defaulting to C.UTF-8
AppStream 17 kB/s | 4.3 kB 00:00
extras 351 B/s | 1.5 kB 00:04
extras 6.2 kB/s | 10 kB 00:01
EPEL 8.5 kB/s | 4.7 kB 00:00
EPEL 14 MB/s | 12 MB 00:00
rpmCentOS - PowerTools - m [ === ] --- B/s | 0 B --:-- ECentOS - PowerTools - mirrors.aliyum.com 14 kB/s | 4.3 kB 00:00
Package autofs-1:5.1.4-74.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@Centos8 yum.repos.d]# systemctl enable --now autofs
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
[root@Centos8 yum.repos.d]# ls /misc/cd/BaseOS/
Packages repodata
c、centos最小化安装后常用软件:
yum -y install lrzsz tree screen tmux man-pages strace redhat-lsb-core nano vim
[root@Centos8mini ~]# yum -y install lrzsz tree screen tmux man-pages strace redhat-lsb-core nano vim
Failed to set locale, defaulting to C.UTF-8
BaseOS 1.3 MB/s | 4.6 MB 00:03
AppStream 12 MB/s | 8.4 MB 00:00
extras 20 kB/s | 10 kB 00:00
EPEL 15 MB/s | 12 MB 00:00
CentOS - PowerTools - mirrors.aliyum.com 3.1 MB/s | 2.3 MB 00:00
Dependencies resolved.
===========================================================================================================================
Package Architecture Version Repository Size
===========================================================================================================================
Installing:
lrzsz x86_64 0.12.20-43.el8 BaseOS 84 k
man-pages x86_64 4.15-6.el8 BaseOS 5.9 M
nano x86_64 2.9.8-1.el8 BaseOS 581 k
redhat-lsb-core x86_64 4.1-47.el8 AppStream 46 k
screen x86_64 4.6.2-12.el8 epel 581 k
strace x86_64 5.7-3.el8 BaseOS 1.1 M
tmux x86_64 2.7-1.el8 BaseOS 317 k
tree x86_64 1.7.0-15.el8 BaseOS 59 k
vim-enhanced x86_64 2:8.0.1763-16.el8 AppStream 1.4 M
Installing dependencies:
at x86_64 3.1.20-11.el8 BaseOS 81 k
avahi-libs x86_64 0.7-20.el8 BaseOS 62 k
bc x86_64 1.07.1-5.el8 BaseOS 129 k
binutils x86_64 2.30-108.el8_5.1 BaseOS 5.8 M
cups-client x86_64 1:2.2.6-40.el8 AppStream 169 k
cups-libs x86_64 1:2.2.6-40.el8 BaseOS 433 k
ed x86_64 1.14.2-4.el8 BaseOS 82 k
esmtp x86_64 1.2-15.el8 epel 57 k
gpm-libs x86_64 1.20.7-17.el8 AppStream 39 k
libesmtp x86_64 1.0.6-18.el8 epel 70 k
liblockfile x86_64 1.14-1.el8 AppStream 32 k
m4 x86_64 1.4.18-7.el8 BaseOS 223 k
mailx x86_64 12.5-29.el8 BaseOS 257 k
make x86_64 1:4.2.1-10.el8 BaseOS 498 k
ncurses-compat-libs x86_64 6.1-9.20180224.el8 BaseOS 328 k
nspr x86_64 4.32.0-1.el8_4 AppStream 142 k
nss x86_64 3.67.0-7.el8_5 AppStream 741 k
nss-softokn x86_64 3.67.0-7.el8_5 AppStream 487 k
nss-softokn-freebl x86_64 3.67.0-7.el8_5 AppStream 395 k
nss-sysinit x86_64 3.67.0-7.el8_5 AppStream 73 k
nss-util x86_64 3.67.0-7.el8_5 AppStream 137 k
patch x86_64 2.7.6-11.el8 BaseOS 138 k
psmisc x86_64 23.1-5.el8 BaseOS 151 k
redhat-lsb-submod-security x86_64 4.1-47.el8 AppStream 22 k
spax x86_64 1.5.3-13.el8 BaseOS 217 k
time x86_64 1.9-3.el8 BaseOS 54 k
util-linux-user x86_64 2.32.1-28.el8 BaseOS 100 k
vim-common x86_64 2:8.0.1763-16.el8 AppStream 6.3 M
vim-filesystem noarch 2:8.0.1763-16.el8 AppStream 49 k
Installing weak dependencies:
man-pages-overrides noarch 8.5.0.1-1.el8 AppStream 98 k
Transaction Summary
===========================================================================================================================
Install 39 Packages
Total download size: 27 M
Installed size: 78 M
Downloading Packages:
(1/39): bc-1.07.1-5.el8.x86_64.rpm 434 kB/s | 129 kB 00:00
(2/39): at-3.1.20-11.el8.x86_64.rpm 272 kB/s | 81 kB 00:00
(3/39): avahi-libs-0.7-20.el8.x86_64.rpm 205 kB/s | 62 kB 00:00
(4/39): cups-libs-2.2.6-40.el8.x86_64.rpm 2.8 MB/s | 433 kB 00:00
(5/39): ed-1.14.2-4.el8.x86_64.rpm 454 kB/s | 82 kB 00:00
(6/39): lrzsz-0.12.20-43.el8.x86_64.rpm 979 kB/s | 84 kB 00:00
(7/39): m4-1.4.18-7.el8.x86_64.rpm 1.7 MB/s | 223 kB 00:00
(8/39): binutils-2.30-108.el8_5.1.x86_64.rpm 17 MB/s | 5.8 MB 00:00
(9/39): mailx-12.5-29.el8.x86_64.rpm 2.2 MB/s | 257 kB 00:00
(10/39): make-4.2.1-10.el8.x86_64.rpm 4.4 MB/s | 498 kB 00:00
(11/39): nano-2.9.8-1.el8.x86_64.rpm 4.0 MB/s | 581 kB 00:00
(12/39): ncurses-compat-libs-6.1-9.20180224.el8.x86_64.rpm 3.2 MB/s | 328 kB 00:00
(13/39): patch-2.7.6-11.el8.x86_64.rpm 1.4 MB/s | 138 kB 00:00
(14/39): psmisc-23.1-5.el8.x86_64.rpm 1.5 MB/s | 151 kB 00:00
(15/39): man-pages-4.15-6.el8.x86_64.rpm 15 MB/s | 5.9 MB 00:00
(16/39): spax-1.5.3-13.el8.x86_64.rpm 1.2 MB/s | 217 kB 00:00
(17/39): strace-5.7-3.el8.x86_64.rpm 7.5 MB/s | 1.1 MB 00:00
(18/39): time-1.9-3.el8.x86_64.rpm 530 kB/s | 54 kB 00:00
(19/39): tmux-2.7-1.el8.x86_64.rpm 3.0 MB/s | 317 kB 00:00
(20/39): tree-1.7.0-15.el8.x86_64.rpm 468 kB/s | 59 kB 00:00
(21/39): cups-client-2.2.6-40.el8.x86_64.rpm 2.5 MB/s | 169 kB 00:00
(22/39): util-linux-user-2.32.1-28.el8.x86_64.rpm 1.0 MB/s | 100 kB 00:00
(23/39): gpm-libs-1.20.7-17.el8.x86_64.rpm 445 kB/s | 39 kB 00:00
(24/39): man-pages-overrides-8.5.0.1-1.el8.noarch.rpm 2.4 MB/s | 98 kB 00:00
(25/39): liblockfile-1.14-1.el8.x86_64.rpm 389 kB/s | 32 kB 00:00
(26/39): nspr-4.32.0-1.el8_4.x86_64.rpm 3.1 MB/s | 142 kB 00:00
(27/39): nss-softokn-3.67.0-7.el8_5.x86_64.rpm 9.5 MB/s | 487 kB 00:00
(28/39): nss-3.67.0-7.el8_5.x86_64.rpm 10 MB/s | 741 kB 00:00
(29/39): nss-softokn-freebl-3.67.0-7.el8_5.x86_64.rpm 8.1 MB/s | 395 kB 00:00
(30/39): nss-util-3.67.0-7.el8_5.x86_64.rpm 3.2 MB/s | 137 kB 00:00
(31/39): nss-sysinit-3.67.0-7.el8_5.x86_64.rpm 1.3 MB/s | 73 kB 00:00
(32/39): redhat-lsb-core-4.1-47.el8.x86_64.rpm 387 kB/s | 46 kB 00:00
(33/39): redhat-lsb-submod-security-4.1-47.el8.x86_64.rpm 225 kB/s | 22 kB 00:00
(34/39): vim-filesystem-8.0.1763-16.el8.noarch.rpm 898 kB/s | 49 kB 00:00
(35/39): vim-enhanced-8.0.1763-16.el8.x86_64.rpm 9.9 MB/s | 1.4 MB 00:00
(36/39): esmtp-1.2-15.el8.x86_64.rpm 727 kB/s | 57 kB 00:00
(37/39): screen-4.6.2-12.el8.x86_64.rpm 4.8 MB/s | 581 kB 00:00
(38/39): libesmtp-1.0.6-18.el8.x86_64.rpm 476 kB/s | 70 kB 00:00
(39/39): vim-common-8.0.1763-16.el8.x86_64.rpm 15 MB/s | 6.3 MB 00:00
---------------------------------------------------------------------------------------------------------------------------
Total 15 MB/s | 27 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : nspr-4.32.0-1.el8_4.x86_64 1/39
Running scriptlet: nspr-4.32.0-1.el8_4.x86_64 1/39
Installing : nss-util-3.67.0-7.el8_5.x86_64 2/39
Installing : avahi-libs-0.7-20.el8.x86_64 3/39
Installing : cups-libs-1:2.2.6-40.el8.x86_64 4/39
Installing : cups-client-1:2.2.6-40.el8.x86_64 5/39
Running scriptlet: cups-client-1:2.2.6-40.el8.x86_64 5/39
Installing : nss-softokn-freebl-3.67.0-7.el8_5.x86_64 6/39
Installing : nss-softokn-3.67.0-7.el8_5.x86_64 7/39
Installing : nss-3.67.0-7.el8_5.x86_64 8/39
Installing : nss-sysinit-3.67.0-7.el8_5.x86_64 9/39
Installing : redhat-lsb-submod-security-4.1-47.el8.x86_64 10/39
Installing : libesmtp-1.0.6-18.el8.x86_64 11/39
Installing : vim-filesystem-2:8.0.1763-16.el8.noarch 12/39
Installing : vim-common-2:8.0.1763-16.el8.x86_64 13/39
Installing : man-pages-overrides-8.5.0.1-1.el8.noarch 14/39
Installing : liblockfile-1.14-1.el8.x86_64 15/39
Running scriptlet: liblockfile-1.14-1.el8.x86_64 15/39
Installing : esmtp-1.2-15.el8.x86_64 16/39
Running scriptlet: esmtp-1.2-15.el8.x86_64 16/39
Installing : gpm-libs-1.20.7-17.el8.x86_64 17/39
Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64 17/39
Installing : util-linux-user-2.32.1-28.el8.x86_64 18/39
Installing : time-1.9-3.el8.x86_64 19/39
Running scriptlet: time-1.9-3.el8.x86_64 19/39
Installing : spax-1.5.3-13.el8.x86_64 20/39
Running scriptlet: spax-1.5.3-13.el8.x86_64 20/39
Installing : psmisc-23.1-5.el8.x86_64 21/39
Installing : patch-2.7.6-11.el8.x86_64 22/39
Installing : ncurses-compat-libs-6.1-9.20180224.el8.x86_64 23/39
Installing : make-1:4.2.1-10.el8.x86_64 24/39
Running scriptlet: make-1:4.2.1-10.el8.x86_64 24/39
Installing : mailx-12.5-29.el8.x86_64 25/39
Installing : m4-1.4.18-7.el8.x86_64 26/39
Running scriptlet: m4-1.4.18-7.el8.x86_64 26/39
Installing : ed-1.14.2-4.el8.x86_64 27/39
Running scriptlet: ed-1.14.2-4.el8.x86_64 27/39
Installing : binutils-2.30-108.el8_5.1.x86_64 28/39
Running scriptlet: binutils-2.30-108.el8_5.1.x86_64 28/39
Installing : bc-1.07.1-5.el8.x86_64 29/39
Running scriptlet: bc-1.07.1-5.el8.x86_64 29/39
Installing : at-3.1.20-11.el8.x86_64 30/39
Running scriptlet: at-3.1.20-11.el8.x86_64 30/39
Installing : redhat-lsb-core-4.1-47.el8.x86_64 31/39
Installing : vim-enhanced-2:8.0.1763-16.el8.x86_64 32/39
Installing : man-pages-4.15-6.el8.x86_64 33/39
Running scriptlet: screen-4.6.2-12.el8.x86_64 34/39
Installing : screen-4.6.2-12.el8.x86_64 34/39
Installing : tree-1.7.0-15.el8.x86_64 35/39
Installing : tmux-2.7-1.el8.x86_64 36/39
Running scriptlet: tmux-2.7-1.el8.x86_64 36/39
Installing : strace-5.7-3.el8.x86_64 37/39
Installing : nano-2.9.8-1.el8.x86_64 38/39
Running scriptlet: nano-2.9.8-1.el8.x86_64 38/39
Installing : lrzsz-0.12.20-43.el8.x86_64 39/39
Running scriptlet: nss-3.67.0-7.el8_5.x86_64 39/39
Running scriptlet: lrzsz-0.12.20-43.el8.x86_64 39/39
Running scriptlet: vim-common-2:8.0.1763-16.el8.x86_64 39/39
Verifying : at-3.1.20-11.el8.x86_64 1/39
Verifying : avahi-libs-0.7-20.el8.x86_64 2/39
Verifying : bc-1.07.1-5.el8.x86_64 3/39
Verifying : binutils-2.30-108.el8_5.1.x86_64 4/39
Verifying : cups-libs-1:2.2.6-40.el8.x86_64 5/39
Verifying : ed-1.14.2-4.el8.x86_64 6/39
Verifying : lrzsz-0.12.20-43.el8.x86_64 7/39
Verifying : m4-1.4.18-7.el8.x86_64 8/39
Verifying : mailx-12.5-29.el8.x86_64 9/39
Verifying : make-1:4.2.1-10.el8.x86_64 10/39
Verifying : man-pages-4.15-6.el8.x86_64 11/39
Verifying : nano-2.9.8-1.el8.x86_64 12/39
Verifying : ncurses-compat-libs-6.1-9.20180224.el8.x86_64 13/39
Verifying : patch-2.7.6-11.el8.x86_64 14/39
Verifying : psmisc-23.1-5.el8.x86_64 15/39
Verifying : spax-1.5.3-13.el8.x86_64 16/39
Verifying : strace-5.7-3.el8.x86_64 17/39
Verifying : time-1.9-3.el8.x86_64 18/39
Verifying : tmux-2.7-1.el8.x86_64 19/39
Verifying : tree-1.7.0-15.el8.x86_64 20/39
Verifying : util-linux-user-2.32.1-28.el8.x86_64 21/39
Verifying : cups-client-1:2.2.6-40.el8.x86_64 22/39
Verifying : gpm-libs-1.20.7-17.el8.x86_64 23/39
Verifying : liblockfile-1.14-1.el8.x86_64 24/39
Verifying : man-pages-overrides-8.5.0.1-1.el8.noarch 25/39
Verifying : nspr-4.32.0-1.el8_4.x86_64 26/39
Verifying : nss-3.67.0-7.el8_5.x86_64 27/39
Verifying : nss-softokn-3.67.0-7.el8_5.x86_64 28/39
Verifying : nss-softokn-freebl-3.67.0-7.el8_5.x86_64 29/39
Verifying : nss-sysinit-3.67.0-7.el8_5.x86_64 30/39
Verifying : nss-util-3.67.0-7.el8_5.x86_64 31/39
Verifying : redhat-lsb-core-4.1-47.el8.x86_64 32/39
Verifying : redhat-lsb-submod-security-4.1-47.el8.x86_64 33/39
Verifying : vim-common-2:8.0.1763-16.el8.x86_64 34/39
Verifying : vim-enhanced-2:8.0.1763-16.el8.x86_64 35/39
Verifying : vim-filesystem-2:8.0.1763-16.el8.noarch 36/39
Verifying : esmtp-1.2-15.el8.x86_64 37/39
Verifying : libesmtp-1.0.6-18.el8.x86_64 38/39
Verifying : screen-4.6.2-12.el8.x86_64 39/39
Installed:
at-3.1.20-11.el8.x86_64 avahi-libs-0.7-20.el8.x86_64
bc-1.07.1-5.el8.x86_64 binutils-2.30-108.el8_5.1.x86_64
cups-client-1:2.2.6-40.el8.x86_64 cups-libs-1:2.2.6-40.el8.x86_64
ed-1.14.2-4.el8.x86_64 esmtp-1.2-15.el8.x86_64
gpm-libs-1.20.7-17.el8.x86_64 libesmtp-1.0.6-18.el8.x86_64
liblockfile-1.14-1.el8.x86_64 lrzsz-0.12.20-43.el8.x86_64
m4-1.4.18-7.el8.x86_64 mailx-12.5-29.el8.x86_64
make-1:4.2.1-10.el8.x86_64 man-pages-4.15-6.el8.x86_64
man-pages-overrides-8.5.0.1-1.el8.noarch nano-2.9.8-1.el8.x86_64
ncurses-compat-libs-6.1-9.20180224.el8.x86_64 nspr-4.32.0-1.el8_4.x86_64
nss-3.67.0-7.el8_5.x86_64 nss-softokn-3.67.0-7.el8_5.x86_64
nss-softokn-freebl-3.67.0-7.el8_5.x86_64 nss-sysinit-3.67.0-7.el8_5.x86_64
nss-util-3.67.0-7.el8_5.x86_64 patch-2.7.6-11.el8.x86_64
psmisc-23.1-5.el8.x86_64 redhat-lsb-core-4.1-47.el8.x86_64
redhat-lsb-submod-security-4.1-47.el8.x86_64 screen-4.6.2-12.el8.x86_64
spax-1.5.3-13.el8.x86_64 strace-5.7-3.el8.x86_64
time-1.9-3.el8.x86_64 tmux-2.7-1.el8.x86_64
tree-1.7.0-15.el8.x86_64 util-linux-user-2.32.1-28.el8.x86_64
vim-common-2:8.0.1763-16.el8.x86_64 vim-enhanced-2:8.0.1763-16.el8.x86_64
vim-filesystem-2:8.0.1763-16.el8.noarch
Complete!
d、邮箱邮件配置:
yum -y install postfix mailx
systemctl enable --now postfix
[root@Centos8mini ~]# yum -y install postfix mailx
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:01:01 ago on Fri Jul 22 23:38:34 2022.
Package mailx-12.5-29.el8.x86_64 is already installed.
Dependencies resolved.
===========================================================================================================================
Package Architecture Version Repository Size
===========================================================================================================================
Installing:
postfix x86_64 2:3.5.8-2.el8 BaseOS 1.5 M
Installing dependencies:
libicu x86_64 60.3-2.el8_1 BaseOS 8.8 M
Transaction Summary
===========================================================================================================================
Install 2 Packages
Total download size: 10 M
Installed size: 36 M
Downloading Packages:
(1/2): postfix-3.5.8-2.el8.x86_64.rpm 3.1 MB/s | 1.5 MB 00:00
(2/2): libicu-60.3-2.el8_1.x86_64.rpm 14 MB/s | 8.8 MB 00:00
---------------------------------------------------------------------------------------------------------------------------
Total 17 MB/s | 10 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libicu-60.3-2.el8_1.x86_64 1/2
Running scriptlet: libicu-60.3-2.el8_1.x86_64 1/2
Running scriptlet: postfix-2:3.5.8-2.el8.x86_64 2/2
Installing : postfix-2:3.5.8-2.el8.x86_64 2/2
Running scriptlet: postfix-2:3.5.8-2.el8.x86_64 2/2
Verifying : libicu-60.3-2.el8_1.x86_64 1/2
Verifying : postfix-2:3.5.8-2.el8.x86_64 2/2
Installed:
libicu-60.3-2.el8_1.x86_64 postfix-2:3.5.8-2.el8.x86_64
Complete!
[root@Centos8mini ~]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
a、先安装http
yum -y install httpd
systemctl enable --now httpd
[root@Centos8mini ~]# yum -y install httpd
[root@Centos8mini ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
网站即可在本地浏览器访问ip了
接下来进入网站目录:cd /var/www/html/
[root@Centos8mini ~]# cd /var/www/html/
[root@Centos8mini html]# ls
[root@Centos8mini html]# mkdir centos/{7,8} -pv
mkdir: created directory 'centos'
mkdir: created directory 'centos/7'
mkdir: created directory 'centos/8'
[root@Centos8mini html]# tree centos
centos
|-- 7
`-- 8
2 directories, 0 files
接下来查看一下硬盘基本情况:lsblk
[root@Centos8mini html]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
|-sda1 8:1 0 100G 0 part /
|-sda2 8:2 0 50G 0 part /data
|-sda3 8:3 0 2G 0 part [SWAP]
|-sda4 8:4 0 1K 0 part
`-sda5 8:5 0 1G 0 part /boot
sdb 8:16 0 10G 0 disk
sdc 8:32 0 20G 0 disk
sr0 11:0 1 9.5G 0 rom
sr1 11:1 1 10.1G 0 rom
sr0是centos7的光盘,把sr0拷贝到7的文件夹下,
先在data下创建centos7,并挂载光盘,再拷贝Packages 和repodata 到/var/www/html/centos/7/。
回到浏览器,输入ip(10.0.0.9)/centos/7/即可看到仓库文件。
[root@Centos8mini centos]# cd
[root@Centos8mini ~]# cd /data
[root@Centos8mini data]# ls
[root@Centos8mini data]# mkdir centos{7,8} -pv
mkdir: created directory 'centos7'
mkdir: created directory 'centos8'
[root@Centos8mini data]# ls
centos7 centos8
[root@Centos8mini data]# cd centos7
[root@Centos8mini centos7]# cd
[root@Centos8mini ~]# mount /dev/sr0 /data/centos7
mount: /data/centos7: WARNING: device write-protected, mounted read-only.
[root@Centos8mini ~]# cd /data/centos7
[root@Centos8mini centos7]# ls
CentOS_BuildTag EULA LiveOS RPM-GPG-KEY-CentOS-7 TRANS.TBL isolinux
EFI GPL Packages RPM-GPG-KEY-CentOS-Testing-7 images repodata
[root@Centos8mini ~]# cp /data/centos7/repodata /var/www/html/centos/7/ -r
[root@Centos8mini ~]# cp /data/centos7/Packages /var/www/html/centos/7/ -r
[root@Centos8mini ~]# cd /var/www/html/centos/7/
[root@Centos8mini 7]# ls
Packages repodata
sr1是centos8的光盘,把sr1挂载到8的文件夹下
[root@Centos8mini ~]# mount /dev/sr1 /var/www/html/centos/8
mount: /var/www/html/centos/8: WARNING: device write-protected, mounted read-only.
[root@Centos8mini ~]# cd /var/www/html/centos/8
[root@Centos8mini 8]# ls
AppStream BaseOS EFI LICENSE TRANS.TBL images isolinux media.repo
回到centos7的机器,进入cd /etc/yum.repos.d/,编辑base仓库,注释掉原来的网络源链接,新建baseurl=http://10.0.0.9/centos/7/
保存退出,运行yum repolist 检查是否成功,并尝试安装vsftpd,完成即可。centos8挂载成功后,在8的机器同理操作替换。
[root@Centos7 yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: 10.0.0.9
* extras: mirrors.nju.edu.cn
* updates: mirrors.nju.edu.cn
源标识 源名称 状态
!base/7/x86_64 CentOS-7 - Base 10,072
!extras/7/x86_64 CentOS-7 - Extras 512
!updates/7/x86_64 CentOS-7 - Updates 4,050
repolist: 14,634
[root@Centos7 yum.repos.d]# yum list vsftpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: 10.0.0.9
* extras: mirrors.nju.edu.cn
* updates: mirrors.nju.edu.cn
可安装的软件包
vsftpd.x86_64 3.0.2-29.el7_9 updates
[root@Centos7 yum.repos.d]# yum install vsftpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: 10.0.0.9
* extras: mirrors.nju.edu.cn
* updates: mirrors.nju.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 16 MB 00:01:05
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-29.el7_9 将被 安装
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================================
Package 架构 版本 源 大小
===========================================================================================================================
正在安装:
vsftpd x86_64 3.0.2-29.el7_9 updates 173 k
事务概要
===========================================================================================================================
安装 1 软件包
总下载量:173 k
安装大小:353 k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-29.el7_9.x86_64.rpm | 173 kB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : vsftpd-3.0.2-29.el7_9.x86_64 1/1
验证中 : vsftpd-3.0.2-29.el7_9.x86_64 1/1
已安装:
vsftpd.x86_64 0:3.0.2-29.el7_9
完毕!
[root@Centos8 ~]# yum repolist
Failed to set locale, defaulting to C.UTF-8
repo id repo name
AppStream AppStream
BaseOS BaseOS
PowerTools CentOS - PowerTools - mirrors.aliyum.com
epel EPEL
extras extras
[root@Centos8 ~]# yum -y install vsftpd
Failed to set locale, defaulting to C.UTF-8
BaseOS 23 MB/s | 2.6 MB 00:00
AppStream 78 MB/s | 7.5 MB 00:00
extras 4.7 kB/s | 1.5 kB 00:00
EPEL 15 kB/s | 4.7 kB 00:00
Dependencies resolved.
===========================================================================================================================
Package Architecture Version Repository Size
===========================================================================================================================
Installing:
vsftpd x86_64 3.0.3-34.el8 AppStream 181 k
Transaction Summary
===========================================================================================================================
Install 1 Package
Total download size: 181 k
Installed size: 347 k
Downloading Packages:
vsftpd-3.0.3-34.el8.x86_64.rpm 303 kB/s | 181 kB 00:00
---------------------------------------------------------------------------------------------------------------------------
Total 298 kB/s | 181 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : vsftpd-3.0.3-34.el8.x86_64 1/1
Running scriptlet: vsftpd-3.0.3-34.el8.x86_64 1/1
Verifying : vsftpd-3.0.3-34.el8.x86_64 1/1
Installed:
vsftpd-3.0.3-34.el8.x86_64
Complete!
首先检查一下http包的版本: yum info httpd
再进入文件夹内:cd /usr/local/src
下载源码包:wget https://dlcdn.apache.org/httpd/httpd-2.4.54.tar.bz2
或者在Windows下载源码包,再导入该文件夹。
再解压文件:tar xvf httpd-2.4.54.tar.bz2
再进入http文件夹内:cd httpd-2.4.54/
查看一下帮助:./configure --help
执行配置命令:./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all --withmpm=prefork
期间会遇到缺包报错,对于不认识的包可以命令检查,一般情况下所缺的包报错名称是大写时,安装时要在包名后加 小写包名-devel,:yum provides 包名,:yum -y install gcc apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
报错解决后再执行配置命令:./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all
再执行:make -j 2(CPU核数,lscpu可查看)
再执行:make install
安装成功后,可执行检查安装情况:tree /apps/httpd24/ -d
再制作启动PATH路径:echo 'PATH=/apps/httpd24/bin/:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh
[root@Centos8 ~]#cd /usr/local/src
[root@Centos8 src]# wget https://dlcdn.apache.org/httpd/httpd-2.4.54.tar.bz2
[root@Centos8 src]# tar xvf httpd-2.4.54.tar.bz2
[root@Centos8 src]# cd httpd-2.4.54/
[root@Centos8 httpd-2.4.54]# ./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all
[root@Centos8 httpd-2.4.54]# yum -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
[root@Centos8 httpd-2.4.54]# ./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all
[root@Centos8 httpd-2.4.54]# make -j 2
[root@Centos8 httpd-2.4.54]# make install
[root@Centos8 httpd-2.4.54]# tree /apps/httpd24/ -d
[root@Centos8 httpd-2.4.54]# echo 'PATH=/apps/httpd24/bin/:$PATH' > /etc/profile.d/httpd24.sh
[root@Centos8 httpd-2.4.54]# . /etc/profile.d/httpd24.sh
[root@Centos8 httpd-2.4.54]# apachectl start
[root@Centos8 httpd-2.4.54]# ps -aux |grep httpd
root 1663829 0.0 0.2 118620 5452 ? Ss 02:43 0:00 /apps/httpd24/bin/httpd -k start
daemon 1663886 0.0 0.6 1339248 13608 ? Sl 02:43 0:00 /apps/httpd24/bin/httpd -k start
daemon 1663887 0.0 0.3 1339248 7596 ? Sl 02:43 0:00 /apps/httpd24/bin/httpd -k start
daemon 1663888 0.0 0.3 1339248 7728 ? Sl 02:43 0:00 /apps/httpd24/bin/httpd -k start
root 1674170 0.0 0.0 9208 1144 pts/2 S+ 02:45 0:00 grep --color=auto httpd
打开本地浏览器地址栏输入ip(10.0.0.8),表示安装成功。
刚刚我们看到进程显示deamon,可以修改一下,新建组和用户,指定为apache,shell类型为/sbin/nologin,存放网页的目录为/var/www/。再进入etc的httpd配置文件,修改组和用户名称,重启服务,完成安装。
[root@Centos8 httpd-2.4.54]# groupadd -r -g 66 apache
[root@Centos8 httpd-2.4.54]# useradd -r -g apache -s /sbin/nologin -d /var/www/ apache
[root@Centos8 httpd-2.4.54]# cd /etc/httpd/
[root@Centos8 httpd]# ls
extra httpd.conf magic mime.types original
[root@Centos8 httpd]# sed -i 's#User daemon#User apache#' httpd.conf
[root@Centos8 httpd]# sed -i 's#Group daemon#Group apache#' httpd.conf
[root@Centos8 httpd]# apachectl stop
[root@Centos8 httpd]# ps -aux | grep httpd
root 1830261 0.0 0.0 9208 1136 pts/0 S+ 03:13 0:00 grep --color=auto httpd
[root@Centos8 httpd]# apachectl start
[root@Centos8 httpd]# ps -aux | grep httpd
root 1839565 0.0 0.2 118620 5452 ? Ss 03:15 0:00 /apps/httpd24/bin/httpd -k start
apache 1839566 0.0 0.3 1339248 7596 ? Sl 03:15 0:00 /apps/httpd24/bin/httpd -k start
apache 1839567 0.0 0.4 1339248 9636 ? Sl 03:15 0:00 /apps/httpd24/bin/httpd -k start
apache 1839568 0.0 0.4 1339248 9636 ? Sl 03:15 0:00 /apps/httpd24/bin/httpd -k start
root 1839902 0.0 0.0 9208 1152 pts/0 S+ 03:15 0:00 grep --color=auto httpd
-r 扩展正则表达式,-n不自动打印,不输出模式空间内容到屏幕。2p打印第二行,2s///p搜索替代并打印第二行,()分组,\1第一个分组,[0-9.]+数字0到9点一个或多个,
使用扩展正则表达式搜索第二行并替代为第一个分组打印到屏幕。
[root@Centos8 ~]# ifconfig eth0 | sed -rn '2s/.*inet ([0-9.]+) netmask.*/\1/p'
10.0.0.8
[root@Centos8 ~]# ifconfig eth0 | sed -rn '2s/.*inet ([0-9.]+) .*/\1/p'
10.0.0.8
[root@Centos8 ~]# sed -e '/^$/d' -e'/^# /d' /etc/fstab
#
#
#
#
UUID=34802d53-30ba-4119-b0b6-d9e97f876021 / xfs defaults 0 0
UUID=3c35c7a5-70f8-47d5-a170-f5fed4032a94 /boot ext4 defaults 1 2
UUID=2f311184-9b10-4d2a-a303-b51d842a0616 /data xfs defaults 0 0
UUID=61275660-c98b-4e6c-a9ec-a79d85467d39 none swap defaults 0 0
basename 取出基名,dirname 可取出路径名
如图代码以两个括号中的/为分界 分组,\1代表第一个括号分组,\2代表第二个括号分组,托字符开头一个或任意个字符 为第一组,/之后跟非/的字符一个或多个,从路径看,符号情况的只有最后一个文件夹前的/符合 条件分组。
[root@Centos8 ~]# echo /etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@Centos8 ~]# basename /etc/sysconfig/network-scripts/ifcfg-eth0
ifcfg-eth0
[root@Centos8 ~]# dirname /etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts
[root@Centos8 ~]# echo /etc/sysconfig/network-scripts/ifcfg-eth0 |sed -rn 's#^(.*)/([^/]+)#\1#p'
/etc/sysconfig/network-scripts
[root@Centos8 ~]# echo /etc/sysconfig/network-scripts/ifcfg-eth0 |sed -rn 's#^(.*)/([^/]+)#\2#p'
ifcfg-eth0
apt 命令 | 命令的功能 |
apt install | 安装软件包 |
apt remove | 移除软件包 |
apt purge | 移除软件包及配置文件 |
apt update | 刷新存储库索引 |
apt upgrade | 升级所有可升级的软件包 |
apt autoremove | 自动删除不需要的包 |
apt full-upgrade | 在升级软件包时自动处理依赖关系 |
apt search | 搜索应用程序 |
apt show | 显示安装细节 |
#查看文件来自于哪个包,类似redhat中的yum provides
apt-file search 'string' #默认是包含此字符串的文件
apt-file search -x '正则表达式'
apt-file search -F /path/file
[root@ubuntu1804 ~]#apt purge ufw lxd lxd-client lxcfs liblxc-common
[root@ubuntu1804 ~]#apt install iproute2 ntpdate tcpdump telnet traceroute nfskernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev
zlib1g-dev gcc openssh-server iotop unzip zip