1. 程式人生 > 實用技巧 >CentOS8 初始化相關推薦操作

CentOS8 初始化相關推薦操作

1.設定SSH永不過期

vim /etc/ssh/sshd_config
設定以下內容:
ClientAliveInterval 60
ClientAliveCountMax 3

2.安裝vim

yum install vim -y

3.設定主機名

hostnamectl set-hostname 主機名

4.設定時區(如果需要)

timedatectl set-timezone Asia/Shanghai

5.切換iptables(如果需要)

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
yum install iptables-services -y #vim /etc/sysconfig/iptables systemctl restart iptables.service systemctl enable iptables.service

6.自己安裝的伺服器有可能時間不對,一般雲伺服器不會

date #檢視時間
hwclock --show #檢視硬體時間
yum install ntpdate #可能須要
/usr/sbin/ntpdate time.windows.com #同步系統時間 有可能失敗 換個伺服器或重試
#將硬體時鐘調整為與系統時鐘一致
timedatectl set
-local-rtc 1 #或者 hwclock --systohc --localtime

7.關閉selinux,一般雲伺服器預設都關了

vim /etc/selinux/config
#找到 SELINUX=enfoceing 修改為:
SELINUX=disabled

8.history 記錄時間IP等資訊

echo 'HISTTIMEFORMAT="%F %T `who am i` "' >> /etc/profile
source /etc/profile

9.安裝GCC(如果需要,比如最小安裝找不到make命令時)

yum install gcc*