文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>centosserver的基本设定脚本

centosserver的基本设定脚本

时间:2010-06-09  来源:laohuanggua



根据高手前辈整理得到的。不知道算不算完全原创

#!/bin/bash

#date:2010-06-06

#author_email:[email protected]


#设置升级源

cd /etc/yum.repos.d/
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.orig
sed -i -e 's/mirrorlist/#mirrorlist/' CentOS-Base.repo
sed -i -e 's/#baseurl/baseurl/' CentOS-Base.repo
sed -i -e 's/lt.mirrors.sohu.com/mirror.centos.org/' CentOS-Base.repo

#安装工具软件mlocate, crotab,wget,unzip,ntp,fonts-chinese,vim增强版


#install updatedb

yum install mlocate

#install crontab

yum install -y vixie-cron
chkconfig --level 35 crond on

#安装下载工具 wget

yum install -y wget

#安装解压缩工具 unzip

yum install -y unzip

#安装校时软件 ntp

yum install -y ntpdate
echo "/usr/sbin/ntpdate cn.pool.ntp.org" >> /etc/cron.daily/ntpdate

#安装帮助文档

yum install -y man man-pages

#安装vim

yum install -y vim-enhanced

#设置vim

alias vi='vim'

#修改vim配置文件

cp /etc/vimrc /etc/vimrc.orig

#设定一些特性

sed -i -e "39 a set history=1000" /etc/vimrc
sed -i -e "39 a syntax on" /etc/vimrc
sed -i -e "39 a set tabstop=4" /etc/vimrc
sed -i -e "39 a set showmatch" /etc/vimrc
sed -i -e "39 a set vb t_vb=" /etc/vimrc
sed -i -e "39 a set mouse=a" /etc/vimrc
sed -i -e "39 a set ignorecase" /etc/vimrc
sed -i -e "39 a set autowrite" /etc/vimrc
sed -i -e "39 a set ruler" /etc/vimrc


#安装完成后做一些基本的设置

#关闭SELINUX

cp /etc/sysconfig/selinux /etc/sysconfig/selinux.save
sed -i '/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux

#修改主机名,修改俩文件/etc/sysconfig/network和/etc/hosts

sed -i -e "/HOSTNAME/s/^/#/" /etc/sysconfig/network
sed -i -e "$ a HOSTNAME=centos101.hayashi2.com" /etc/sysconfig/network

sed -i -e "/127.0.0.1/c 127.0.0.1    centos101.hayashi2.com centos101 localhost.localdomain localhost" /etc/hosts


#disable IPV6

cp /etc/modprobe.conf /etc/modprobe.conf.save
echo "alias net-pf-10 off" >> /etc/modprobe.conf
echo "alias ipv6 off" >> /etc/modprobe.conf

#设置ssh

#允许root远程登录

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.save
sed -i '/#PermitRootLogin/s/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config

#屏蔽掉GSSAPIAuthentication yes和GSSAPICleanupCredentials yes

sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' /etc/ssh/sshd_config

#取消使用DNS

sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

#44行是#PubkeyAuthentication yes。48行是#RhostsRSAAuthentication no


sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' /etc/ssh/sshd_config

/etc/init.d/sshd restart

#将错误按键的beep声关掉。stop the “beep"


cp /etc/inputrc /etc/inputrc.save
sed -i '/#set bell-style none/s/#set bell-style none/set bell-style none/' /etc/inputrc


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载