Inspect systemd config in /etc/systemd
In the previous steps, we used the systemctl command to interact with systemd. Now, let's look at where systemd stores its configuration files.
The primary directory for systemd configuration files is /etc/systemd. This directory contains subdirectories for different types of unit files and configuration settings.
Let's list the contents of the /etc/systemd directory using the ls command. Remember, /etc is a standard directory in Linux for configuration files.
Type the following command in your terminal and press Enter:
ls /etc/systemd/
You will see a list of directories and files, similar to this:
journald.conf logind.conf networkd.conf resolved.conf system system.conf timesyncd.conf user user.conf
The most important subdirectory here is /etc/systemd/system. This is where system-wide unit files are often placed or linked to. Let's look inside this directory.
Change your current directory to /etc/systemd/system using the cd command.
cd /etc/systemd/system
Now, list the contents of this directory:
ls
You'll see a list of files and directories, many of which are symbolic links (->) pointing to the actual unit files located elsewhere (often in /lib/systemd/system). This is how services are enabled or disabled – by creating or removing these symbolic links.
For example, you might see something like:
multi-user.target.wants -> /lib/systemd/system/multi-user.target.wants
sockets.target.wants -> /lib/systemd/system/sockets.target.wants
...
The .wants directories contain symbolic links to services that should be started when that target is reached. For instance, multi-user.target.wants contains links to services that should run when the system is in a multi-user state (like after booting up).
Let's look inside the multi-user.target.wants directory.
ls multi-user.target.wants/
You'll see a list of services that are enabled to start in the multi-user target.
anacron.service -> ../anacron.service
apache2.service -> ../../apache2.service
...
This shows that apache2.service is linked here, meaning it's enabled to start with the multi-user target.
Exploring the /etc/systemd/system directory helps you understand how systemd organizes and manages the services on your system.
Click Continue to finish this lab.