CentOS7 reset script to initialize a new virtual machine
It can be used and needs to be improved.
CentOS7 test
Ha ha
Reset2.0.sh (20190906)
#! / bin/bash
# * *
# Author: 28
# QQ: × × ×
# Date: 2019-08-01
# FileName: reset.sh
# URL: https://blog.51cto.com/14012942
# Description: The test script
# Copyright (C): 2019 Copyright ©site name. All rights reserved.
# *
# set-e
RED= "\ 033 [0ter31m"
GREEN= "\ 033 [0x 32m"
NO_COLOR= "\ 033 [0m"
Modify alias
Modify_alias () {
Cat > > ~ / .bashrc > / etc/profile.d/env.sh
}
Install basic softwar
Install_software () {
Yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils-y
}
Replace the yum source
Replace_yum () {
# wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Curl-o / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Sed-I-e'/ mirrors.cloud.aliyuncs.com/d'-e'/ mirrors.aliyuncs.com/d' / etc/yum.repos.d/CentOS-Base.repo
# wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Curl-o / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Yum makecache
}
Vimvimrc, copy it over.
Modify_vimrc () {
Cat > ~ / .vimrc > / var/spool/cron/root
}
# ssh tuning
Ssh_adjust () {
Cp / etc/ssh/sshd_config {, _ bak}
Sed'/ ^ GSSAPIAuthentication/d' / etc/ssh/sshd_config-I
Sed'/ ^ UseDNS/d' / etc/ssh/sshd_config-I
Echo "GSSAPIAuthentication no" > > / etc/ssh/sshd_config
Echo "UseDNS no" > > / etc/ssh/sshd_config
Systemctl restart sshd
}
# maximum number of file openings
Limits_tune () {
Echo'
Soft nofile 128000hard nofile 256000
Root soft nofile 128000
Root hard nofile 256000
'> > / etc/security/limits.conf
}
Main () {
Judge_root
Check_release
Replace_yum
Install_software
Iptables_selinux_stop
Modify_alias
Modify_vimrc
Timezone_adjust
Time_sync
Limits_tune
Ssh_adjust
Modify_PS1
Modify_eth_card
Bash_completion
}
Main
Reset1.0.sh (20190808)
#! / bin/bash
# * *
# Author: 28
# QQ: × × ×
# Date: 2019-08-01
# FileName: reset.sh
# URL: https://blog.51cto.com/14012942
# Description: The test script
# Copyright (C): 2019 Copyright ©site name. All rights reserved.
# *
# set-e
RED= "\ 033 [0ter31m"
GREEN= "\ 033 [0x 32m"
NO_COLOR= "\ 033 [0m"
Modify alias
Modify_alias () {
Cat > > ~ / .bashrc > / etc/profile.d/env.sh
}
Install basic softwar
Install_software () {
Yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils-y
}
Replace the yum source
Replace_yum () {
# wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Curl-o / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Sed-I-e'/ mirrors.cloud.aliyuncs.com/d'-e'/ mirrors.aliyuncs.com/d' / etc/yum.repos.d/CentOS-Base.repo
# wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Curl-o / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
Yum makecache
}
Vimvimrc, copy it over.
Modify_vimrc () {
Cat > ~ / .vimrc