To narrow down the list of units displayed by the "systemctl list-units" command to only show service units, you can utilize the filtering capabilities provided by systemd. Systemd is a system and service manager for Linux operating systems that provides a range of features to manage and control system services.
When you run the "systemctl list-units" command, it displays a list of all units currently known to systemd, including services, targets, sockets, devices, and more. To filter this list and display only service units, you can use the "–type" option followed by the unit type you want to filter.
In this case, to show only service units, you would use the following command:
systemctl list-units --type=service
This command instructs systemctl to only display service units, filtering out other types of units from the output. The "–type" option is used to specify the unit type, and "service" is the value provided to filter only service units.
By running this command, you will see a list of service units currently running on your system. Each unit will be displayed with its corresponding status, such as running, inactive, or failed, along with other information like the unit name, load state, and description.
For example, the output might look like this:
UNIT LOAD ACTIVE SUB DESCRIPTION cron.service loaded active running Regular background program processing daemon dbus.service loaded active running D-Bus System Message Bus network.service loaded active running LSB: Bring up/down networking sshd.service loaded active running OpenSSH server daemon
This filtered output provides a concise view of the service units, allowing you to focus specifically on services without being cluttered by other unit types.
To narrow down the list of units displayed by "systemctl list-units" to only show service units, you can use the "–type=service" option when running the command. This will filter out other unit types and provide you with a focused view of the service units on your Linux system.
Other recent questions and answers regarding EITC/IS/LSA Linux System Administration:
- How to mount a disk in Linux?
- Which Linux commands are mostly used?
- How important is Linux usage nowadays?
- How does the "conflicts" directive in systemd prevent two units from being active simultaneously?
- What is the purpose of the "requisite" directive in systemd and how is it different from "required by"?
- Why is it recommended to manage dependencies on units that you are creating or managing yourself, rather than editing system units?
- How does the "before" directive in systemd specify the execution order of units?
- What is the difference between weak dependencies and explicit ordering in systemd?
- What is the purpose of the "rescue.target" and how can it be used for troubleshooting without rebooting the system?
- What command can be used to switch between targets in systemd and how is it similar to switching between run levels in sysvinit?
View more questions and answers in EITC/IS/LSA Linux System Administration

