Iafzal: Hey folks, in this lecture,
we will learn about the Systemd-Analyze Command in Linux.
According to freedesktop.org,
"Systemd-Analyze Command is used to determine system boot-up
or boot dash up performance statistics
and retrieve other state and tracing information
from the system and service manager,
and to verify the correctness of unit files."
All right, let's put it in a simpler words.
First of all, as its name suggests,
Systemd-analyze is a part of the Systemd package.
Systemd-analyze helps you to understand
how long your Linux system takes to boot,
by showing the time taken by the kernel,
services, and initrd.
Here, initrd is a temporary root file system
used during the boot process
to initialize the system's hardware.
It also identifies the slowest services,
known as the critical chain, which highlights the service
that takes the longest to start
and may delay the boot process.
Furthermore, it lists services
by start time in the blame list,
helping to identify which services
are slowing down the boot time.
You can also create a graphical boot chart,
check for configuration errors and assess service security.
So this tool is useful for optimizing boot performance,
by identifying and addressing services that delay startup.
So it is a great tool for system administrators
and engineers when it comes
to troubleshooting system-related issue.
So in short, Systemd-Analyze Command
analyzes boot performance, high-lighting slow services,
and providing insights for optimizing startup time.
Now let's quickly go over its history.
In 2010, Systemd-Analyze was developed
as part of the Systemd Project,
which was initiated by Lennart Poettering.
I hope I am pronouncing it right.
All right, and then 2014, it was included
in Red Hat Enterprise Linux 7 and CentOS 7.
All right, as of today, it remains an integral part
of the Systemd Suite and continues to be
widely used tool for Analyzing and Optimizing
the Boot Process in Linux systems.
All right, before any further delay,
let's move on to do some practice.
So I have opened the Putty Session here,
and the first step you always do is to check
who you logged in as,
and for that run the command, whoami.
I am myself.
Which directory you are in.
You are in home directory.
The host name, MyFirstLinuxVM, perfect.
All right, let's first explore
what Systemd-Analyze can do for us.
To dive deeper into its capabilities,
let's check out its manual page
by typing the command man systemd-analyze.
Here you find a wide range of parameters available
in systemd-analyze.
For example, using systemd-analyze,
where the time parameter shows the total boot time.
While the blame parameters list all services
started during boot.
It has approximately 20 different parameters available here.
If you scroll down, you can see each parameters is described
with an example.
You can explore all of them from this manual.
If you scroll down further, you will see a list of options
that can be used for more specific details,
such as viewing only the system instance
or user instance using these options.
All right, let's quit from it
and practice some of its features.
First, let's see the total boot time of our machine,
by typing systemd-analyze,
with the time parameter and pressing Enter.
You can see system startup took a total of 25 seconds,
with approximately two seconds spent on the kernel,
five seconds on the initial RAM disk, which is initrd,
and 17 seconds in user space.
User space means where user applications
and processes run is separate from the kernel,
allowing user to interact with the system
through applications.
Finally, graphical interface was ready in 17 seconds
after user space started.
All right, moving on.
If you want to check which services were started
during boot, type systemd-analyze,
with the blame parameter and hit Enter.
Here, you could see a lot of services were started
during the boot time.
Let's pick one of them as an example,
like a firewalld.service,
which took 860 milliseconds to start
during the systems boot process.
There are almost 43 pages here,
with many services listed.
You can review each of them.
Furthermore, if you want to filter out only the services
that started during boot time for the current user,
in my case it's Iafzal,
you can use the option --user
at the end of the systemd-analyze blame command.
Now you can see it has filtered four processes
with their respective start up times
during the boot processes for Iafzal.
These processes are specific to this user.
And that's the end of the session
on this topic topic, boys and girls.
Now it's your turn to explore run systemd-analyze
on your system to see how your system starts up,
and what might be affecting its performance.
Dive in and discover what's happening behind the scenes.
Now, when someone asks you about a question,
tell me your troubleshooting experience with the system,
definitely make sure you mention
that you used the tool Systemd-Analyze.
I hope you learned something useful in this lecture,
and I'll see you in the next one.