Systemd Commands
Systemd Command Reference
Systemd is a system and service manager for Linux operating systems. Mastering its commands is crucial for effective system administration. This guide provides essential systemd commands to help you manage services, analyze system performance, and control processes.
Analyze System Startup
Understanding how your system boots and which services take the longest to load is key to optimizing performance. The systemd-analyze command is your primary tool for this.
# To display overall system startup time:
systemd-analyze
# To display startup time at the service level, showing which units take the longest:
systemd-analyze blame
Manage Systemd Units
systemctl is the central command for controlling systemd units, which can be services, sockets, devices, mount points, and more. Here are some fundamental operations:
# To list all active (running) units:
systemctl list-units
# To enable a unit to start automatically at boot:
systemctl enable foo.service
# To disable a unit from starting at boot:
systemctl disable foo.service
# To start a unit immediately:
systemctl start foo.service
# To stop a unit immediately:
systemctl stop foo.service
# To restart a unit:
systemctl restart foo.service
# To check the status of a unit:
systemctl status foo.service
Systemd Unit File Locations
Systemd unit files define how services and other units are managed. Knowing their locations helps in customizing or creating new units.
# System-wide configuration files (highest priority):
/etc/systemd/system
# Default unit files installed by packages:
/usr/lib/systemd/system
Further Resources
For more in-depth information on systemd and its commands, refer to the official documentation: