1 00:00:06,799 --> 00:00:13,179 Okay, so we need to create users as well as groups and make sure that the users are a member of the group. 2 00:00:13,740 --> 00:00:19,385 Now, to do that conveniently, I'm going to start by creating the groups. So sudo group 3 00:00:19,385 --> 00:00:25,030 add sales already exists. Well, I'm ignoring that because we are going to need it anyway. 4 00:00:25,530 --> 00:00:29,190 Sudo groupadd account and that creates a group. 5 00:00:29,850 --> 00:00:34,655 And we also need sudo group add users 6 00:00:34,655 --> 00:00:39,460 and that already exists. That's not a problem. 7 00:00:40,179 --> 00:00:43,859 But now I can create my users. So sudo user. 8 00:00:46,539 --> 00:00:53,500 I know that user lynda already exists, so let's not try to create that user again and let's make it user model ag. 9 00:00:55,659 --> 00:00:59,850 User Linda needs to be a member of sales and also of the group users. 10 00:01:00,490 --> 00:01:04,284 So for user Linda, quick check sudo id. Linda is 11 00:01:04,284 --> 00:01:08,079 showing that membership of groups has been set successfully. 12 00:01:09,420 --> 00:01:14,859 All right, sudo user mod g sales users for Lora. 13 00:01:15,560 --> 00:01:22,009 I don't have a user Lora yet, so there's no risk that I'm overwriting any group membership. And that's 14 00:01:22,009 --> 00:01:28,459 why just minus uppercase g is enough. Oops, did I really use user mod? I meant user add. 15 00:01:29,620 --> 00:01:35,349 We also need to do something similar for usernooc, which is also a user that does not exist yet. 16 00:01:35,870 --> 00:01:41,560 So user add users for Anouk. 17 00:01:42,260 --> 00:01:44,299 And then we need another user mod. 18 00:01:45,519 --> 00:01:51,866 So let's do that for user Anna. She needs to be a member of account as well 19 00:01:51,866 --> 00:01:58,213 as users. And also she should not use current assignments and this should be doing it. So 20 00:01:58,213 --> 00:02:04,560 ID on Anna is showing all the groups that user Anna is a member of. 21 00:02:05,480 --> 00:02:09,990 Oh boy, did I forget to set passwords to expire after 60 days? Yeah, I did. 22 00:02:09,990 --> 00:02:14,500 And that means that it doesn't make sense to put it in. Etc, Login devs. 23 00:02:15,000 --> 00:02:17,280 Hey, how about passwd? 24 00:02:18,080 --> 00:02:19,150 PASSWD Help? 25 00:02:21,979 --> 00:02:28,120 Does that have an option to expire the password? Yeah, that's the X option. 26 00:02:29,120 --> 00:02:35,120 So I am going to need X, but I'm also going to need to set the password. 27 00:02:37,120 --> 00:02:40,840 We need input redirection to set the password. 28 00:02:41,560 --> 00:02:48,463 How am I going to do that? Well, I'm going 29 00:02:48,463 --> 00:02:55,367 to use a small shell scripting structure for I in 30 00:02:55,367 --> 00:03:02,271 Anna Nuke and Linda and Laura do echo password, pipe 31 00:03:02,271 --> 00:03:09,175 pass WD standard in on $I and let's also use 32 00:03:09,176 --> 00:03:16,080 minus x60 which is the expiration warning. 33 00:03:17,479 --> 00:03:21,139 And then we need a don on a separate line. 34 00:03:21,800 --> 00:03:28,683 And oh boy, that's telling me only root can use standard in S. What is going wrong? Well, what 35 00:03:28,683 --> 00:03:35,566 is going wrong is that my do command is using echo password and then we have passwd without sudo. 36 00:03:35,566 --> 00:03:42,449 So I need a sudo in front of passwd and there we can see that the password has changed. 37 00:03:43,289 --> 00:03:48,409 Let's analyze what is going on in this iteration we loop over a list. 38 00:03:49,639 --> 00:03:53,590 In every iteration we put the current item in a variable with the name I. 39 00:03:55,639 --> 00:04:01,509 Then the second part is the do part, which is all of this. We 40 00:04:01,509 --> 00:04:07,379 set the password for $I using sudo passwd with this option x60 and also 41 00:04:07,379 --> 00:04:13,250 with this option standard in which is accepting the password from the pipe. 42 00:04:13,830 --> 00:04:19,319 And as we can see, password has been changed for all of that. Now I 43 00:04:19,319 --> 00:04:24,810 would like to know if that has worked out. All right. So I'm going to 44 00:04:24,810 --> 00:04:30,300 use sudo passwds for my random test user and oh boy, that's not very readable. 45 00:04:30,660 --> 00:04:37,300 But here the 60 that's what I'm looking for. That's a password explanation that has been set for user lynda. 46 00:04:38,399 --> 00:04:41,904 Now I also needed to make sure that my users have a home 47 00:04:41,904 --> 00:04:45,409 directory. Now I'm on red hat and on red hat. That's simple. 48 00:04:45,949 --> 00:04:48,620 User home directories are created by default. 49 00:04:49,500 --> 00:04:53,764 If you would have been on Ubuntu, you need useradd M. Without 50 00:04:53,764 --> 00:04:58,029 the M, your users don't get a home directory. And that's all.