CentOS system optimization script, unfinished

#! /bin/bash

Determine whether a current user is a root user, or if it is not, you will be prompted to use sudo to elevate permissions

if [ $user != "root"]

then

echo "Scripts that require sudo to use"]

exit 1

fi

Set Selinux to off

sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

Download a CentOS yum source

cd /usr/local/src

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

Backup the previous yum source

cd /etc/yum.repo.d/

mv CentOS-Base.repo CentOS-Base.repo.bak

Copy the yum source just downloaded to the /etc/yum.repo.d/ directory

cp /usr/local/src/CentOS6-Base-163.repo ./CentOS-Base.repo

yum clean all #Clear cache information

yum makecache #Regenerate the cache

yum update -y #Upgrade the system and its installation package

Add epel external yum source

cd /usr/local/src

wget http://d1.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm

Install gcc basic library files and sysstat tool

sysstat is a software package that includes a set of tools for testing system performance and efficiency.

yum -y install gcc gcc-c++ vim-enhanced unzip unrar sysstat

yum install -y setuptool setup's main toolkit

yum install -y system-config-network-tui setup supporting network card setup toolkit

yum install -y iptables system-config-securitylevel-tui setup supporting firewall toolkit

yum install --y bash-completion-20090212-1mdv2009.1.noarch command completion toolkit

yum install --y tree.x86_64 tree display directory structure

Configure ntpdate automatic time synchronization

yum -y install ntp

echo "01 01 * * * /usr/sbin/ntpdate ntp.api.bz >> /dev/null 2>&1" >> /etc/crontab

/usr/sbin/ntpdate ntp.api.bz

service crond restart

for i in chkconfig --list  | grep 3:on |awk -F " " '{print $1}'

do

/sbin/chkconfig --level 3 $i off

done

for a in {crond,network,rsyslog,sshd,sysstat}

do

/sbin/chkconfig --level 3 $a on

done

Personalized vim settings

cat >>/root/.vimrc<<EOF

set number #display with line number

set ruler

set nohlsearch

set shiftwidth=2

set tabstop=4 #tab is 4 spaces

set expandtab

set cindent

set autoindent #Automatic alignment

set mouse=v

syntax on

EOF

Hide linux information

echo “” > /etc/issue

This is a historical command

echo "export HISTSIZE=500" >>/etc/profile

echo “export HISTFILE=/dev/null” >>/etc/profile

echo “export HISTFILESIZE=50” >> /etc/profile

echo “export TIMEOUT=300” >>/etc/profile

source /etc/profile

Restart the computer

reboot

Unfinished

I hope you can give me more advice and join a group of 764640548 to learn and make progress together! ! ! ! ! ! ! ! ! !

Recommended Posts

CentOS system optimization script, unfinished
Centos7.2 system optimization original
CentOS 6.X system initialization script
CentOS 7.X system installation and optimization
Centos7.6 operating system installation and optimization record
centos system management
01 CentOS 7.6 switch system language
CentOS7.5-1804 system kernel upgrade
CentOS system startup process
VirtualBox install CentOS system
A centos initialization script
Centos system process management
Centos various time [system time/hardware time]
Centos7 system commonly used commands
Install docker on Centos system
Centos system modify time zone
Centos backend system setup record
Centos6 system boot loading process
Linux centos system boot process
CentOS 6 automatically installs RabbitMQ script
CentOS 7.4 view CPU information (including script)
CentOS7.2 install lepus database monitoring system
Install Centos7 operating system in Docker
001. Installation of enterprise-level CentOS7.6 operating system