From 3bfd62a320444f0b4a4b79debd27b66f9def1824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=8B=E9=91=AB?= <2952978450@qq.com> Date: Sun, 23 Jun 2024 13:57:12 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王友鑫 <2952978450@qq.com> --- ...15\345\212\241\347\256\241\347\220\206.md" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\347\216\213\345\217\213\351\221\253/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" diff --git "a/\347\216\213\345\217\213\351\221\253/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" "b/\347\216\213\345\217\213\351\221\253/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" new file mode 100644 index 0000000..08a7189 --- /dev/null +++ "b/\347\216\213\345\217\213\351\221\253/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" @@ -0,0 +1,55 @@ +## 什么是服务 + +常驻内存在后台运行,响应用户或其他进程的请求,并提供对某种功能服务的程序 + +## 服务管理管什么 + +| 相关命令 | 启用 | 关闭 | 重启 | 重新加载 | 开机自启动 | 查看状态 | 语法 | +| ------------ | ----- | ---- | ------- | -------- | ---------- | -------- | ----------------------- | +| systemctl | start | stop | restart | reload | enable | status | systemctl start nginx | +| service | start | stop | restart | reload | enable | status | service nginx start | +| /etc/init.d/ | start | stop | restart | reload | enable | status | /etc/init.d/nginx start | + +service --status -all :列出所有正在运行的服务 + +## systemctl + +```bash +systemctl start nginx # 启动服务 + +systemctl stop nginx # 关闭服务 + +systemctl restart nginx # 重启服务 + +systemctl status nginx# 显示服务的状态 + +systemctl enable nginx # 在开机时启用服务 + +systemctl disable nginx # 在开机时禁用服务 + +systemctl is-enabled nginx # 查看服务是否开机启动 + +systemctl list-unit-files|grep enabled # 查看已启动的服务列表 + +systemctl list-unit-files # 列出已经安装的服务 + +systemctl --failed # 查看启动失败的服务列表 + +systemctl --version # 查看版本号 +``` + +## service + +服务(service) 本质就是进程,但是是运行在后台的,通常都会监听某个端口,等待其它程序的请求,比如(mysqld , sshd、防火墙等),因此我们又称为**守护进程**,是 Linux 中非常重要的知识点。 + +### service管理指令 + +- 请使用 `service` 指令,查看,关闭,启动 `network` [注意:在虚拟系统演示,因为网络连接会关闭] + 指令: + +```shell +service network status +service network stop +service network start +``` + -- Gitee