Linux Installation Optimization Script

Source: Internet
Author: User

Linux server needs to be optimized after installation

Cat >>/server/scripts/youhua.sh<<end


#!/bin/bash

#selinux off

Sed-i ' s/selinux=enforcing/selinux=disabled/'/etc/selinux/config

Setenforce 0

#iptables off

/etc/init.d/iptables stop

Chkconfig iptables off


#add users

Useradd Alvin

echo "142857" |passwd--stdin Alvin

\cp/etc/sudoers/etc/sudoers.ori

echo "Alvin All= (All) Nopasswd:all" >>/etc/sudoers

Tail-l/etc/sudoers

Visudo-c


#services

#chkconfig egrep-v "Crond|sshd|network|rsyslog|sysstat" |awk ' {print "Chkconfig", $, "Off"} ' |bash

lang=en

For Alvin in ' Chkconfig--list|grep 3:on|awk ' {print '} ';d o chkconfig--level 3 $alvin off;done

For Alvin in Crond network Rsyslog sshd sysstat;d o chkconfig--level 3 $alvin on; Done

Chkconfig--list|grep 3:on


#ntpdate

Ntpdate times.aliyun.com

echo ' #time sync ' >>/var/spool/cron/root

Echo ' */5 * * * * */usr/sbin/ntpdate times.aliyun.com >/dev/null 2>&1 ' >>/var/spool/cron/root

Crontab-l


#ulimit

Echo ' *-nofile 65535 ' >>/etc/security/limits.conf

Tail-l/etc/security/limits.conf


#kernel

Cat >>/etc/sysctl.conf << EOF

Net.ipv4.tcp_fin_timeout = 2

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_tw_recycle = 1

Net.ipv4.tcp_syncookies = 1

Net.ipv4.tcp_keepalive_time = 600

Net.ipv4.ip_local_port_range = 400065000

Net.ipv4.tcp_max_syn_backlog = 16384

Net.ipv4.tcp_max_tw_buckets = 36000

Net.ipv4.route.gc_timeout = 100

Net.ipv4.tcp_syn_retries = 1

Net.ipv4.tcp_synack_retries = 1

Net.core.somaxconn = 16384

Net.core.netdev_max_backlog = 16384

Net.ipv4.tcp_max_orphans = 16384


#iptables


Net.nf_conntrack_max = 25000000

Net.netfilter.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_tcp_timeout_established = 180

net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

Net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60

net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120

Eof


#yumrepo

Mv/etc/yum.repos.d/centos-base.repo \

/etc/yum.repos.d/centos-base.repo.backup

Wget-o/etc/yum.repos.d/centos-base.repo \

Http://mirrors.aliyun.com/repo/Centos-6.repo


Mv/etc/yum.repos.d/epel.repo/etc/yum.repos.d/epel.repo.backup

Wget-o/etc/yum.repos.d/epel.repo \

Http://mirrors.aliyun.com/repo/epel-6.repo


#install command

Yum Install tree telnet dos2unix sysstat lrzsz NC nmap-y


#update system

Cd/etc/pki/rpm-gpg

RPM--import/etc/pki/rpm-gpg/rpm-gpg-key*

Yum Update-y


END

This article is from the "Knowledge Change Destiny" blog, please be sure to keep this source http://ahtornado.blog.51cto.com/4826737/1891313

Linux Installation Optimization Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.