sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4 — Transcript
Full transcript
- 0:00managing users in linux this is
- 0:02essential you got to know this if you
- 0:03want to get into linux or become a
- 0:04hacker or do anything
- 0:06don't skip this so assemble the avengers
- 0:08we gotta stop thanos
- 0:14what
- 0:18welcome to linux for hackers and
- 0:20everyone because everyone
- 0:22needs to learn linux this is episode 4
- 0:24and you don't want to miss this when
- 0:25we're talking about user management user
- 0:27accounts and linux and we're pretty much
- 0:29going to cover everything from creating
- 0:30users deleting them changing them
- 0:32creating groups deleting those putting
- 0:34on the infinity gauntlet and giving
- 0:35yourself super godlike permissions
- 0:37which is also known as sudo or the
- 0:39sudoer's file we'll cover all that
- 0:41and yeah we're gonna assemble the
- 0:42avengers and stop thanos we're going to
- 0:44save the world and when i say we i mean
- 0:46we because you're going to do this with
- 0:47me you're getting a free
- 0:48linux lab right here in this video check
- 0:50the link in the description thanks to
- 0:52our sponsor
- 0:52hack the box academy it's seriously
- 0:54amazing free to sign up
- 0:55hack the box academy is basically a
- 0:57trading ground for hackers
- 0:59good hackers mind you so if you want to
- 1:00follow along with me learn how to manage
- 1:02users in linux and save the world
- 1:04then click the link below get signed up
- 1:05for free and you'll have a linux
- 1:07lab right here in your browser and then
- 1:09of course whatever else you want to
- 1:10learn regarding hacking it's there so
- 1:12check that out too also hack the box
- 1:13academy now has a student subscription
- 1:15and you get cpe credits for completing
- 1:18tier 1 modules or above
- 1:20kind of killer check it out link below
- 1:22to learn more have you hacked the
- 1:23youtube algorithm today let's make sure
- 1:25you do hit that like button subscribe
- 1:26comment
- 1:27notification bell let's hack youtube
- 1:28today ethically of course
- 1:30anyways no time to waste get your
- 1:32stinking coffee let's do this
- 1:35right now okay here we go we're going to
- 1:37learn nearly everything you need to know
- 1:38about managing users and linux
- 1:40and we're gonna have a bit of fun with
- 1:42it too so get your copy and let's go
- 1:44now first we gotta launch our lab our
- 1:46free linux lab from hack the box academy
- 1:49so go ahead and navigate out there
- 1:50hack the blogs account of me they are
- 1:52our sponsor and they're amazing it's
- 1:54completely free if you haven't already
- 1:55signed up we'll get signed up i've got a
- 1:56video walking you through that right
- 1:58here
- 1:58so log in to hack the box academy go and
- 2:00click on the linux fundamentals course
- 2:01to get started go ahead and open up the
- 2:03user management module right here and
- 2:05then to launch our free amazing phone
- 2:06box our lab
- 2:08scroll about halfway down and click on
- 2:09start instance and it's going to start
- 2:11quick coffee break just a little sip and
- 2:14it is ready go ahead and click on
- 2:15interact to uh
- 2:17interact with it and i've said it before
- 2:18this is amazing it's your free linux lab
- 2:20in your browser that you can mess with
- 2:22and break things and
- 2:23let's do this okay let's talk about
- 2:25users every computer system has a user
- 2:28including linux and you know what you're
- 2:30a user
- 2:32to be able to log into the server this
- 2:34linux box and do anything you have to be
- 2:36a user on the system which user are you
- 2:38let's see in a previous video we showed
- 2:40this already so let's go ahead and
- 2:41launch our terminal
- 2:42our green or yellow box up at the top
- 2:44here this is launching our shell
- 2:46if you don't know what that is we'll go
- 2:47back to the last video and watch that
- 2:48one we talk all about it to quickly see
- 2:50who you are you simply type in who
- 2:52am i and there you are your user account
- 2:55and you as user 86527 can log into this
- 2:58linux machine
- 2:58and do stuff you can launch programs
- 3:00play games hack
- 3:01create things delete things if you have
- 3:03the right permissions we'll cover that
- 3:04here in a moment
- 3:05you you can do a lot of stuff as a user
- 3:07of the system but not all users are the
- 3:09same now hey
- 3:10i've got some bad news we're under
- 3:12attack our system our linux
- 3:14box here we're being attacked by
- 3:17thanos that's his name right the bad guy
- 3:19from avengers yes thanos he's attacking
- 3:21us
- 3:21bad guy thanos is gonna snap his fingers
- 3:23and destroy all our user accounts and we
- 3:24won't be able to have fun on linux
- 3:26anymore
- 3:26we have to stop him but how do we do
- 3:28that avengers assemble we need the
- 3:30avengers right let's call them do they
- 3:32have like a bat signal i don't know how
- 3:33you call them
- 3:34they just know they need help right or
- 3:35that we need help but they're not in our
- 3:37system right now we have to create these
- 3:38user accounts to come and stop thanos
- 3:40before he
- 3:41snaps anyways let's start by adding the
- 3:44avengers to our system
- 3:45let's start with thor he's my favorite
- 3:47so the command will be
- 3:49add user thor and honestly it's that
- 3:52simple that's all we need
- 3:53the command add user will obviously add
- 3:55a user but it's not the only one that
- 3:57does this by the way just so you know
- 3:59there's add user and then confusingly
- 4:01there's another one called
- 4:02user add which they do both add a user
- 4:06but this command right here is a little
- 4:07lazy
- 4:08he doesn't do as much whereas this
- 4:09command will do a lot i'll show you the
- 4:11difference here real quick we'll bring
- 4:12in our other avengers
- 4:13anyways let's add thor real quick now
- 4:14i'm going to hit enter but it's not
- 4:16going to work
- 4:17watch only root may add a user a group
- 4:19to the system now what is a root
- 4:21i mean root's another user on the system
- 4:23if you watched our previous videos in
- 4:24the series you would know all about root
- 4:26not groot
- 4:27root but we're going to temporarily
- 4:28borrow some power from the root which
- 4:30he's also known as the super user um so
- 4:33what we're going to do here is hit the
- 4:34up arrow to get our command back in
- 4:35there add user thor we're going to go to
- 4:37the beginning of our command
- 4:38and type in sudo or it's also often
- 4:41pronounced soo do but it's spelt sudo so
- 4:43i want to say that
- 4:44this is kind of like saying please in
- 4:45linux please do this i'm getting super
- 4:47powers to do this
- 4:48again i'll explain more about that here
- 4:50in a moment but anyways this is gonna
- 4:51work
- 4:52okay cool we got a fun prompt here let's
- 4:54put a password in for thor i'm gonna say
- 4:56hammer type it in again hammer full name
- 4:58i think it's just thor
- 5:00it'll ask you for all this random
- 5:01information you don't have to put it all
- 5:02in just enter enter enter
- 5:03is it correct sure and thor's created he
- 5:05is now a user on the system but how do
- 5:08we know that where
- 5:09is he well to find out what users are on
- 5:12your system there's one simple place to
- 5:13look
- 5:13i'm going to clear my screen real quick
- 5:15by typing in clear or i can just do
- 5:16control
- 5:17l whoo nice and clean there's a file in
- 5:19the system that has a list of every user
- 5:20on this
- 5:21box or this system we're going to use
- 5:23the command cat which we learned before
- 5:25we're going to cat the forward slash
- 5:27etsy forward slash pass
- 5:28wd when we do that here's what happens
- 5:31boom bunch of users on our system i bet
- 5:33you're surprised like where all these
- 5:35users come from i mean the first two we
- 5:36recognize right i mean the last two
- 5:38uh this one right here is us user blah
- 5:40blah
- 5:41and then thor the one we just created
- 5:42there he is all these other entries are
- 5:44indeed
- 5:45user accounts on this system and they do
- 5:47serve a purpose a lot of these you can't
- 5:48log in
- 5:49with like right here it says no login on
- 5:51this account they do serve a purpose not
- 5:53the topic for another video anyways now
- 5:55real quick
- 5:55what does all this right here mean it's
- 5:58kind of gobbledygook right i mean the
- 5:59first bit we understand what it is the
- 6:01username
- 6:02thor and user blah blah blah but what's
- 6:04all the stuff after it well just after
- 6:06the username we have
- 6:07just an x sitting there all by himself
- 6:09in fact you'll see this on pretty much
- 6:10every user account appear
- 6:12x max and what the x indicates is that
- 6:14your password is stored in a separate
- 6:16file called the
- 6:17shadow file more specifically it's in a
- 6:19place called etsy
- 6:21shadow in linux we store our passwords
- 6:23in the shadows where they're hidden you
- 6:25can't see them but for real
- 6:26if we go to it real quick we can
- 6:27actually look at it let's do cat
- 6:29etc etsy shadow oh permission deny we
- 6:32need some
- 6:33listen please sudo there we go and right
- 6:35here next to the username thor we have
- 6:37his password which that's actually not
- 6:38his password
- 6:39that's the hashed version topic for
- 6:41another time anyways now just after x we
- 6:43have two numbers
- 6:44and they're the same we have one
- 6:45thousand one and one thousand one what
- 6:48are those
- 6:48well those are his ids the first one is
- 6:52his user id or a uid it's a number
- 6:55which you can obviously see it's 1001.
- 6:57the second one is his
- 6:59group id we'll cover groups here in a
- 7:00second but just know that when we create
- 7:02a user in linux
- 7:03we both create a user and a group for
- 7:06that user so we have a username named
- 7:07thor
- 7:08we also have a group named thor and the
- 7:10member of that group
- 7:11is thor and then after that we got some
- 7:13like random filler stuff like his name
- 7:15and comments and stuff
- 7:16and then after that we have his home
- 7:19directory where he gives his hammer and
- 7:21his
- 7:21chest plate i don't know what thor has
- 7:23his hair ties for thor his home
- 7:25directory is in
- 7:26the same place that a lot of people's
- 7:27home directories are home
- 7:30and then a directory called thor we'll
- 7:32look at that here in a moment and then
- 7:33just after that
- 7:34we have his default shell when thor logs
- 7:37into the system
- 7:37what shell is he going to be given again
- 7:39if you don't know what i'm talking about
- 7:40go look at our previous video
- 7:42but by default when we created his user
- 7:44account with the add user command
- 7:46it's going to be bash so that is what
- 7:48all that gobbledygook means now let me
- 7:49show you what the user add command does
- 7:51our
- 7:52alternative command which is kind of
- 7:54weird so we have thor he's pretty
- 7:56awesome but we need some extra help
- 7:57i think we need iron man yeah yeah let's
- 7:59get iron man in here so we'll do sudo
- 8:01and instead of add user we're gonna
- 8:03we're gonna do user
- 8:05add and same as before we'll just type
- 8:07in the user name iron man
- 8:09and watch what happens here it is
- 8:11different it's simple
- 8:13that's it so remember add user like asks
- 8:16hey put in his password
- 8:17uh what's his first name last name
- 8:19what's social security number
- 8:21favorite flavor ice cream like all that
- 8:22stuff this one just says
- 8:24okay you're like uh what else
- 8:27what do i do now that's what i meant by
- 8:29saying that command is lazy because he
- 8:30doesn't do anything but just say okay
- 8:32yeah here's a user account i'm not gonna
- 8:33do anything else like
- 8:34set the password for you like you can do
- 8:36that yourself um and i'll show you how
- 8:37to do that here in a second but right
- 8:38now
- 8:39iron man is created but you can't really
- 8:40do much with him so if we cat our
- 8:42password file again to see what user
- 8:44accounts we have in our system cat
- 8:45slash etsy pass wd he's there iron man
- 8:49is shown up
- 8:49but there's a few things missing now for
- 8:51example he has the x there saying that
- 8:53his password's in the shadow file but is
- 8:54it really because we didn't set a
- 8:55password did we also notice here that
- 8:58um his default shell is different it's
- 9:00sh for
- 9:01shell instead of bash so real quick i
- 9:03want to take a look at the shadow file
- 9:05to see if the stuff is there
- 9:06that's interesting you can see that he
- 9:08does have
- 9:09an entry in the shadow file but it
- 9:11doesn't seem to be a password
- 9:12and i don't think it is but we can set
- 9:14this password real quick command to set
- 9:16a password for someone or change a
- 9:17password for any username
- 9:18is going to be password without the o-r
- 9:22i'll show you so we'll we'll need super
- 9:24powers sudo command is p-a-s-s-w-d
- 9:28and then the user name so i'll type in
- 9:30iron man and now we can set his password
- 9:32jarvis there we go he's got a legit hash
- 9:34there so we know it's working now one
- 9:36thing the ad user command did not do for
- 9:37iron man is it did not give him a home
- 9:39he doesn't have a house right now he
- 9:40doesn't have a home directory if i
- 9:41navigate to the home directory well all
- 9:42the
- 9:43user directories live i go cd forward
- 9:45slash home
- 9:46and i type in ls i can see there are two
- 9:48directories there for thor and then for
- 9:50me
- 9:51but iron man he doesn't have a home dude
- 9:53and that's one downside of using the
- 9:55user ad command
- 9:56is again he's lazy he doesn't do this
- 9:57kind of stuff if i jump into the thor
- 9:59directory by doing cd
- 10:01thor and then lsing his contents
- 10:04yeah he's got a desktop he's got
- 10:05templates if i do ls
- 10:07dash al to reveal the hidden files he's
- 10:10got a bunch of stuff going on in there
- 10:11which we're not going to get into right
- 10:13now i mean it is important but right now
- 10:14we got to save the world
- 10:15thor is here and he's coming clear our
- 10:17screen now if we cap the password file
- 10:19again
- 10:20etsy pass wd i'm super annoyed that iron
- 10:23man's
- 10:24default shell is not the same as
- 10:25everyone else's it's just sh
- 10:27let's make sure it is bash we can modify
- 10:29user account new command time are you
- 10:31ready the command is
- 10:32user mod which stands for user
- 10:34modification and as you might expect it
- 10:36will modify a user account now there are
- 10:38a ton of things we can change if you do
- 10:40dash h for help to see like what can i
- 10:42do with this it'll tell you
- 10:44a lot of stuff and i'm not going to
- 10:46cover everything right now that take
- 10:47forever and
- 10:48thanos is here so i'll do sudo because
- 10:50we will need special permissions
- 10:52user mod and let's say i want to change
- 10:53that shell for iron man
- 10:55i'll do iron man say that's who i want
- 10:57to change it for
- 10:58dash dash shell and i'll say ben
- 11:02bash done and if we cap the user or the
- 11:05cat the password file once more welcome
- 11:07iron man you now are using bash just
- 11:09like everyone else
- 11:09and we can change other things too like
- 11:11maybe his name like sometimes iron man
- 11:13isn't iron man sometimes he's tony stark
- 11:15so if we do sudo user mod once more
- 11:18we'll use the switch
- 11:19dash l and then we'll put in the new
- 11:22information
- 11:23tony stark that's his new username and
- 11:25then the old one
- 11:26iron man done so if i cat the password
- 11:30file once more
- 11:30huh he's tony stark now but we don't
- 11:32need tony stark right now we need iron
- 11:33man let's change it back
- 11:35okay better okay here we go now again
- 11:37thanos is here and we need more than
- 11:38just two avengers
- 11:40avengers assemble let's create more
- 11:42right now real quick
- 11:43fast and that is where the user add
- 11:45command comes in handy because you can
- 11:46add things really quickly enough to go
- 11:47through a menu every single time so
- 11:49we'll just do it real quick
- 11:50and we also have switches to help us
- 11:51with that if i do user add dash h
- 11:53we can do a lot of the stuff that the
- 11:55add user command does just in one line
- 11:57so i'll do user add let's bring in
- 12:01hulk and i'll do a dash m which dash m
- 12:04will actually create a home directory
- 12:05form so whereas iron man didn't get one
- 12:07by default i almost forgot we need
- 12:09superhero permissions there we go let's
- 12:11get spider-man in here
- 12:13loki why not oh we can't forget captain
- 12:15america
- 12:16and i suppose we'll need doctor strange
- 12:18i don't like that movie that much
- 12:19didn't like it at all wasn't a fan but
- 12:21he kind of played a key role so we'll
- 12:22put him in here
- 12:23so now we have some avengers if i do uh
- 12:26cat
- 12:27etsy password file boom
- 12:31we got them they're here if you've seen
- 12:33the movies you know it doesn't go
- 12:35great at first thanos does get the power
- 12:37he gets the
- 12:38the gauntlet or what is it called ah
- 12:40okay the infinity gauntlet almost forgot
- 12:42actually i did forget i had to look it
- 12:43up thanos has the power and he does
- 12:46flick his fingers or snaps fingers and
- 12:48do some bad stuff
- 12:50now i'm gonna add the user account
- 12:52thanos
- 12:53we're bringing him in he's there i'm
- 12:55going to set his password real quick
- 12:57password inevitable let's see if he's
- 13:00here yep there's thanos
- 13:01now here in linux the infinity gauntlet
- 13:03that gives you super
- 13:04awesome powers and has all the stones
- 13:06and you can flick your fingers and
- 13:07everyone disappears
- 13:09in linux that's definitely the pseudo
- 13:11command
- 13:12or pseudo we haven't really dived into
- 13:14that deeply just yet
- 13:16but right now we are it's a command we
- 13:17use all the time it stands for
- 13:20super user do essentially every time we
- 13:22use that command it's like we're
- 13:23slipping on the infinity gauntlet
- 13:24the super powerful glove and this is the
- 13:26worst glove you'll ever see we slip that
- 13:28glove on and for one moment
- 13:30we have powers to do whatever we frickin
- 13:31want so the sudo command or the sudo
- 13:33command
- 13:34were able to grab the powers of the
- 13:36super user the root user
- 13:37and use them for that command now the
- 13:40super user in the system
- 13:41which is the root user he's the boss he
- 13:43can do whatever stinking wants on linux
- 13:45he can change all the settings
- 13:46he can delete all the settings he can
- 13:48ruin everything delete half your stuff
- 13:50rmrf man that's what thanos is gonna do
- 13:54and if you can use the pseudo command to
- 13:55impersonate him just for a moment
- 13:57that's a pretty stinking powerful
- 13:59command it's a command that you don't
- 14:00want to just give to anyone you want to
- 14:02restrict that access and by default it
- 14:04is pretty restricted
- 14:05now you can see that right now we've
- 14:07been using sudo all day
- 14:08we have the infinity gauntlet we can put
- 14:10that sucker on and use it whenever we
- 14:11want to
- 14:12but not everyone can use it for example
- 14:14iron man he can't use it we can actually
- 14:16pretend to be iron man real quick
- 14:17new command time you ready the command
- 14:19is s u
- 14:20s u allows us to impersonate another
- 14:22user we're actually switching
- 14:24users we're becoming this user so let's
- 14:26become iron man
- 14:27i've always wanted to be iron man let's
- 14:29do this so again the command is su
- 14:31we'll do a space a dash or a tick space
- 14:33and then the username of who we want to
- 14:34switch into
- 14:35now real quick by default if you don't
- 14:37put anything here just
- 14:38su space dash it's going to switch you
- 14:41to the root user
- 14:42which we can do like watch and i don't
- 14:44know the root password
- 14:46um actually but we can do this we can
- 14:49put our gauntlet on
- 14:50put the affinity gauntlet on sudo su
- 14:54space dash i just became the root user i
- 14:57just became the infinity gauntlet which
- 14:58is kind of weird
- 14:59you never want to become the infinity
- 15:00gauntlet never log in as root that's why
- 15:02we have sudo so i'm going to hit ctrl
- 15:04d or we can just type in exit or
- 15:07log out either of any of those so i'll
- 15:10just do ctrl d
- 15:11to become myself again but anyways back
- 15:13to becoming iron man so i'll do su
- 15:14space dash iron man now doing this
- 15:18without the gauntlet on i will have to
- 15:20know iron man's password this goes for
- 15:22any time you use the su command but if i
- 15:24were to use sudo
- 15:25and put my gauntlet back on i don't have
- 15:27to put a password in but anyways
- 15:29i'll become iron man put his password in
- 15:31jarvis
- 15:32i'm iron man now iron man is pretty
- 15:34powerful but he cannot use a pseudo
- 15:35command let's try it real quick
- 15:37i'll do sudo and i'll try to add a user
- 15:39user add
- 15:40let's try to bring in pepper potts his
- 15:42wife right yeah wife
- 15:43that's gonna ask for a pseudo password
- 15:45okay just type in jarvis
- 15:47things are looking pretty good right no
- 15:49we're in trouble
- 15:50you're not in the sudoers file this
- 15:52incident will be reported you're like
- 15:54you're grounded iron man you can't do
- 15:56this i do love that we're talking about
- 15:57marvel and we have this spider-man line
- 15:59that comes in
- 16:00anyways that's an overused line anyway
- 16:02um so real quick
- 16:03what is this right here the sue doers
- 16:06file which is a very very awkward phrase
- 16:09basically this file the sudor's file
- 16:11defines
- 16:12who can use sudo who can wear the
- 16:14gauntlet right now iron man
- 16:16is not in that file so we can't put it
- 16:18on so what do you say we go take a look
- 16:19at that file i know you're itching to so
- 16:20let's do it real quick now the scooters
- 16:22file is a very important file that you
- 16:23don't want to jack up
- 16:24and you can jack it up you can ruin your
- 16:26entire system by
- 16:27messing up the scenarios file but there
- 16:29are some checks in place to keep you
- 16:30safe now normally in linux
- 16:31to edit a file you might just use your
- 16:33default text editor right the one you
- 16:35love like we might use
- 16:36nano or them but with a suitor's file
- 16:39the best practice is to do but with the
- 16:40scooter
- 16:41but with these two doors file there's a
- 16:42certain way we have to do it now we will
- 16:44have to use sudo to do this so i'm going
- 16:45to stop being iron man for a second i'm
- 16:47going to
- 16:48ctrl d to log out of iron man okay i'm
- 16:50me again the command will be sudo
- 16:52and then right after that it'll be vi
- 16:56sudo this is the only best practice
- 16:58recommended way to
- 16:59edit the sudoers file so let's uh get in
- 17:02there and take a look and it's not a
- 17:03crazy big file either it's kind of
- 17:05simple in a way so i'll hit enter
- 17:07and we're in and then i'll scroll down
- 17:08through this document to
- 17:10about here right here is where we're
- 17:12able to see who's got permission to do
- 17:14what obviously root can use sudo and
- 17:16i'll explain what all this means here in
- 17:18a moment and then down here in this
- 17:19section we have allowed members of a
- 17:20group
- 17:21pseudo access or pseudo to execute any
- 17:23command and then just below that we have
- 17:25something else we have a percent sign
- 17:26and then
- 17:27pseudo this actually is a group and if
- 17:29you're a member of this group the sudo
- 17:31group
- 17:32well you can do all this and what this
- 17:34actually means is you can enter
- 17:35any command at all and you don't have to
- 17:37enter
- 17:39a password which is pretty dangerous
- 17:40kind of risky but
- 17:42it's okay so if you're in this file
- 17:45you have the power and thanos does have
- 17:47the power let's go ahead and add thanos
- 17:48real quick
- 17:49we'll pretend he's already in there so
- 17:51just under root i'm going to add thanos
- 17:53so we'll start with the username which
- 17:54is
- 17:55thanos the first option here is what
- 17:57systems
- 17:58can thanos have ultimate power on well
- 18:01it's the infinity gauntlet
- 18:02all systems and this would be if they're
- 18:04like multi-system situations but
- 18:06and then i'll do a space equals not plus
- 18:09sign
- 18:09equals all and that all stands for all
- 18:13commands now if you want to just give
- 18:15thanos options to do one thing like
- 18:16maybe add a user we might do forward
- 18:18slash
- 18:19sbn forward slash user add giving him
- 18:22access to that one command
- 18:24we don't want to do that thanos has all
- 18:26power
- 18:27oh and that's all we need i'm going to
- 18:29hit control
- 18:30x to say i want out of here don't want
- 18:32to save it hit y
- 18:33hit enter to write it to that file and
- 18:36thanos is there
- 18:37he's got the gauntlet on he can do
- 18:38whatever he wants let's see if he can
- 18:40we're going to become thanos for a
- 18:41second so i'll do sudo
- 18:44su space dash space thanos
- 18:47we're thanos right now so let's do sudo
- 18:49user ad what's another bad guy he uses
- 18:51oh yeah his daughter nebulous little
- 18:53spring nebula in here the stanos have
- 18:55access let's see
- 18:57what's his password inevitable yep
- 19:00it did it worked so let's cap the uh
- 19:03password file yep there's nebula
- 19:05so thanos has ultimate power he's got
- 19:07the gauntlet on
- 19:08and crap he's about to snap you ready
- 19:11he's going to delete half the
- 19:12population in our case half the avengers
- 19:14we have here to delete a user
- 19:16new new command time it's terrible but
- 19:19new command time coffee break
- 19:22okay i'm ready sudo user
- 19:25del or user delete as you might expect
- 19:28this command will
- 19:29delete a user and we'll take out thor
- 19:32thor is gone if we catch the password
- 19:35file
- 19:36thor he's gone pseudo user delete
- 19:39spider-man gone bye doctor strange
- 19:43gone and just like that with a snap of
- 19:44his fingers we're down to
- 19:46hulk loki and captain america oh and
- 19:49iron man two there he is
- 19:50and just when it seems hopeless just
- 19:52when it seems all is lost the avengers
- 19:54have a plan ant-man comes in somehow
- 19:56quantum stuff anyways we need the
- 19:57gauntlet we need pseudo access to be
- 19:59able to
- 20:00bring captain america back and all the
- 20:01other people got got deleted so let's do
- 20:03this right now so
- 20:04we're gonna explore a new concept we're
- 20:06going to create a group to do that
- 20:08new command time here we go we'll do
- 20:11sudo group
- 20:12add and as you might expect group add
- 20:14will simply add a new group i'll do a
- 20:16space i'll name my group
- 20:18infinite
- 20:21gauntlet does spell that right i don't
- 20:24care that's what it's going to be called
- 20:26and the group is there but how do we
- 20:28know where is that group at
- 20:29well just like we have a password file
- 20:31to look at our users in the system
- 20:33we have a file to look at the groups and
- 20:35it's much more self-explanatory it makes
- 20:37more sense
- 20:38i'm going to cat the etsy group
- 20:41file and there it is infinity gauntlet
- 20:45right there
- 20:45as well as every other group that was
- 20:47created for our users
- 20:49i told you whenever a user account is
- 20:50created also they have a group created
- 20:52for themselves as well
- 20:53now what i want to do is make sure that
- 20:54the members of the infinity gauntlet
- 20:56group
- 20:56do have ultimate power because you mean
- 20:58you should you have the infinity
- 21:00gauntlet on
- 21:00so we need to add the infinity gauntlet
- 21:02group to our sudoers file
- 21:04let's do that real quick so again we'll
- 21:05do sudo vi sudo to edit that file the
- 21:08only way to do it don't you ever do it a
- 21:09different way
- 21:10i'm just kidding but seriously um let's
- 21:13edit that file we're gonna scroll down
- 21:14to
- 21:15where we were and then right here right
- 21:17now we see that members of the sudo
- 21:19group
- 21:20can do whatever they want and actually
- 21:21real quick let me show you the reason we
- 21:23can do whatever we want
- 21:24is because we're members of the sudo
- 21:26group if i do
- 21:27actually new command time if you just
- 21:29type in group i'm sorry
- 21:31groups groot
- 21:34it'll tell you what groups you are a
- 21:36member of the current user account
- 21:37you're logged in as and here i'm a
- 21:38member of my own group user 86527
- 21:40and the pseudo group which gives me
- 21:43gauntlet
- 21:44access anyways let's make sure the
- 21:45gauntlet does have the appropriate
- 21:47permissions here so just under
- 21:49the sudo group i'm going to add percent
- 21:51infinity
- 21:54gauntlet make sure you spell it right
- 21:56i'll do a space and i'll pretty much
- 21:57copy the one just above it i'll say all
- 21:58which again is all systems
- 22:00space equal sign space i'll say no
- 22:02password which is nopa sswd like we see
- 22:05here
- 22:06i'll do a colon and say all essentially
- 22:08it's saying you can do everything you
- 22:09want
- 22:10all commands and you don't need a
- 22:11password you got all them stones
- 22:13anyways so i'm going to hit control now
- 22:16actually you know what real quick before
- 22:17i do that
- 22:18i'm going to mess it up like i mentioned
- 22:20before if you mess up your suitors file
- 22:22you can break the entire system
- 22:24there is some checks in there that'll
- 22:26keep you safe so i'll just go
- 22:29and i hit control x to get out of there
- 22:32yes to save hit enter it'll say whoa
- 22:35whoa whoa
- 22:36there is a syntax error right there not
- 22:38supposed to do that what are you doing
- 22:40what are you going to do now what do you
- 22:41want to do are you sure you want to save
- 22:42this if i hit enter it will give me some
- 22:44options
- 22:44and i love this it's like you might want
- 22:47to go edit it again hit e
- 22:48hit x to get out of there and don't save
- 22:50it just forget what you're doing you
- 22:51don't know what you're doing or says you
- 22:52know what if you're pretty confident
- 22:53just hit q and say you want to save it
- 22:55danger um let's be smart let's hit e to
- 22:59edit it
- 23:00and remove that crap we put in there and
- 23:02then we can hit ctrl
- 23:03x y and enter no errors we're good
- 23:07so the infinity gauntlet group does have
- 23:10ultimate sudo
- 23:11super user due powers and now what's
- 23:13left is the avengers have to somehow
- 23:15become part of that group
- 23:16put on the glove and change history and
- 23:18if you've seen the movie
- 23:19spoiler alert um iron man he does this
- 23:22so we need to somehow get iron man into
- 23:25the infinity gauntlet group let's do
- 23:26that right now now real quick let's
- 23:28demonstrate that iron man can't do crap
- 23:29right now so if i
- 23:30become iron man and i try to bring back
- 23:34spider-man i can't i don't have the
- 23:36glove i can't do it man iron man is
- 23:37helpless but let's add them to the group
- 23:39so to add a user to a group
- 23:40pretty simple we're going to use the
- 23:41same command we used earlier to modify a
- 23:43user the user mod command
- 23:45so we'll do sudo and keeping in mind i'm
- 23:47logged in as me now not ironman anymore
- 23:49i'll do sudo
- 23:50user mod and the switch is dash
- 23:53g now dash g by itself will add this
- 23:56user to a group
- 23:57but it will add it to that group and
- 23:59kind of eliminate all other groups
- 24:01you may not want to do that so we often
- 24:03want to change this to
- 24:04dash lowercase a capital g the a stands
- 24:08for append
- 24:08so this command here we're appending the
- 24:10groups that ironman
- 24:12is part of so just after dash ag we'll
- 24:15type in
- 24:16the group which is infinity gauntlet
- 24:19and then the user we want to add which
- 24:21will be iron man
- 24:22just like that iron man has the glove on
- 24:25we can actually see if that's happening
- 24:26by going to
- 24:27or catting the group file
- 24:30etsy group and here we can see the
- 24:33infinity gauntlet group
- 24:34the members over here on the right and
- 24:35there's iron man right there now again
- 24:37if you saw the movie you know that iron
- 24:38man and
- 24:39and thanos were kind of wrestling with
- 24:41the gloves so thanos was in the group
- 24:43too
- 24:43they kept going back and forth let me
- 24:45add thanos in there real quick
- 24:46so yes right now iron man and thanos are
- 24:48both part of this group they both have
- 24:49super awesome
- 24:50powerful pseudo access but eventually
- 24:53iron man does wrestle the
- 24:55glove off of thanos and puts it on
- 24:56himself so new command time how do you
- 24:58remove
- 24:59a user from a group this command is
- 25:01called g password
- 25:03the commands sometimes are weird um so
- 25:05we'll do sudo
- 25:06g pass wd we're gonna do dash d for
- 25:09delete specify the user we want to
- 25:11remove which will be
- 25:13thanos take that off take that take it
- 25:15and then we'll specify the group
- 25:17infinity gauntlet take that thanos look
- 25:20at the group once more
- 25:21no one's in there so anyways iron man he
- 25:23has the gauntlet
- 25:24he snaps his fingers and he creates the
- 25:27users we lost
- 25:28let me become iron man i am iron man
- 25:31pseudo
- 25:32user ad captain america pseudo
- 25:35user ad spiderman done we'll bring back
- 25:39doctor strange
- 25:40and i forgot who else but anyways you
- 25:41get the picture right iron man has the
- 25:43gauntlet on he has the power he's part
- 25:45of the group
- 25:46and he can now bring back everyone and
- 25:48shoot while he's at it let's defeat
- 25:50thanos right
- 25:51sudo user delete
- 25:55thanos here we go
- 25:58goodbye thanos and then finally iron man
- 26:00realizes the infinity gauntlet it's too
- 26:02powerful
- 26:03for anyone to possess so he destroys it
- 26:05i think that's what happens
- 26:06that's what we're going to do right now
- 26:07so using the principle of least
- 26:08privilege
- 26:09we're going to remove the the infinity
- 26:11gauntlet group we're going to delete
- 26:12that group by doing the
- 26:14group delete command in fact iron man
- 26:16will do it himself right now and he's
- 26:17going to
- 26:18delete his access to do it at the same
- 26:20time which is kind of weird right
- 26:21so sudo group delete uh new command time
- 26:25i forgot to sit man
- 26:26which obviously means we're gonna be
- 26:28deleting a group and the usage is pretty
- 26:30straightforward just after group delete
- 26:32we'll enter the name of the group
- 26:33infinity gauntlet now this does not
- 26:36delete any
- 26:37users in that group it just deletes the
- 26:39group and gone are also iron man's
- 26:41privileges to do anything special
- 26:42anymore
- 26:43for example if he got greedy and wanted
- 26:45to create the group once more
- 26:47sorry iron man you don't have it anymore
- 26:49and i think you have other problems to
- 26:50worry about
- 26:51we did it i think like we saved the
- 26:53world right i mean iron man's
- 26:54not okay but we we learned how to manage
- 26:57users and linux and in the process we
- 26:59assembled the avengers and took away the
- 27:01infinity gauntlet destroyed it and saved
- 27:03the world
- 27:04yeah but seriously we learned a lot
- 27:06today we learned how to manage users in
- 27:07linux
- 27:08add them delete them groups permissions
- 27:11all that
- 27:12and that's essential to managing a linux
- 27:13system to becoming a hacker to doing
- 27:16anything with linux now and
- 27:17pretty much every area of it involves
- 27:19linux and also if you want a quick
- 27:21review of what we covered in text form
- 27:23uh mosey on over to hack the box academy
- 27:25the page we were at the whole time
- 27:26and look it over they've got the
- 27:27commands we we talked about in text form
- 27:30and they also have a delightful quiz at
- 27:32the very bottom to test your knowledge
- 27:33and see how you do
- 27:34and if you get it right you earn cubes
- 27:36back which with the junk or cubes
- 27:38go watch episode one if you don't know
- 27:39what they are also if you want to test
- 27:41your skills even further
- 27:42i've got a quiz in the description below
- 27:44it's free click the link
- 27:45and uh let's see what you got and again
- 27:47huge shout out to our sponsor hack the
- 27:49box academy
- 27:50it's free to access right now to do what
- 27:52we've been doing here if you want to go
- 27:53further and learn how to hack wordpress
- 27:55and
- 27:55and do python stuff and just man just so
- 27:58many things
- 27:59check them out link below i'll catch you
- 28:01guys next time
- 28:03[Music]
- 28:17[Music]
- 28:18you
About this transcript
This page contains the full transcript of sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4 by NetworkChuck, generated from the public captions YouTube serves with the video. The transcript has 6,199 words across 965 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.