1、打包/etc/目录下面所有conf结尾的文件,压缩包名称为当天的时间,并拷贝到/usr/local/src目录备份。

[root@tianpp ~]# cd /etc/
[root@tianpp etc]#find ./ -name "*.conf" -exec tar -zcvf /usr/local/src/conf_`date +%Y%m%d`.tar.gz {} \; &>/dev/null
[root@tianpp etc]# ls -lrt /usr/local/src/
总用量 4
-rw-r--r--. 1 root root 151 7月  27 22:08 conf_20210727.tar.gz

2、查找当前系统上没有属主或属组,且最近一个周内曾被访问过的文件或目录

[root@tianpp /]# find ./ \( -nogroup -o -nouser \) -a -atime -7

3、查找/etc目录下至少有一类用户没有执行权限的文件

[root@tianpp ~]# cd /etc/
[root@tianpp etc]# find ./ -not -perm /111

4、自建网络yum源(通过httpd实现)

V0.1机器:

[root@tianpp ~]# ping www.baidu.com -c1
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=128 time=10.5 ms

--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.450/10.450/10.450/0.000 ms
[root@tianpp ~]# cd /etc/yum.repos.d/
[root@tianpp yum.repos.d]# mkdir backup
[root@tianpp yum.repos.d]# mv *.repo backup/
[root@tianpp yum.repos.d]# vim tian.repo
[root@tianpp yum.repos.d]# cat tian.repo 
[AppStream]
name=AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[BaseOS]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///var/www/html/yum_repolist/RPM-GPG-KEY-EPEL-8
[root@tianpp ~]# dnf repolist
repo id                                                repo name
AppStream                                              AppStream
BaseOS                                                 BaseOS
epel                                                   epel
extras                                                 extras
[root@tianpp ~]# dnf --quiet -y install httpd
[root@tianpp ~]# rpm -qa httpd
httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64
[root@tianpp ~]# systemctl enable httpd --now
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@tianpp ~]# systemctl status httpd
[root@tianpp ~]# systemctl stop firewalld.service 
[root@tianpp ~]# systemctl disable firewalld.service 
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@tianpp ~]# systemctl status firewalld.service 
[root@tianpp ~]# cd /var/www/html/
[root@tianpp html]# mkdir yum_repolist
[root@tianpp html]# cd yum_repolist
[root@tianpp yum_repolist]# wget https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-8
[root@tianpp yum_repolist]# dnf reposync --repoid=AppStream --download-metadata -p .
[root@tianpp yum_repolist]# dnf reposync --repoid=BaseOS --download-metadata -p .
[root@tianpp yum_repolist]# dnf reposync --repoid=epel --download-metadata -p .
[root@tianpp yum_repolist]# dnf reposync --repoid=extras --download-metadata -p .

image.png  

V0.2机器:

[root@tianpp-02 ~]# yum --quiet -y install telnet
[root@tianpp-02 ~]# rpm -qa telnet
telnet-0.17-76.el8.x86_64
[root@tianpp-02 ~]# telnet 192.168.204.130 80
Trying 192.168.204.130...
Connected to 192.168.204.130.
Escape character is '^]'.
^]
telnet> quit
Connection closed.

[root@tianpp-02 ~]# cd /etc/yum.repos.d/
[root@tianpp-02 yum.repos.d]# mkdir backup
[root@tianpp-02 yum.repos.d]# mv *.repo backup/
[root@tianpp-02 yum.repos.d]# vim tian.repo
[root@tianpp-02 yum.repos.d]# cat tian.repo 
[AppStream]
name=AppStream
baseurl=http://192.168.204.130/yum_repolist/AppStream
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[BaseOS]
name=BaseOS
baseurl=http://192.168.204.130/yum_repolist/BaseOS
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[extras]
name=extras
baseurl=http://192.168.204.130/yum_repolist/extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[epel]
name=epel
baseurl=http://192.168.204.130/yum_repolist/epel
enabled=1
gpgcheck=1
gpgkey=http://192.168.204.130/yum_repolist/RPM-GPG-KEY-EPEL-8
[root@tianpp-02 yum.repos.d]# dnf repolist
仓库标识                                                                                                                               仓库名称
AppStream                                                                                                                              AppStream
BaseOS                                                                                                                                 BaseOS
epel                                                                                                                                   epel
extras                                                                                                                                 extras
[root@tianpp-02 yum.repos.d]#

5、利用sed 取出ifconfig命令中本机的IPv4地址

[root@tianpp ~]# ifconfig |sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
192.168.204.130
或者:
[root@tianpp ~]# ifconfig ens160 |sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)#\2#gp'
192.168.204.130

6、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@tianpp-02 ~]# cat /etc/fstab |sed -r 's/^#\ ?(.*)/\1/'| sed '/^$/d'
/etc/fstab
Created by anaconda on Mon Feb 22 06:53:51 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/cl-root     /                       xfs     defaults        0 0
UUID=5dab4c15-71d7-4215-9a00-3b7693db4243 /boot                   ext4    defaults        1 2
/dev/mapper/cl-home     /home                   xfs     defaults        0 0
/dev/mapper/cl-swap     swap                    swap    defaults        0 0

7、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@tianpp-02 ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\1#'
etc
[root@tianpp-02 ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\2#'
fstab