购买
下载掌阅APP,畅读海量书库
立即打开
畅读海量书库
扫码下载掌阅APP

1.3.1 Linux基础参数配置

由于系统是使用最小化的方式安装的,因此在安装并启动后只能通过文本界面的方式来对系统进行日常的维护管理,在启动后会看到文本登录认证界面。

Linux系统的最高权限用户是root,系统参数的大部分操作都需要来自该用户的权限,但由于权限过大,使得即使无意间执行一个错误的操作,也可能会导致系统宕机或重启时无法启动,因此在使用root账号的过程中需要多注意,特别是涉及系统核心参数的更改时更要注意。

登录系统后,需要对SELinux的配置进行更改。SELinux属于安全模块,启动后会对一些部署在系统中的应用的正常运行有限制,不过该模块的功能使用得并不多,因此建议把它关闭,不然在启动应用后可能无法访问。

要关闭SELinux的功能,需要更改它的配置文件/etc/selinux/config,该文件的内容如下:


# 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=enforcing 
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

关闭SELinux时要把SELinux的值更改为disabled,即用vi命令打开该文件,并按a或i键进入编辑模式后更改,更改后按Esc键,以“:wq”方式保存并退出(不包括双引号)。注意,更改SELinux的配置需要重启系统,这样才能够永久性生效。

另外,有些环境中并不要求使用防火墙,因此可根据实际需要来决定开启或关闭防火墙。

防火墙默认处于运行状态,可以使用以下命令来查看它(使用q键退出):


[root@centos-s8 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-11-30 21:00:53 CST; 2h 15min ago
     Docs: man:firewalld(1)
 Main PID: 925 (firewalld)
    Tasks: 2 (limit: 12318)
   Memory: 36.3M
   CGroup: /system.slice/firewalld.service
           └─925 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid
 
Nov 30 21:00:52 centos8 systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 30 21:00:53 centos8 systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 30 21:00:53 centos8 firewalld[925]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configura>

如果要关闭防火墙,可以执行以下命令:


[root@centos-s8 ~]# systemctl stop firewalld.service

要永久性关闭防火墙,可以执行以下命令:


[root@centos-s8 ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

最后,建议在/etc/hosts配置文件中进行主机名与IP地址之间的映射(解析),即实现主机名的本地解析。


127.0.0.1   localhost localhost.localdomain localhost4 localhost4. localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.50   centos-s8 

最后,使用reboot命令来重启系统。

这样,系统的基础环境初始化完成。

运维前线

对于在虚拟机下安装的系统,由于是用于学习和测试的,因此对系统的配置参数进行更改和安装相关的软件都很正常,但安装的软件过多会对测试造成一定的影响。为了减少甚至避免测试过程中受到影响,建议使用最纯洁的系统来测试(刚安装好的系统),这样才能够发现问题所在,但这意味着需要重复安装系统。

为了减少重复安装系统带来的麻烦,建议对刚安装并初始化的系统(其实就是该虚拟机的相关文件)进行备份,并在需要使用时直接复制,覆盖之前使用过的系统(文件),而不需要再次进行安装,从而节省大量的时间。

另外,对于系统中安装的一些软件或一些重要的配置,建议也进行备份。

在需要关闭系统时,只需要在终端提示符上执行“shutdown -h now”命令并按回车键就可以。 /vVONk+W4WSVT//XHyOygEciMbMm2cm0yLjowhUQjedJWywR9EbLkdf1qMhRBhlY

点击中间区域
呼出菜单
上一章
目录
下一章
×