linux恢复出厂设置命令“一键初始化Linux服务器脚本”
发布:白小白 时间:2022-10-24 19:25:30#!/usr/bin/env bash
#关闭防火墙
close_firewalld(){
echo “closed firewalld/iptables”
if egrep “7.[0-9]” /etc/redhat-release &>/dev/null; then
systemctl stop firewalld
systemctl disable firewalld
elif egrep “6.[0-9]” /etc/redhat-release &>/dev/null; then
service iptables stop
chkconfig iptables off
fi
}
#关闭SElinux
close_SE(){
echo “SElinux —> disabled”
sed -i ‘/SELINUX/{s/permissive/disabled/}’ /etc/selinux/config
}
#安装jdk
install_jdk(){
java=$(cat /etc/profile | grep JAVA_HOME)
if [ -z “$java” ]; then
echo “请将安装文件
jdk-8u271-linux-x64.tar.gz 存放在/data/soft目录中”
echo “请输入Java安装目录”
read install_home
tar -zxvf /data/soft/jdk-8u271-linux-x64.tar.gz -C $install_home
cd $install_home
basepath=$(cd `dirname $0`; pwd)
JAVA_HOME1=”$basepath/jdk1.8.0_271″
echo “export JAVA_HOME=$basepath/jdk1.8.0_271” >> /etc/profile
echo “export PATH=$JAVA_HOME1/bin:$PATH” >> /etc/bash_profile
echo “export CLASSPATH=$JAVA_HOME1/lib/dt.jar:$JAVA_HOME1/lib/tools.jar” >> /etc/bash_profile
source /etc/bash_profile
else
echo java has installed >> log.txt
fi
}
#创建用户
create_user(){
echo -e “请输入用户名:”
read UserName
id $UserName >&/dev/null && echo “user exist” && exit 3
echo -e “请输入所创建用户的家目录,最后一个/不要写 /bigdata/install”
read userHome
groupadd $UserName
useradd -g $UserName -m -d $userHome $UserName
echo “$UserName ALL=(ALL) ALL ” >> /etc/sudoers
echo “$UserName ALL=(ALL) NOPASSWD:ALL” >> /etc/sudoers
}
close_firewalld
close_SE
install_jdk
create_user
O(∩_∩)O
Copyright©2022 吾尊时尚 www.wuzunfans.com
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。闽ICP备11008833号-10
邮件联系方式: toplearningteam#gmail.com (请将#换成@)