1. Get information about units
The systemctl list-units can be used to quickly get information about all units.
|
|
The systemctl list-dependencies allows you to get the dependency information of the units.
2. units state management
Managing unit status (mainly service type units) via systemctl is the most common operation for users.
|
|
3. units configuration management
The systemctl user can quickly add/remove, configuration information for units and environment variable information. These additional additions are saved as files in the /etc/systemd/system.control/<unit-name>. <unit-type>.d/
directory.
|
|
When users manually edit the units configuration file, they need to reload the configuration with the following command.
4. Environment Variable Management
Systemd has a separate environment variable management system, and there are several ways for users to inject environment variables into systemd-managed processes.
- user-defined service unit configuration using Environment or EnvironmentFile injection for a single unit.
- Injection via systemd global/user environment variables, where there are several ways to manage these two environment variables.
- Setting environment variables via the DefaultEnvironment parameter in
/etc/systemd/system.conf
and/etc/systemd/user.conf
(effective upon system reboot). - Generating environment variables via custom scripts in the
/usr/lib/systemd/system-environment-generators/
and/usr/local/lib/systemd/user-environment-generators/
directories (ref), which can take effect viasystemctl daemon-reload after
the user places the script - The global environment variables of systemd or user-level environment variables are managed with the following command (with the -user argument), but the variables generated in this way are temporary.
- Setting environment variables via the DefaultEnvironment parameter in
|
|
5. remote management
systemctl can manage units on remote hosts based on sshd, and users can execute any command via passwd
or password-free configuration. However, systemctl does not provide parameters to specify the sshd port on the other side, so you can modify /etc/ssh/ssh_config to specify the port number.
|
|
6. manage the operating system
Manage system restart, suspend, etc. via systemctl.
|
|
7. Other command line tools
systemd-analyze provides tools to analyze system boot time and boot process.