Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos6 anf Centos7 system_init

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

#! / bin/bash

# this script is mainly aimed at tuning the parameters of the system that has just been installed.

# check id root #

If [$(id-u)! = "0"]; then

Echo "You must be root to run this script..."

Exit 1

Fi

# set function #

CentOS6 ()

{

Yum install-y wget

/ usr/bin/wget-qO / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

/ usr/bin/wget-qO / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

Yum install-y tree screen make cmake vim ntpdate telnet nc lrzsz gcc gcc-c++

/ etc/init.d/iptables stop & & chkconfig iptables off

}

CentOS7 ()

{

Yum install-y wget

/ usr/bin/wget-qO / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

/ usr/bin/wget-qO / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

Yum install-y tree screen make cmake vim ntpdate telnet nc lrzsz gcc gcc-c++

Systemctl stop firewalld.service & & systemctl disable firewalld.service

}

# get system Edition #

Edition= `grep-o'[[: digit:]]'/ etc/redhat-release | head-1`

If [$Edition = ='6']; then

Echo-e "\ n\ 033 [34mStart CentOS6 installation.\ 033 [0m\ n"

CentOS6

Elif [$Edition = ='7']; then

Echo-e "\ n\ 033 [34mStart CentOS7 installation.\ 033 [0m\ n"

CentOS7

Else

Echo "This system is not CentOS 6, script execution failed..."

Exit 2

Fi

# the gorgeous split line 6 is different from the command 7, and the same command is written below # #

# disable selinux & & iptables #

Sed-I'/ SELINUX/s/enforcing/disabled/' / etc/selinux/config

Setenforce 0

# set vim #

Sed-I "7a alias vi='vim'" / root/.bashrc

Sed-I "8a alias grep='grep-- color'" / root/.bashrc

# set ssh #

Ssh_cf= "/ etc/ssh/sshd_config"

Sed-I 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' $ssh_cf

Sed-I 's/GSSAPIAuthentication yes/#GSSAPIAuthentication yes/g' $ssh_cf

Sed-I "s/#UseDNS yes/UseDNS no/" $ssh_cf

# set ntpdate #

Echo'* / 4 * / usr/sbin/ntpdate time.windows.com > / dev/null 2 > & 1'> > / var/spool/cron/root

\ cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

#\ cp / usr/share/zoneinfo/America/New_York / etc/localtime New York (West 5)

#\ cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime China (East 8)

#\ cp / usr/share/zoneinfo/Asia/Bangkok / etc/localtime Thailand (East 7)

#\ cp / usr/share/zoneinfo/Asia/Korea / etc/localtime Korea (East 9)

#\ cp / usr/share/zoneinfo/Asia/Tokyo / etc/localtime Japan (East 9)

# set limits #

Echo-e "* soft nofile 65535\ n * hard nofile 65535" > > / etc/security/limits.conf

# set kernel #

> / etc/sysctl.conf

Cat > > / etc/sysctl.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 291

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report