Command & Development/Shell Script

[Shell Script] Linux 설치 후 초기 설정

Richard.Ryu 2023. 1. 31. 15:45
반응형
#!/bin/bash

#check system
#redhat path : /etc/redhat-release
echo "=========Version========="
echo `cat /etc/*release*`
echo "========================="
#kernel check = uname -r
echo "=========Kernel=========="
echo `cat /proc/version | awk '{print $1, $2, $3}'`
echo "========================="


#root password change
#passwd

#yum update & package install
#yum clean all
#yum update
yum -y install net-tools unzip rdate epel-release wget vim lsof chronyd tree

#ip address
echo "=========befor=========="
cat /etc/sysconfig/network-scripts/ifcfg-ens33 | grep -i onboot #ifcfg-### onboot check
echo "========================"

sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-ens33

echo "=========after=========="
cat /etc/sysconfig/network-scripts/ifcfg-ens33 | grep -i onboot
echo "========================"

#if used ubuntu linux
#apt update
#apt upgrade -y
#apt install net-tools unzip ...etc

#create user
echo "=====user add====="
read user

if [[ -z $user ]]
        then
        echo "Please Check create user"
        else
        useradd $user #user add
        passwd $user #change password
fi

#selinux disabled
echo `cat /etc/selinux/config | grep -i selinux=` #before check
echo " "
sed -i 's/enforcing/disabled/g' /etc/selinux/config #enforcing -> disabled
echo " "
echo `cat /etc/selinux/config | grep -i selinux=` #after check
source /etc/selinux/config

#firewall disabled
#systemctl stop firewalld
#firewall disabled
#systemctl stop firewalld
#systemctl disalbe firewalld

#ssh enable
#netstat -an | grep LISTEN | grep 22
#yum -y install openssh-server openssh-clients
#chkconfig sshd on
#service sshd start

#time set
timedatectl set-timezone Asia/Seoul
hwclock -w #hw time
echo `date`

#chrony set & check
#sed -n '3,7p' /etc/chrony.conf
#sed '/ /a\server time.bora.net
systemctl status chronyd | grep -iE "active|inactive"
#systemctl start chronyd
#systemctl enable chronyd


echo " "
chronyc sources
echo " "
echo "======================"
echo "      Finished        "
echo "======================"

상황에 맞춰 변경하시길 권장드립니다.

반응형