1
00:00:04,430 --> 00:00:10,610
All right, Now let me demonstrate you how you could create a new user, and I will do that as root

2
00:00:10,610 --> 00:00:13,130
user in Ubuntu Docker container.

3
00:00:13,160 --> 00:00:19,820
Please notice that if you want to create new users, you need to have root access to the system and

4
00:00:19,820 --> 00:00:24,680
if you are root user you are good to go and you are able to create any other users.

5
00:00:24,770 --> 00:00:30,830
If you are logged in as a regular user, you need to prepend commands that we will use here in this

6
00:00:30,830 --> 00:00:33,440
lecture and next lectures with sudo.

7
00:00:33,650 --> 00:00:39,890
And when you enter any command with sudo prefix you will be asked for root password.

8
00:00:39,890 --> 00:00:45,380
And if you don't have access to root password, of course you will not be able to perform such actions

9
00:00:45,380 --> 00:00:47,540
as creation of new users.

10
00:00:47,720 --> 00:00:48,560
All right.

11
00:00:48,560 --> 00:00:56,060
You are able to create new users using two different commands either user add or add user.

12
00:00:56,060 --> 00:01:00,540
And first, let's have a quick look at help for those both commands.

13
00:01:00,570 --> 00:01:02,910
User add Dash Dash help.

14
00:01:03,510 --> 00:01:07,680
And here you see different options that could be used along with this command.

15
00:01:07,680 --> 00:01:11,910
And you see that the this command is used for creation of the new user.

16
00:01:11,910 --> 00:01:18,360
And here in place of login, you need to enter new username for the user you want to add.

17
00:01:18,900 --> 00:01:26,550
Let's have a look at Add user command, clear terminal, add user dash dash help and here is a help

18
00:01:26,550 --> 00:01:34,170
page for Add user command and for example, with such option as dash dash home, you are able to set

19
00:01:34,200 --> 00:01:42,270
custom home directory for specific new user and here as user you should enter any username that will

20
00:01:42,270 --> 00:01:44,220
be used for creation of the new user.

21
00:01:44,250 --> 00:01:47,730
All right, I'll show you both commands in action.

22
00:01:47,730 --> 00:01:50,790
And let me start with user add command.

23
00:01:50,820 --> 00:01:53,940
Let me clear a terminal and enter user add.

24
00:01:53,940 --> 00:01:59,070
And next let me enter my name as username user add mock done.

25
00:01:59,070 --> 00:02:01,440
And you see that actually nothing happened.

26
00:02:01,440 --> 00:02:06,880
I saw no prompts and it seems that new user was created.

27
00:02:07,120 --> 00:02:14,830
Let me now try to login as Bogdan user and you are able to log in as other user if you are already logged

28
00:02:14,830 --> 00:02:16,750
in as for example, root user.

29
00:02:16,750 --> 00:02:23,770
And for that you could use command as u this one and next you could type simply username you want to

30
00:02:23,770 --> 00:02:34,600
log in with as you Bogdan and notice that I was logged into other shell and actually now you see Shell

31
00:02:34,990 --> 00:02:36,280
as root user.

32
00:02:36,280 --> 00:02:44,260
I was logged in into the bash shell and from that bash shell I was logged into shell for Bogdan user

33
00:02:44,260 --> 00:02:46,840
And if I enter here, who am I?

34
00:02:47,900 --> 00:02:48,440
I see.

35
00:02:48,470 --> 00:02:52,940
Bogdan And that means that now I'm logged in as Bogdan User.

36
00:02:52,970 --> 00:02:55,730
But let's have a look at the contents of the folder.

37
00:02:55,770 --> 00:03:01,160
I'm currently in LHS, and here I see error permission denied.

38
00:03:01,370 --> 00:03:10,190
If I enter W, I see that I'm still in the root folder, but you could remember that this folder is

39
00:03:10,190 --> 00:03:17,360
actually home directory for root user and this folder has read, write and execute permissions only

40
00:03:17,360 --> 00:03:18,620
for root user.

41
00:03:18,620 --> 00:03:27,320
And if I enter LHS and here type slash, you'll see this information here on this line root folder can

42
00:03:27,320 --> 00:03:29,870
be accessed only by root user.

43
00:03:29,900 --> 00:03:36,440
That's why if I try to access it here as Bogdan user, I'll get permission error and that's fully correct.

44
00:03:36,470 --> 00:03:37,190
All right.

45
00:03:37,190 --> 00:03:43,100
That's how I was able to log into the shell using different user.

46
00:03:43,340 --> 00:03:46,640
But let's try to list contents of the home directory.

47
00:03:46,640 --> 00:03:50,620
I have told you that each user should have home directory.

48
00:03:50,630 --> 00:03:57,680
Let's enter LHS slash home and here I see actually no other subfolders.

49
00:03:57,830 --> 00:04:03,590
And that means that no home directory was created for this new user.

50
00:04:03,590 --> 00:04:09,920
Bogdan And if you want to create new home directory, you need to perform additional action.

51
00:04:10,040 --> 00:04:17,899
Also, this user does not have any password set and if you will try to access this computer remotely

52
00:04:17,899 --> 00:04:24,110
and login as Bogdan user, you will not be able to do so because there was no password for this user.

53
00:04:24,440 --> 00:04:31,550
Now let's go back to root user and if you want to exit from current session for Bogdan user, you need

54
00:04:31,550 --> 00:04:33,170
to enter simply exit.

55
00:04:33,170 --> 00:04:37,490
And now I'm back to bash shell for root user.

56
00:04:37,820 --> 00:04:45,290
All right next command that you need to use if you want to set up a password for specific user is pass

57
00:04:45,290 --> 00:04:52,980
WD and next comes username Bogdan and here I could set new password for specific user.

58
00:04:52,980 --> 00:04:54,780
Let me set something random.

59
00:04:54,780 --> 00:04:55,650
One, two, three.

60
00:04:55,680 --> 00:05:03,390
Here, I'll retype one two, three and password was updated successfully and now I will be able to log

61
00:05:03,390 --> 00:05:08,700
in as regular Bogdan user using this password that I have just configured.

62
00:05:08,730 --> 00:05:16,680
Let's now again try to log in as Bogdan user by typing as you Bogdan and you see that I was not asked

63
00:05:16,680 --> 00:05:23,100
for any password and the reason for that is that I'm already logged into the system as root user and

64
00:05:23,100 --> 00:05:27,630
that's why there is no need to ask for password for other user.

65
00:05:27,900 --> 00:05:28,710
All right.

66
00:05:28,710 --> 00:05:33,000
That's how we were able to set password for a specific new user.

67
00:05:33,000 --> 00:05:36,570
But there is still no home directory for this user.

68
00:05:36,990 --> 00:05:41,760
Let me show you how you could create new user with Home directory.

69
00:05:41,760 --> 00:05:48,090
And first, let's simply remove this user that we have just created and for that use following command

70
00:05:48,120 --> 00:05:49,380
user del.

71
00:05:49,380 --> 00:05:51,480
And next comes username.

72
00:05:52,030 --> 00:06:00,100
User was removed and now let's create the same user back again, but with another option that will automatically

73
00:06:00,100 --> 00:06:03,130
create a new home directory for this user.

74
00:06:03,160 --> 00:06:10,990
Let's type user, add dash, dash help and let's look for option that will create home directory.

75
00:06:10,990 --> 00:06:17,400
And actually I'm able to filter this output using pipe operator and here will be grab command.

76
00:06:17,410 --> 00:06:22,030
We have already discussed this command before and here type home like so.

77
00:06:22,030 --> 00:06:30,880
And you see that with dash D option you are able to set specific home directory or you are able to use

78
00:06:30,880 --> 00:06:37,380
dash m option that will create home directory automatically in the slash home directory.

79
00:06:37,390 --> 00:06:39,520
Let's use dash m option.

80
00:06:39,520 --> 00:06:46,780
Let's clear terminal user add dash m and next comes username back down again.

81
00:06:46,780 --> 00:06:50,050
And now let's list contents of the home folder.

82
00:06:50,050 --> 00:06:57,770
And now you see new sub folder that was created here automatically and name matches user name for this

83
00:06:57,770 --> 00:06:59,810
user that we have just created.

84
00:07:00,380 --> 00:07:08,270
Let's list contents of this bag down folder and let's add here options Dash LA in order to see hidden

85
00:07:08,270 --> 00:07:11,180
files and see results in table format.

86
00:07:11,360 --> 00:07:14,630
And now I see that there are three hidden files.

87
00:07:14,630 --> 00:07:18,410
Bash log out, bash, RC and profile.

88
00:07:18,410 --> 00:07:23,180
And those files were created automatically for this particular user.

89
00:07:23,510 --> 00:07:31,280
But now question how Linux system decides which shell specific user should use by default.

90
00:07:31,900 --> 00:07:37,900
Let me show you how E-t-c default user add.

91
00:07:37,930 --> 00:07:42,190
There is such file located in default directory.

92
00:07:42,250 --> 00:07:49,960
Let's have a look actually at this file using cut command and you'll see set of default options that

93
00:07:49,960 --> 00:07:52,870
are used for creation of the new user.

94
00:07:52,870 --> 00:08:00,520
When you enter user add command and if you scroll up a bit, you'll see such variable that is set to

95
00:08:00,550 --> 00:08:00,970
bin.

96
00:08:02,720 --> 00:08:09,710
And that actually indicates the default shell that will be used for new users that you create using

97
00:08:09,710 --> 00:08:16,940
user add command and you are able actually adjust this default configuration file, you are able to

98
00:08:16,940 --> 00:08:22,070
uncomment some sections, you are able to add additional parameters, you are able to modify existing

99
00:08:22,070 --> 00:08:23,450
parameters and so on.

100
00:08:23,570 --> 00:08:31,280
And let's actually try to modify this file and adjust shell to bin bash and afterwards let's try to

101
00:08:31,280 --> 00:08:32,510
create new user.

102
00:08:32,510 --> 00:08:39,470
But first let's log in as Bogdan user and ensure that we will be logged in into the shell Let's clear

103
00:08:39,500 --> 00:08:48,140
terminal and enter as log Bogdan And you see here that I'm logged in into the shell as Bogdan user and

104
00:08:48,140 --> 00:08:54,560
we are able to verify which shell we are currently using by entering a command echo dollar sign zero

105
00:08:54,560 --> 00:08:55,580
And here I see.

106
00:08:57,180 --> 00:08:57,780
All right.

107
00:08:57,780 --> 00:09:01,980
Let's now try to create new user under this session.

108
00:09:02,280 --> 00:09:07,470
Let's try to enter user ID and for example, let's create new user called test.

109
00:09:07,470 --> 00:09:10,080
And here I see error permission denied.

110
00:09:10,080 --> 00:09:15,960
And the reason for that is that I'm trying to create new user from regular user session.

111
00:09:15,960 --> 00:09:21,240
And I have told you before that if you want to create new users, you need to have root privileges.

112
00:09:21,240 --> 00:09:26,010
And if you try to do so as regular user, you will get definitely an error.

113
00:09:26,310 --> 00:09:28,740
All right, let's exit from this session.

114
00:09:28,740 --> 00:09:33,750
And now let's modify configuration file for user add command.

115
00:09:33,750 --> 00:09:39,480
Let's use Nano Editor Nano here type path to this configuration file.

116
00:09:39,480 --> 00:09:40,980
It is located in EDC.

117
00:09:41,220 --> 00:09:47,130
I'll use absolute path next default and here will be user add like this.

118
00:09:47,130 --> 00:09:49,110
And let's modify this line.

119
00:09:49,110 --> 00:09:54,660
Shell will be bin bash like so let's save changes.

120
00:09:54,660 --> 00:09:56,340
Control X yes.

121
00:09:56,340 --> 00:10:02,520
Enter and let's read the contents of this file in order to verify that changes were saved.

122
00:10:02,520 --> 00:10:04,560
And let's scroll up here.

123
00:10:05,570 --> 00:10:07,580
And yes, here is this change.

124
00:10:07,580 --> 00:10:09,800
Shell is set to bin bash.

125
00:10:09,830 --> 00:10:10,490
All right.

126
00:10:10,490 --> 00:10:12,260
Let's now create one more user.

127
00:10:12,260 --> 00:10:18,170
And again, I'll use option M that will automatically create new home directory for this new user.

128
00:10:18,170 --> 00:10:21,740
And afterwards we will try to log in as new user.

129
00:10:21,770 --> 00:10:23,570
Let's enter user Add.

130
00:10:23,600 --> 00:10:27,980
Next comes option and afterwards let's enter username test.

131
00:10:28,010 --> 00:10:30,980
We will create new user with username test.

132
00:10:31,010 --> 00:10:35,540
Let's press enter and now let's use as test.

133
00:10:35,540 --> 00:10:38,750
And now you see that I'm inside of the bash shell.

134
00:10:38,780 --> 00:10:42,800
Let's type echo dollar sign zero and you see bash.

135
00:10:43,100 --> 00:10:50,540
And notice that if you use as command without any other options, then current working directory will

136
00:10:50,540 --> 00:10:51,830
remain unchanged.

137
00:10:51,860 --> 00:10:58,700
Notice that here I was inside of the home directory for root user, it is slash root and when I have

138
00:10:58,700 --> 00:11:03,530
changed user I still remain in this folder slash root.

139
00:11:03,620 --> 00:11:09,330
And if you don't want such behavior you need to use additional option with as command.

140
00:11:09,360 --> 00:11:10,320
Let me show you that.

141
00:11:10,320 --> 00:11:13,950
Let's exit from here and type dash, dash, help.

142
00:11:14,310 --> 00:11:17,570
And here you will see this option on this line.

143
00:11:17,580 --> 00:11:23,220
You could either use simply dash or dash l or dash dash login.

144
00:11:23,220 --> 00:11:29,850
And with this option you will be logged into new session completely from scratch as new user.

145
00:11:29,880 --> 00:11:38,340
Let me show you that as dash and here type username test and you'll see that I have changed user to

146
00:11:38,340 --> 00:11:47,280
test and now I'm inside of the home directory for this test user and if I enter PWD you'll see path

147
00:11:47,280 --> 00:11:50,250
to home directory for test user.

148
00:11:50,250 --> 00:11:52,680
It is slash home slash test.

149
00:11:53,160 --> 00:11:55,680
Same applies to other users.

150
00:11:55,710 --> 00:12:03,180
For example, let's exit from here and as you dash and here type Bogdan username and now I'm actually

151
00:12:03,180 --> 00:12:04,380
in the shell.

152
00:12:04,410 --> 00:12:08,830
But if I enter PWD you'll see same picture.

153
00:12:08,840 --> 00:12:13,370
I'm inside of the home directory for this particular user.

154
00:12:13,400 --> 00:12:17,420
That's what this option dash or dash L does.

155
00:12:17,840 --> 00:12:18,530
All right.

156
00:12:18,530 --> 00:12:23,000
That's how you could create new users using user add command.

157
00:12:23,000 --> 00:12:30,350
And with such option as you are able to automatically create new home directory for specific user.

158
00:12:30,380 --> 00:12:30,950
Great.

159
00:12:30,950 --> 00:12:39,200
Let's exit from here and let's use user command in order to remove Bogdan user and let's verify whether

160
00:12:39,200 --> 00:12:42,840
home directory for this user is still in place or not.

161
00:12:42,860 --> 00:12:50,930
Let's list files in Home directory and yes, I still see here Bogdan Subfolder and that means that user

162
00:12:50,930 --> 00:12:57,440
Del Command without any additional options does not remove home directory for specific user.

163
00:12:57,470 --> 00:13:02,030
Let's have a look at the help options for user del Command User del Dash.

164
00:13:02,030 --> 00:13:02,810
Dash Help.

165
00:13:03,430 --> 00:13:10,150
And here in list of those options, you'll see option dash R that will automatically remove home directory

166
00:13:10,180 --> 00:13:11,830
for a specific user.

167
00:13:11,860 --> 00:13:15,490
Let's use this option in order to remove test user.

168
00:13:15,490 --> 00:13:19,180
Let's enter user Dell dash r test.

169
00:13:19,600 --> 00:13:23,020
You see warning that the test mail spool wasn't found.

170
00:13:23,020 --> 00:13:24,160
Just ignore it.

171
00:13:24,160 --> 00:13:31,480
Let's list the contents of the home directory now and don't see test sub folder here in this home folder.

172
00:13:31,630 --> 00:13:35,140
Let's also remove manually this sub folder.

173
00:13:35,140 --> 00:13:40,660
Let's use rm dash r slash home slash Bogdan enter.

174
00:13:40,660 --> 00:13:43,090
Let's list contents of the home directory.

175
00:13:43,090 --> 00:13:44,530
And now it is empty.

176
00:13:44,560 --> 00:13:45,310
All right.

177
00:13:45,310 --> 00:13:52,180
That's how you could create a new users using user add command with another command pass WD you are

178
00:13:52,180 --> 00:13:58,810
able to set password or modify it if it is already set for a particular user and using user del command

179
00:13:58,810 --> 00:14:01,540
you are able to remove created user.

180
00:14:01,870 --> 00:14:06,410
Let's now proceed and next let me show you another command add user.

181
00:14:06,410 --> 00:14:12,230
It is slightly different from user add command, but just with single command you are able to set home

182
00:14:12,230 --> 00:14:15,560
directory password and other options if you want to do so.

183
00:14:15,590 --> 00:14:17,510
Let's talk about it in the next lecture.

184
00:14:17,510 --> 00:14:18,080
Bye bye.

