使用systemctl管理Linux开机自启服务:1. 执行systemctl list-unit-files --type=service | grep enabled查看已启用的服务;2. 用systemctl is-enabled 服务名.service检查特定服务是否开机自启;3. 使用systemctl enable/disable 服务名.service启用或禁用服务自启;4. 运行systemctl list-units --type=service --all查看所有服务状态。操作简单高效,是系统维护基础技能。

在Linux系统中,管理开机自启服务主要依赖于systemd(现代发行版如Ubuntu 16.04+、CentOS 7+、Debian 8+等)或传统的SysVinit。大多数情况下,使用systemctl命令即可完成查看和管理操作。
要列出所有在系统启动时自动运行的服务,执行:
systemctl list-unit-files --type=service | grep enabled
这条命令会显示所有已启用(enabled)的服务及其状态,便于你快速识别哪些服务会随系统启动而运行。
如果你想确认某个服务(例如sshd、nginx)是否设置为开机自启,可以使用:
systemctl is-enabled 服务名.service
例如:
systemctl is-enabled sshd.service
返回enabled表示已开启自启,disabled则表示未开启。
启用一个服务开机自启:
systemctl enable 服务名.service
例如:
systemctl enable nginx.service
禁用一个服务开机自启:
systemctl disable 服务名.service
例如:
systemctl disable bluetooth.service
注意:enable/disable 只控制是否开机启动,不会立即启动或停止服务。如需立即生效,配合 start/stop 使用。
查看包括运行状态、是否启用在内的完整信息:
systemctl list-units --type=service --all
该命令列出所有已加载的服务,包含活动(active)和非活动状态,帮助你全面掌握服务运行情况。
基本上就这些常用操作。通过 systemctl 管理服务简单高效,是现代Linux系统维护的基础技能之一。
以上就是LINUX怎么查看启动项_LINUX管理开机自启服务的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号