Linux 开机启动服务可以通过以下步骤实现:

  1. 打开终端,输入命令 'sudo systemctl list-unit-files | grep enabled',查看系统中已启用的服务。

  2. 如果需要开机启动某个服务,可以使用命令 'sudo systemctl enable 服务名',例如 'sudo systemctl enable nginx'。

  3. 如果需要禁止某个服务开机启动,可以使用命令 'sudo systemctl disable 服务名',例如 'sudo systemctl disable nginx'。

  4. 可以使用命令 'sudo systemctl is-enabled 服务名',查看某个服务是否已开机启动,返回值为 'enabled' 表示已开机启动,返回值为 'disabled' 表示未开机启动。

  5. 如果需要立即启动或停止某个服务,可以使用命令 'sudo systemctl start 服务名' 和 'sudo systemctl stop 服务名'。

  6. 如果需要重新加载某个服务的配置文件,可以使用命令 'sudo systemctl reload 服务名'。

  7. 如果需要重启某个服务,可以使用命令 'sudo systemctl restart 服务名'。

Linux 开机启动服务:管理指南及常用命令

原文地址: https://www.cveoy.top/t/topic/nAEY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录