Linux 上的一些有用的shell脚本

1. 在进入 root 模式下 , 想要快速修改 主机hostname  

快速修改 本机 hostname 映射 ,需要 root ,或者你 sudo

echo 'abby001' > /etc/hostname      ( > 这个是用来直接写了覆盖,由于hostname只需要一个)

2.使用 脚本 实现对 hosts 映射的修改

  具体语法是:   

sed -i '$a 你的内容' /etc/hosts
sed -i '$a 192.168.1.101 abby001
192.168.1.101 abby002
192.168.1.101 abby003' /etc/hosts
好像  echo $"vn17-11" >> filename  也能直接追加吧!

 上面是我要追加的三个映射 , 支持 作为换行符,由于是追加,自动换行 , 所以最后一个不用

3.关闭防火墙并禁用 . 这个可以直接写在执行里面 , 需要 root 权限

centos7可用
systemctl stop firewalld.service systemctl disable firewalld.service

4.

原文地址:https://www.cnblogs.com/alpha-cat/p/12873878.html