 Hey guys a user identifies who you are on a Linux system and we can organize our users into groups now a user will always have one primary group by default and that is the same name as the username other groups that a user may Be a member of would be called supplementary groups. So let's go and get our hands dirty right now So as the administrative user what I'm gonna do is create a bunch of users So let's go and use the user add command and one thing I just want to show you I'm gonna backspace a little bit over here I'm gonna type in user and I'm gonna hit tab twice and I want to show you all the different Commands that begin with user and some of the commands that we could use are include user add to add users user del self-explanatory to delete users and we also have user mod that would modify the properties of an existing user So this stage I'm gonna use user add in its simplest form I'm gonna create a user called John and there we go now if you want to get more information about the user John You could use the ID command so I could say ID John and it would reveal the properties of that user So what we can see over here is that we have the user ID set to one thousand and one now everything is identifiable in a system numerically and User accounts are no exception So a UID is the numerical identifier that represents a user and you can see that user ID 1001 is for the John user and then we can see the GID or the group ID again This is a numerical identifier representing the user's primary group. This is really important. So Here we have 1001 and that is the group John So like I said when you create a user that user is automatically made a member of a group And that would be the primary group of that user which is set to their username now any other group is Called a supplementary group and it's indicated with groups equals So what we're gonna do right now is that we're gonna add a group So let's gonna use the group add command and again if you want to find out more about the different group commands that we have Just type in group on its own hit tab twice and it can see very similarly to the user add user mod and user del commands We have group add group del and group mod So let's gonna have some fun right now So we're gonna say group add and we're gonna create a group called the Beatles now John is not a member of The group Beatles well not at this stage and that's exactly what we are gonna be doing So remember that when you add a user the user is not a member of any other groups other than the group that represents their own user account and we can make use of the user mod command to change the properties of a user account So that's exactly what we are gonna do So we're gonna say user mod right now and we're gonna append to the secondary group membership list We're gonna append the group Beatles for the user John and Remember the argument is always gonna be the thing that we are affecting so we are modifying a user called John So it's not Beatles Beatles doesn't come last So let's go and run the ID command of a year against John and we can see that something has changed and We could see that after groups it will list two things It's gonna list John's primary group and then it's also gonna go and list This the supplementary group or one of the supplementary groups, which is Beatles So what I'm gonna do right now is go and give John a password Of course John needs to log into my system right now and we can allocate a password using the past WD command So let's go and say past WD now if I were to hit enter at this stage I'd be changing my own password now because I'm logged in as the root user I could change the password of another user so I could say past WD John and now we are changing the password for that user So let's go and type in red hat as the password and I know that it's a bad password We're gonna follow through with that anyway and there you go So now I can go to John and say listen up your mates years your user name your password is John And when you log into the system all processes of course are gonna execute with the permissions of the John user And John is also a member of a group called Beatles and therefore has the same access privileges that the Beatles group has So let me give you an example of a deletion command We're gonna go ahead right now and we're gonna delete The the user John so we're gonna say user Dell and then John nice and simple now when you delete a user The user's data is not automatically deleted and that's that could be a very good thing So the home directory would remain behind as well as all the other files that have been created by that particular user Also what I'm gonna do right now is going to delete the well, let's go and delete the group So we're gonna use the group del command and we're gonna delete the group called Beatles And you can see that the group is no longer On my system the transaction went through and again. This is because we don't have an error message telling us otherwise Now all the user account information is stored inside of a file called Etsy past WD And as you can tell it's below the Etsy directory. So it has to be a configuration file So this is the configuration file that we have for our user accounts. Now, there's nothing Terribly sensitive about the users in terms of their passwords even though it's called past WD That is not where we store passwords. So just to show you the contents of that file I'm gonna use the grep command. I'm gonna show you the entry that exists for the student user inside of past WD And you could see yeah, there's nothing about a password over here Just a bit of a spoiler the password for the student user is student Further to that if you are interested in password related information We store that kind of data inside of another configuration file called shadow And it's also in the Etsy directory and this over here this long string Let's go and highlight that for you that represents the user's hash group relates and information is stored inside of a separate file It's called Etsy group and again It just shows you what the Etsy directory is used for for configuration files So let's go and have a look at that So I'm gonna show you the entry that exists for a group called wheel inside of Etsy group And you could see over here that we have the group wheel and you could see That if there's a numerical identifier representing the group's ID and the user student is a member of the group wheel Should you ever want to change privileges you could make use of a command called sudo sudo allows you to run commands as another user and Because the student user is a member of the group wheel. I can do exactly that by default on a rel8 machine So let's go and try that right now. So I'm gonna say sudo and I'm gonna show you the The entry that exists inside of let's go and run the grep command And we're gonna show the entry that exists inside of Etsy shadow for the student user Now it prompts me for my own password it wants to check that I am in fact the student user And you can see that we have a success result because that command was being executed as the root user So let's go and try and repeat that command without Going via sudo and you could see immediately I get a permission denied Because the grep command is running with the privileges of the student user now The cool thing about sudo is that I could also go and run commands as other users Let me give you an example So I'm going to say sudo dash you and I'm going to run a command As a completely different user. I'm going to choose a user called cockpit ws And the command that I'm going to run is who am I now typically when you run who am I on its own It will tell you who you are currently logged in as so I'm going to run Who am I without going via sudo and you could see that normally it would return students But because I said explicitly that we're going to run the sudo command We're going to run a command as another user that user dash you is cockpit ws And you can see the command that I'm running is who am I and you can see that the output is completely different Of course if you don't use the dash dash you it's going to assume root As it is over there. I'm going to show you how you could go and switch user accounts So I'm going to use the su command and the dash over here is very important I'm going to be switching user accounts right now and I'm going to do it for the user root Now it's going to ask me for a password and this is the user's password that I would like to switch to So the root password is red hat and there you go. And if you type in who am I right now I'm logged in as root and I have a root shell now to return to the previous state. I can always go and hit exit I'm lazy. I've just typed in control d control d always kind of means exit or log out And I'm returned to my previous state the state where I'm logged in as student So with that guys, it does bring this video to an end. I will see you in the next chapter