Files
nexus/wiki/concepts/systemd.md
2026-04-16 20:05:13 +08:00

61 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: systemd
title: "systemd"
type: concept
tags: [linux, service-manager]
date: 2026-04-16
---
## Definition
systemd 是 Linux 系统的服务管理器,负责管理系统进程、服务和启动项,是大多数现代 Linux 发行版的初始系统。
## Key Components
- **systemd**:系统和服务管理器
- **systemctl**:命令行管理工具
- **journald**:日志收集系统
- **unit files**:服务配置文件(.service
## Common Commands
```bash
# 启动服务
sudo systemctl start <service>
# 停止服务
sudo systemctl stop <service>
# 重启服务
sudo systemctl restart <service>
# 查看状态
sudo systemctl status <service>
# 开机自启
sudo systemctl enable <service>
# 禁用开机自启
sudo systemctl disable <service>
# 查看日志
sudo journalctl -u <service>
```
## Unit File Structure
```ini
[Unit]
Description=<description>
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/path/to/executable
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
```
## Connections
- [[systemd]] ← manages ← [[Linux系统服务]]
- [[systemd]] ← writes_logs_to ← [[journald]]