1 00:00:00,000 --> 00:00:11,360 The basics of systemd consists 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,020 Use systemctl enable with the optional argument minus minus now to start it now also if it 11 00:00:46,020 --> 00:00:51,340 hasn't been started yet, and that will make sure that the unit is automatically started. 12 00:00:51,340 --> 00:00:57,759 And systemctl disable minus minus now takes away automatic starting of the unit. 13 00:00:57,759 --> 00:01:03,840 Systemctl list units will show all units currently loaded, and systemctl list dependencies shows 14 00:01:03,840 --> 00:01:07,879 all that was loaded to get to the current system state. 15 00:01:07,879 --> 00:01:13,400 And finally, the command systemctl list unit files shows all unit files on this system, 16 00:01:13,400 --> 00:01:15,360 and that can be convenient as well. 17 00:01:15,360 --> 00:01:17,040 Let's check this out. 18 00:01:17,040 --> 00:01:21,040 So I'm going to demonstrate the HHPD unit. 19 00:01:21,739 --> 00:01:26,379 To start it, I need to install it using dnf install minus y hhtpd. 20 00:01:26,379 --> 00:01:32,620 I like to demonstrate HHPD because it's not an essential service that will break functionality 21 00:01:32,620 --> 00:01:35,059 if something is going wrong. 22 00:01:35,059 --> 00:01:42,260 Now let's start by using systemctl status on HHPD where we can see that systemd is aware 23 00:01:42,260 --> 00:01:49,220 of the HHPD.service, but the white dot here is indicating that currently it's inactive. 24 00:01:49,220 --> 00:01:55,540 We can also see that systemd has found the unit file, and use ellipse systemd system, 25 00:01:55,540 --> 00:02:01,160 and the name is hhtpd.service, but currently it's disabled and the preset is disabled. 26 00:02:01,160 --> 00:02:08,899 Let me change that using systemctl enable minus minus now hhtpd, which is not only going 27 00:02:08,899 --> 00:02:14,080 to flag it for automatic start, but which will start it right now as well. 28 00:02:14,080 --> 00:02:19,679 So when you enable a unit, it flags for automatic start, and behind the scenes, a symbolic link 29 00:02:19,679 --> 00:02:25,699 is created in the etc systemd system multi-user target dot once directory. 30 00:02:25,699 --> 00:02:30,320 And this symbolic link means that if you enter the multi-user target, it will follow the 31 00:02:30,320 --> 00:02:34,960 symbolic link, and as a result, it will automatically start the unit. 32 00:02:34,960 --> 00:02:37,240 Now let's investigate the status again. 33 00:02:37,240 --> 00:02:40,240 As you can see, there's a lot more information now. 34 00:02:40,240 --> 00:02:45,460 So we can see that it is enabled, preset disabled, that means that the default state 35 00:02:45,460 --> 00:02:49,800 of the unit as defined in the package is disabled. 36 00:02:49,800 --> 00:02:55,139 The unit is active and running, and we can even see the main process ID of the unit. 37 00:02:55,139 --> 00:02:57,779 That's convenient for process management. 38 00:02:57,779 --> 00:03:02,619 There is the number of tasks, there is the amount of memory it is using, and more relevant 39 00:03:02,619 --> 00:03:07,179 information, including the logs for this unit. 40 00:03:07,179 --> 00:03:11,259 These logs are convenient because if anything doesn't work out well, well, you can easily 41 00:03:11,259 --> 00:03:14,179 troubleshoot right here. 42 00:03:14,179 --> 00:03:17,520 Now the unit works with different parameters. 43 00:03:17,520 --> 00:03:22,539 We call them directives, and if you want to know more about these directives, use systemctl 44 00:03:22,539 --> 00:03:26,460 show on httpd.service. 45 00:03:26,460 --> 00:03:31,220 So systemctl show followed by the name of the unit shows all of the directives that 46 00:03:31,220 --> 00:03:35,300 are relevant for this specific unit. 47 00:03:35,300 --> 00:03:38,940 And there you can see many directives, and sometimes you will wonder, what is this directive 48 00:03:38,940 --> 00:03:39,940 doing? 49 00:03:39,940 --> 00:03:45,100 Well, if ever you are wondering what is this directive doing, you can look that up. 50 00:03:45,100 --> 00:03:48,580 Let's look up IP accounting, for instance. 51 00:03:48,580 --> 00:03:53,860 To do so, I'm using man systemd.directives. 52 00:03:53,860 --> 00:03:57,179 And there you can find the list of all directives that exist. 53 00:03:57,179 --> 00:04:04,619 So when I search for IP accounting using forward slash IP account, there we can see 54 00:04:04,619 --> 00:04:09,740 that IP accounting is further defined in systemd resource control 5. 55 00:04:09,740 --> 00:04:10,979 That's a man page. 56 00:04:10,979 --> 00:04:22,339 So if I want to know more about IP accounting, I am going to use man systemd.resourcecontrol. 57 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. 58 00:04:27,100 --> 00:04:29,220 Now this was just one example. 59 00:04:29,220 --> 00:04:32,299 It will work for all directives. 60 00:04:32,299 --> 00:04:36,019 Now we have a couple of units that are listed right now. 61 00:04:36,019 --> 00:04:41,779 I like to figure out which these are, and to do so, there is systemctl list units. 62 00:04:41,779 --> 00:04:46,739 That will show you a list of all the units and their current state. 63 00:04:46,739 --> 00:04:51,459 That can be convenient, but this is focused on units that are currently active. 64 00:04:51,459 --> 00:04:57,700 If you want to see units that are inactive as well, I would suggest you use systemctl 65 00:04:57,700 --> 00:04:59,339 list unit files. 66 00:04:59,339 --> 00:05:04,980 There we can see the name of the units, nicely grouped by the unit type and the current state 67 00:05:04,980 --> 00:05:05,980 and the preset. 68 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 69 00:05:12,100 --> 00:05:16,980 need to do to get your system in the desired state. 70 00:05:16,980 --> 00:05:21,660 Now for a nice overview of everything that is happening in the current situation, you 71 00:05:21,660 --> 00:05:28,480 can also use systemctl list dependencies. 72 00:05:28,480 --> 00:05:32,739 That is showing the current state where you are, so the default target. 73 00:05:32,739 --> 00:05:36,420 Default target on a graphical system is graphical.target. 74 00:05:36,420 --> 00:05:39,700 And in the graphical.target, we have a couple of units. 75 00:05:39,700 --> 00:05:44,700 Then graphical.target includes the multi-user target, which has units as well. 76 00:05:44,700 --> 00:05:48,579 And you can see units that are currently running, but also units that are currently 77 00:05:48,579 --> 00:05:50,179 not running. 78 00:05:50,179 --> 00:05:55,100 And even in some cases with the Red Cross units that have had an issue. 79 00:05:55,100 --> 00:06:00,339 I like systemctl list dependencies a lot, because you get an overview of everything 80 00:06:00,339 --> 00:06:04,100 and you see the relation between the units in an easy way.