WEBVTT

00:01.080 --> 00:08.580
Modern operating systems are usually multitasking, meaning that they create the illusion of doing more

00:08.580 --> 00:15.090
than one thing at once by rapidly switching from one execution to another.

00:15.850 --> 00:20.170
So the kernel manages this truth, the use of the processes.

00:20.170 --> 00:27.140
So the processes are how Linux organizes the different programs waiting for their turn at the CPU.

00:27.160 --> 00:31.990
So sometimes a computer will become sluggish on our application will stop responding.

00:31.990 --> 00:37.630
In this section you will learn and we will look at some of the tools available at the command line that

00:37.630 --> 00:45.610
lets us examine what programs are doing and how to terminate processes that are misbehaving.

00:45.610 --> 00:54.280
In this section, you will learn about command, top command, and you will also learn about the jobs.

00:55.360 --> 01:01.310
BG which, uh, the jobs here will list active jobs.

01:01.330 --> 01:05.390
BG Place a job in the background.

01:05.520 --> 01:06.280
EFG.

01:07.740 --> 01:08.940
A place, a job.

01:09.900 --> 01:12.300
In the foreground and kill.

01:12.300 --> 01:18.420
With this kill command, you will send a signal to a process and kill all here.

01:18.450 --> 01:21.980
Kill all the you will send.

01:21.990 --> 01:25.580
Kill the process by name and shut down.

01:25.590 --> 01:26.820
Shut down.

01:27.710 --> 01:32.150
Here you will shut down your computer.

01:32.160 --> 01:34.860
Actually, I don't want to shut down right now.

01:34.860 --> 01:37.410
So let's see what happens when I talk.

01:37.410 --> 01:41.760
So actually, let's learn about how a process works.

01:41.760 --> 01:49.230
So when a system starts up, the kernel initiates a few of its own activities as processes and launches

01:49.230 --> 01:59.520
a program called Init in turn runs a series of shell scripts located in here and are called the init

01:59.520 --> 01:59.820
scripts.

01:59.820 --> 02:06.060
Actually, let's terminate the shutdown process right now with C and as you can see, we terminate the

02:06.060 --> 02:16.330
shutdown process, clear the console and let's CD to ATC here, LZ and these are our shell scripts and

02:16.330 --> 02:20.590
some of these scripts called Init Scripts, which starts all the system services.

02:20.590 --> 02:26.920
So many of these services are implemented as a daemon programs, the programs that just sit in the background

02:26.920 --> 02:30.310
and do their thing without having any user interface.

02:30.310 --> 02:39.070
So even if we are not logged in, the system is at least a little busy performing routine stuff.

02:39.070 --> 02:46.630
So the fact that a program can launch other programs is expressed in the process stream as a parent

02:46.630 --> 02:49.540
process producing a child process.

02:49.540 --> 02:56.650
So the kernel maintains information about each process to help to keep things organized.

02:56.650 --> 03:03.760
So, for example, each process is assigned a number called process ID and process IDs are assigned

03:03.760 --> 03:05.080
in ascending order.

03:05.080 --> 03:12.640
So with init always getting process ID one, so the kernel also keeps track of the memory assigned to

03:12.640 --> 03:20.410
each process and these these each process readiness and resume execution here.

03:21.310 --> 03:29.590
So like files persons also have owners and user IDs if and also effective user IDs and so on.

03:29.590 --> 03:35.230
So let's actually start with viewing our processes right now here.

03:36.170 --> 03:36.920
Clear.

03:36.920 --> 03:40.310
And here you can view the process with PS command.

03:40.310 --> 03:42.860
And as you can see, we get just two processes, right?

03:43.400 --> 03:50.240
So the most commonly used command to view process and there are actually several commands and the most

03:50.240 --> 03:57.200
common use is PS, So the PS program has a lot of options, but in its simplest form it is used like

03:57.200 --> 03:57.680
this.

03:57.980 --> 04:09.020
So the result in this example lists two processes the process 13709 and process 23501.

04:09.980 --> 04:16.430
As we can see by default s doesn't show us very much, right?

04:16.430 --> 04:19.880
So just the process associated with the current terminal session.

04:21.140 --> 04:23.900
And to see more, we need to add some options.

04:23.900 --> 04:27.950
However, before we do that, let's look at the other fields produced by P.

04:27.950 --> 04:28.310
S.

04:28.310 --> 04:32.060
So theta is short for actually let me write that down here.

04:32.060 --> 04:33.320
So t.

04:34.110 --> 04:36.120
He I.

04:37.340 --> 04:42.890
Is short for teletype and refers to controlling terminal for the process.

04:42.890 --> 04:51.470
So Unix is showing its age here, so the time field is the amount of the time field is the amount.

04:52.360 --> 04:55.450
A of CPU time consumed by the process.

04:55.450 --> 04:59.950
So as we can see, neither process makes the computer work very hard.

04:59.950 --> 05:00.370
Right.

05:00.370 --> 05:02.140
Actually and as you can see here.

05:02.140 --> 05:09.070
So if we add an option like this, p x, and as you can see here, we get an A bigger picture of what

05:09.070 --> 05:10.180
the system is doing.

05:10.870 --> 05:13.260
So adding the option.

05:13.270 --> 05:18.730
Note that there is no leading dash in this exception with just an X here.

05:19.770 --> 05:21.650
So let's run it again.

05:21.660 --> 05:27.060
Clear and ps6 X here.

05:27.060 --> 05:31.710
So there's the x command we entered is without a dash.

05:33.730 --> 05:34.330
So.

05:36.330 --> 05:42.780
And this tells us to show all of our process regardless of what terminal, if any, they are controlled

05:42.780 --> 05:43.150
by.

05:43.170 --> 05:51.210
So the presence of a question mark here, the presence of the question mark in the team, as I said

05:51.240 --> 05:54.000
to is actually teletype.

05:54.000 --> 06:01.080
So the question mark is a column in this column indicates here, actually, let me take my marker.

06:01.080 --> 06:08.070
So in this command, the question marks in this column indicates.

06:09.180 --> 06:10.500
No controlling terminal.

06:10.620 --> 06:16.780
So using this option, we can list every process that we own.

06:16.800 --> 06:24.960
So because a system is running a lot of processes, PS produced, PS produced a long list, so it is

06:24.960 --> 06:31.980
often helpful to pipe the output from PS into less so for easy viewing.

06:32.010 --> 06:32.430
Of course.

06:32.430 --> 06:38.910
So some options combinations also produce a long lines of output, so maximizing the terminal emulator

06:38.910 --> 06:42.030
window might be a good idea too.

06:42.720 --> 06:48.240
And in next lecture you will learn about more in PS and processes.

06:48.240 --> 06:49.800
So I'm waiting you in next lecture.
