linux恢复出厂设置命令 一键初始化Linux服务器脚本
原创

linux恢复出厂设置命令 一键初始化Linux服务器脚本

好文
试试语音读文章

热门答案:

linux恢复出厂设置命令(一键初始化Linux服务器脚本)linux恢复出厂设置命令(一键初始化Linux服务器脚本)

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

大家还在搜:

  • linux恢复出厂设置命令
  • 更多网络推广文章推荐

    以上就是由互联网推广工程师 网创网 整理编辑的,如果觉得有帮助欢迎收藏转发~

    相关推荐

    发表评论

    您的电子邮箱地址不会被公开。

    评论(2)

    • 心太野╮ 永久VIP 2022年10月12日 22:44:27

      请输入,初始化,一键,脚本,命令,服务器,放在,用户,请将,要写

    • 长空夕醉 永久VIP 2022年10月12日 22:44:27

      linux恢复出厂设置命令 一键初始化Linux服务器脚本,现在知道了,不过这这篇解答确实也是太好了

    • 浮生三叹 永久VIP 2022年10月12日 22:44:27

      #!/usr/bin/env bash#关闭防火墙close_firewalld(){echo closed