1
00:00:00,150 --> 00:00:00,983
In this lesson,

2
00:00:00,983 --> 00:00:03,900
we'll go over creating modifying and deleting users

3
00:00:03,900 --> 00:00:05,130
in a Linux environment.

4
00:00:05,130 --> 00:00:06,450
So the first thing we're going to do

5
00:00:06,450 --> 00:00:09,390
is to view the default settings when we create a new user.

6
00:00:09,390 --> 00:00:12,059
So we going to do that by doing a "sudo" command.

7
00:00:12,059 --> 00:00:13,977
We go "useradd" fetch "D"

8
00:00:17,340 --> 00:00:19,030
Okay let's enter my password

9
00:00:21,390 --> 00:00:23,820
All right so whenever we create a new user

10
00:00:23,820 --> 00:00:26,370
these are the settings that's going to be given to it.

11
00:00:28,050 --> 00:00:28,980
Now in this nest command

12
00:00:28,980 --> 00:00:31,230
we're actually going to go over the settings that are applied

13
00:00:31,230 --> 00:00:33,840
to currently added new users.

14
00:00:33,840 --> 00:00:36,873
So let's get started here we'll go with "less" here,

15
00:00:38,403 --> 00:00:41,543
"etc" "login" dash "defs"

16
00:00:44,520 --> 00:00:45,353
There you go.

17
00:00:49,680 --> 00:00:52,530
See there's more detailed information

18
00:00:52,530 --> 00:00:55,140
about what happens when we're actually creating these users

19
00:00:55,140 --> 00:00:56,130
in their settings.

20
00:00:56,130 --> 00:00:56,963
A little bit of information

21
00:00:56,963 --> 00:00:58,613
about each one of those settings there.

22
00:01:01,770 --> 00:01:03,070
All right want to quit that.

23
00:01:05,820 --> 00:01:09,990
Now the next thing we want to do is also look at a scale file.

24
00:01:09,990 --> 00:01:13,230
Now what allows us to do is see what files will be copied

25
00:01:13,230 --> 00:01:15,960
to the user's home directory when we create them.

26
00:01:15,960 --> 00:01:16,860
So let's look here

27
00:01:17,910 --> 00:01:21,387
ready slash "etc" slash "skel".

28
00:01:22,440 --> 00:01:23,273
Do this.

29
00:01:25,440 --> 00:01:28,110
Now as you see when we created a new home directory

30
00:01:28,110 --> 00:01:29,760
after we create a new user

31
00:01:29,760 --> 00:01:32,710
these are the files that's going to be added to the directory.

32
00:01:35,880 --> 00:01:36,870
So for this example

33
00:01:36,870 --> 00:01:39,320
we're going to create a user called Michael Anderson

34
00:01:40,410 --> 00:01:42,423
Going to add "sudo" here.

35
00:01:43,440 --> 00:01:46,090
Says we need higher level privileges to add and users

36
00:01:47,712 --> 00:01:52,712
"manderson"

37
00:01:54,240 --> 00:01:55,350
All right so there's that.

38
00:01:55,350 --> 00:01:56,500
So now we're going to view

39
00:02:01,440 --> 00:02:02,840
the information of the user.

40
00:02:03,870 --> 00:02:06,240
So we scroll down and we see Michael Anderson was added

41
00:02:06,240 --> 00:02:07,380
at the bottom here.

42
00:02:07,380 --> 00:02:09,990
So reading from left to right we see the first thing

43
00:02:09,990 --> 00:02:11,283
is the user ID.

44
00:02:12,420 --> 00:02:14,970
The next thing is the password but

45
00:02:14,970 --> 00:02:16,980
an "x" is there to represent the fact that

46
00:02:16,980 --> 00:02:18,450
the password is stored in another file

47
00:02:18,450 --> 00:02:20,940
which is going to be the shadow file.

48
00:02:20,940 --> 00:02:23,793
Next line is going to be the user ID.

49
00:02:24,750 --> 00:02:26,943
Next the group ID.

50
00:02:28,080 --> 00:02:31,800
Then we have the user's default directory

51
00:02:31,800 --> 00:02:35,280
and then also the default bash shell when a user logs in.

52
00:02:35,280 --> 00:02:38,010
So that's what that information is telling us there.

53
00:02:38,010 --> 00:02:40,380
So whenever you need to find that type of information out

54
00:02:40,380 --> 00:02:43,770
just use that same command "cat" "etc" "password"

55
00:02:43,770 --> 00:02:45,503
and we'll get all the information we need.

56
00:02:46,740 --> 00:02:49,170
Next we can create another user,

57
00:02:49,170 --> 00:02:51,360
but this time I want to add a comment to

58
00:02:51,360 --> 00:02:54,570
have their name appended to the information.

59
00:02:54,570 --> 00:02:57,143
So we're going to do Chris Mason,

60
00:03:01,470 --> 00:03:02,850
Mason will be his name.

61
00:03:02,850 --> 00:03:07,293
So of course then we go to the "etc" file "password"

62
00:03:08,160 --> 00:03:10,050
I'm going to see the information there again.

63
00:03:10,050 --> 00:03:12,870
So it's right below the Michael Anderson

64
00:03:12,870 --> 00:03:15,310
going to see C Mason again

65
00:03:16,620 --> 00:03:17,670
the next indication is

66
00:03:17,670 --> 00:03:20,130
that the password files is in another file.

67
00:03:20,130 --> 00:03:21,340
The user ID

68
00:03:22,650 --> 00:03:23,530
the group ID

69
00:03:24,420 --> 00:03:26,430
and the comment represents the name.

70
00:03:26,430 --> 00:03:27,690
So Chris Mason

71
00:03:27,690 --> 00:03:30,840
that's a good thing for us as administrators

72
00:03:30,840 --> 00:03:34,740
to be able to quickly find out who the user name belongs to.

73
00:03:34,740 --> 00:03:36,450
And of course the comment

74
00:03:36,450 --> 00:03:39,300
the next thing is the user directory file

75
00:03:39,300 --> 00:03:42,000
and then also again the default bash other one to use

76
00:03:42,000 --> 00:03:42,833
for the user.

77
00:03:44,100 --> 00:03:45,360
We'll clear this here

78
00:03:45,360 --> 00:03:47,370
and just a little bit more practice,

79
00:03:47,370 --> 00:03:49,170
create another account

80
00:03:49,170 --> 00:03:52,663
for user Aiden Riley,

81
00:03:56,550 --> 00:03:57,750
create down here.

82
00:03:57,750 --> 00:03:59,950
Same thing keep it fast

83
00:04:00,870 --> 00:04:02,713
in our up arrow "ralexander"

84
00:04:07,470 --> 00:04:10,593
get up arrow roll quickly.

85
00:04:12,090 --> 00:04:13,890
See they were quickly created there.

86
00:04:15,060 --> 00:04:16,800
So the next thing we're going to do is create a

87
00:04:16,800 --> 00:04:17,899
temporary user account

88
00:04:21,757 --> 00:04:25,650
"useradd" got to create the

89
00:04:25,650 --> 00:04:27,930
dash E stands for the expiration date,

90
00:04:27,930 --> 00:04:32,427
and it's going to be year month day format

91
00:04:35,820 --> 00:04:37,220
that's before it slash year,

92
00:04:39,150 --> 00:04:40,050
along with username

93
00:04:40,050 --> 00:04:42,310
we're going to use R Stanley for our example

94
00:04:45,120 --> 00:04:48,563
Quick let's get to this up arrow.

95
00:04:52,287 --> 00:04:54,237
Now we see the users add at the bottom.

96
00:04:58,290 --> 00:05:01,477
Now a quick way to change the expiration is the

97
00:05:01,477 --> 00:05:02,583
"chage" command.

98
00:05:03,450 --> 00:05:07,325
I'm not sure if I'm saying that right but I hope I am.

99
00:05:07,325 --> 00:05:08,430
Let's do it quickly here

100
00:05:09,480 --> 00:05:12,840
and we can change the expiration date and just say

101
00:05:12,840 --> 00:05:14,077
we want to make it 2022

102
00:05:17,696 --> 00:05:18,529
12 31

103
00:05:19,955 --> 00:05:21,500
Well oops not 13 31

104
00:05:24,000 --> 00:05:25,347
for "rstanley".

105
00:05:30,900 --> 00:05:34,380
Huh? Looks like I have to again.

106
00:05:34,380 --> 00:05:38,703
Use the oh let's do our "sudo" here.

107
00:05:39,750 --> 00:05:41,250
There we go.

108
00:05:41,250 --> 00:05:44,340
So remember the "sudo" exclamation point exclamation point

109
00:05:44,340 --> 00:05:47,100
allows us to call the last command

110
00:05:47,100 --> 00:05:49,740
with the "sudo" command invoked.

111
00:05:49,740 --> 00:05:51,240
So it saves a lot of time.

112
00:05:51,240 --> 00:05:53,340
That's one great benefit of Linux as well.

113
00:05:54,780 --> 00:05:58,800
Another thing we can do is actually see what

114
00:05:58,800 --> 00:06:00,633
the information is.

115
00:06:02,100 --> 00:06:05,970
The "chage" stands for change age,

116
00:06:05,970 --> 00:06:08,070
so it's only dealing with expiration date.

117
00:06:10,140 --> 00:06:13,400
So if we want to see the expiration date for "rstanley"

118
00:06:13,400 --> 00:06:14,373
do it like this.

119
00:06:15,600 --> 00:06:18,097
Also if we want to we can change the

120
00:06:18,097 --> 00:06:21,580
"sudo" change the maximum

121
00:06:26,040 --> 00:06:28,350
days until the user have to change that password.

122
00:06:28,350 --> 00:06:29,313
So "rstanley" here.

123
00:06:32,220 --> 00:06:33,333
So click it back up.

124
00:06:34,860 --> 00:06:38,760
Now we can see the days that the user has until they have to

125
00:06:38,760 --> 00:06:39,860
change their password.

126
00:06:41,280 --> 00:06:44,520
Hopefully everything turns into if and two-factor

127
00:06:44,520 --> 00:06:46,560
authentication in your organization but

128
00:06:46,560 --> 00:06:48,360
currently we still use the password so

129
00:06:48,360 --> 00:06:51,330
90 days is typically the standard for a normal user

130
00:06:51,330 --> 00:06:53,780
and 60 is usually the standard for administrator.

131
00:06:56,160 --> 00:06:58,950
Another thing we're able to do is warn the user when they

132
00:06:58,950 --> 00:07:00,780
need to change their password,

133
00:07:00,780 --> 00:07:03,443
it's going to be "chage" up or "sudo"

134
00:07:07,530 --> 00:07:09,980
Say five days over "rstanley".

135
00:07:13,140 --> 00:07:14,653
Let's see if this is set for

136
00:07:16,917 --> 00:07:18,330
all right.

137
00:07:18,330 --> 00:07:20,970
We're able to successfully configure every single

138
00:07:20,970 --> 00:07:25,020
one of the options for the password expiration.

139
00:07:25,020 --> 00:07:28,200
The next thing we're going to do is modify user information.

140
00:07:28,200 --> 00:07:31,890
So this is we're just going to modify the user's account name.

141
00:07:31,890 --> 00:07:33,990
So we go "rstanley" again

142
00:07:33,990 --> 00:07:36,600
and this time what we're going to do is

143
00:07:36,600 --> 00:07:41,600
we're going to change the user's name,

144
00:07:42,000 --> 00:07:44,667
but the syntax is going to be dash "L".

145
00:07:46,440 --> 00:07:49,290
We're going to use the name we want to change it to,

146
00:07:49,290 --> 00:07:51,930
and then the actual name that's currently in the system.

147
00:07:51,930 --> 00:07:56,217
So we're going to change it to "rstanley1" from "rstanley".

148
00:08:02,580 --> 00:08:04,930
We're going to verify the information was changed.

149
00:08:08,047 --> 00:08:10,023
"etc" password file.

150
00:08:11,520 --> 00:08:14,430
And we can see at the bottom is now "rstanley1"

151
00:08:14,430 --> 00:08:16,620
when it was prior "rstanley".

152
00:08:16,620 --> 00:08:19,500
So that's some of the information we use.

153
00:08:19,500 --> 00:08:20,970
There's more documentation of course,

154
00:08:20,970 --> 00:08:22,330
if you want to go to the man

155
00:08:25,278 --> 00:08:26,400
and you can see the

156
00:08:26,400 --> 00:08:29,553
all the options that are available for user modification.

157
00:08:30,870 --> 00:08:32,490
Now as an administrator sometimes it might be

158
00:08:32,490 --> 00:08:35,280
necessary to lock and unlock users

159
00:08:35,280 --> 00:08:38,020
a quick way to do this "sudo" password

160
00:08:40,169 --> 00:08:43,563
and use dash "L" use "rstanley" here.

161
00:08:46,320 --> 00:08:47,760
When we see they're locked

162
00:08:47,760 --> 00:08:50,290
now we want to unlock it just simply dash up

163
00:08:51,210 --> 00:08:53,400
change this "L" to "U".

164
00:08:53,400 --> 00:08:55,680
And now we see unlock Stanley's account.

165
00:08:55,680 --> 00:08:59,580
So again very quick very easy.

166
00:08:59,580 --> 00:09:04,230
Now the graphic user interface it might be a little easier

167
00:09:04,230 --> 00:09:07,170
but this is much faster and much more powerful.

168
00:09:07,170 --> 00:09:09,780
So learning command line is very important.

169
00:09:09,780 --> 00:09:12,150
Now in this lecture we'll continue to focus

170
00:09:12,150 --> 00:09:15,150
on modifying users in Linux.

171
00:09:15,150 --> 00:09:17,340
So the first thing we want to do just a little refresher

172
00:09:17,340 --> 00:09:20,190
let go back and check these user accounts

173
00:09:20,190 --> 00:09:22,140
and the "etc" password file.

174
00:09:22,140 --> 00:09:24,510
Now as you see J Kelly at the bottom

175
00:09:24,510 --> 00:09:28,020
A Riley R Alexander and R Stanley.

176
00:09:28,020 --> 00:09:30,210
Again note the X after is showing

177
00:09:30,210 --> 00:09:32,610
that the password is stored in a different file.

178
00:09:33,510 --> 00:09:37,740
So the file in question is going to be the "sudo" "cat"

179
00:09:37,740 --> 00:09:40,710
because we have to have permissions to get to this file

180
00:09:40,710 --> 00:09:42,510
and that's going to be the shadow file.

181
00:09:44,100 --> 00:09:46,320
The shadow file stores the hash of the password

182
00:09:46,320 --> 00:09:48,450
not the actual password itself.

183
00:09:48,450 --> 00:09:52,200
And you can see here noted for mine and A Riley's

184
00:09:52,200 --> 00:09:53,640
that the password is there,

185
00:09:53,640 --> 00:09:56,310
but again for R Alexander and R Stanley,

186
00:09:56,310 --> 00:09:58,020
it shows the exclamation points again

187
00:09:58,020 --> 00:10:01,230
identifying that there is no password set.

188
00:10:01,230 --> 00:10:02,700
So the next thing we want to do is go through

189
00:10:02,700 --> 00:10:04,890
and set those passwords right now.

190
00:10:04,890 --> 00:10:06,450
So it's administrative function

191
00:10:06,450 --> 00:10:08,340
so we need to set password.

192
00:10:08,340 --> 00:10:10,297
We're going to use "ralexander".

193
00:10:13,200 --> 00:10:16,863
All right we're going to set a password for them.

194
00:10:21,060 --> 00:10:22,620
So it's giving us an error letting us know

195
00:10:22,620 --> 00:10:25,830
that it doesn't pass the dictionary check for this example.

196
00:10:25,830 --> 00:10:27,120
We're just going to let it go.

197
00:10:27,120 --> 00:10:29,130
So we want to make sure it went through here,

198
00:10:29,130 --> 00:10:30,750
just go back to the shadow file

199
00:10:30,750 --> 00:10:33,390
now you see R Alexander has a hash

200
00:10:33,390 --> 00:10:35,730
of his password shown in the file.

201
00:10:35,730 --> 00:10:37,020
So just for more practice,

202
00:10:37,020 --> 00:10:39,663
we're going to do one more for Stanley.

203
00:10:40,650 --> 00:10:41,583
Use the up arrow,

204
00:10:44,317 --> 00:10:47,700
"rstanley" password.

205
00:10:47,700 --> 00:10:49,100
Try to do a better password.

206
00:10:50,010 --> 00:10:53,290
Little bit more secure

207
00:10:57,480 --> 00:10:59,220
see what a fuss that was

208
00:10:59,220 --> 00:11:00,720
All right.

209
00:11:00,720 --> 00:11:01,713
No fussing yet.

210
00:11:06,030 --> 00:11:08,230
All right looks like we're good to go there.

211
00:11:10,170 --> 00:11:12,783
Okay R Stanley has a password set now.

212
00:11:14,130 --> 00:11:16,350
Now next thing we going to do is modify the user account

213
00:11:16,350 --> 00:11:18,000
just by adding a comment,

214
00:11:18,000 --> 00:11:18,930
really stating their name.

215
00:11:18,930 --> 00:11:21,543
So we're going to go with R Stanley first.

216
00:11:23,031 --> 00:11:26,040
We're going to use the "usermod" command.

217
00:11:26,040 --> 00:11:28,140
So we're just going to dash "C"

218
00:11:28,140 --> 00:11:30,540
we're just going to add a comment

219
00:11:30,540 --> 00:11:35,280
give name say Ramone Stanley

220
00:11:35,280 --> 00:11:37,890
it's going to be his name for this example.

221
00:11:37,890 --> 00:11:41,880
And got to make sure we add it to the Stanley account.

222
00:11:41,880 --> 00:11:43,020
Press enter,

223
00:11:43,020 --> 00:11:44,700
let's go check that again.

224
00:11:44,700 --> 00:11:46,830
Again we'll go to the password file to make sure we

225
00:11:46,830 --> 00:11:50,490
see information about the users in question.

226
00:11:50,490 --> 00:11:53,647
So here we go.

227
00:11:53,647 --> 00:11:55,740
"Password" so now we're seeing

228
00:11:55,740 --> 00:11:57,140
at the very bottom R Stanley

229
00:11:58,470 --> 00:12:00,900
Raymond Stanley so the comments again,

230
00:12:00,900 --> 00:12:04,140
are good information for an administrator quickly

231
00:12:04,140 --> 00:12:06,420
see who a user is.

232
00:12:06,420 --> 00:12:08,250
That's what it's mostly used for what you can add

233
00:12:08,250 --> 00:12:11,010
all type of other information of course.

234
00:12:11,010 --> 00:12:13,410
And so we'll stick with Stanley in this example

235
00:12:13,410 --> 00:12:14,910
and this time we're going to actually just look

236
00:12:14,910 --> 00:12:18,933
and see the information for Stanley's password.

237
00:12:20,760 --> 00:12:22,500
But to do this we want to used the command

238
00:12:22,500 --> 00:12:26,273
from earlier change age is what it stands for,

239
00:12:26,273 --> 00:12:28,703
"chage" again I think I'm saying that right.

240
00:12:29,680 --> 00:12:31,767
Going to do "rstanley"

241
00:12:31,767 --> 00:12:34,770
and now we can see all the information about the password.

242
00:12:34,770 --> 00:12:37,020
The last time the password was changed

243
00:12:37,020 --> 00:12:38,433
when the password expires,

244
00:12:39,390 --> 00:12:40,860
if it's inactive

245
00:12:40,860 --> 00:12:42,660
when the account expires

246
00:12:42,660 --> 00:12:45,150
the minimum number of days between password change

247
00:12:45,150 --> 00:12:47,850
maximum number of days between password change.

248
00:12:47,850 --> 00:12:50,820
The number of days before a warning is set to

249
00:12:50,820 --> 00:12:53,220
let the user know that they need to change their password.

250
00:12:53,220 --> 00:12:56,160
So this is a quick way to get all that information.

251
00:12:56,160 --> 00:12:57,510
Now we're just going to test out one of these commands

252
00:12:57,510 --> 00:12:59,190
we're going to go through

253
00:12:59,190 --> 00:13:03,900
and we're going to actually change the expiration

254
00:13:03,900 --> 00:13:06,310
of Stanley's password

255
00:13:07,230 --> 00:13:12,230
change to 2026.

256
00:13:12,630 --> 00:13:14,100
So also just remember of note

257
00:13:14,100 --> 00:13:17,253
you have to use the year month then day.

258
00:13:18,090 --> 00:13:18,923
Let's see

259
00:13:18,923 --> 00:13:22,017
Oops forgot to add to to "rstanley".

260
00:13:22,920 --> 00:13:23,753
There we go.

261
00:13:25,717 --> 00:13:27,930
"rstaley" again and now you can see we've

262
00:13:27,930 --> 00:13:32,253
changed the count expiration to December 31st, 2026.

263
00:13:33,660 --> 00:13:36,120
And again we're just going to use another command.

264
00:13:36,120 --> 00:13:38,430
We're going to lock out Stanley.

265
00:13:38,430 --> 00:13:42,697
So this be the "sudo" password dash "L".

266
00:13:44,340 --> 00:13:46,660
Then just stands to lock the account

267
00:13:50,880 --> 00:13:53,910
and then if we ever want to unlock Stanley the same thing

268
00:13:53,910 --> 00:13:54,743
go through here.

269
00:13:56,010 --> 00:13:58,800
The unlock key the "U"

270
00:13:58,800 --> 00:14:01,560
and now we've unlocked Stanley's password.

271
00:14:01,560 --> 00:14:04,770
Now the last thing we're going to do is user delete.

272
00:14:04,770 --> 00:14:08,010
Now it's very common that going to delete a user.

273
00:14:08,010 --> 00:14:11,280
Maybe the user leaves the organization,

274
00:14:11,280 --> 00:14:12,720
fired terminated.

275
00:14:12,720 --> 00:14:15,957
So quick way to do this is just a simple "userdel".

276
00:14:17,280 --> 00:14:20,430
So we're going to use "sudo" "userdel" all right

277
00:14:20,430 --> 00:14:23,947
now I'm going to verify that that account is gone again.

278
00:14:23,947 --> 00:14:25,870
"etc" password file

279
00:14:30,540 --> 00:14:33,000
and you see R Stanley is definitely gone.

280
00:14:33,000 --> 00:14:34,320
Now one thing to note

281
00:14:34,320 --> 00:14:35,400
when you're deleting an account

282
00:14:35,400 --> 00:14:38,130
it doesn't delete the directory that's stored

283
00:14:38,130 --> 00:14:39,390
along with Stanley.

284
00:14:39,390 --> 00:14:43,050
So if we check really quick we'll see that

285
00:14:43,050 --> 00:14:45,420
we should still have R Stanley's information.

286
00:14:45,420 --> 00:14:47,760
As far as this directories files that are stored

287
00:14:47,760 --> 00:14:49,320
still in the system.

288
00:14:49,320 --> 00:14:53,700
So again if you want to delete everything about the user

289
00:14:53,700 --> 00:14:56,910
you're going to have to use the dash "R" option.

290
00:14:56,910 --> 00:14:58,860
So who can I test that out with

291
00:14:58,860 --> 00:15:00,573
A Riley so let's try that,

292
00:15:01,567 --> 00:15:06,393
"sudo" dash "ariley"

293
00:15:07,290 --> 00:15:08,370
All right.

294
00:15:08,370 --> 00:15:12,150
Now same thing just check make sure she's gone.

295
00:15:12,150 --> 00:15:12,983
All right.

296
00:15:12,983 --> 00:15:14,010
A Riley has gone.

297
00:15:14,010 --> 00:15:17,883
Now let's check to see if the directory is also gone.

298
00:15:18,930 --> 00:15:20,610
Yep directory is gone.

299
00:15:20,610 --> 00:15:23,112
So that's a quick note how to wrap up

300
00:15:23,112 --> 00:15:26,520
and delete users also to modify their accounts

301
00:15:26,520 --> 00:15:28,500
change the expiration dates,

302
00:15:28,500 --> 00:15:30,330
adding comments things of that nature.

303
00:15:30,330 --> 00:15:32,790
So that's all for now and I'll see you

304
00:15:32,790 --> 00:15:33,740
in the next lesson.

