1
00:00:01,080 --> 00:00:08,580
Modern operating systems are usually multitasking, meaning that they create the illusion of doing more

2
00:00:08,580 --> 00:00:15,090
than one thing at once by rapidly switching from one execution to another.

3
00:00:15,850 --> 00:00:20,170
So the kernel manages this truth, the use of the processes.

4
00:00:20,170 --> 00:00:27,140
So the processes are how Linux organizes the different programs waiting for their turn at the CPU.

5
00:00:27,160 --> 00:00:31,990
So sometimes a computer will become sluggish on our application will stop responding.

6
00:00:31,990 --> 00:00:37,630
In this section you will learn and we will look at some of the tools available at the command line that

7
00:00:37,630 --> 00:00:45,610
lets us examine what programs are doing and how to terminate processes that are misbehaving.

8
00:00:45,610 --> 00:00:54,280
In this section, you will learn about command, top command, and you will also learn about the jobs.

9
00:00:55,360 --> 00:01:01,310
BG which, uh, the jobs here will list active jobs.

10
00:01:01,330 --> 00:01:05,390
BG Place a job in the background.

11
00:01:05,520 --> 00:01:06,280
EFG.

12
00:01:07,740 --> 00:01:08,940
A place, a job.

13
00:01:09,900 --> 00:01:12,300
In the foreground and kill.

14
00:01:12,300 --> 00:01:18,420
With this kill command, you will send a signal to a process and kill all here.

15
00:01:18,450 --> 00:01:21,980
Kill all the you will send.

16
00:01:21,990 --> 00:01:25,580
Kill the process by name and shut down.

17
00:01:25,590 --> 00:01:26,820
Shut down.

18
00:01:27,710 --> 00:01:32,150
Here you will shut down your computer.

19
00:01:32,160 --> 00:01:34,860
Actually, I don't want to shut down right now.

20
00:01:34,860 --> 00:01:37,410
So let's see what happens when I talk.

21
00:01:37,410 --> 00:01:41,760
So actually, let's learn about how a process works.

22
00:01:41,760 --> 00:01:49,230
So when a system starts up, the kernel initiates a few of its own activities as processes and launches

23
00:01:49,230 --> 00:01:59,520
a program called Init in turn runs a series of shell scripts located in here and are called the init

24
00:01:59,520 --> 00:01:59,820
scripts.

25
00:01:59,820 --> 00:02:06,060
Actually, let's terminate the shutdown process right now with C and as you can see, we terminate the

26
00:02:06,060 --> 00:02:16,330
shutdown process, clear the console and let's CD to ATC here, LZ and these are our shell scripts and

27
00:02:16,330 --> 00:02:20,590
some of these scripts called Init Scripts, which starts all the system services.

28
00:02:20,590 --> 00:02:26,920
So many of these services are implemented as a daemon programs, the programs that just sit in the background

29
00:02:26,920 --> 00:02:30,310
and do their thing without having any user interface.

30
00:02:30,310 --> 00:02:39,070
So even if we are not logged in, the system is at least a little busy performing routine stuff.

31
00:02:39,070 --> 00:02:46,630
So the fact that a program can launch other programs is expressed in the process stream as a parent

32
00:02:46,630 --> 00:02:49,540
process producing a child process.

33
00:02:49,540 --> 00:02:56,650
So the kernel maintains information about each process to help to keep things organized.

34
00:02:56,650 --> 00:03:03,760
So, for example, each process is assigned a number called process ID and process IDs are assigned

35
00:03:03,760 --> 00:03:05,080
in ascending order.

36
00:03:05,080 --> 00:03:12,640
So with init always getting process ID one, so the kernel also keeps track of the memory assigned to

37
00:03:12,640 --> 00:03:20,410
each process and these these each process readiness and resume execution here.

38
00:03:21,310 --> 00:03:29,590
So like files persons also have owners and user IDs if and also effective user IDs and so on.

39
00:03:29,590 --> 00:03:35,230
So let's actually start with viewing our processes right now here.

40
00:03:36,170 --> 00:03:36,920
Clear.

41
00:03:36,920 --> 00:03:40,310
And here you can view the process with PS command.

42
00:03:40,310 --> 00:03:42,860
And as you can see, we get just two processes, right?

43
00:03:43,400 --> 00:03:50,240
So the most commonly used command to view process and there are actually several commands and the most

44
00:03:50,240 --> 00: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

45
00:03:57,200 --> 00:03:57,680
this.

46
00:03:57,980 --> 00:04:09,020
So the result in this example lists two processes the process 13709 and process 23501.

47
00:04:09,980 --> 00:04:16,430
As we can see by default s doesn't show us very much, right?

48
00:04:16,430 --> 00:04:19,880
So just the process associated with the current terminal session.

49
00:04:21,140 --> 00:04:23,900
And to see more, we need to add some options.

50
00:04:23,900 --> 00:04:27,950
However, before we do that, let's look at the other fields produced by P.

51
00:04:27,950 --> 00:04:28,310
S.

52
00:04:28,310 --> 00:04:32,060
So theta is short for actually let me write that down here.

53
00:04:32,060 --> 00:04:33,320
So t.

54
00:04:34,110 --> 00:04:36,120
He I.

55
00:04:37,340 --> 00:04:42,890
Is short for teletype and refers to controlling terminal for the process.

56
00:04:42,890 --> 00:04:51,470
So Unix is showing its age here, so the time field is the amount of the time field is the amount.

57
00:04:52,360 --> 00:04:55,450
A of CPU time consumed by the process.

58
00:04:55,450 --> 00:04:59,950
So as we can see, neither process makes the computer work very hard.

59
00:04:59,950 --> 00:05:00,370
Right.

60
00:05:00,370 --> 00:05:02,140
Actually and as you can see here.

61
00:05:02,140 --> 00: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

62
00:05:09,070 --> 00:05:10,180
the system is doing.

63
00:05:10,870 --> 00:05:13,260
So adding the option.

64
00:05:13,270 --> 00:05:18,730
Note that there is no leading dash in this exception with just an X here.

65
00:05:19,770 --> 00:05:21,650
So let's run it again.

66
00:05:21,660 --> 00:05:27,060
Clear and ps6 X here.

67
00:05:27,060 --> 00:05:31,710
So there's the x command we entered is without a dash.

68
00:05:33,730 --> 00:05:34,330
So.

69
00:05:36,330 --> 00:05:42,780
And this tells us to show all of our process regardless of what terminal, if any, they are controlled

70
00:05:42,780 --> 00:05:43,150
by.

71
00:05:43,170 --> 00:05:51,210
So the presence of a question mark here, the presence of the question mark in the team, as I said

72
00:05:51,240 --> 00:05:54,000
to is actually teletype.

73
00:05:54,000 --> 00:06:01,080
So the question mark is a column in this column indicates here, actually, let me take my marker.

74
00:06:01,080 --> 00:06:08,070
So in this command, the question marks in this column indicates.

75
00:06:09,180 --> 00:06:10,500
No controlling terminal.

76
00:06:10,620 --> 00:06:16,780
So using this option, we can list every process that we own.

77
00:06:16,800 --> 00:06:24,960
So because a system is running a lot of processes, PS produced, PS produced a long list, so it is

78
00:06:24,960 --> 00:06:31,980
often helpful to pipe the output from PS into less so for easy viewing.

79
00:06:32,010 --> 00:06:32,430
Of course.

80
00:06:32,430 --> 00:06:38,910
So some options combinations also produce a long lines of output, so maximizing the terminal emulator

81
00:06:38,910 --> 00:06:42,030
window might be a good idea too.

82
00:06:42,720 --> 00:06:48,240
And in next lecture you will learn about more in PS and processes.

83
00:06:48,240 --> 00:06:49,800
So I'm waiting you in next lecture.
