在 Linux 系统中,启动管理通常指的是系统启动过程,包括启动内核、加载驱动程序、初始化服务、加载用户空间程序等。Linux 系统使用 init(或 systemd)来管理启动过程。
一、传统方式:init(SysVinit)
在早期的 Linux 发行版(如 Debian、Ubuntu 等)中,使用的是 SysVinit,init 是启动进程的入口。
常见命令:
sudo systemctl start <service>:用于启动服务(适用于 systemd 系统)。sudo service <service> start:用于启动服务(适用于 SysVinit 系统)。sudo reboot:重启系统。sudo shutdown -r now:立即重启系统。
示例:
sudo systemctl start nginx
sudo service apache2 start
sudo reboot
二、现代方式:systemd
在大多数现代 Linux 发行版(如 Fedora、Ubuntu 20+、CentOS 7+)中,使用的是 systemd,这是由 systemd 项目维护的初始化系统。
常见命令:
sudo systemctl start <service>:启动服务。sudo systemctl enable <service>:设置开机自启。sudo systemctl status <service>:查看服务状态。sudo systemctl reboot:重启系统。sudo systemctl poweroff:关机。
示例:
sudo systemctl start sshd
sudo systemctl enable sshd
sudo systemctl status sshd
sudo systemctl reboot
三、查看系统启动顺序(systemd)
sudo systemctl list-units --type=service --all
或:
sudo systemctl list-dependents
四、查看服务状态(systemd)
sudo systemctl status <service>
五、查看开机自启服务
sudo systemctl list-unit-files | grep enabled
六、查看服务是否已启动
sudo systemctl is-active <service>
七、查看日志(系统日志、服务日志)
journalctl -b
journalctl -u <service>
八、重启、关机、休眠等命令
sudo rebootsudo shutdown -r nowsudo shutdown -h now:关机sudo systemctl poweroff:关机sudo systemctl hibernate:休眠
九、查看启动过程(systemd)
sudo systemd-analyze
十、查看启动时间
sudo uptime
总结
| 系统 | 启动管理方式 | 常用命令 |
|---|---|---|
| SysVinit | service |
service <service> start |
| systemd | systemctl |
systemctl start <service> |
如果你有具体的问题,比如:
- 如何启动一个服务?
- 如何设置开机自启?
- 如何查看服务状态?
- 如何查看启动日志?
欢迎继续提问!

