1 00:00:00,720 --> 00:00:06,540 Now that we can see and monitor processes, let's gain some control over them. 2 00:00:06,540 --> 00:00:13,300 So for our experiments, we are going to use a little program called X Logo as our guinea pig. 3 00:00:13,320 --> 00:00:20,430 So the X logo program is a simple and sample program supplied with the X window system and the underlying 4 00:00:20,430 --> 00:00:26,220 engine that makes the graphics on our display go, which simply displays a resizable window containing 5 00:00:26,220 --> 00:00:26,910 the x logo. 6 00:00:26,910 --> 00:00:33,780 Here you will enter x logo here and as you can see here, that's our X program right here. 7 00:00:33,780 --> 00:00:35,120 You can resize this. 8 00:00:35,130 --> 00:00:36,270 Oops, where'd it go? 9 00:00:36,270 --> 00:00:36,630 Here. 10 00:00:36,630 --> 00:00:40,740 So you can resize this, right that and drag this down. 11 00:00:40,740 --> 00:00:42,900 So actually it doesn't have any functions. 12 00:00:43,020 --> 00:00:45,540 It's just a sample and dummy program. 13 00:00:45,540 --> 00:00:50,550 So after entering the command, the small window containing the logo should appear somewhere on the 14 00:00:50,550 --> 00:00:57,390 screen here on some systems X logo might print a warning message, but it can safely be ignored. 15 00:00:57,390 --> 00:01:02,500 And if your system does not include X logo program, try gedit. 16 00:01:03,370 --> 00:01:04,510 Actually, let's close this. 17 00:01:04,510 --> 00:01:14,020 So try gedit or as you can see it asks me to install or you can also use the gedit. 18 00:01:14,020 --> 00:01:16,900 And here the second program was. 19 00:01:21,090 --> 00:01:21,420 Actual. 20 00:01:21,420 --> 00:01:22,650 The second program was key. 21 00:01:22,680 --> 00:01:22,890 Right. 22 00:01:22,890 --> 00:01:23,540 Yeah, right. 23 00:01:23,550 --> 00:01:23,970 Your key. 24 00:01:23,970 --> 00:01:24,540 Right. 25 00:01:25,390 --> 00:01:27,970 Here as we let's install the key right now. 26 00:01:27,970 --> 00:01:29,530 Enter our password. 27 00:01:29,560 --> 00:01:31,900 Yes, it's 175MB. 28 00:01:31,900 --> 00:01:36,760 I think the that is going to be much less in size. 29 00:01:37,570 --> 00:01:39,370 Edit Yes. 30 00:01:40,060 --> 00:01:41,980 As you can see, it's 50MB. 31 00:01:41,980 --> 00:01:47,860 And you can also open just another window in from your tab here. 32 00:01:47,860 --> 00:01:53,050 In this case, let's actually we can also use the screen recording for just for just example here. 33 00:01:53,050 --> 00:01:56,740 But in most systems, the X logo is comes with default. 34 00:01:56,740 --> 00:01:58,090 So you don't have to install it. 35 00:01:58,330 --> 00:02:01,930 Probably it has in your system Linux system here. 36 00:02:01,930 --> 00:02:09,070 So we can verify that the x log is running by resizing and its window if the log is redrawn in the new 37 00:02:09,070 --> 00:02:16,900 size like this and here like this, then it means the program is running. 38 00:02:16,900 --> 00:02:22,600 So notice how our shell prompt has not returned, as you can see here, just doing a sync. 39 00:02:22,600 --> 00:02:28,870 So this is because the shell is waiting for the program to finish, just like all other programs we 40 00:02:28,870 --> 00:02:30,070 have used so far. 41 00:02:30,070 --> 00:02:33,820 So if we close the X logo window right here. 42 00:02:35,060 --> 00:02:40,940 As you can see here, the prompt returns and we can enter a new command in this prompt here. 43 00:02:40,940 --> 00:02:44,480 So let's observe what happens when we run X log again. 44 00:02:44,480 --> 00:02:50,840 So first, enter the X log command and verify that the program is running. 45 00:02:50,840 --> 00:02:54,140 Next, return the terminal window and control. 46 00:02:54,350 --> 00:02:59,390 Actually, let's actually see happens right here and make it X logo. 47 00:03:00,280 --> 00:03:02,440 Here and now. 48 00:03:02,440 --> 00:03:03,820 We're going to in-terminal. 49 00:03:03,830 --> 00:03:06,250 We're going to press control. 50 00:03:07,810 --> 00:03:10,270 Quantum control. 51 00:03:13,020 --> 00:03:13,360 Thompson. 52 00:03:17,420 --> 00:03:18,880 And see. 53 00:03:18,920 --> 00:03:20,150 Command and see. 54 00:03:20,150 --> 00:03:20,360 Let's. 55 00:03:20,630 --> 00:03:22,550 Let's see what happens right here. 56 00:03:23,950 --> 00:03:26,050 And that's it here, as you can see in terminal. 57 00:03:26,410 --> 00:03:28,270 We press the Ctrl key. 58 00:03:28,750 --> 00:03:33,010 When you press any programming control C, it will interrupt a program. 59 00:03:33,010 --> 00:03:39,580 So this means we are politely asking the program to terminate after we press Ctrl C, the x log of windows 60 00:03:39,610 --> 00:03:43,690 is closed here and the shell prompt returned. 61 00:03:43,840 --> 00:03:50,560 Many, but not all common line programs can be interrupted by using this technique. 62 00:03:50,590 --> 00:03:53,770 Let's actually put a process in the background right now. 63 00:03:53,770 --> 00:03:59,260 So let's say we wanted to get the shell prompt back without terminating the program. 64 00:03:59,260 --> 00:04:00,610 We can do this. 65 00:04:00,790 --> 00:04:02,800 Actually, we can do this. 66 00:04:04,540 --> 00:04:06,790 By placing the program in the background. 67 00:04:07,920 --> 00:04:14,480 A think of the thermal as having a foreground with the stuff visible on the surface, like the shell 68 00:04:14,480 --> 00:04:22,490 prompt and the background with the stuff hidden behind the surface to launch a program so that it it 69 00:04:22,490 --> 00:04:25,940 is immediately, immediately placed in the background. 70 00:04:25,970 --> 00:04:35,390 We will use this command X logo and operator X logo and operator ampersand character here enter. 71 00:04:35,390 --> 00:04:42,860 And as you can see here, we now enter the shell and we also opened our X logo without terminating it. 72 00:04:42,860 --> 00:04:47,630 So after entering the command X logo, window appeared, as you can see here, and the shell prompt 73 00:04:47,630 --> 00:04:48,980 is returned. 74 00:04:48,980 --> 00:04:51,800 But some funny numbers were printed right here. 75 00:04:51,980 --> 00:04:59,480 So this matches is a part of a shell feature feature called the Job Control. 76 00:05:00,340 --> 00:05:00,740 Your. 77 00:05:01,800 --> 00:05:02,580 Job. 78 00:05:04,030 --> 00:05:04,930 Control. 79 00:05:09,230 --> 00:05:09,710 So. 80 00:05:10,640 --> 00:05:12,410 The job control with this message. 81 00:05:12,410 --> 00:05:18,680 The Shell is telling us that we have a started job number. 82 00:05:19,640 --> 00:05:26,810 Job number one and that it has process ID So this is a job number and this is a process ID after job 83 00:05:26,810 --> 00:05:31,780 number is 12,496. 84 00:05:31,790 --> 00:05:35,330 So if we run the PS command right here. 85 00:05:35,330 --> 00:05:35,620 Yeah. 86 00:05:35,630 --> 00:05:40,070 If we run the PS command right now, we can see our processes. 87 00:05:40,580 --> 00:05:41,360 That's it. 88 00:05:42,240 --> 00:05:47,520 12 496 12 496 and X logo. 89 00:05:47,520 --> 00:05:47,760 Here. 90 00:05:47,760 --> 00:05:50,280 As you can see, our program name is writing right here. 91 00:05:50,310 --> 00:05:56,460 So the Shell job control facility also gives us a way to list the jobs that have been launched from 92 00:05:56,460 --> 00:05:57,380 our terminal. 93 00:05:57,390 --> 00:06:04,380 So using the jobs command, using the jobs command, we can see this list right here. 94 00:06:04,380 --> 00:06:14,190 So the result shows that we have one job number one that it is running and that the command was X logon. 95 00:06:16,560 --> 00:06:19,100 Let's now return the process to the foreground. 96 00:06:19,110 --> 00:06:22,710 So a process in the background is. 97 00:06:22,710 --> 00:06:29,740 You mean you mean from terminal keyboard input, including any attempt to interrupt it with the control 98 00:06:29,790 --> 00:06:30,420 C here. 99 00:06:30,420 --> 00:06:33,810 As you can see, whenever we click Ctrl C it does not. 100 00:06:34,140 --> 00:06:35,910 It happens nothing here actually. 101 00:06:35,910 --> 00:06:43,680 Let's make it always on top and make it right here so it will not disappear right as it did in previous 102 00:06:43,680 --> 00:06:44,130 here. 103 00:06:44,640 --> 00:06:46,650 Clear the clear. 104 00:06:51,030 --> 00:06:55,050 As I said, it processes in the background is immune from terminal keyboard input. 105 00:06:55,050 --> 00:06:57,720 So to return a process to the foreground. 106 00:06:58,570 --> 00:07:00,250 Use the f g. 107 00:07:01,290 --> 00:07:02,880 Command in this way. 108 00:07:02,910 --> 00:07:07,410 So first, you're going to enter the jobs here to see what is is here. 109 00:07:07,410 --> 00:07:13,110 And now we're going to use the FG and percentage and one. 110 00:07:13,890 --> 00:07:22,080 Here, As you can see here, the FG command followed by a present sign on the job number called a job 111 00:07:22,080 --> 00:07:23,870 spec does a trick. 112 00:07:23,880 --> 00:07:29,670 So if we only have one background job, the job spec is optional too. 113 00:07:29,670 --> 00:07:32,700 To terminate the x logo here. 114 00:07:33,790 --> 00:07:42,370 Uh, you will press the control C here and it will terminate our process that we used in background. 115 00:07:42,760 --> 00:07:45,910 We can also pause or stop a process. 116 00:07:45,910 --> 00:07:52,060 So sometimes we will want to stop a process without terminating it, which you will learn in next lecture. 117 00:07:52,060 --> 00:07:53,710 How to stop a process. 118 00:07:53,710 --> 00:07:55,360 So I'm waiting you in next lecture.