WEBVTT

00:00.720 --> 00:06.540
Now that we can see and monitor processes, let's gain some control over them.

00:06.540 --> 00:13.300
So for our experiments, we are going to use a little program called X Logo as our guinea pig.

00:13.320 --> 00:20.430
So the X logo program is a simple and sample program supplied with the X window system and the underlying

00:20.430 --> 00:26.220
engine that makes the graphics on our display go, which simply displays a resizable window containing

00:26.220 --> 00:26.910
the x logo.

00:26.910 --> 00:33.780
Here you will enter x logo here and as you can see here, that's our X program right here.

00:33.780 --> 00:35.120
You can resize this.

00:35.130 --> 00:36.270
Oops, where'd it go?

00:36.270 --> 00:36.630
Here.

00:36.630 --> 00:40.740
So you can resize this, right that and drag this down.

00:40.740 --> 00:42.900
So actually it doesn't have any functions.

00:43.020 --> 00:45.540
It's just a sample and dummy program.

00:45.540 --> 00:50.550
So after entering the command, the small window containing the logo should appear somewhere on the

00:50.550 --> 00:57.390
screen here on some systems X logo might print a warning message, but it can safely be ignored.

00:57.390 --> 01:02.500
And if your system does not include X logo program, try gedit.

01:03.370 --> 01:04.510
Actually, let's close this.

01:04.510 --> 01:14.020
So try gedit or as you can see it asks me to install or you can also use the gedit.

01:14.020 --> 01:16.900
And here the second program was.

01:21.090 --> 01:21.420
Actual.

01:21.420 --> 01:22.650
The second program was key.

01:22.680 --> 01:22.890
Right.

01:22.890 --> 01:23.540
Yeah, right.

01:23.550 --> 01:23.970
Your key.

01:23.970 --> 01:24.540
Right.

01:25.390 --> 01:27.970
Here as we let's install the key right now.

01:27.970 --> 01:29.530
Enter our password.

01:29.560 --> 01:31.900
Yes, it's 175MB.

01:31.900 --> 01:36.760
I think the that is going to be much less in size.

01:37.570 --> 01:39.370
Edit Yes.

01:40.060 --> 01:41.980
As you can see, it's 50MB.

01:41.980 --> 01:47.860
And you can also open just another window in from your tab here.

01:47.860 --> 01:53.050
In this case, let's actually we can also use the screen recording for just for just example here.

01:53.050 --> 01:56.740
But in most systems, the X logo is comes with default.

01:56.740 --> 01:58.090
So you don't have to install it.

01:58.330 --> 02:01.930
Probably it has in your system Linux system here.

02:01.930 --> 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

02:09.070 --> 02:16.900
size like this and here like this, then it means the program is running.

02:16.900 --> 02:22.600
So notice how our shell prompt has not returned, as you can see here, just doing a sync.

02:22.600 --> 02:28.870
So this is because the shell is waiting for the program to finish, just like all other programs we

02:28.870 --> 02:30.070
have used so far.

02:30.070 --> 02:33.820
So if we close the X logo window right here.

02:35.060 --> 02:40.940
As you can see here, the prompt returns and we can enter a new command in this prompt here.

02:40.940 --> 02:44.480
So let's observe what happens when we run X log again.

02:44.480 --> 02:50.840
So first, enter the X log command and verify that the program is running.

02:50.840 --> 02:54.140
Next, return the terminal window and control.

02:54.350 --> 02:59.390
Actually, let's actually see happens right here and make it X logo.

03:00.280 --> 03:02.440
Here and now.

03:02.440 --> 03:03.820
We're going to in-terminal.

03:03.830 --> 03:06.250
We're going to press control.

03:07.810 --> 03:10.270
Quantum control.

03:13.020 --> 03:13.360
Thompson.

03:17.420 --> 03:18.880
And see.

03:18.920 --> 03:20.150
Command and see.

03:20.150 --> 03:20.360
Let's.

03:20.630 --> 03:22.550
Let's see what happens right here.

03:23.950 --> 03:26.050
And that's it here, as you can see in terminal.

03:26.410 --> 03:28.270
We press the Ctrl key.

03:28.750 --> 03:33.010
When you press any programming control C, it will interrupt a program.

03:33.010 --> 03:39.580
So this means we are politely asking the program to terminate after we press Ctrl C, the x log of windows

03:39.610 --> 03:43.690
is closed here and the shell prompt returned.

03:43.840 --> 03:50.560
Many, but not all common line programs can be interrupted by using this technique.

03:50.590 --> 03:53.770
Let's actually put a process in the background right now.

03:53.770 --> 03:59.260
So let's say we wanted to get the shell prompt back without terminating the program.

03:59.260 --> 04:00.610
We can do this.

04:00.790 --> 04:02.800
Actually, we can do this.

04:04.540 --> 04:06.790
By placing the program in the background.

04:07.920 --> 04:14.480
A think of the thermal as having a foreground with the stuff visible on the surface, like the shell

04:14.480 --> 04:22.490
prompt and the background with the stuff hidden behind the surface to launch a program so that it it

04:22.490 --> 04:25.940
is immediately, immediately placed in the background.

04:25.970 --> 04:35.390
We will use this command X logo and operator X logo and operator ampersand character here enter.

04:35.390 --> 04:42.860
And as you can see here, we now enter the shell and we also opened our X logo without terminating it.

04:42.860 --> 04:47.630
So after entering the command X logo, window appeared, as you can see here, and the shell prompt

04:47.630 --> 04:48.980
is returned.

04:48.980 --> 04:51.800
But some funny numbers were printed right here.

04:51.980 --> 04:59.480
So this matches is a part of a shell feature feature called the Job Control.

05:00.340 --> 05:00.740
Your.

05:01.800 --> 05:02.580
Job.

05:04.030 --> 05:04.930
Control.

05:09.230 --> 05:09.710
So.

05:10.640 --> 05:12.410
The job control with this message.

05:12.410 --> 05:18.680
The Shell is telling us that we have a started job number.

05:19.640 --> 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

05:26.810 --> 05:31.780
number is 12,496.

05:31.790 --> 05:35.330
So if we run the PS command right here.

05:35.330 --> 05:35.620
Yeah.

05:35.630 --> 05:40.070
If we run the PS command right now, we can see our processes.

05:40.580 --> 05:41.360
That's it.

05:42.240 --> 05:47.520
12 496 12 496 and X logo.

05:47.520 --> 05:47.760
Here.

05:47.760 --> 05:50.280
As you can see, our program name is writing right here.

05:50.310 --> 05:56.460
So the Shell job control facility also gives us a way to list the jobs that have been launched from

05:56.460 --> 05:57.380
our terminal.

05:57.390 --> 06:04.380
So using the jobs command, using the jobs command, we can see this list right here.

06:04.380 --> 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.

06:16.560 --> 06:19.100
Let's now return the process to the foreground.

06:19.110 --> 06:22.710
So a process in the background is.

06:22.710 --> 06:29.740
You mean you mean from terminal keyboard input, including any attempt to interrupt it with the control

06:29.790 --> 06:30.420
C here.

06:30.420 --> 06:33.810
As you can see, whenever we click Ctrl C it does not.

06:34.140 --> 06:35.910
It happens nothing here actually.

06:35.910 --> 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

06:43.680 --> 06:44.130
here.

06:44.640 --> 06:46.650
Clear the clear.

06:51.030 --> 06:55.050
As I said, it processes in the background is immune from terminal keyboard input.

06:55.050 --> 06:57.720
So to return a process to the foreground.

06:58.570 --> 07:00.250
Use the f g.

07:01.290 --> 07:02.880
Command in this way.

07:02.910 --> 07:07.410
So first, you're going to enter the jobs here to see what is is here.

07:07.410 --> 07:13.110
And now we're going to use the FG and percentage and one.

07:13.890 --> 07:22.080
Here, As you can see here, the FG command followed by a present sign on the job number called a job

07:22.080 --> 07:23.870
spec does a trick.

07:23.880 --> 07:29.670
So if we only have one background job, the job spec is optional too.

07:29.670 --> 07:32.700
To terminate the x logo here.

07:33.790 --> 07:42.370
Uh, you will press the control C here and it will terminate our process that we used in background.

07:42.760 --> 07:45.910
We can also pause or stop a process.

07:45.910 --> 07:52.060
So sometimes we will want to stop a process without terminating it, which you will learn in next lecture.

07:52.060 --> 07:53.710
How to stop a process.

07:53.710 --> 07:55.360
So I'm waiting you in next lecture.
