Skip to content

Commit 8c2dd3c

Browse files
RocherKongjaywcjlove
authored andcommitted
Update systemctl.md
make systemctl list-units --type=service correct
1 parent 81bac2e commit 8c2dd3c

File tree

1 file changed

+157
-157
lines changed

1 file changed

+157
-157
lines changed

command/systemctl.md

Lines changed: 157 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,157 @@
1-
systemctl
2-
===
3-
4-
系统服务管理器指令
5-
6-
## 补充说明
7-
8-
**systemctl命令** 是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
9-
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
134-
```
135-
136-
开启防火墙22端口
137-
138-
```
139-
iptables -I INPUT -p tcp --dport 22 -j accept
140-
```
141-
142-
如果仍然有问题,就可能是SELinux导致的
143-
144-
关闭SElinux:
145-
146-
修改`/etc/selinux/config`文件中的`SELINUX=””`为disabled,然后重启。
147-
148-
彻底关闭防火墙:
149-
150-
```
151-
sudo systemctl status firewalld.service
152-
sudo systemctl stop firewalld.service          
153-
sudo systemctl disable firewalld.service
154-
```
155-
156-
157-
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
1+
systemctl
2+
===
3+
4+
系统服务管理器指令
5+
6+
## 补充说明
7+
8+
**systemctl命令** 是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
9+
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
134+
```
135+
136+
开启防火墙22端口
137+
138+
```
139+
iptables -I INPUT -p tcp --dport 22 -j accept
140+
```
141+
142+
如果仍然有问题,就可能是SELinux导致的
143+
144+
关闭SElinux:
145+
146+
修改`/etc/selinux/config`文件中的`SELINUX=””`为disabled,然后重启。
147+
148+
彻底关闭防火墙:
149+
150+
```
151+
sudo systemctl status firewalld.service
152+
sudo systemctl stop firewalld.service          
153+
sudo systemctl disable firewalld.service
154+
```
155+
156+
157+
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->

0 commit comments

Comments
 (0)