1、打包/etc/目录上面所有conf结尾的文件,压缩包名称为当天的工夫,并拷贝到/usr/local/src目录备份。
find /etc/ -regex ".*\.conf$" | xargs tar -zcvf `date +%F`-confs.tar.gz && cp `date +%F`-confs.tar.gz /usr/local/src
2、查找以后零碎上没有属主或属组,且最近一个周内曾被拜访过的文件或目录
find / -nouser -o -nogroup -mtime -7 -ls
3、查找/etc目录下至多有一类用户没有执行权限的文件
find /etc/ ! -perm /111 -ls
4、自建网络yum源(通过httpd实现)
自建网络yum源须要2台机器,一台做server,一台做client
server端操作
以huawei mirror为例
# 配置华为云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo
sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo
yum repolist all
## 应用httpd公布到局域网
dnf -y install httpd
systemctl enable --now httpd
# 同步须要的repos BaseOS AppStream extras
dnf reposync --repoid=BaseOS --download-metadata -p /var/www/html/centos/8
dnf reposync --repoid=AppStream --download-metadata -p /var/www/html/centos/8
dnf reposync --repoid=extras --download-metadata -p /var/www/html/centos
# 配置EPEL指定华为源
touch /etc/yum.repo.d/epel.repo
[epel]
name=EPEL
baseurl=https://repo.huaweicloud.com/epel/8/Everything/x86_64/
gpgcheck=0
# 同步 epel
dnf reposync --repoid=epel --download-metadata -p /var/www/html
# 下载 epel key
wget -P /var/www/html/epel/ https://repo.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-8
# 敞开防火墙
systemctl stop firewalld.service
client配置应用
vim /etc/yum.repos.d/test.repo
[BaseOS]
name=BaseOS
baseurl=http://192.168.0.121/centos/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=Appstream
baseurl=http://192.168.0.121/centos/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[extras]
name=extras
baseurl=http://192.168.0.121/centos/extras/
[epel]
name=epel
baseurl=http://192.168.0.121/epel/
gpgkey=http://192.168.0.121/epel/RPM-GPG-KEY-EPEL-8
yum repolist all
5、利用sed 取出ifconfig命令中本机的IPv4地址
ifconfig | sed -rn '2s/^[^0-9]+([0-9.]+) .*$/\1/p'
6、删除/etc/fstab文件中所有以#结尾,前面至多跟一个空白字符的行的行首的#和空白字符
sed -Ei.bak "s/^#[[:space:]]+(.*)/\1/" /etc/fstab
7、解决/etc/fstab门路,应用sed命令取出其目录名和基名
[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\1#'
etc
[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\2#'
fstab
发表回复