1 00:00:07,140 --> 00:00:09,900 - In this video, I will show you how to work with systemD. 2 00:00:09,900 --> 00:00:12,570 So I have a couple of commands that I want to show you. 3 00:00:12,570 --> 00:00:14,130 And here, we can see the commands. 4 00:00:14,130 --> 00:00:15,183 Let me just show you. 5 00:00:18,450 --> 00:00:23,280 So, as I mentioned, systemD is managing many things. 6 00:00:23,280 --> 00:00:25,230 We use systemCTL, which is the main 7 00:00:25,230 --> 00:00:29,640 systemD management command minus T help. 8 00:00:29,640 --> 00:00:32,220 That will show you the different unit types 9 00:00:32,220 --> 00:00:33,510 that it can manage. 10 00:00:33,510 --> 00:00:34,890 And amongst these unit types, 11 00:00:34,890 --> 00:00:38,010 you have the service as the most important. 12 00:00:38,010 --> 00:00:40,050 But it can mount file systems. 13 00:00:40,050 --> 00:00:42,510 It can take care of devices. 14 00:00:42,510 --> 00:00:44,190 It can open network sockets. 15 00:00:44,190 --> 00:00:45,870 It can do so much more. 16 00:00:45,870 --> 00:00:47,670 If you wanna get an impression of everything 17 00:00:47,670 --> 00:00:50,550 that it is doing, use systemCTL. 18 00:00:50,550 --> 00:00:52,170 And before we do anything else, 19 00:00:52,170 --> 00:00:54,150 let's do the tab completion. 20 00:00:54,150 --> 00:00:56,130 Here you can see all the different commands 21 00:00:56,130 --> 00:00:58,290 that you can use with systemCTL, 22 00:00:58,290 --> 00:01:03,290 including list-unit-files, for instance. 23 00:01:03,930 --> 00:01:04,950 What is that doing? 24 00:01:04,950 --> 00:01:07,320 Well, that's showing all the different unit files 25 00:01:07,320 --> 00:01:10,923 that are used on your system and their current status. 26 00:01:12,960 --> 00:01:15,900 Nice to see what systemD is managing. 27 00:01:15,900 --> 00:01:18,720 But we should not explore this in much detail right now, 28 00:01:18,720 --> 00:01:23,720 because, as you can see, 382 unit files in total. 29 00:01:24,060 --> 00:01:25,500 That's kind of impressive. 30 00:01:25,500 --> 00:01:27,960 If you wanna know what is happening right now, 31 00:01:27,960 --> 00:01:32,960 then systemCTL list-units is the best way to figure out. 32 00:01:34,980 --> 00:01:38,370 That is showing the units currently loaded. 33 00:01:38,370 --> 00:01:39,300 And as you can see, 34 00:01:39,300 --> 00:01:41,520 it starts with a bunch of devices. 35 00:01:41,520 --> 00:01:43,860 After the devices you have the mounts. 36 00:01:43,860 --> 00:01:46,503 And yes, that is true systemD is taking over the work 37 00:01:46,503 --> 00:01:49,410 of etc fstab, it's taking care of the mounts. 38 00:01:49,410 --> 00:01:51,930 And here we can see the services. 39 00:01:51,930 --> 00:01:53,430 Now let's take the cups service, 40 00:01:53,430 --> 00:01:55,710 just a random service as an example. 41 00:01:55,710 --> 00:01:57,450 We can see that the service is loaded, 42 00:01:57,450 --> 00:01:59,223 it is active and it is running. 43 00:02:00,270 --> 00:02:05,250 So loaded means that systemD is aware of the configuration. 44 00:02:05,250 --> 00:02:09,840 And active means that it is currently active 45 00:02:09,840 --> 00:02:12,060 And running means that the state is running. 46 00:02:12,060 --> 00:02:13,170 That's not always the same 47 00:02:13,170 --> 00:02:15,750 because you can also have a service that is active, 48 00:02:15,750 --> 00:02:17,550 but in a state of exited, 49 00:02:17,550 --> 00:02:20,370 as if the service has done its work 50 00:02:20,370 --> 00:02:22,083 and it's already done with it. 51 00:02:22,920 --> 00:02:24,390 Now, the most important things 52 00:02:24,390 --> 00:02:27,540 in systemD is service management. 53 00:02:27,540 --> 00:02:28,710 And in order to show you, 54 00:02:28,710 --> 00:02:30,810 I'm going to install a software package. 55 00:02:30,810 --> 00:02:35,810 So sudo, DNF install minus Y HTTPD. 56 00:02:36,720 --> 00:02:39,630 That's installing the HTTP web server. 57 00:02:39,630 --> 00:02:42,480 I don't care about the HTTPD web server here, 58 00:02:42,480 --> 00:02:43,680 but I need an example. 59 00:02:43,680 --> 00:02:45,990 So I just installed the web server 60 00:02:45,990 --> 00:02:50,990 and I'm going to use sudo systemCTL status on HTTPD 61 00:02:51,420 --> 00:02:54,540 to figure out the status of this server. 62 00:02:54,540 --> 00:02:56,640 Now, what do we see here? 63 00:02:56,640 --> 00:03:00,540 We see that the service is loaded. 64 00:03:00,540 --> 00:03:02,520 Loaded means that systemD is aware 65 00:03:02,520 --> 00:03:03,870 of the configuration file. 66 00:03:03,870 --> 00:03:04,980 The configuration file 67 00:03:04,980 --> 00:03:08,730 is usr/lib/systemD/system/HTTPD.service. 68 00:03:08,730 --> 00:03:12,840 It is disabled, which means that it is not enabled 69 00:03:12,840 --> 00:03:15,810 for automatic start at system boot. 70 00:03:15,810 --> 00:03:19,053 And we also can see that it's inactive and dead. 71 00:03:19,980 --> 00:03:24,980 Now let's change this and let's do a start on HTTPD. 72 00:03:25,020 --> 00:03:26,127 Now I'm using status again. 73 00:03:26,127 --> 00:03:27,510 And what do we see? 74 00:03:27,510 --> 00:03:29,523 A whole lot more information. 75 00:03:30,570 --> 00:03:32,940 We can see that it is active. 76 00:03:32,940 --> 00:03:36,060 We can see information about the documentation, 77 00:03:36,060 --> 00:03:39,510 but also information about the process IDs, 78 00:03:39,510 --> 00:03:41,460 about the memory that it's using, 79 00:03:41,460 --> 00:03:44,400 and even information from the logs. 80 00:03:44,400 --> 00:03:47,010 This is what makes systemD so cool. 81 00:03:47,010 --> 00:03:51,720 Services write the log information directly to systemD. 82 00:03:51,720 --> 00:03:54,840 And if you use systemCTL status to get information 83 00:03:54,840 --> 00:03:57,633 about your service, you automatically see that. 84 00:03:58,530 --> 00:04:00,150 One more thing to be noticed. 85 00:04:00,150 --> 00:04:03,120 And that is that the service is still disabled, 86 00:04:03,120 --> 00:04:05,070 which means that it's not going to be started 87 00:04:05,070 --> 00:04:08,100 automatically at system start. 88 00:04:08,100 --> 00:04:11,628 And if you don't like that, well, we are just going to use 89 00:04:11,628 --> 00:04:15,210 systemCTL enable on the service. 90 00:04:15,210 --> 00:04:17,163 Enable means that the service is added 91 00:04:17,163 --> 00:04:21,270 to its default environment. 92 00:04:21,270 --> 00:04:23,610 And this default environment is a target. 93 00:04:23,610 --> 00:04:26,970 The target defines the state that the system is starting in. 94 00:04:26,970 --> 00:04:31,660 And here we can see multi-user target to which it is added. 95 00:04:31,660 --> 00:04:34,860 We will talk about it later in just a bit. 96 00:04:34,860 --> 00:04:38,040 If you use systemCTL status on HTTPD again, 97 00:04:38,040 --> 00:04:40,860 now we can see that everything is configured. 98 00:04:40,860 --> 00:04:44,160 The service is enabled, the service is active 99 00:04:44,160 --> 00:04:47,820 and it is running and we are all good. 100 00:04:47,820 --> 00:04:49,680 Now you can also do the opposite, 101 00:04:49,680 --> 00:04:54,303 and that will be sudo systemCTL stop on HTTPD. 102 00:04:55,410 --> 00:04:58,110 You can probably guess what is happening if you do that. 103 00:04:58,110 --> 00:05:00,900 And that's right, we just stopped it. 104 00:05:00,900 --> 00:05:02,790 Now, by stopping it we can still see 105 00:05:02,790 --> 00:05:05,700 the relevant information, including log information, 106 00:05:05,700 --> 00:05:09,150 because after all this thing has been active. 107 00:05:09,150 --> 00:05:12,750 And that is quite kind of useful. 108 00:05:12,750 --> 00:05:15,750 You don't have to explore any log files anymore. 109 00:05:15,750 --> 00:05:19,560 All the information that you need is right here. 110 00:05:19,560 --> 00:05:22,470 Now, this is a very important part of working with systemD, 111 00:05:22,470 --> 00:05:24,870 management of these services. 112 00:05:24,870 --> 00:05:27,300 There is more, and we will find out more about it 113 00:05:27,300 --> 00:05:28,893 in the next couple of videos.