第一題
- 打包/etc/目錄下面所有conf結(jié)尾的文件,壓縮包名稱為當(dāng)天的時(shí)間,并拷貝到/usr/local/src目錄備份。
[root@localhost alsa]# find /etc/ -name "*.conf" |xargs tar zcvf /usr/local/src/`date +%F`.tar.gz
第二題 查找當(dāng)前系統(tǒng)上沒有屬主或?qū)俳M,且最近一個(gè)周內(nèi)曾被訪問過的文件或目錄
[root@localhost ~]# find / \( -nouser -o -nogroup -a -atime -7 \)
第三題 查找/etc目錄下至少有一類用戶沒有執(zhí)行權(quán)限的文件
[root@localhost ~]# find /etc/ -not -perm /111 -ls
68003193 4 -rw-r--r-- 1 root root 451 May 20 00:31 /etc/httpd/conf.modules.d/01-cgi.conf
68341886 4 -rw-r--r-- 1 root root 496 May 20 00:33 /etc/httpd/conf.modules.d/README
101516644 12 -rw-r--r-- 1 root root 11899 May 20 00:31 /etc/httpd/conf/httpd.conf
101516645 16 -rw-r--r-- 1 root root 13064 May 20 00:33 /etc/httpd/conf/magic
35224550 4 -rw-r----- 1 root root 3181 May 18 2020 /etc/sudo-ldap.conf
35224551 4 -rw-r----- 1 root root 1786 May 18 2020 /etc/sudo.conf
35224552 8 -r--r----- 1 root root 4328 May 18 2020 /etc/sudoers
35239063 8 -rw-r--r-- 1 root root 5165 May 11 2019 /etc/man_db.conf
35239854 8 -rw-r--r-- 1 root root 4760 Nov 8 2019 /etc/enscript.cfg
35239980 12 -rw-r--r-- 1 root root 9450 May 11 2019 /etc/nanorc
2286514 4 -rw-r--r-- 1 root root 69 May 24 12:55 /etc/nvme/hostnqn
2286515 4 -rw-r--r-- 1 root root 37 May 24 12:55 /etc/nvme/hostid
35247646 4 -rw-r--r-- 1 root root 1362 May 14 2019 /etc/pbm2ppa.conf
35247647 8 -rw-r--r-- 1 root root 6300 May 14 2019 /etc/pnm2ppa.conf
35286917 4 -rw-r--r-- 1 root root 272 May 11 2017 /etc/mailcap
35286918 60 -rw-r--r-- 1 root root 60352 May 11 2017 /etc/mime.types
35593052 4 -rw-r--r-- 1 root root 19 May 24 13:21 /etc/locale.conf
第四題 自建網(wǎng)絡(luò)yum源(通過httpd實(shí)現(xiàn))
1.安裝Http服務(wù)
1.1 安裝httpd服務(wù)
[root@localhost ~]# dnf -y install httpd
1.2 啟動(dòng)httpd服務(wù)
[root@localhost ~]# systemctl start httpd
1.3 查看端口監(jiān)聽狀態(tài)
[root@localhost ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1798/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1099/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1095/cupsd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2341/sshd: root@pts
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 66733/httpd
tcp6 0 0 :::22 :::* LISTEN 1099/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1095/cupsd
tcp6 0 0 ::1:6010 :::* LISTEN 2341/sshd: root@pts
1.4 查看防火墻的工作狀態(tài)
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-06-26 09:02:37 EDT; 2 days ago
Docs: man:firewalld(1)
Main PID: 1007 (firewalld)
Tasks: 2 (limit: 4615)
Memory: 2.5M
CGroup: /system.slice/firewalld.service
└─1007 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid
Jun 26 09:02:35 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 26 09:02:37 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Jun 26 09:02:38 localhost.localdomain firewalld[1007]: WARNING: AllowZoneDrifting is enabled. This is considered>
lines 1-13/13 (END)
1.5 停用防火墻功能方淤,再次查看確認(rèn)處于關(guān)閉狀態(tài)。
[root@localhost ~]# systemctl stop firewalld
2.訪問http服務(wù)
3.創(chuàng)建yum源
3.1 創(chuàng)建文件夾
[root@localhost ~]# mkdir /var/www/html/centos/8 -pv
mkdir: created directory '/var/www/html/centos'
mkdir: created directory '/var/www/html/centos/8'
3.2 掛載光盤
[root@localhost ~]# mount /dev/sr0 /tmp/
mount: /tmp: WARNING: device write-protected, mounted read-only.
3.3 拷貝rpm包
[root@localhost ~]# cp -a /mnt/* /var/www/html/centos/8
[root@localhost 8]# pwd
/var/www/html/centos/8
[root@localhost 8]# ls
AppStream BaseOS EFI images isolinux LICENSE media.repo TRANS.TBL
[root@localhost 8]#
3.4 查看倉庫內(nèi)容
4. 客戶端配置
4.1 客戶端yum配置
[root@localhost ~]# cat /etc/yum.repos.d/test.repo
[BaseOS]
name = BaseOS
baseurl = http://192.168.56.129/centos/8/BaseOS/
gpgcheck = 1
gpgkey = fire:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[AppStream]
name=Appstream
baseurl = http://192.168.56.129/centos/8/AppStream/
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
4.2 驗(yàn)證yum配置成功
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
AppStream | 4.4 kB 00:00:00
BaseOS | 3.9 kB 00:00:00
(1/2): BaseOS/group_gz | 55 kB 00:00:00
(2/2): BaseOS/primary_db | 1.6 MB 00:00:00
repo id repo name status
AppStream Appstream 5,686
BaseOS BaseOS 1,784
repolist: 7,470
第五題 利用sed 取出ifconfig命令中本機(jī)的IPv4地址
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:e5:0f:96 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.129/24 brd 192.168.56.255 scope global dynamic noprefixroute ens33
valid_lft 1007sec preferred_lft 1007sec
inet6 fe80::fa3f:fac4:982b:b3f5/64 scope link dadfailed tentative noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::58d6:e2f6:3fb3:5bbd/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:01:06:54 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:01:06:54 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# ip a |grep "ens33" |grep "inet" | sed 's/^.*inet//g' | sed 's/brd.*$//g'
192.168.56.129/24
第六題 刪除/etc/fstab文件中所有以#開頭蹄殃,后面至少跟一個(gè)空白字符的行的行首的#和空白字符
[root@localhost data]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon May 24 16:48:36 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/cs-root / xfs defaults 0 0
UUID=76ccc4ba-6504-499d-af17-27d2550ff522 /boot xfs defaults 0 0
/dev/mapper/cs-swap none swap defaults 0 0
[root@localhost data]# cat /etc/fstab | sed 's/^# *//g'
/etc/fstab
Created by anaconda on Mon May 24 16:48:36 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.
After editing this file, run 'systemctl daemon-reload' to update systemd
units generated from this file.
/dev/mapper/cs-root / xfs defaults 0 0
UUID=76ccc4ba-6504-499d-af17-27d2550ff522 /boot xfs defaults 0 0
/dev/mapper/cs-swap none swap defaults 0 0
[root@localhost data]#
第七題 處理/etc/fstab路徑,使用sed命令取出其目錄名和基名
[root@localhost ~]# echo "/etc/fstab" | sed -r 's#^/(.*)/(.*)#\1#'
etc
[root@localhost ~]# echo "/etc/fstab" | sed -r 's#^/(.*)/(.*)#\2#'
fstab
[root@localhost ~]#