@@ -7,130 +7,25 @@ systemctl
77
88** systemctl命令** 是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
99
10- <table >
11-
12- <tbody >
13-
14- <tr >
15-
16- <td >任务</td >
17-
18- <td >旧指令</td >
19-
20- <td >新指令</td >
21-
22- </tr >
23-
24- <tr >
25-
26- <td >使某服务自动启动</td >
27-
28- <td >chkconfig --level 3 httpd on</td >
29-
30- <td >systemctl enable httpd.service</td >
31-
32- </tr >
33-
34- <tr >
35-
36- <td >使某服务不自动启动</td >
37-
38- <td >chkconfig --level 3 httpd off</td >
39-
40- <td >systemctl disable httpd.service</td >
41-
42- </tr >
43-
44- <tr >
45-
46- <td >检查服务状态</td >
47-
48- <td >service httpd status</td >
49-
50- <td >systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)</td >
51-
52- </tr >
53-
54- <tr >
55-
56- <td >显示所有已启动的服务</td >
57-
58- <td >chkconfig --list</td >
59-
60- <td >systemctl list-units --type=service</td >
61-
62- </tr >
63-
64- <tr >
65-
66- <td >启动某服务</td >
67-
68- <td >service httpd start</td >
69-
70- <td >systemctl start httpd.service</td >
71-
72- </tr >
73-
74- <tr >
75-
76- <td >停止某服务</td >
77-
78- <td >service httpd stop</td >
79-
80- <td >systemctl stop httpd.service</td >
81-
82- </tr >
83-
84- <tr >
85-
86- <td >重启某服务</td >
87-
88- <td >service httpd restart</td >
89-
90- <td >systemctl restart httpd.service</td >
91-
92- </tr >
93-
94- </tbody >
95-
96- </table >
97-
98- ### 实例
99-
100- 1.启动nfs服务
101-
102- ```
103- systemctl start nfs-server.service
104- ```
105-
106- 2.设置开机自启动
107-
108- ```
109- systemctl enable nfs-server.service
110- ```
111-
112- 3.停止开机自启动
113-
114- ```
115- systemctl disable nfs-server.service
116- ```
117-
118- 4.查看服务当前状态
119-
120- ```
121- systemctl status nfs-server.service
122- ```
123-
124- 5.重新启动某服务
125-
126- ```
127- systemctl restart nfs-server.service
128- ```
129-
130- 6.查看所有已启动的服务
131-
132- ```
133- systemctl list-units --type=service
10+ | 任务 | 旧指令 | 新指令 |
11+ | ---- | ---- | ---- |
12+ | 使某服务自动启动 | chkconfig --level 3 httpd on | systemctl enable httpd.service |
13+ | 使某服务不自动启动 | chkconfig --level 3 httpd off | systemctl disable httpd.service |
14+ | 检查服务状态 | service httpd status | systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active) |
15+ | 显示所有已启动的服务 | chkconfig --list | systemctl list-units --type=service |
16+ | 启动某服务 | service httpd start | systemctl start httpd.service |
17+ | 停止某服务 | service httpd stop | systemctl stop httpd.service |
18+ | 重启某服务 | service httpd restart | systemctl restart httpd.service |
19+
20+ ### 实例
21+
22+ ``` bash
23+ systemctl start nfs-server.service . # 启动nfs服务
24+ systemctl enable nfs-server.service # 设置开机自启动
25+ systemctl disable nfs-server.service # 停止开机自启动
26+ systemctl status nfs-server.service # 查看服务当前状态
27+ systemctl restart nfs-server.service # 重新启动某服务
28+ systemctl list-units --type=service # 查看所有已启动的服务
13429```
13530
13631开启防火墙22端口
@@ -143,11 +38,11 @@ iptables -I INPUT -p tcp --dport 22 -j accept
14338
14439关闭SElinux:
14540
146- 修改` /etc/selinux/config ` 文件中的` SELINUX=”” ` 为disabled,然后重启。
41+ 修改` /etc/selinux/config ` 文件中的` SELINUX="" ` 为disabled,然后重启。
14742
14843彻底关闭防火墙:
14944
150- ```
45+ ``` bash
15146sudo systemctl status firewalld.service
15247sudo systemctl stop firewalld.service
15348sudo systemctl disable firewalld.service
0 commit comments