CENTOS 6.6初始化SHELL脚本
2016-02-23 17:38
519 查看
这个脚本是在刚安装完CENTOS6.6后可能需要进行的操作。在学习CENTOS的时候,可以先运行这个脚本进行一些配置,可以帮助你不会被这些防火墙 yum selinux ip这些困扰。
#!/bin/bash #判断是不是root用户 if [[ "$(whoami)" != "root" ]]; then echo "please run this script as root ." >&2 exit 1 fi echo -e "\033[31m 这个是系统初始化脚本,请慎重运行!确定使用请注释指定行 \033[0m" #请注释下一行 exit 1; #关闭SELINUX selinux(){ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux setenforce 0 } #设置动态ip ip(){ sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0 service network restart > /dev/null } #设置时间时区同步 zone_time(){ rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # 更新时间 /usr/sbin/ntpdate pool.ntp.org echo '*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' > /var/spool/cron/root;chmod 600 /var/spool/cron/root /sbin/service crond restart } #配置yum源 yum_update(){ yum -y install wget cd /etc/yum.repos.d/ mkdir bak mv ./*.repo bak wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo } # 清空iptables规则并保存 iptables(){ iptables -F iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT service iptables save } other(){ # 可以在这里定制你想做的something } main(){ ip yum_update selinux zone_time iptables other } main
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- VBS脚本写的Windows硬件检测工具分享
- 用vbscript实现隐藏任务栏图标的脚本
- 用autoit编写第一个脚本(Hello World)
- VBS调用WMI快速关闭IE的脚本
- Oracle数据库执行脚本常用命令小结
- 收集的ROS防火墙脚本
- JSP脚本漏洞面面观
- shell字符串操作详解
- 不错的批处理脚本 第一部分
- VBS脚本加密/解密VBS脚本(简易免杀版1.1)
- 不错的批处理脚本实例代码 第二部分
- 使用脚本和批处理清除电脑中的痕迹的代码第1/2页