Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Centos6 anf Centos7 system_init

Shulou Source: shulou.com Published: 2022-06-03 06:06:04 10月04日 Update

#! / 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

Tags: Commands systems different same functions split lines parameters scripts China Japan Thailand New York Korea gorgeous Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Microsoft Xiaomi OPPO Reno