logo
🐧 Linux 命令

Systemd

Systemd Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。

📂 分类 · Linux 命令🧭 Markdown 速查🏷️ 2 个标签
#systemd#service
向下滚动查看内容
返回全部 Cheat Sheets

systemd Core Utilities

systemd utility List
UtilityDescription
systemctlManages services (start, stop, restart, enable, disable, etc.)
journalctlViews and filters logs collected by the systemd journal
loginctlManages user logins and sessions
hostnamectlSets or queries the hostname and related machine metadata
timedatectlSets or queries the system date, time, and NTP settings
systemd-analyzeAnalyzes system boot-up performance
systemd-cgtopMonitors control group resource usage in real time
systemd-runRuns a command as a transient service or scope
resolvectlResolves domain names using the systemd-resolved service
busctlInteracts with the D-Bus message bus system

{.left-text}


Utility Commands

systemctl

systemctl - System Commands

  • Manage systemd units and control system services (start, stop, enable, etc.).
CommandDescription
systemctl haltStop all running software, leave the hardware powered on.
systemctl hibernateSave contents of system memory to disk and power off the hardware.
systemctl poweroffHalt and power off the system.
systemctl rebootReboot the system.

{.left-text}

systemctl - Service Commands

CommandDescription
systemctl start <service>Start a service immediately
systemctl stop <service>Stop a running service
systemctl restart <service>Restart a service
systemctl reload <service>Reload service configuration without restart
systemctl enable <service>Enable service to start at boot
systemctl disable <service>Disable boot-time start
systemctl status <service>Show current status and recent logs
systemctl mask <service>Prevent service from being started
systemctl unmask <service>Remove mask so it can start again
systemctl list-unitsList active units
systemctl list-unit-filesList all unit files and their enabled state

{.left-text}

journalctl
  • Query and filter logs from the systemd journal.
CommandDescription
journalctlShow entire journal
journalctl -bShow logs from current boot
journalctl --list-bootsList all boot sessions
journalctl -b -1Logs from previous boot
journalctl -u <service>Show logs for a specific unit/service
journalctl -n 100Show the last 100 log entries
journalctl -fFollow new log entries (tail -f style)
journalctl -p err..emergShow only error (and above) priority logs
journalctl --disk-usageShow disk usage of journal
journalctl --since todayShow logs since today

{.left-text}

busctl
  • Inspect and monitor D-Bus (Desktop Bus) for debugging or introspection.
CommandDescription
busctl listList all services/peers on the bus
busctl status [SERVICE|PID]Show process info & credentials for service or PID
busctl monitor [SERVICE...]Dump live message traffic, Ctrl+C to stop
busctl capture [SERVICE...]Capture bus traffic to a pcap file
busctl tree [SERVICE...]Show object tree exported by service(s)

{.left-text}

loginctl
  • Manages user sessions and login-related settings.
CommandDescription
loginctl list-sessionsList all active sessions
loginctl list-usersList logged-in users
loginctl user-status <UID>Show all sessions & processes for user <UID>
loginctl session-status <ID>Show detailed info and logs for session <ID>
loginctl show-session <ID>Show machine-parsable properties of a session
loginctl terminate-session <ID>End all processes in session <ID>
loginctl lock-session <ID>Lock the specified session
loginctl unlock-session <ID>Unlock the specified session

{.left-text}

systemd-analyze
  • Analyze system boot performance and unit dependencies.
CommandDescription
systemd-analyzeShow total boot time breakdown
systemd-analyze blameList services ordered by startup time
systemd-analyze plot > boot.svgGenerate SVG visual of boot sequence

{.left-text}

systemd-cgtop
  • Real-time monitoring of resource usage by cgroups (CPU, memory, I/O).
CommandDescription
systemd-cgtopMonitor top cgroups resource usage
systemd-cgtop -cSort cgroups by CPU usage
systemd-cgtop -d <delay>Change refresh delay interval

{.left-text}

timedatectl
  • Manage system date, time, timezone, and NTP synchronization.
CommandDescription
timedatectl statusShow current date/time settings
timedatectl list-timezonesList all available timezones
timedatectl set-timezone <Zone>Set system timezone
timedatectl set-time "YYYY-MM-DD"Manually set date
timedatectl set-time "HH:MM:SS"Manually set time
timedatectl set-ntp trueEnable NTP sync
timedatectl set-ntp falseDisable NTP sync

{.left-text}

resolvectl
  • Interact with systemd-resolved DNS resolver service.
CommandDescription
resolvectl statusShow DNS configuration and link info
resolvectl query <hostname>Resolve hostname via systemd-resolved
resolvectl dns <interface> <IP>Set DNS server(s) for a specific interface
resolvectl domain <interface> <name>Set search domain(s) for an interface
resolvectl flush-cachesClear the DNS cache managed by systemd-resolved
resolvectl reset-statisticsReset all DNS resolution statistics

{.left-text}

hostnamectl
  • Query and set the system hostname (static, transient, pretty) and related metadata.

↓ Commands

CommandDescription
hostnamectl statusShow current hostname & system info
hostnamectl hostname <NAME>Set the static/transient/pretty hostname
hostnamectl set-hostname <NAME> --staticSet only the static hostname
hostnamectl set-hostname <NAME> --transientSet only the transient hostname
hostnamectl set-hostname <NAME> --prettySet the pretty (user-friendly) hostname
hostnamectl set-chassis <TYPE>Set chassis type (e.g., desktop, laptop, server)

{.left-text}

↓ Description

MARKDOWN
滚动查看更多
-   Static - The permanent hostname stored in `/etc/hostname`. Used at boot time.
-   Transient - Temporary hostname set at runtime (often by DHCP or manually). Lost on reboot.
-   Pretty - A user-friendly, display name (can include spaces and special characters).

{.left-text}

systemd-run
  • Run a command as a transient systemd unit (service, scope, timer, etc.).
CommandDescription
systemd-run <command>Run command as a transient .service unit
systemd-run -p BlockIOWeight=10 updatedbRun with a specific resource limit property
systemd-run -p MemoryMax=100M script.shRun a memory-hungry task with a memory usage limit
systemd-run --on-calendar='YYYY-MM-DD HH:MM' script.shSchedule script to run at a specific date and time
systemd-run -E VAR=value script.shRun a script with environment variables set

{.left-text}

Types of systemd limits{.col-span-3}

MARKDOWN
滚动查看更多
There are different kinds of limit that can be imposed:

-   CPU Limits
-   Memory Limits
-   I/O Limits
-   Task/Thread Limits
-   Security/Isolation
-   Execution/Environment

Example

BASH
滚动查看更多
systemd-run -p MemoryMax=100M -p CPUQuota=50% scriptFile.sh

Also See

相关 Cheat Sheets

1v1免费职业咨询
logo

Follow Us

linkedinfacebooktwitterinstagramweiboyoutubebilibilitiktokxigua

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png

地址

Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号
Business Hub, 155 Waymouth St, Adelaide SA 5000

Disclaimer

footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议

© 2017-2025 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572