CENTOS 6.6初始化SHELL脚本
时间:2016-02-24 00:30来源:blog.51cto.com 作者:“xxlixin” 博客 举报 点击:1717次
这个脚本是在刚安装完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 |
分类:
shell
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)