CentOS 8.0 基本配置

本文详细介绍如何在CentOS系统中进行关键配置优化,包括修改主机名为Server,关闭SELinux,禁用防火墙,更新系统软件包,以及验证更改是否生效。通过这些步骤,可以显著提升系统的性能和安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 修改主机名

[root@localhost ~]# hostname
localhost.localdomain

[root@localhost ~]# vi /etc/hostname                     //将文件中的“localhost.localdomain”修改为“Server”,需重启后方可生效
localhost.localdomain  ->   Server

2. 关闭selinux

[root@localhost ~]# vi /etc/selinux/config               // 将文件中的“SELINUX=enforcing”修改成“SELINUX=disabled”,需重启后方可生效

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

3. 关闭防火墙并禁止开机自启动

[root@localhost ~]# systemctl stop firewalld.service                   //停止防火墙服务

[root@localhost ~]# systemctl disable firewalld.service                   //禁止防火墙服务开机自启动
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

4. 更新系统软件

[root@localhost ~]# yum -y update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.18.0-5.el7 will be updated
---> Package NetworkManager.x86_64 1:1.18.0-5.el7_7.1 will be an update
---> Package NetworkManager-adsl.x86_64 1:1.18.0-5.el7 will be updated
---> Package NetworkManager-adsl.x86_64 1:1.18.0-5.el7_7.1 will be an update
---> Package NetworkManager-glib.x86_64 1:1.18.0-5.el7 will be updated
---> Package NetworkManager-glib.x86_64 1:1.18.0-5.el7_7.1 will be an update
(中间省略……)
sos.noarch 0:3.7-6.el7.centos
systemd.x86_64 0:219-67.el7_7.1
systemd-libs.x86_64 0:219-67.el7_7.1
systemd-python.x86_64 0:219-67.el7_7.1
systemd-sysv.x86_64 0:219-67.el7_7.1
tuned.noarch 0:2.11.0-5.el7_7.1
Complete!

5. 重启

[root@localhost ~]# reboot

6. 验证主机名

[root@Server ~]# hostname
Server

7.验证防火墙状态

[root@Server ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

8. 验证selinux状态

[root@Server ~]# getenforce
Disabled



作者:复苏的兵马俑
链接:https://www.jianshu.com/p/016e6ba954cb
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

❸杨开泰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值