【Linux】構築時の初期設定メモ

Linuxサーバ(CentOS, Almalinux)構築後に行う設定作業をメモしておく。

yum update -y

# Sudo can be used no password. (Just Intranet.)
visudo
visudo -c

# Create User
useradd <username>
passwd <username>

# Give sudo Authority to created user
usermod -aG wheel almalinux

# Install software packages
tar # For VS Code.
tmux
git
wget
vim
python (miniconda, pyenvy or From AppStream)

# SELinux is disabled. (Just Intranet.)
vim selinux # Disabled

# Auto log.
mkdir ~/logs
vim ~/.bash_profile に script ~/logs/$(date +%Y%m%d_%H%M%S).log を追記

# Enable access with key authentication.
mkdir .ssh
chmod 700 ~/.ssh
vim ~/.ssh/authorized_keys # Register private key of LOCAL
chmod 600 ~/.ssh/authorized_keys

# Disable firewall. (Just Intranet.)
sudo systemctl stop firewalld
sudo systemctl disable firewalld

# Setting static IP.
sudo yum install net-tools
route # Check default gateway
cat /etc/resolve.conf # Check DNS IPadress
sudo nmcli connection modify <NIC> ipv4.addresses "192.168.x.x/24"
sudo nmcli connection modify <NIC> ipv4.gateway 192.168.x.0
sudo nmcli connection modify <NIC> ipv4.dns 192.168.x.0
sudo nmcli connection modify <NIC> ipv4.method manual
sudo nmcli connection down <NIC>
sudo nmcli connection up <NIC>