码迷,mamicode.com
首页 > 系统相关 > 详细

linux命令大全详解

时间:2015-09-21 01:44:08      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:linux

#!/bin/bash
if [[ "$(whoami)" != "root" ]]; then
 echo "Please run this script as root." >&2
 exit 1
fi
echo "------- system init ---------"
echo "------- epel -------"
cd /etc/yum.repos.d/
if [ -f CentOS-Base.repo ];then
  mv CentOS-Base.repo{,.bak}
else
  mv rhel-source.repo{,.bak}
fi
curl -I -s http://172.16.4.250|grep "OK" &> /dev/null
if [[ $? -eq 0 ]];then
  wget http://172.16.4.250/base.repo &> /dev/null
  sleep 3
else
  exit 4
fi
echo "------ close firewall and selinux---"
cp /etc/selinux/config /etc/selinux/config.bak
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
setenforce 0
/etc/init.d/iptables stop &> /dev/null
chkconfig iptables off
sleep 3
echo "------- ntp ---------"
echo "20 * * * * /usr/sbin/ntpdate 172.16.0.213 &> /dev/null" >> /var/spool/cron/root
/usr/sbin/ntpdate 172.16.0.213 &> /dev/null
/etc/init.d/crond restart &> /dev/null
sleep 3
read -p ‘PLZ input a name:‘ name
sed -i ‘s/HOSTNAME=localhost/HOSTNAME=$name/‘ /etc/sysconfig/network
/bin/hostname $name
echo "-----limits-----"
cat >> /etc/security/limits.conf << EOF
* soft nofile 65535
* hard nofile 65535
EOF
ulimit -HSn 65535
echo "-----sysctl(system kernel)--------"
/bin/cp /etc/sysctl.conf /etc/sysctl.conf.`date + %F`
cat>>/etc/sysctl.conf<<EOF
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 87380 16777216
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.ip_local_port_range = 1024 65535
EOF
/sbin/sysctl -p &> /dev/null
echo "------ init finish ------"


本文出自 “IT大壮-Carlton” 博客,转载请与作者联系!

linux命令大全详解

标签:linux

原文地址:http://xuxingzhuang.blog.51cto.com/9924392/1696599

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!