[root@SYL4 ~]# cd /etc/yum.repos.d/
[root@SYL4 yum.repos.d]# ls
[root@SYL4 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-100 2495 100 2495 0 0 6012 0 --:--:-- --:--:-- --:--:-- 6026
[root@SYL4 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@SYL4 yum.repos.d]#
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@SYL4 yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@SYL4 yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@SYL4 yum.repos.d]# yum clean all
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
18 files removed
[root@SYL4 yum.repos.d]#
[root@SYL4 yum.repos.d]# yum makecache
[root@SYL4 yum.repos.d]# yum makecache
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
CentOS-8.5.2111 - Base - mirr 1.4 MB/s | 4.6 MB 00:03
CentOS-8.5.2111 - Extras - mi 57 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - 2.3 MB/s | 8.4 MB 00:03
Extra Packages for Enterprise 1.8 MB/s | 11 MB 00:06
Extra Packages for Enterprise 658 kB/s | 1.0 MB 00:01
Metadata cache created.
[root@SYL4 yum.repos.d]# yum list all
[root@SYL4 yum.repos.d]# ls
CentOS-Base.repo epel-testing-modular.repo epel.repo
epel-modular.repo epel-testing.repo redhat.repo
[root@SYL4 yum.repos.d]# cd
[root@SYL4 ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@SYL4 ~]# ls
anaconda-ks.cfg apr-util-1.6.1.tar.gz
apr-1.7.0.tar.gz httpd-2.4.53.tar.gz
[root@SYL4 ~]# tar xf apr-1.7.0.tar.gz
[root@SYL4 ~]# tar xf apr-util-1.6.1.tar.gz
[root@SYL4 ~]# tar xf httpd-2.4.53.tar.gz
[root@SYL4 ~]#
[root@SYL4 ~]# useradd -r -M -s /sbin/nologin apache
[root@SYL4 ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
[root@SYL4 ~]#
[root@SYL4 ~]# yum groups mark install "Development Tools"
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:04:19 ago on Mon Apr 25 20:33:51 2022.
Dependencies resolved.
==============================================================
Package Architecture Version Repository Size
==============================================================
Installing Groups:
Development Tools
Transaction Summary
==============================================================
Is this ok [y/N]: y
Complete!
[root@SYL4 ~]#
[root@SYL4 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool make gcc-c++ gcc
[root@SYL4 ~]# cd apr-1.7.0
[root@SYL4 apr-1.7.0]# vim configure
[root@SYL4 apr-1.7.0]# cat configure|grep cfgfile
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile"
cat <<_LT_EOF >> "$cfgfile"
cat <<'_LT_EOF' >> "$cfgfile"
cat <<\_LT_EOF >> "$cfgfile"
sed '$q' "$ltmain" >> "$cfgfile" \
|| (rm -f "$cfgfile"; exit 1)
mv -f "$cfgfile" "$ofile" ||
(rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
[root@SYL4 apr-1.7.0]#
[root@SYL4 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@SYL4 apr-1.7.0]# make -j 4
[root@SYL4 apr-1.7.0]# make install
[root@SYL4 ~]# cd apr-util-1.6.1
[root@SYL4 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@SYL4 apr-util-1.6.1]# make install
root@SYL4 apr-util-1.6.1]# make -j 4
[root@SYL4 ~]# cd httpd-2.4.53
[root@SYL4 httpd-2.4.53]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
[root@SYL4 httpd-2.4.53]# make -j 4
[root@SYL4 httpd-2.4.53]# make install
[root@SYL4 ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@SYL4 ~]# source /etc/profile.d/apache.sh
[root@SYL4 ~]# which apache
/usr/bin/which: no apache in (/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@SYL4 ~]# which httpd
/usr/local/apache/bin/httpd
[root@SYL4 ~]# ln -s /usr/local/apache/include /usr/include/apache
[root@SYL4 ~]# cd /usr/local/apache/
[root@SYL4 apache]# ls
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@SYL4 apache]# vim /etc/man_db.conf
[root@SYL4 apache]# cat /etc/man_db.conf |grep apache
MANDATORY_MANPATH /usr/local/apache/man
[root@SYL4 apache]#
[root@SYL4 ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@SYL4 ~]# cd /usr/lib/systemd/system
[root@SYL4 system]# cp sshd.service httpd.service
[root@SYL4 system]# vim httpd.service
[root@SYL4 system]# systemctl daemon-reload
[root@SYL4 system]# cd
[root@SYL4 ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@SYL4 ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; ena>
Active: active (running) since Mon 2022-04-25 21:05:33 CST>
Process: 186993 ExecStart=/usr/local/apache/bin/apachectl s>
Main PID: 188037 (httpd)
Tasks: 6 (limit: 11216)
Memory: 4.3M
CGroup: /system.slice/httpd.service
├─188037 /usr/local/apache/bin/httpd -k start
├─188680 /usr/local/apache/bin/httpd -k start
├─188681 /usr/local/apache/bin/httpd -k start
├─188682 /usr/local/apache/bin/httpd -k start
├─188683 /usr/local/apache/bin/httpd -k start
└─188684 /usr/local/apache/bin/httpd -k start
Apr 25 21:05:17 SYL4 systemd[1]: Starting httpd server daemon>
Apr 25 21:05:33 SYL4 apachectl[186993]: AH00558: httpd: Could>
Apr 25 21:05:33 SYL4 systemd[1]: Started httpd server daemon.
[root@SYL4 ~]#
[root@SYL4 ~]# cd /usr/local/apache/htdocs/
[root@SYL4 htdocs]# ls
index.html
[root@SYL4 htdocs]# mkdir www.example.com
[root@SYL4 htdocs]# mkdir blop.example.com
[root@SYL4 htdocs]# cd www.example.com
[root@SYL4 www.example.com]# ls
[root@SYL4 www.example.com]# echo 'www test page' > index.html
[root@SYL4 www.example.com]# cd
[root@SYL4 ~]# cd /usr/local/apache/htdocs/
[root@SYL4 htdocs]# ls
blop.example.com index.html www.example.com
[root@SYL4 htdocs]# rm -rf blop.example.com
[root@SYL4 htdocs]# mkdir blog.example.com
[root@SYL4 htdocs]# cd blog.example.com
[root@SYL4 blog.example.com]# echo 'blog test page' > index.html
[root@SYL4 blog.example.com]# cd
[root@SYL4 ~]#
[root@SYL4 conf]# cd extra/
[root@SYL4 extra]# ls
httpd-autoindex.conf httpd-mpm.conf
httpd-dav.conf httpd-multilang-errordoc.conf
httpd-default.conf httpd-ssl.conf
httpd-info.conf httpd-userdir.conf
httpd-languages.conf httpd-vhosts.conf
httpd-manual.conf proxy-html.conf
[root@SYL4 extra]# vim httpd-vhosts.conf
[root@SYL4 extra]# cat httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/www.example.com"
ServerName www.example.com
ErrorLog "logs/www.example.com-error_log"
CustomLog "logs/www.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/blog.example.com"
ServerName blog.example.com
ErrorLog "logs/blog.example.com-error_log"
CustomLog "logs/blog.example.com-access_log" common
</VirtualHost>
[root@SYL4 extra]#
[root@SYL4 ~]# systemctl restart httpd
[root@SYL4 ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; ena>
Active: active (running) since Mon 2022-04-25 21:22:40 CST>
Process: 256862 ExecStop=/usr/local/apache/bin/apachectl st>
Process: 257892 ExecStart=/usr/local/apache/bin/apachectl s>
Main PID: 258966 (httpd)
Tasks: 6 (limit: 11216)
Memory: 4.3M
CGroup: /system.slice/httpd.service
├─258966 /usr/local/apache/bin/httpd -k start
├─259650 /usr/local/apache/bin/httpd -k start
├─259651 /usr/local/apache/bin/httpd -k start
├─259652 /usr/local/apache/bin/httpd -k start
├─259653 /usr/local/apache/bin/httpd -k start
└─259654 /usr/local/apache/bin/httpd -k start
Apr 25 21:22:25 SYL4 systemd[1]: Starting httpd server daemon>
Apr 25 21:22:40 SYL4 apachectl[257892]: AH00558: httpd: Could>
Apr 25 21:22:40 SYL4 systemd[1]: Started httpd server daemon.
[root@SYL4 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@SYL4 ~]#
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZQgwXX55-1681433245444)(C:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20220425212814296.png)]
[root@SYL4 ~]# cd /usr/local/apache/conf/
[root@SYL4 conf]# ls
extra httpd.conf magic mime.types original
[root@SYL4 conf]# vim httpd.conf
[root@SYL4 conf]# cat httpd.conf |grep vhosta
[root@SYL4 conf]# cat httpd.conf |grep vhosts
Include conf/extra/httpd-vhosts.conf
[root@SYL4 conf]#
[root@SYL4 ~]# systemctl restart httpd
[root@SYL4 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@SYL4 ~]#
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sW5fRW43-1681433245445)(C:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20220425213625738.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dLVJ4OEF-1681433245445)(C:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/image-20220425213656358.png)]
[root@SYL4 ~]# groupadd admins
[root@SYL4 ~]# useradd -G admins harry
[root@SYL4 ~]# useradd -G admins natasha
[root@SYL4 ~]# useradd -s /sbin/nologin alice
[root@SYL4 ~]# echo 'redhat' |passwd --stdin harry
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@SYL4 ~]# echo 'redhat' |passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@SYL4 ~]# echo 'redhat' |passwd --stdin alice
Changing password for user alice.
passwd: all authentication tokens updated successfully.
[root@SYL4 ~]#
[root@SYL4 ~]# which echo
/usr/bin/echo
[root@SYL4 ~]#
[root@SYL4 ~]# su - harry
[harry@SYL4 ~]$ crontab -e
no crontab for harry - using an empty one
crontab: installing new crontab
[harry@SYL4 ~]$ crontab -l
*/5 * * * * /usr/bin/echo wangqing
[harry@SYL4 ~]$
[root@SYL4 ~]# mkdir /home/tools
[root@SYL4 ~]# chown .admins /home/tools
[root@SYL4 ~]# chmod 770 /home/tools
[root@SYL4 ~]# ll /home/tools/
total 0
[root@SYL4 ~]# cd /home/tools/
[root@SYL4 tools]# ll
total 0
[root@SYL4 tools]# ll -d
drwxrwx---. 2 root admins 6 Apr 25 21:39 .
[root@SYL4 tools]# cd
[root@SYL4 ~]# chmod g+s /home/tools
[root@SYL4 ~]# ll -d /home/tools/
drwxrws---. 2 root admins 6 Apr 25 21:39 /home/tools/
[root@SYL4 ~]#
[root@SYL4 ~]# cp /etc/fstab /var/tmp/
[root@SYL4 ~]# chown root:root /var/tmp/fstab
[root@SYL4 ~]#
[root@SYL4 ~]# ll /var/tmp/fstab
-rw-r--r--. 1 root root 579 Apr 25 21:44 /var/tmp/fstab
[root@SYL4 ~]#
[root@SYL4 ~]# setfacl -m u:harry:rw /var/tmp/fstab
[root@SYL4 ~]# setfacl -m u:natasha:--- /var/tmp/fstab
[root@SYL4 ~]# setfacl -m u::r /var/tmp/fstab
[root@SYL4 ~]# getfacl /var/tmp/fstab
getfacl: Removing leading '/' from absolute path names
# file: var/tmp/fstab
# owner: root
# group: root
user::r--
user:harry:rw-
user:natasha:---
group::r--
mask::rw-
other::r--
[root@SYL4 ~]#
[root@SYL4 ~]# useradd -u 2020 wangqing
[root@SYL4 ~]# echo 'redhat'|passwd --stdin wangqing
Changing password for user wangqing.
passwd: all authentication tokens updated successfully.
[root@SYL4 ~]# id wangqing
uid=2020(wangqing) gid=2020(wangqing) groups=2020(wangqing)
[root@SYL4 ~]#
[root@SYL4 ~]# mkdir /root/findfiles
[root@SYL4 ~]# find /etc -size +5M
/etc/udev/hwdb.bin
/etc/selinux/targeted/policy/policy.31
[root@SYL4 ~]# cp /etc/udev/hwdb.bin /root/findfiles
[root@SYL4 ~]# cp /etc/selinux/targeted/policy/policy.31 /root/findfiles
[root@SYL4 ~]#
[root@SYL4 ~]# yum -y install bzip2
[root@SYL4 ~]# tar -jcf /root/backup.tar.bz2 /usr/local/
tar: Removing leading `/' from member names
[root@SYL4 ~]# ls
anaconda-ks.cfg apr-util-1.6.1 findfiles
apr-1.7.0 apr-util-1.6.1.tar.gz httpd-2.4.53
apr-1.7.0.tar.gz backup.tar.bz2 httpd-2.4.53.tar.gz
[root@SYL4 ~]# file backup.tar.bz2
backup.tar.bz2: bzip2 compressed data, block size = 900k
[root@SYL4 ~]#
1)预先创建2GiB的分区/dev/sdb1,并⽤于创建卷组testvg
2)创建⼤⼩为200MiB的逻辑卷/dev/testvg/vo,格式化为xfs⽂件系统, 并挂载在/mnt/vo上
3)将逻辑卷/dev/testvg/vo及其⽂件系统⼤⼩调整300MiB,确保⽂件系统内容保持不变。
[root@SYL4 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write [root@SYL4 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xefe73080.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +2G
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@SYL4 ~]# vgcreate testvg /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
Volume group "testvg" successfully created
[root@SYL4 ~]#
[root@SYL4 ~]# mkdir /mnt/vo
[root@SYL4 ~]# lvcreate -n vo -L 200M teatvg
Volume group "teatvg" not found
Cannot process volume group teatvg
[root@SYL4 ~]# lvcreate -n vo -L 200M testvg
Logical volume "vo" created.
[root@SYL4 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- <17.00g
swap rhel -wi-ao---- 2.00g
vo testvg -wi-a----- 200.00m[root@SYL4 ~]# mkfs.xfs /dev/testvg/vo
[root@SYL4 ~]# mkfs.xfs /dev/testvg/vo
[root@SYL4 ~]# blkid /dev/testvg/vo
/dev/testvg/vo: UUID="def02c3f-d2c3-4f66-bd69-5971df6dceed" BLOCK_SIZE="512" TYPE="xfs"
[root@SYL4 ~]#
[root@SYL4 ~]# vim /etc/fstab
[root@SYL4 ~]# cat /etc/fstab |grep xfs
/dev/mapper/rhel-root / xfs defaults 0 0
UUID="def02c3f-d2c3-4f66-bd69-5971df6dceed" /mnt xfs defaults 0 0
UUID=607eef03-8945-4759-8d33-45d3e47f7dfc /boot xfs defaults 0 0
[root@SYL4 ~]# mount -a
[root@SYL4 ~]#
[root@SYL4 ~]# lvextend -L 300 /dev/testvg/vo
Size of logical volume testvg/vo changed from 200.00 MiB (50 extents) to 300.00 MiB (75 extents).
Logical volume testvg/vo successfully resized.
[root@SYL4 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- <17.00g
swap rhel -wi-ao---- 2.00g
vo testvg -wi-a----- 300.00m
[root@SYL4 ~]#
-L 300 /dev/testvg/vo
Size of logical volume testvg/vo changed from 200.00 MiB (50 extents) to 300.00 MiB (75 extents).
Logical volume testvg/vo successfully resized.
[root@SYL4 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- <17.00g
swap rhel -wi-ao---- 2.00g
vo testvg -wi-a----- 300.00m
[root@SYL4 ~]#