赞
踩
SELinux、系统故障修复、HTTPD/FTP服务搭建、防火墙策略管理、服务管理
SELinux(Security-Enhanced Linux),美国NSA国家安全局主导开发,一套增强Linux系统安全的强制访问控制体系,集成到Linux内核(2.6及以上)中运行,RHEL7基于SELinux体系针对用户、进程、目录和文件提供了预设的保护策略及管理工具;
注意:任何模式变成disabled模式,都要经历重启系统
1)SELinux切换模式:
配置文件:/etc/selinux/config //影响下一次开机,重启生效(类似/etc/hostname)
例如:
- [root@svr7 ~]# setenforce 1 //临时切换运行模式
- [root@svr7 ~]# getenforce //查看当前运行模式
- Enforcing
- [root@svr7 ~]# setenforce 0
- [root@svr7 ~]# getenforce
- Permissive
例如:
- [root@svr7 ~]# vim /etc/selinux/config //修改配置文件
- [root@svr7 ~]# cat /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=permissive //修改默认区域
- # SELINUXTYPE= can take one of three two values:
- # targeted - Targeted processes are protected,
- # minimum - Modification of targeted policy. Only selected processes are protected.
- # mls - Multi Level Security protection.
- SELINUXTYPE=targeted
Web服务提供一个页面内容的服务
- 提供Web服务的软件:Httpd、Nginx(支持并发访问量优秀)、Tomcat(Java)
- Http协议:超文本传输协议(httpd,d表示:daemon进程)
- Httpd默认存放页面路径:/var/www/html/ //安装httpd软件包自动生成路径
- 默认索引页面文件: index.html
1)运行提供web服务程序
提前检查软件包
- [root@svr7 ~]# yum -y install httpd //安装httpd软件包
- [root@svr7 ~]# rpm -q httpd
- httpd-2.4.6-80.el7.centos.x86_64
-
- [root@pc207 ~]# curl http://192.168.4.7 //不运行执行程序则报错
- curl: (7) Failed connect to 192.168.4.7:80; 拒绝连接
- [root@svr7 ~]# which httpd //服务安装完软件包后要运行程序
- /usr/sbin/httpd
- [root@svr7 ~]# /usr/sbin/httpd //绝对路径运行程序
-
- [root@svr7 ~]# vim /var/www/html/index.html //编写页面文件
- [root@svr7 ~]# cat /var/www/html/index.html
- <h1> hello world //<h1>:标题字体
- [root@svr7 ~]# ls /var/www/html/
- index.html
- [root@svr7 ~]# curl http://192.168.4.7
- <h1> hello world

使用火狐浏览器打开:# firefox http://192.168.4.7
补充:Curl命令
Curl是常用的命令行工具,用来请求 Web 服务器。它的名字就是客户端(client)的 URL 工具的意思(支持HTTP、HTTPS、FTP、FTPS、DICT、TELNET、LDAP、FILE等协议)
作用:支持文件上传和下载,所以是综合传输工具
格式:curl [选项...]
常用选项:
- [-l] 只获得对方的响应首部信息
- [-v] 显示一次HTTP请求的通信过程
FTP服务:文本传输协议,传输内容
实现FTP服务功能的软件:vsftpd
默认共享数据的主目录:/var/ftp/
1)运行提供FTP服务程序
提前检查软件包
- [root@svr7 ~]# yum -y install vsftpd //安装vsftpd软件包
- [root@svr7 ~]# rpm -q vsftpd
- vsftpd-3.0.2-22.el7.x86_64
-
- [root@svr7 ~]# curl ftp://192.168.4.7 //不运行执行程序则报错
- curl: (7) Failed connect to 192.168.4.7:21; 拒绝连接
- [root@svr7 ~]# which vsftpd
- /usr/sbin/vsftpd
- [root@svr7 ~]# /usr/sbin/vsftpd //绝对路径运行程序
-
- [root@svr7 ~]# ls /var/ftp/ //查看目录内容
- pub
- [root@svr7 ~]# touch /var/ftp/1.txt //创建文件
- [root@svr7 ~]# curl ftp://192.168.4.7
- -rw-r--r-- 1 0 0 0 Mar 12 03:30 1.txt
- drwxr-xr-x 2 0 0 6 Aug 03 2017 pub

作用:隔离,严格按照策略规则过滤入站、放行出站
防火墙类型:硬件防火墙(Huawei E800)、软件防火墙(360、卡巴斯基)
系统服务:firewalld //开机自启
管理工具:firewall-cmd、firewall-config(图形工具)
根据所在的网络场所区分,预设保护规则集
- [ public ] 仅允许访问本机的sshd、dhcp、ping等少数几个服务
- [ trusted ] 允许任何访问
- [ block ] 拒绝任何来访请求。明确拒绝并回应
- [ drop ] 丢弃任何来访的数据包,不给任何回应
配置规则的位置:
列表查看操作命令:
例如:
- [root@svr7 ~]# firewall-cmd --list-all //查看当前区域规则信息
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
例如:
- [root@svr7 ~]# firewall-cmd --list-all-zones //查看所有区域规则信息
- block
- target: %%REJECT%%
- icmp-block-inversion: no
- interfaces:
- sources:
- services:
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- dmz
- target: default
- icmp-block-inversion: no
- interfaces:
- sources:
- services: ssh
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- drop
- target: DROP
- icmp-block-inversion: no
- interfaces:
- sources:
- services:
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- external
- target: default
- icmp-block-inversion: no
- interfaces:
- sources:
- services: ssh
- ports:
- protocols:
- masquerade: yes
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- home
- target: default
- icmp-block-inversion: no
- interfaces:
- sources:
- services: ssh mdns samba-client dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- internal
- target: default
- icmp-block-inversion: no
- interfaces:
- sources:
- services: ssh mdns samba-client dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- trusted
- target: ACCEPT
- icmp-block-inversion: no
- interfaces:
- sources:
- services:
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- work
- target: default
- icmp-block-inversion: no
- interfaces:
- sources:
- services: ssh dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:

例如:
- [root@svr7 ~]# firewall-cmd --get-zones //查看防火墙有哪些区域
- block dmz drop external home internal public trusted work
例如:
- [root@svr7 ~]# firewall-cmd --get-services //查看防火墙有哪些服务
- RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master high-availability http https imap
- imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kibana klogin kpasswd kshell ldap ldaps libvirt libvirt-tls managesieve mdns mosh mountd ms-wbt mssql mysql nfs nfs3
例如:
- [root@svr7 ~]# firewall-cmd --get-default-zone //查看当前默认区域
- public
默认区域为public,限制较严格(对于开放式环境,建议将默认区域修改为trusted)
针对(运行时 / 永久)配置策略规则时,运行时为临时操作,永久需添加--permanent写入防火墙配置文件,写入后需要配合--reload重新加载配置文件或reboot重启才能生效
防火墙判定原则:根据客户端请求的来源IP地址并查看防火墙区域规则哪个区域有该源IP地址规则,满足规则要求则进入该区域,否则进入默认区域(默认情况下为public)
配置防火墙区域命令:
配置防火墙规则命令(运行时、永久):
注意:permanent只用在防火墙规则,对设置默认区域无效,默认区域设置是永久生效
重载防火墙配置文件命令:
注意:重载防火墙永久策略,临时策略将清空
① 配置防火墙默认区域(指定默认的安全区域)
命令:firewall-cmd --set-default-zone=区域名
例如:修改主机1防火墙默认区域为trusted,主机2实现http和ftp访问
- 主机2:
- [root@pc207 ~]# curl http://192.168.4.7
- curl: (7) Failed connect to 192.168.4.7:80; 没有到主机的路由 //防火墙策略限制
- [root@pc207 ~]# curl ftp://192.168.4.7
- curl: (7) Failed connect to 192.168.4.7:21; 没有到主机的路由
-
- 主机1:配置默认区域
- [root@svr7 ~]# firewall-cmd --get-default-zone //查看防火墙默认区域
- public
- [root@svr7 ~]# firewall-cmd --set-default-zone=trusted //修改防火墙默认区域
- success
- [root@svr7 ~]# firewall-cmd --get-default-zone
- trusted
-
- 主机2:
- [root@pc207 ~]# curl http://192.168.4.7 //验证http服务
- <h1> hello world
- [root@pc207 ~]# curl ftp://192.168.4.7 //验证ftp服务
- -rw-r--r-- 1 0 0 0 Mar 12 03:30 1.txt
- drwxr-xr-x 2 0 0 6 Aug 03 2017 pub

② 配置防火墙规则(默认区域开通服务)< 临时生效 >
命令:firewall-cmd --zone=区域名 --add-service=服务名
例如:修改主机1防火墙默认区域public,添加服务,主机2实现http和ftp访问
- 主机1:
- [root@svr7 ~]# firewall-cmd --set-default-zone=public
- success
- [root@svr7 ~]# firewall-cmd --list-all --zone=public
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client //允许服务中未有添加http和ftp
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules
- 主机2:
- [root@pc207 ~]# curl http://192.168.4.7 //访问失败
- curl: (7) Failed connect to 192.168.4.7:80; 没有到主机的路由 //防火墙策略限制
-
- 主机1:
- [root@svr7 ~]# firewall-cmd --zone=public --add-service=http //添加服务http
- success
- [root@svr7 ~]# firewall-cmd --zone=public --add-service=ftp //添加服务ftp
- success
- [root@svr7 ~]# firewall-cmd --list-all --zone=public
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client http ftp //允许服务中已添加http和ftp
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
- 主机2:
- [root@pc207 ~]# curl http://192.168.4.7 //访问成功
- <h1> hello world
- [root@pc207 ~]# curl ftp://192.168.4.7 //访问成功
- -rw-r--r-- 1 0 0 0 Mar 12 03:30 1.txt
- drwxr-xr-x 2 0 0 6 Aug 03 2017 pub

③ 配置防火墙规则(永久配置-添加)< 永久生效 >
命令:firewall-cmd --permanent --zone=区域名 --add-service=服务名
例如:修改永久防火墙规则配置,并重新加载永久防火墙策略
- [root@svr7 ~]# firewall-cmd --reload //重载防火墙永久策略,临时策略将清空
- success
- [root@svr7 ~]# firewall-cmd --zone=public --list-all
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
- [root@svr7 ~]# firewall-cmd --permanent --zone=public --add-service=http
- success
- [root@svr7 ~]# firewall-cmd --permanent --zone=public --add-service=ftp
- success
- [root@svr7 ~]# firewall-cmd --zone=public --list-all
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
- [root@svr7 ~]# firewall-cmd --reload //重载防火墙永久策略,才能生效
- success
- [root@svr7 ~]# firewall-cmd --zone=public --list-all
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client http ftp
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:

④ 配置防火墙规则(永久配置-删除)< 永久生效 >
命令:firewall-cmd --permanent --zone=区域名 --remove-service=服务名
例如:永久修改并删除ftp服务
- [root@svr7 ~]# firewall-cmd --permanent --zone=public --remove-service=ftp
- success
- [root@svr7 ~]# firewall-cmd --zone=public --list-all
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client http ftp
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
- [root@svr7 ~]# firewall-cmd --reload
- success
- [root@svr7 ~]# firewall-cmd --zone=public --list-all
- public (active)
- target: default
- icmp-block-inversion: no
- interfaces: eth0
- sources:
- services: ssh dhcpv6-client http
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:

⑤ 配置防火墙规则(添加限制网段)
命令:firewall-cmd [--permanent] --zone=区域名 --add-source=网段/IP地址
例如:修改主机1防火墙默认区域规则,拒绝主机2网段、服务访问本机
- 主机1:
- [root@svr7 ~]# firewall-cmd --zone=block --add-source=192.168.4.0/24
- success
- =[root@svr7 ~]# firewall-cmd --zone=block --list-all
- block (active)
- target: %%REJECT%%
- icmp-block-inversion: no
- interfaces:
- sources: 192.168.4.0/24
- services:
- ports:
- protocols:
- masquerade: no
- forward-ports:
- source-ports:
- icmp-blocks:
- rich rules:
-
- 主机2:
- [root@pc207 ~]# curl ftp://192.168.4.7
- curl: (7) Failed connect to 192.168.4.7:21; 没有到主机的路由
- [root@pc207 ~]# curl http://192.168.4.7
- curl: (7) Failed connect to 192.168.4.7:80; 没有到主机的路由
- [root@pc207 ~]# ssh root@192.168.4.7
- ssh: connect to host 192.168.4.7 port 22: No route to host
- [root@pc207 ~]# ping 192.168.4.7
- PING 192.168.4.7 (192.168.4.7) 56(84) bytes of data.
- From 192.168.4.7 icmp_seq=1 Destination Host Prohibited
- From 192.168.4.7 icmp_seq=2 Destination Host Prohibited
- ^C
- --- 192.168.4.7 ping statistics ---
- 2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1000ms

常见报错:已经是block区域报错
- [root@svr7 ~]# firewall-cmd --set-default-zone=block
- Warning: ZONE_ALREADY_SET: block
常见报错:--get不与--list-all共用
- [root@svr7 ~]# firewall-cmd --get-default-zone --list-all
- usage: see firewall-cmd man page
- Can't use stand-alone options with other options.
常见报错:规则冲突
- [root@svr7 ~]# firewall-cmd --zone=block --add-source=192.168.4.0/24
- success
- [root@svr7 ~]# firewall-cmd --zone=trusted --add-source=192.168.4.0/24
- Error: ZONE_CONFLICT: '192.168.4.0/24' already bound to a zone
1)遗忘root用户密码
故障现象:无法执行需要root权限的管理操作,若没有其他可用账号,将无法登录系统;
解决思路:引导进入修复模式,然后重设密码;
步骤1:重启系统,进入recovery恢复模式
步骤2:以可写方式重新挂载/sysroot,并切换到此环境
- Switch_root# mount -o remount,rw /sysroot
- Switch_root# chroot /sysroot
步骤3:将root用户的密码设置为redhat
echo redhat | passwd --stdin root
步骤4:重设SELinux安全标签
touch /.autorelabel
步骤5:先后执行exit、reboot完成恢复
- exit
- reboot
2)系统文件损坏故障
- 故障现象:/etc/fstab文件内容有误,系统无法正常开机
- 解决思路:引导进入恢复模式,然后进行修复
1)init程序的作用(即初始化程序)
Linux系统和服务管理器systemd,是内核引导之后加载的第一个初始化进程(PID=1),负责掌控整个Linux的运行/服务资源组合;
传统的init程序风格:
2)Systemd服务管理器(一个更高效的系统&服务管理器)
开机服务并行启动,各系统服务间的精确依赖
配置目录:/etc/systemd/system/
服务目录:/lib/systemd/system/
主要管理工具:systemctl
3)列出服务常用命令
列出活动的系统服务
列出所有系统服务(包括不活动的)
4)对于服务的管理(与手动启动有冲突)
例如:
- [root@svr7 ~]# yum -y install httpd //安装软件包
- [root@svr7 ~]# rpm -q httpd
- httpd-2.4.6-80.el7.centos.x86_64
- [root@svr7 ~]# > /etc/resolv.conf //清除dns文件内容
- [root@svr7 ~]# /usr/sbin/httpd //手动启动httpd程序
- [root@svr7 ~]# pgrep -lx httpd //查看进程信息
- 3387 httpd
- [root@svr7 ~]# killall httpd //杀死手动启动的httpd,否则会与服务管理器冲突
-
- [root@svr7 ~]# systemctl restart httpd //重启httpd服务
- [root@svr7 ~]# pgrep -lx httpd
- 3420 httpd
- 3430 httpd
- 3431 httpd
- 3432 httpd
- 3433 httpd
- 3434 httpd
- [root@svr7 ~]# systemctl status httpd //查看服务httpd状态
- ● httpd.service - The Apache HTTP Server
- Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
- Active: active (running) since 一 2021-03-15 09:56:17 CST; 36s ago
- Docs: man:httpd(8)
- man:apachectl(8)
- Main PID: 3639 (httpd)
- Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
- Tasks: 6
- CGroup: /system.slice/httpd.service
- ├─3639 /usr/sbin/httpd -DFOREGROUND
- ├─3640 /usr/sbin/httpd -DFOREGROUND
- ├─3641 /usr/sbin/httpd -DFOREGROUND
- ├─3642 /usr/sbin/httpd -DFOREGROUND
- ├─3643 /usr/sbin/httpd -DFOREGROUND
- └─3644 /usr/sbin/httpd -DFOREGROUND
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: Starting The Apache HTTP Server...
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: Started The Apache HTTP Server.
-
- [root@svr7 ~]# systemctl enable httpd //设置httpd开机自启动
- Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
- [root@svr7 ~]# systemctl is-enabled httpd //查看httpd是否是开机自启动
- enabled
-
- [root@svr7 ~]# systemctl disable httpd //关闭httpd开机自启动
- Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
- [root@svr7 ~]# systemctl is-enabled httpd //查看httpd是否是开机自启动
- disabled
-
- [root@svr7 ~]# systemctl stop httpd //停止服务
- [root@svr7 ~]# systemctl status httpd
- ● httpd.service - The Apache HTTP Server
- Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
- Active: inactive (dead)
- Docs: man:httpd(8)
- man:apachectl(8)
- 3月 15 09:53:49 svr7.tedu.cn systemd[1]: Starting The Apache HTTP Server...
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: httpd.service stop-sigterm timed out. Killing.
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: httpd.service: main process exited, code=killed, status=9/KILL
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: Unit httpd.service entered failed state.
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: httpd.service failed.
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: Starting The Apache HTTP Server...
- 3月 15 09:56:17 svr7.tedu.cn systemd[1]: Started The Apache HTTP Server.
- 3月 15 10:19:24 svr7.tedu.cn systemd[1]: Stopping The Apache HTTP Server...
- 3月 15 10:19:25 svr7.tedu.cn systemd[1]: Stopped The Apache HTTP Server.
- Hint: Some lines were ellipsized, use -l to show in full.

1)RHEL6:运行级别,共300个服务
- 0:关机,0个服务(类似poweroff)
- 1:单用户模式(基本功能的实现,破解Linux密码),50个服务
- 2:多用户字符界面(不支持网络),80个服务
- 3:多用户字符界面(支持网络)服务器默认运行级别,100个服务
- 4:暂未定义,0个服务
- 5:图形界面(功能丰富,但占用资源最高),300个服务
- 6:重起,0个服务(类似reboot)
切换运行级别:init 数字
注意:5级别,前提是已安装图形界面工具的软件包;
注意:RHEL8的8.5版本将取消运行级别;
2)RHEL7:运行模式(运行级别)
3)切换运行模式
① 列出可用运行模式
- 命令:systemctl -t target
② 当前直接切换到字符模式 (影响当前)
- 命令:systemctl isolate multi-user.target //相当于原来的init 3
③ 当前直接切换到图形模式(影响当前)
- 命令:systemctl isolate graphical.target //相当于原来的init 5
4)设置默认运行模式
① 查看默认级别
- 命令:systemctl get-default
② 设置默认级别
- 命令:systemctl set-default multi-user.target
- 命令:systemctl set-default graphical.target
例如:
- [root@svr7 ~]# systemctl -t target //列出可运行模式
- UNIT LOAD ACTIVE SUB DESCRIPTION
- basic.target loaded active active Basic System
- cryptsetup.target loaded active active Local Encrypted Volumes
- getty-pre.target loaded active active Login Prompts (Pre)
- getty.target loaded active active Login Prompts
- graphical.target loaded active active Graphical Interface
- local-fs-pre.target loaded active active Local File Systems (Pre)
- local-fs.target loaded active active Local File Systems
- multi-user.target loaded active active Multi-User System
- network-online.target loaded active active Network is Online
- network-pre.target loaded active active Network (Pre)
- network.target loaded active active Network
- nfs-client.target loaded active active NFS client services
- nss-user-lookup.target loaded active active User and Group Name Lookups
- paths.target loaded active active Paths
- remote-fs-pre.target loaded active active Remote File Systems (Pre)
- remote-fs.target loaded active active Remote File Systems
- rpc_pipefs.target loaded active active rpc_pipefs.target
- slices.target loaded active active Slices
- sockets.target loaded active active Sockets
- sound.target loaded active active Sound Card
- swap.target loaded active active Swap
- sysinit.target loaded active active System Initialization
- timers.target loaded active active Timers
- LOAD = Reflects whether the unit definition was properly loaded.
- ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
- SUB = The low-level unit activation state, values depend on unit type.
- 23 loaded units listed. Pass --all to see loaded but inactive units, too.
- To show all installed unit files use 'systemctl list-unit-files'.

例如:切换运行模式为字符模式
[root@svr7 ~]# systemctl isolate multi-user.target
如图所示:
例如:切换运行模式为图形模式
[root@svr7 ~]# systemctl isolate graphical.target
如图所示:
例如:
- [root@svr7 ~]# systemctl set-default multi-user.target //设置默认运行模式
- Removed symlink /etc/systemd/system/default.target.
- Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
- [root@svr7 ~]# systemctl get-default
- multi-user.target
- [root@svr7 /]# reboot //重启验证
例如:设置永久策略,每次开机自动进入graphical.target字符模式
- [root@svr7 ~]# systemctl isolate graphical.target
- [root@svr7 ~]# systemctl set-default graphical.target //设置默认运行模式
- Removed symlink /etc/systemd/system/default.target.
- Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target
- [root@svr7 ~]# systemctl get-default
- graphical.target
- [root@svr7 /]# reboot //重启验证
补充:ssh登录提示
记录用户登录记录/root/.sshr/known_hosts,同一用户登录,记录不一样会报错
本篇章节为 【第一阶段】ENGINEER-DAY5 的学习笔记,可以初步了解到 SELinux、系统故障修复、HTTPD/FTP服务搭建、防火墙策略管理、服务管理。除此之外推荐参考相关学习网址:
Tip:毕竟两个人的智慧大于一个人的智慧,如果你不理解本章节的内容或需要相关笔记、视频,可私信小安,请不要害羞和回避,可以向他人请教,花点时间直到你真正的理解
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。