1
00:00:00,000 --> 00:00:01,290
In this lesson, we're going to walk

2
00:00:01,290 --> 00:00:03,090
through how the troubleshoot processes

3
00:00:03,090 --> 00:00:04,560
within the Linux system.

4
00:00:04,560 --> 00:00:05,550
Now, during your operation

5
00:00:05,550 --> 00:00:08,189
on the system might encounter various issues

6
00:00:08,189 --> 00:00:09,750
that degrade the performance,

7
00:00:09,750 --> 00:00:11,400
and it makes the system unusable.

8
00:00:11,400 --> 00:00:14,790
So common cases are process hangups causing instability

9
00:00:14,790 --> 00:00:17,670
that a process consuming too many resources,

10
00:00:17,670 --> 00:00:20,430
making the system sluggish in general.

11
00:00:20,430 --> 00:00:21,270
So we're going to go through

12
00:00:21,270 --> 00:00:23,790
and learn how to identify these processes,

13
00:00:23,790 --> 00:00:25,620
Figure out the current states that they should be in,

14
00:00:25,620 --> 00:00:29,070
like running interruptible sleep,

15
00:00:29,070 --> 00:00:31,320
uninterruptible sleep, zombie mode,

16
00:00:31,320 --> 00:00:33,670
different ways to kill processes and view them.

17
00:00:34,560 --> 00:00:35,940
So let's get started.

18
00:00:35,940 --> 00:00:37,200
Now, the first command we're going to go over,

19
00:00:37,200 --> 00:00:38,520
is the process command.

20
00:00:38,520 --> 00:00:40,260
Now by default, what it does is,

21
00:00:40,260 --> 00:00:42,000
it identifies the current processes,

22
00:00:42,000 --> 00:00:45,630
that's running in this shell by the user, okay?

23
00:00:45,630 --> 00:00:49,200
So right now, we always know Bash is the default shell

24
00:00:49,200 --> 00:00:51,150
for this Linux distribution.

25
00:00:51,150 --> 00:00:54,210
So that's always going to be running in the background for us.

26
00:00:54,210 --> 00:00:57,210
And that process command is what we just executed.

27
00:00:57,210 --> 00:00:58,800
Now, if you see, that has a process ID,

28
00:00:58,800 --> 00:01:00,570
and this is going to be vital when it comes

29
00:01:00,570 --> 00:01:03,030
to identifying services, killing processes,

30
00:01:03,030 --> 00:01:05,220
changing priorities, things of that nature.

31
00:01:05,220 --> 00:01:07,260
Now, in order to see everyone's process,

32
00:01:07,260 --> 00:01:09,393
we can use the dash e option,

33
00:01:10,230 --> 00:01:11,670
and that's going to show us all the processes

34
00:01:11,670 --> 00:01:13,920
that are currently running on the system.

35
00:01:13,920 --> 00:01:16,350
Okay, we see there's a lot of them running,

36
00:01:16,350 --> 00:01:19,350
and again, practice with the less command.

37
00:01:19,350 --> 00:01:20,610
We want to see it from top to bottom.

38
00:01:20,610 --> 00:01:24,120
Remember, there's our systemd there, always the first one.

39
00:01:24,120 --> 00:01:27,300
And each process always increments one after the other,

40
00:01:27,300 --> 00:01:29,430
of course, starting with the first in it,

41
00:01:29,430 --> 00:01:30,933
which going to be systemd for us.

42
00:01:31,800 --> 00:01:32,940
Sometimes there'd be a situation

43
00:01:32,940 --> 00:01:35,070
where you don't actually know the process ID.

44
00:01:35,070 --> 00:01:37,800
To quickly do it use the P grep command.

45
00:01:37,800 --> 00:01:41,370
And so, for example, we're going to use sshd.

46
00:01:41,370 --> 00:01:45,210
That's going to be the secure shell daemon, quick command,

47
00:01:45,210 --> 00:01:46,680
enter the process that we're looking for,

48
00:01:46,680 --> 00:01:49,200
and it's going to spit out the process ID.

49
00:01:49,200 --> 00:01:50,970
Now there'll be times where you're running process

50
00:01:50,970 --> 00:01:52,320
typically as script,

51
00:01:52,320 --> 00:01:54,720
and you need to run that process in the background,

52
00:01:54,720 --> 00:01:56,160
meaning that it's not going to consume,

53
00:01:56,160 --> 00:01:58,500
the entire commands line screen, okay?

54
00:01:58,500 --> 00:02:00,720
So we're going to use the ampersand symbol

55
00:02:00,720 --> 00:02:02,400
at the end of the command,

56
00:02:02,400 --> 00:02:05,190
and that's going to allow it to go into the background.

57
00:02:05,190 --> 00:02:06,480
And now we're going to use the sleep command,

58
00:02:06,480 --> 00:02:08,430
just to see this happen, right?

59
00:02:08,430 --> 00:02:09,630
So we're going to do sleep,

60
00:02:11,550 --> 00:02:14,730
300 seconds ampersand,

61
00:02:14,730 --> 00:02:15,563
okay?

62
00:02:15,563 --> 00:02:17,250
So it spits out the process ID for us,

63
00:02:17,250 --> 00:02:19,320
and we're going to run this process just

64
00:02:19,320 --> 00:02:21,753
to see that it is actually running.

65
00:02:22,770 --> 00:02:25,230
Okay, now, as mentioned earlier,

66
00:02:25,230 --> 00:02:27,180
we're going to learn how to kill processes,

67
00:02:27,180 --> 00:02:28,580
and we'll use the kill here,

68
00:02:29,760 --> 00:02:31,593
just to end this command.

69
00:02:34,080 --> 00:02:34,913
Okay?

70
00:02:35,760 --> 00:02:37,053
Going to run this again.

71
00:02:39,990 --> 00:02:42,903
And we see that that process was terminated, okay?

72
00:02:43,770 --> 00:02:46,530
Another useful command that we can use is the top command.

73
00:02:46,530 --> 00:02:49,320
And what this does is, it's like an interactive prompt

74
00:02:49,320 --> 00:02:53,160
to allow us to see all the process's memory consumption,

75
00:02:53,160 --> 00:02:54,420
and CPU consumption.

76
00:02:54,420 --> 00:02:56,970
It's usually going to be the most important and vital.

77
00:02:56,970 --> 00:03:00,090
And here, we're also able to change the nice values,

78
00:03:00,090 --> 00:03:03,303
which coordinate with the priority of the process.

79
00:03:04,410 --> 00:03:05,430
So, we're going to check this out.

80
00:03:05,430 --> 00:03:08,700
We're going to use the uppercase M,

81
00:03:08,700 --> 00:03:09,990
and that allows us to sort everything

82
00:03:09,990 --> 00:03:13,140
by the amount of memory that is taken up.

83
00:03:13,140 --> 00:03:16,170
So you see the top one is the shell that we're running.

84
00:03:16,170 --> 00:03:18,720
That's consuming the most memory currently.

85
00:03:18,720 --> 00:03:20,853
And then we also can do capital P,

86
00:03:21,750 --> 00:03:25,020
and that's going to sort things by the CPU process,

87
00:03:25,020 --> 00:03:27,510
whatever's running the highest CPU process.

88
00:03:27,510 --> 00:03:28,890
Currently, not a lot of things are running.

89
00:03:28,890 --> 00:03:29,850
A lot of things are very,

90
00:03:29,850 --> 00:03:33,780
using very minimal CPU process.

91
00:03:33,780 --> 00:03:36,180
But in a enterprise environment,

92
00:03:36,180 --> 00:03:37,650
there will be a lot of processes running,

93
00:03:37,650 --> 00:03:40,563
and some will consume the CPU and memory heavily.

94
00:03:42,630 --> 00:03:46,320
List of lsof, it shows us a list

95
00:03:46,320 --> 00:03:48,417
of the files that are currently being ran,

96
00:03:48,417 --> 00:03:51,603
and the processes that are running them, okay?

97
00:03:52,590 --> 00:03:54,700
So again, let's try to see this

98
00:03:56,640 --> 00:04:01,640
from the top and we can see the command process ID, user,

99
00:04:02,100 --> 00:04:05,610
we get the name of the file that's being open, et cetera,

100
00:04:05,610 --> 00:04:08,250
a lot of get useful information about this one.

101
00:04:08,250 --> 00:04:10,200
Again, remember, this is all relative

102
00:04:10,200 --> 00:04:12,120
to the files that we're trying to open

103
00:04:12,120 --> 00:04:14,640
because it can be situations where you're unable

104
00:04:14,640 --> 00:04:17,160
to open a certain file that you're trying to,

105
00:04:17,160 --> 00:04:18,930
and it's because of processes hogging

106
00:04:18,930 --> 00:04:20,313
up the particular object.

107
00:04:23,040 --> 00:04:25,770
As we saw earlier, that systemd,

108
00:04:25,770 --> 00:04:28,830
that's the initial boot process.

109
00:04:28,830 --> 00:04:33,033
Now, we're going to use this again for the analysis.

110
00:04:34,110 --> 00:04:38,130
We're going to analyze the boot order, okay,

111
00:04:38,130 --> 00:04:40,290
and we see this command.

112
00:04:40,290 --> 00:04:42,630
It's mostly going to be used with the blame command,

113
00:04:42,630 --> 00:04:45,480
and that's to see how long it actually takes

114
00:04:45,480 --> 00:04:47,160
for all the processes to run it.

115
00:04:47,160 --> 00:04:50,730
So it, by itself, just gives us how long the startup takes,

116
00:04:50,730 --> 00:04:53,340
and that's for us to identify any performance issues.

117
00:04:53,340 --> 00:04:56,460
But when we do it this way, we add the blame,

118
00:04:56,460 --> 00:04:58,650
it gives us all the services

119
00:04:58,650 --> 00:05:02,553
to go see how long it took them to start, okay?

120
00:05:03,690 --> 00:05:05,010
This will definitely be useful,

121
00:05:05,010 --> 00:05:08,013
when we're troubleshooting any type of booting up process.

122
00:05:10,080 --> 00:05:13,050
All right, next, we're going to go through,

123
00:05:13,050 --> 00:05:16,830
and learn how to modify the priority of systems.

124
00:05:16,830 --> 00:05:19,890
Now, typically, the scheduler is pretty effective

125
00:05:19,890 --> 00:05:22,380
at scheduling and prioritizing processes

126
00:05:22,380 --> 00:05:24,630
that need to be ran in a certain order.

127
00:05:24,630 --> 00:05:26,220
But again, it'll be time where we want

128
00:05:26,220 --> 00:05:28,230
to increase the priority,

129
00:05:28,230 --> 00:05:30,933
and let the system know, Hey, we want this done first.

130
00:05:31,800 --> 00:05:34,193
And so we want to use this command really quick, xl,

131
00:05:36,390 --> 00:05:39,450
and it's going to give us the priorities run by the user,

132
00:05:39,450 --> 00:05:41,300
and it shows the nice values of them.

133
00:05:42,360 --> 00:05:45,240
By default, the nice value is going to be zero,

134
00:05:45,240 --> 00:05:47,340
and the lower the priority,

135
00:05:47,340 --> 00:05:49,500
the lower the number, the higher the priority.

136
00:05:49,500 --> 00:05:53,010
And it's going to range from negative 19 to 20.

137
00:05:53,010 --> 00:05:55,080
So, anything with negative 19,

138
00:05:55,080 --> 00:05:57,723
it's going to be first, and 20 will be last,

139
00:05:58,710 --> 00:05:59,910
and anywhere in between.

140
00:06:02,293 --> 00:06:04,110
Okay, so we're going to simulate a long-running process,

141
00:06:04,110 --> 00:06:04,943
switch bit,

142
00:06:04,943 --> 00:06:07,860
and this command is just going to be an iteration of copies.

143
00:06:07,860 --> 00:06:11,850
Okay, so, we see the process ID, 15, nine, four, seven,

144
00:06:11,850 --> 00:06:12,950
15, nine, four, seven.

145
00:06:13,833 --> 00:06:14,820
We want to use the sudo top command,

146
00:06:14,820 --> 00:06:17,033
'cause we want to change the nice value of this.

147
00:06:22,065 --> 00:06:22,898
Okay?

148
00:06:24,720 --> 00:06:26,973
So, we're going to go in here, and do R.

149
00:06:28,110 --> 00:06:29,523
And going to do 15,

150
00:06:30,960 --> 00:06:31,983
nine, four, seven.

151
00:06:33,810 --> 00:06:34,650
Okay.

152
00:06:34,650 --> 00:06:37,113
And we're going to change this value to negative 15.

153
00:06:42,330 --> 00:06:43,163
A little quick.

154
00:06:48,600 --> 00:06:51,150
I'm going to look here, see if it went through for us.

155
00:06:53,250 --> 00:06:55,380
Okay, so we see I had that folder,

156
00:06:55,380 --> 00:06:56,343
taken care of,

157
00:06:57,180 --> 00:06:58,500
and again,

158
00:06:58,500 --> 00:07:00,090
pretty much as soon as we got,

159
00:07:00,090 --> 00:07:01,140
as soon as we changed that nice value,

160
00:07:01,140 --> 00:07:04,083
you can see at the bottom, how it says, done.

161
00:07:05,280 --> 00:07:09,210
Now, with quick processes, our, our CPUs are there so fast,

162
00:07:09,210 --> 00:07:12,810
that they can get done with copy processes pretty quickly,

163
00:07:12,810 --> 00:07:15,597
but changing that priority really amped it up.

164
00:07:15,597 --> 00:07:18,240
And so that's going to just indicate that, hey,

165
00:07:18,240 --> 00:07:19,800
we were able to copy the Etsy folder

166
00:07:19,800 --> 00:07:22,053
into a backup directory very quickly.

167
00:07:22,950 --> 00:07:25,770
Okay, so we went over how to troubleshoot certain processes

168
00:07:25,770 --> 00:07:29,010
by identifying the process IDs, how to kill them,

169
00:07:29,010 --> 00:07:32,100
how to run processes in the background,

170
00:07:32,100 --> 00:07:35,400
and how to change the priority that the scheduler uses

171
00:07:35,400 --> 00:07:37,770
for processes when we're running commands

172
00:07:37,770 --> 00:07:39,570
on our Linux system.

173
00:07:39,570 --> 00:07:41,010
Thank you for sticking with me through this walkthrough,

174
00:07:41,010 --> 00:07:42,810
and I'll see you in the next lesson.

