1
00:00:00,000 --> 00:00:11,360
The basics of systemd consist of managing the state of a systemd unit.

2
00:00:11,360 --> 00:00:12,600
So how does that work?

3
00:00:12,600 --> 00:00:18,120
Well, you would use the systemctl command to manage everything that is going on.

4
00:00:18,120 --> 00:00:20,760
Systemctl start will start the unit.

5
00:00:20,760 --> 00:00:26,660
Systemctl status will show unit status and systemctl stop will stop it.

6
00:00:26,660 --> 00:00:31,719
To find out about different unit properties, use systemctl show.

7
00:00:31,719 --> 00:00:35,720
Also important is to make sure that units are started automatically when your system

8
00:00:35,720 --> 00:00:36,720
boots.

9
00:00:36,720 --> 00:00:40,040
We call that enabling and disabling units.

10
00:00:40,040 --> 00:00:46,040
Use systemctl enable with the optional argument minus minus now to start it now also if it

11
00:00:46,040 --> 00:00:47,639
hasn't been started yet.

12
00:00:47,639 --> 00:00:51,320
And that will make sure that the unit is automatically started.

13
00:00:51,320 --> 00:00:57,759
And systemctl disable minus minus now takes away automatic starting of the unit.

14
00:00:57,759 --> 00:01:03,840
Systemctl list units will show all units currently loaded and systemctl list dependencies shows

15
00:01:03,840 --> 00:01:07,879
all that was loaded to get to the current system state.

16
00:01:07,879 --> 00:01:13,400
And finally, the command systemctl list unit files shows all unit files on this system.

17
00:01:13,400 --> 00:01:15,360
And it can be convenient as well.

18
00:01:15,360 --> 00:01:17,040
Let's check this out.

19
00:01:17,040 --> 00:01:19,879
So I'm going to demonstrate the Httpd unit.

20
00:01:19,879 --> 00:01:26,400
To start it, I need to install it using dnf install minus y Httpd.

21
00:01:26,400 --> 00:01:32,639
I like to demonstrate Httpd because it's not an essential service that will break functionality

22
00:01:32,639 --> 00:01:35,080
if something is going wrong.

23
00:01:35,080 --> 00:01:42,040
Now let's start by using systemctl status on Httpd where we can see that systemd is

24
00:01:42,040 --> 00:01:47,599
aware of the Httpd.service, but the white dot here is indicating that currently it's

25
00:01:47,599 --> 00:01:48,599
inactive.

26
00:01:48,599 --> 00:01:55,599
We can also see that systemd has found the unit file in userlib systemd system and the

27
00:01:55,599 --> 00:02:01,160
name is Httpd.service, but currently it's disabled and the preset is disabled.

28
00:02:01,160 --> 00:02:09,000
Let me change that using systemctl enable minus minus now Httpd, which is not only going

29
00:02:09,000 --> 00:02:14,080
to flag it for automatic start, but which will start it right now as well.

30
00:02:14,080 --> 00:02:19,440
So when you enable a unit, it's flagged for automatic start and behind the scenes, a symbolic

31
00:02:19,440 --> 00:02:25,679
link is created in the etc systemd system multi-user target dot once directory.

32
00:02:25,679 --> 00:02:30,320
And this symbolic link means that if you enter the multi-user target, it will follow the

33
00:02:30,320 --> 00:02:34,960
symbolic link and as a result, it will automatically start the unit.

34
00:02:34,960 --> 00:02:37,240
Now let's investigate the status again.

35
00:02:37,240 --> 00:02:40,240
As you can see, there's a lot more information now.

36
00:02:40,240 --> 00:02:44,059
So we can see that it is enabled, preset disabled.

37
00:02:44,059 --> 00:02:49,800
That means that the default state of the unit as defined in the package is disabled.

38
00:02:49,800 --> 00:02:55,119
The unit is active and running and we can even see the main process ID of the unit.

39
00:02:55,119 --> 00:02:57,759
That's convenient for process management.

40
00:02:57,759 --> 00:03:02,600
There is the number of tasks, there is the amount of memory it is using and more relevant

41
00:03:02,600 --> 00:03:07,160
information, including the logs for this unit.

42
00:03:07,160 --> 00:03:11,240
These logs are convenient because if anything doesn't work out well, well, you can easily

43
00:03:11,240 --> 00:03:14,160
troubleshoot right here.

44
00:03:14,160 --> 00:03:17,520
Now the unit works with different parameters.

45
00:03:17,520 --> 00:03:19,199
We call them directives.

46
00:03:19,199 --> 00:03:26,440
And if you want to know more about these directives, use systemctl show on httpd dot service.

47
00:03:26,440 --> 00:03:31,240
So systemctl show followed by the name of the unit shows all of the directives that

48
00:03:31,240 --> 00:03:35,300
are relevant for this specific unit.

49
00:03:35,300 --> 00:03:38,940
And there you can see many directives and sometimes you will wonder what is this directive

50
00:03:38,940 --> 00:03:39,940
doing?

51
00:03:39,940 --> 00:03:45,100
Well, if ever you are wondering what is this directive doing, you can look that up.

52
00:03:45,100 --> 00:03:48,580
Let's look up IP accounting, for instance.

53
00:03:48,580 --> 00:03:53,860
To do so, I'm using man systemd dot directives.

54
00:03:53,860 --> 00:03:57,179
And there you can find the list of all directives that exist.

55
00:03:57,179 --> 00:04:04,619
So when I search for IP accounting using forward slash IP account, there we can see

56
00:04:04,619 --> 00:04:09,740
that IP accounting is further defined in systemd resource control 5.

57
00:04:09,740 --> 00:04:10,979
That's a man page.

58
00:04:10,979 --> 00:04:17,619
So if I want to know more about IP accounting, I am going to use man systemd dot resource

59
00:04:17,619 --> 00:04:22,339
control.

60
00:04:22,339 --> 00:04:27,100
And there I can look it up, IP accounting, and I get a description of this directive.

61
00:04:27,100 --> 00:04:29,220
Now this was just one example.

62
00:04:29,220 --> 00:04:32,299
It will work for all directives.

63
00:04:32,299 --> 00:04:36,019
Now we have a couple of units that are listed right now.

64
00:04:36,019 --> 00:04:38,140
I like to figure out which these are.

65
00:04:38,140 --> 00:04:41,779
And to do so, there is systemctl list units.

66
00:04:41,779 --> 00:04:46,700
That will show you a list of all the units and their current state.

67
00:04:46,700 --> 00:04:51,459
That can be convenient, but this is focused on units that are currently active.

68
00:04:51,459 --> 00:04:57,660
If you want to see units that are inactive as well, I would suggest you use systemctl

69
00:04:57,660 --> 00:04:59,339
list unit files.

70
00:04:59,339 --> 00:05:04,660
There we can see the name of the units, nicely grouped by the unit type, and the current

71
00:05:04,660 --> 00:05:05,980
state, and the preset.

72
00:05:05,980 --> 00:05:12,100
So you can see if it is disabled or enabled, and that might give you a hint on what you

73
00:05:12,100 --> 00:05:17,019
need to do to get your system in the desired state.

74
00:05:17,019 --> 00:05:21,619
Now for a nice overview of everything that is happening in the current situation, you

75
00:05:21,619 --> 00:05:28,500
can also use systemctl list dependencies.

76
00:05:28,500 --> 00:05:32,739
That is showing the current state where you are, so the default target.

77
00:05:32,739 --> 00:05:36,420
Default target on a graphical system is graphical.target.

78
00:05:36,420 --> 00:05:39,700
And in the graphical.target, we have a couple of units.

79
00:05:39,700 --> 00:05:44,700
Then graphical.target includes the multi-user target, which has units as well.

80
00:05:44,700 --> 00:05:48,579
And you can see units that are currently running, but also units that are currently

81
00:05:48,579 --> 00:05:50,179
not running.

82
00:05:50,179 --> 00:05:55,100
And even, in some cases, with the Red Cross units that have had an issue.

83
00:05:55,100 --> 00:06:00,579
I like systemctl list dependencies a lot because you get an overview of everything, and you

84
00:06:00,579 --> 00:06:04,100
see the relation between the units in an easy way.

