#!/bin/bash
# date:2019-03-19
#Author:GuoRi
a=`ifconfig |grep -w inet|awk 'NR==1{print$2}'`
b=hostname
echo "$a $b" >> /etc/hosts
--------------------赛选出本机IP------------
ifconfig |grep -w inet|awk 'NR==1{print$2}'
赛选出本机IP
ifconfig |grep -w inet
完全匹配inet的信息
|awk '{print$2}'
过滤2列
'NR==1
选择第一个IP
---------------------------------------------------------
a=`ifconfig |grep -w inet|awk 'NR==1{print$2}'`
给a赋值:本机IP
echo "$a"
打印a
echo "$a $b" >> /etc/hosts
将a和b的值写入文件
---------------------------------------------------------------
sed -i '7s/enforcing/disabled/g' /etc/selinux/config
替换第7行代码
/enforcing/disabled/
被替换与替换的字符
------------------------------------------
-e多重匹配
sed -i -e '7s/disabled/enforcing/g' -e /etc/selinux/config ''
^ 行首
timedatectl list-timezones|grep shang
设置时区位上海
sed -i '8s/^/server controllwe iburst/g' /etc/con
=================================================
-------------------------完整代码-------------
#!/bin/bash
# date:2019-03-19
#Author:GuoRui
#配置域名映射
echo "配置域名映射"
a=`ifconfig |grep -w inet|awk 'NR==1{print$2}'`
b=`hostname`
echo "$a $b" >> /etc/hosts
sed -i '7s/enforcing/disabled/g' /etc/selinux/config
iptables -F
iptables -X
iptables -Z
/usr/sbin/iptables-save
yum install -y chronyd
systemctl restart chronyd
systemctl enable chronyd
chronyc sources
=======================echo交互界面==修改数据库密码========================
#!/bin/bash
(
echo "000000"
eleep 3
echo "y"
seleep 10
echo "123456"
seleep 3
echo "123456"
seleep 3
echo "y"
seleep 3
echo "n"
seleep 3
echo "y"
seleep 3
echo "y"
seleep 3
)|mysql_secure_installation
seleep 3===>代表上一条命令成功后等待3秒后执行下一条命令
Powered by ddoss.cn 12.0
©2015 - 2025 ddoss
渝公网安备50011302222260号
渝ICP备2024035333号
【实验平台安全承诺书】
小绿叶技术社区,优化网络中,点击查看配置信息
主机监控系统: 安全防火墙已开启检查cc攻击-下载文件完成后等待10s 恢复访问,检查连接数低于峰值恢复访问
您的IP:216.73.216.110,2025-12-01 15:19:02,Processed in 0.01646 second(s).