CentOS 7/8 初始化相关推荐操作

1.安装vim

yum install epel-release
yum
install vim -y

2.设置SSH永不过期

vim /etc/ssh/sshd_config
设置以下内容:
ClientAliveInterval 60
ClientAliveCountMax 3

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.自己安装的服务器有可能时间不对,一般云服务器不会(此项限centos7)

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 -y install gcc gcc-c++ libstdc++-devel

 10.解决/etc/rc.local开机不自动运行

systemctl list-dependencies multi-user.target | grep rc-local
#如果没有输出说明不正常

chmod +x /etc/rc.d/rc.local
systemctl daemon-reload

#再次执行
systemctl list-dependencies multi-user.target | grep rc-local
#输出
● ├─rc-local.service

 11.升级系统及内核

yum -y update

 

 

原文地址:https://www.cnblogs.com/dotqin/p/13560054.html