Defining Access using Linux Groups
In the last few lectures we walked you through the process of defining the access levels of a user but in many cases when you have a lot of users you would want all users to have the same access levels. The easiest way to accomplish this task is by creating a group and then assigning users to that group. The first step of deigning the access level of a group is very similar to the way we did it in the last lesson using visudu (we will see it in the video above). Followed by adding the user into the group:
usermod -a -G wheel GROUPNAME
Video Transcript
00:00Things are about to get more complicated, but they're very simple if you watch this whole thing together.
00:06Please don't hesitate watching it over again.
00:09And obviously I'm not expecting you to learn this by heart and don't try to learn it by heart.
00:13Not a bad idea to write down all these commands so you'll have in your cheat sheet.
00:18That's what I do as well.
00:19What we're going to do in this session, which is a little bit more complicated,
00:23in the last one we saw how to create a user, a user called demo,
00:28and then we've added in the rights, the same privilege rights as the root had by using the visudu.
00:34We went into the visudu file, we used the V, and then we edited and added the user
00:40and gave it the same access rights as root.
00:42Now many times what you'll want to do is you'll want to create a super group, a power group,
00:47and give that power group a certain subset of access rights.
00:52So let's see how to do that.
00:53We're going to look into the steps of, there is a default group that is already in existence,
00:59which is called wheel.
01:01Now the wheel, basically because they hold the wheel and they're in charge.
01:04What we're going to do again, we're going to go into visudu.
01:07We're going to go into that file by typing it.
01:09So you just go right in there.
01:11I'm just going to type array.
01:13We're going to go back into that user, sbin, and into visudu.
01:18And we're going to click on enter and go inside of visudu.
01:22And again, I'm just going to scroll all the way down and find that the groups.
01:27Previously, we saw how we worked with the actual directly with adding the user inside.
01:32So let me just scroll all the way down.
01:34We'll see that we added previously the user directly.
01:36What we want to do now is we want to allow people in groups to run all commands.
01:40So I'm going to click on the A to enable me access to edit.
01:44And what I'm going to do is I'm going to go right here and I'm going to delete this demo user
01:49because we're done with that one.
01:51And I'm going to go to the wheel itself and I'm going to uncomment the wheel.
01:55And there we go.
01:56That's all we had to do to uncomment.
01:57And now our wheel is the group wheel is now available.
02:04Now that the group wheel is available and if I assign users into the group wheel,
02:09they will automatically have access to all just as much as the root does.
02:14So that's it.
02:15That's all I had to do.
02:16And it's time for me now to exit.
02:17So to exit, I'm going to click on escape.
02:19And I really want to save this.
02:20So I'm going to click on shift ZZ quickly and I'm going to save our user.
02:24Sorry, save this group, which is called wheel, give it access, give it that root access
02:29that we wanted it to have.
02:31All right.
02:32So our next step now, now that we have our group, now that we have our group configuration set up
02:37is the step that we really want to do.
02:42And the step that we really want to do is add that user into the group.
02:46Now to add the user into the group is not that rough, not that hard.
02:49It looks weird as every most things on Linux.
02:52So you type inside user mode because we want to modify the user and we want to append something
02:59to it.
03:00So we're going to type there minus a to append something into it and then minus G.
03:04And by the way, every time it's always this command, you always have the minus A
03:09and the minus G and uppercase and that's to add a user into a group.
03:13So to add the user into the group, now that we've set that the next step is to say
03:17to what group do we want to add the user in and we want to add the user into the wheel group
03:22and what user do we want to modify?
03:24It's the demo user.
03:25So those are the steps.
03:26So again, user mode is the command and then minus A space minus uppercase G is the command
03:32that says we want to add the user into a group.
03:35And then we say what group, which is wheel and what user, which is our demo.
03:39And if I click on enter here, now the user will be added into the group.
03:44Now, you might want to test this out and see if this user really is inside of the group.
03:49The way you test to see if the user is inside of a group is using the groups command.
03:54And with the groups command, all you have to do is type the user name itself
03:58and it's going to give you a list of all the groups that user is inside.
04:02And you can see now that this user has the level of control, a wheel user.
04:08That means he has root access.
04:10So if we log in with our demo account, now it will have full root access.
04:14Now, if you by mistake at any point add a user to this group
04:19and you want to remove them, I want to show you the steps involved with them.
04:23They're not very intuitive, but I think it's important to cluster this all together.
04:27So it's all logical.
04:28We saw how to add the user into a group.
04:30We saw how to check to see what groups the user is in.
04:33And we saw also how to configure the group to be an all active group.
04:37So the next step to remove a user, we're going to use the group password.
04:43The group password command, and we're going to say minus D to remove user from a group.
04:49And the next is to say what user, which is going to be demo.
04:53And from what group do we want to remove him?
04:55We want to remove him from wheel.
04:57So again, what we're doing here is it's a few different commands.
05:00You don't have to memorize them, but you do have to understand the difference between them.
05:04So you'll know which one to use and when.
05:06And obviously, any time you have to do something like this, just watch this video again.
05:09It'll refresh your memory.
05:11We have you kind of like clustered all the important stuff and relate it to the user in relation to groups.
05:17So now when we type this, the user is going to be removed from the wheel, the remove from the group.
05:21Now, another important thing to note is if you try to go into your visudu now,
05:26and by the way, the user, if he's logged in right now, will still remain having the same access.
05:32You first have to log him out before it comes into effect.
05:36So if you try to go into your visudu now, you'll see sometimes it's going to tell you that you can get in.
05:41In our case, we didn't have any problem.
05:43Again, let's practice how you get out of visudu.
05:45So I'm going to type here the two point thing.
05:49I always forget how it's called.
05:51And I'm going to type your cue and the command line, type enter, and we're going to be outside of our visudu.
05:58But in any case, you want to restart your computer to give all the computer will restart your session to give things to let things get into effect.
06:06And to do that, you will want to log out or click on exit.
06:09You might need to type exit a few times, but if it's one, it might take one or two times.
06:13But once you type two, you are logged out.
06:15You can see that we're logged out.
06:17It gives us that message and it tells us that the connection was closed.
06:20And that's how we log out.
06:21And I'm just going to log right back in.
06:23So we'll see you in the next videos.
06:25And by the way, if you don't want to learn more in depth about how to use how to work with groups and how to work with users, you could skip the next few videos because I want you to be very comfortable and very familiar with the process of adding and removing users.
06:39If you you can use this video clusters as references, so you don't have to watch the next few videos and you can skip to the next section.
06:48But I recommend you watch them all, even if you're not planning on implementing it right now.
06:52And if you have a completely brand new server, it's a great time to practice all these things to get more comfortable with them.
06:58So we'll see you in the next video when we continue and we'll be back logged in.
