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

CentOS7 reset script to initialize a new virtual machine

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

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

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: 0

*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

Servers

Wechat

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

12
Report