1
00:00:00,240 --> 00:00:01,073
In this lesson,

2
00:00:01,073 --> 00:00:03,393
we're going to go over entering commands in shell.

3
00:00:04,830 --> 00:00:06,900
Now, a shell surrounds the core portion

4
00:00:06,900 --> 00:00:09,750
of the operating system, which we call the kernel.

5
00:00:09,750 --> 00:00:11,280
It allows the user to pass commands

6
00:00:11,280 --> 00:00:13,050
and information to the kernel,

7
00:00:13,050 --> 00:00:16,770
and the kernel also responds back to the user via the shell.

8
00:00:16,770 --> 00:00:19,650
Now, the shell can be thought of as an interpreter

9
00:00:19,650 --> 00:00:23,010
between the human and kernel languages.

10
00:00:23,010 --> 00:00:25,230
So it pretty much it translates our commands

11
00:00:25,230 --> 00:00:28,530
into something that the computer can recognize and use.

12
00:00:28,530 --> 00:00:30,090
Now, the first command we're going to go over

13
00:00:30,090 --> 00:00:31,860
is the echo command.

14
00:00:31,860 --> 00:00:33,960
The echo command only repeats

15
00:00:33,960 --> 00:00:36,150
exactly what it's been told to repeat.

16
00:00:36,150 --> 00:00:37,530
So for example,

17
00:00:37,530 --> 00:00:39,157
I'm going to do echo.

18
00:00:39,157 --> 00:00:39,990
"Hello,

19
00:00:42,270 --> 00:00:43,103
world!"

20
00:00:46,110 --> 00:00:47,760
Voila.

21
00:00:47,760 --> 00:00:49,950
Typically, you're going to use echo in the script.

22
00:00:49,950 --> 00:00:53,190
So for example, whenever the script is going through

23
00:00:53,190 --> 00:00:54,660
and completing all these processes,

24
00:00:54,660 --> 00:00:56,670
sometimes you want to displace something to the user.

25
00:00:56,670 --> 00:01:00,360
Just say, "Update complete, update successful."

26
00:01:00,360 --> 00:01:03,000
You're going to use echo and put the information in

27
00:01:03,000 --> 00:01:05,099
after the results are complete.

28
00:01:05,099 --> 00:01:07,020
Next, we'll use the present working directory.

29
00:01:07,020 --> 00:01:08,823
That's simply PWD.

30
00:01:09,840 --> 00:01:10,950
It just lets the user know

31
00:01:10,950 --> 00:01:13,110
which directory there is currently working in.

32
00:01:13,110 --> 00:01:14,310
So for example, me,

33
00:01:14,310 --> 00:01:16,290
I'm currently working in my home directory

34
00:01:16,290 --> 00:01:17,553
under my profile.

35
00:01:18,780 --> 00:01:20,850
Next, we're going to go over the list command.

36
00:01:20,850 --> 00:01:23,550
What this simply does is print out a list

37
00:01:23,550 --> 00:01:25,320
of the files and folders

38
00:01:25,320 --> 00:01:27,683
that are currently in your present working directory.

39
00:01:28,920 --> 00:01:31,614
So as you see, right now, we just have

40
00:01:31,614 --> 00:01:33,977
just a skew of folders that are currently

41
00:01:33,977 --> 00:01:37,500
in the working directory now, desktop, documents, downloads,

42
00:01:37,500 --> 00:01:38,850
music, pictures, et cetera.

43
00:01:39,930 --> 00:01:43,637
If we want to see more information, we're going to do ls -al.

44
00:01:46,620 --> 00:01:51,620
Now, the A portion of it stands for the hidden attribute.

45
00:01:51,720 --> 00:01:54,630
So whenever you use the A option, pretty much,

46
00:01:54,630 --> 00:01:57,720
it lets you see any file or folder that's hidden.

47
00:01:57,720 --> 00:01:59,580
Now, most of these folders aren't hidden

48
00:01:59,580 --> 00:02:00,750
because of security features.

49
00:02:00,750 --> 00:02:03,630
It's more just to keep the folders looking clean

50
00:02:03,630 --> 00:02:05,130
and remove the user from things

51
00:02:05,130 --> 00:02:07,320
that they typically won't be using.

52
00:02:07,320 --> 00:02:10,590
Now, the L, which stands for the long,

53
00:02:10,590 --> 00:02:13,790
what that does is gives us more information, as we can see,

54
00:02:13,790 --> 00:02:15,480
and so if we look at this screen right here,

55
00:02:15,480 --> 00:02:18,600
we'll see a lot of information to the left.

56
00:02:18,600 --> 00:02:22,683
For example, if we look at the top line, we'll see drwx.

57
00:02:24,780 --> 00:02:26,973
Now, the D stands for the directory,

58
00:02:28,110 --> 00:02:30,750
R is read privileges,

59
00:02:30,750 --> 00:02:32,190
W is write privileges,

60
00:02:32,190 --> 00:02:34,410
and X is executables.

61
00:02:34,410 --> 00:02:36,690
Now, going from left to right,

62
00:02:36,690 --> 00:02:39,990
we'll see that there's multiple sections in the fields.

63
00:02:39,990 --> 00:02:41,643
So in the first section, again,

64
00:02:41,643 --> 00:02:43,290
it's going to be either directory.

65
00:02:43,290 --> 00:02:46,620
Now, if you see a dash there, that means that it's a file.

66
00:02:46,620 --> 00:02:51,600
The first set of rwx's, that's for the owner of the folder.

67
00:02:51,600 --> 00:02:53,400
The next set will be for the group.

68
00:02:53,400 --> 00:02:55,800
If there's a group associated to the file,

69
00:02:55,800 --> 00:02:58,260
those are the privileges that the group will have,

70
00:02:58,260 --> 00:03:00,510
and then the last will be for any other user,

71
00:03:00,510 --> 00:03:02,100
so anyone that's not part of the group

72
00:03:02,100 --> 00:03:03,870
and that's not the owner.

73
00:03:03,870 --> 00:03:05,340
The next field's going to be the links,

74
00:03:05,340 --> 00:03:08,103
the amount of links associated to the file or folder.

75
00:03:09,180 --> 00:03:11,580
After that's going to be the owner.

76
00:03:11,580 --> 00:03:13,800
After that's going to be the group associated with it

77
00:03:13,800 --> 00:03:15,810
'cause, typically, when you create a user profile,

78
00:03:15,810 --> 00:03:18,760
they just all automatically get created as a group as well.

79
00:03:19,740 --> 00:03:22,650
Then you're going to see the amount of bytes

80
00:03:22,650 --> 00:03:25,560
and then the date it was last modified or created,

81
00:03:25,560 --> 00:03:28,533
and then, of course, the name of the directory or file.

82
00:03:30,000 --> 00:03:31,320
So the next command we go over

83
00:03:31,320 --> 00:03:33,180
is the change directory command.

84
00:03:33,180 --> 00:03:34,380
Let's simply cd.

85
00:03:34,380 --> 00:03:36,600
We'll go to the etc directory,

86
00:03:36,600 --> 00:03:39,390
and we'll confirm that with the present working directory.

87
00:03:39,390 --> 00:03:42,300
Now, you can see that we're in the etc directory.

88
00:03:42,300 --> 00:03:46,113
Another one that's very useful is the var log file.

89
00:03:49,110 --> 00:03:51,150
Now, this is where all of these system logs

90
00:03:51,150 --> 00:03:54,240
are typically stored, and if we want to list them out,

91
00:03:54,240 --> 00:03:55,340
of course, we know ls,

92
00:03:58,168 --> 00:04:00,360
of course, for more information to see the hidden files

93
00:04:00,360 --> 00:04:02,280
and more information about 'em.

94
00:04:02,280 --> 00:04:03,723
We add those modifiers.

95
00:04:05,280 --> 00:04:07,830
The next command we're going to go over is the touch command.

96
00:04:07,830 --> 00:04:09,210
Now, if the file already exists,

97
00:04:09,210 --> 00:04:11,460
it will update the modification on it,

98
00:04:11,460 --> 00:04:12,960
but if not, it will just create it.

99
00:04:12,960 --> 00:04:14,210
So we'll do touch myfile.

100
00:04:16,529 --> 00:04:18,240
Oh, see, now, we're in the wrong directory.

101
00:04:18,240 --> 00:04:19,410
So we don't have permissions for that.

102
00:04:19,410 --> 00:04:22,743
So let's go back to my home directory.

103
00:04:26,102 --> 00:04:27,185
Touch myfile.

104
00:04:31,980 --> 00:04:33,791
And then we're going to ls it out,

105
00:04:33,791 --> 00:04:35,793
and we can see the myfile was added.

106
00:04:38,760 --> 00:04:41,400
Now, the next command I'm going to go over is the cat command.

107
00:04:41,400 --> 00:04:44,340
Now, it stands for concatenation,

108
00:04:44,340 --> 00:04:47,550
and what it does is print a display of the information

109
00:04:47,550 --> 00:04:48,510
that we're trying to see.

110
00:04:48,510 --> 00:04:51,660
So for example, we're going to look at a host name.

111
00:04:51,660 --> 00:04:54,543
So this file etc/hostname,

112
00:04:55,590 --> 00:04:57,480
it prints everything out on screen.

113
00:04:57,480 --> 00:04:59,370
That file is very small,

114
00:04:59,370 --> 00:05:01,680
and so it shows only what's in that text,

115
00:05:01,680 --> 00:05:03,990
and it's only one line so it's not too much.

116
00:05:03,990 --> 00:05:04,980
Now, there's going to be examples

117
00:05:04,980 --> 00:05:07,410
where we're going to have files that are very long.

118
00:05:07,410 --> 00:05:09,270
So we're going to use the less command,

119
00:05:09,270 --> 00:05:14,270
and we're going to try the var log file, dmesg file.

120
00:05:17,430 --> 00:05:21,423
Now, this file, again, is very long.

121
00:05:22,320 --> 00:05:24,360
So when we use the less command,

122
00:05:24,360 --> 00:05:28,140
it allows us to use the space to scroll entire pages

123
00:05:28,140 --> 00:05:29,790
or we can use the up and down arrow

124
00:05:29,790 --> 00:05:31,950
just to go one line at a time

125
00:05:31,950 --> 00:05:34,690
or, again, the space changes everything

126
00:05:38,400 --> 00:05:39,550
or to do one at a time,

127
00:05:41,160 --> 00:05:43,710
and we use Q to get out of that,

128
00:05:43,710 --> 00:05:45,690
and, again, if you want to see it with the cat,

129
00:05:45,690 --> 00:05:47,400
you'll see that

130
00:05:47,400 --> 00:05:49,740
we can't see everything on there.

131
00:05:49,740 --> 00:05:51,940
It'll just go to the very bottom

132
00:05:53,190 --> 00:05:56,190
of the screen and only show one page.

133
00:05:56,190 --> 00:06:01,190
So the less command, again, is used for longer files.

134
00:06:03,210 --> 00:06:05,133
I'm going to use Q to quit.

135
00:06:06,000 --> 00:06:08,910
Next thing I want to do is go over the vim command.

136
00:06:08,910 --> 00:06:11,700
Now, the vim allows us to edit a file.

137
00:06:11,700 --> 00:06:15,093
So I'm going to use the same file that I had earlier, myfile.

138
00:06:17,370 --> 00:06:18,780
Now, in order to insert information,

139
00:06:18,780 --> 00:06:20,283
we're want to press the I key,

140
00:06:21,390 --> 00:06:24,003
and for this example, we're just going to say,

141
00:06:24,990 --> 00:06:28,833
Hello, this is Jamario.

142
00:06:30,360 --> 00:06:33,338
Okay, now, to get out of there,

143
00:06:33,338 --> 00:06:34,988
we're going to press the escape key,

144
00:06:35,940 --> 00:06:38,373
and to save, we're going to hit the colon,

145
00:06:39,210 --> 00:06:42,453
write, that's wQ, quit,

146
00:06:44,670 --> 00:06:45,971
and using the command from earlier,

147
00:06:45,971 --> 00:06:47,321
we're going to use cat myfile,

148
00:06:48,900 --> 00:06:51,127
and now, we can see the file displays,

149
00:06:51,127 --> 00:06:51,960
"Hello, this is Jamario,"

150
00:06:51,960 --> 00:06:54,690
and that's what I just wrote into the file.

151
00:06:54,690 --> 00:06:56,370
Now there's other text editors

152
00:06:56,370 --> 00:06:59,280
that we can use another one being nano.

153
00:06:59,280 --> 00:07:00,600
So we're going to do the same thing,

154
00:07:00,600 --> 00:07:03,693
but we're going to create another file called myfile2.

155
00:07:05,850 --> 00:07:08,970
Now, with nano, you just go right into insert.

156
00:07:08,970 --> 00:07:13,297
So do Hello, I am nano

157
00:07:16,257 --> 00:07:17,120
for this...

158
00:07:20,070 --> 00:07:20,903
Simple enough.

159
00:07:20,903 --> 00:07:22,320
Now, to save your information,

160
00:07:22,320 --> 00:07:24,490
you're going to do Control + O

161
00:07:25,770 --> 00:07:30,030
or you'll confirm that with inner file name to write to,

162
00:07:30,030 --> 00:07:33,393
and to get out of here, we're going to do Control + X,

163
00:07:35,640 --> 00:07:39,200
and again, we're going to view the file.

164
00:07:39,200 --> 00:07:42,270
We want to see, "Hello, I'm using nano for this file."

165
00:07:42,270 --> 00:07:44,823
So it's saved and everything was successful.

166
00:07:45,840 --> 00:07:46,690
Clear the screen.

167
00:07:49,380 --> 00:07:52,590
Now, there are going to be times that we need access files

168
00:07:52,590 --> 00:07:55,350
that a regular standard user won't be able to access.

169
00:07:55,350 --> 00:07:58,410
So then we're going to have to switch to the root user

170
00:07:58,410 --> 00:08:00,210
to get that information.

171
00:08:00,210 --> 00:08:02,640
So let's try this out really quick,

172
00:08:02,640 --> 00:08:07,640
cat/var/log/boot.log.

173
00:08:08,550 --> 00:08:11,580
Now, we see that we can't do this as a standard user.

174
00:08:11,580 --> 00:08:13,560
So what we need to do is switch to the root.

175
00:08:13,560 --> 00:08:17,727
So we're going to use the command su - root,

176
00:08:17,727 --> 00:08:20,103
and the su stands for substitute user.

177
00:08:21,720 --> 00:08:24,540
So here, we're going to put in the root password,

178
00:08:24,540 --> 00:08:25,833
and now, we're root,

179
00:08:27,720 --> 00:08:29,010
and now, we're going to try this command again.

180
00:08:29,010 --> 00:08:33,663
So we're going to do cat /var/log .log.

181
00:08:37,110 --> 00:08:40,470
And now, in this example, when you first enter,

182
00:08:40,470 --> 00:08:42,090
that means the command was executed.

183
00:08:42,090 --> 00:08:45,210
If there's no feedback, you know it executed correctly,

184
00:08:45,210 --> 00:08:48,000
but for this example, the boot.log file is empty.

185
00:08:48,000 --> 00:08:51,030
So let's see which file is not empty,

186
00:08:51,030 --> 00:08:52,740
and now, we can see another boot log

187
00:08:52,740 --> 00:08:54,273
with a date stamp to it,

188
00:08:55,290 --> 00:08:58,570
boot log 20220517

189
00:09:01,153 --> 00:09:01,986
var

190
00:09:05,853 --> 00:09:06,936
log-20220517.

191
00:09:13,286 --> 00:09:14,460
And now, we can see the information

192
00:09:14,460 --> 00:09:16,310
that's associated with that boot log,

193
00:09:17,340 --> 00:09:18,720
and next, we want to exit out of this.

194
00:09:18,720 --> 00:09:21,690
Exit switches back to our regular user account.

195
00:09:21,690 --> 00:09:22,680
So the next thing we want to do

196
00:09:22,680 --> 00:09:25,200
is to leverage the tab completion command.

197
00:09:25,200 --> 00:09:27,570
We'll use the example by creating a long file name.

198
00:09:27,570 --> 00:09:29,046
So I'm going to name this

199
00:09:29,046 --> 00:09:30,713
thisisalongfilename.

200
00:09:35,070 --> 00:09:38,073
All right, we'll verify that created.

201
00:09:39,840 --> 00:09:42,340
Now, the tab command autocompletes

202
00:09:43,230 --> 00:09:46,233
any type of command or file name.

203
00:09:47,880 --> 00:09:49,230
So we're going to ls this out,

204
00:09:51,690 --> 00:09:53,547
and all we're going to have to press is the th,

205
00:09:53,547 --> 00:09:57,903
the first two characters of the file name and press tab,

206
00:09:59,010 --> 00:10:00,483
and it'll autocomplete.

207
00:10:03,300 --> 00:10:05,640
Again, this is just another convenient feature Linux

208
00:10:05,640 --> 00:10:08,880
which makes type of commands very efficient.

209
00:10:08,880 --> 00:10:12,120
Next thing we want to do is to use the history command,

210
00:10:12,120 --> 00:10:14,400
but we're going to tab that out,

211
00:10:14,400 --> 00:10:16,170
and the history command just shows you a list

212
00:10:16,170 --> 00:10:19,170
of all your most recent commands.

213
00:10:19,170 --> 00:10:22,530
So it'll be easier to jump back to a command.

214
00:10:22,530 --> 00:10:26,940
Maybe you forgot, but we also know that we can just arrow up

215
00:10:26,940 --> 00:10:29,733
and arrow down as well for those commands.

216
00:10:30,600 --> 00:10:31,710
So again, just want to note,

217
00:10:31,710 --> 00:10:34,018
tab completion works on commands,

218
00:10:34,018 --> 00:10:37,050
file names, and directories.

219
00:10:37,050 --> 00:10:40,650
Last thing want do is reboot the system.

220
00:10:40,650 --> 00:10:42,200
It's going to be a common feature.

221
00:10:48,514 --> 00:10:49,347
Okay.

222
00:10:57,030 --> 00:10:59,080
All right, we're back to our home screen.

223
00:11:00,150 --> 00:11:02,160
So thank you for walking through this lesson with me

224
00:11:02,160 --> 00:11:03,660
on entering shell commands

225
00:11:03,660 --> 00:11:05,460
and I'll see you in the next lesson.

