Inspect unit files in /etc/systemd
In this step, you will explore where systemd stores its unit configuration files and how to view their contents.
Systemd unit files, which define how services and other resources are managed, are typically located in the /etc/systemd/system/
directory. This directory contains unit files installed by the system administrator or packages.
Let's navigate to this directory and list its contents.
Open your terminal if it's not already open.
First, change your current directory to /etc/systemd/system/
using the cd
command:
cd /etc/systemd/system/
Now, list the files in this directory using the ls
command:
ls
You will see a list of .service
, .target
, and other unit files. These files contain the instructions for systemd on how to handle each unit.
Let's inspect the content of the ssh.service
file using the cat
command. Remember, you are currently in the /etc/systemd/system/
directory, so you can refer to the file directly by its name.
cat ssh.service
You will see the content of the ssh.service
file. This file is a plain text file with different sections and directives that tell systemd how to start, stop, and manage the SSH service.
For example, you might see sections like [Unit]
, [Service]
, and [Install]
.
- The
[Unit]
section contains general information about the unit and its dependencies.
- The
[Service]
section defines the commands to execute to start and stop the service.
- The
[Install]
section contains information about how the unit should be installed and enabled.
Understanding the structure and content of these unit files is key to advanced system administration with systemd. While the details can be complex, simply knowing where to find them and how to view them is a great start.
You can use less
instead of cat
to view the file content page by page, which is helpful for larger files:
less ssh.service
Press q
to exit less
.
Click Continue to complete this lab.