sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4
Summary
TLDRO vídeo ensina sobre a gestão de usuários no Linux, abordando a criação, modificação e exclusão de contas de usuários e grupos. O apresentador utiliza uma narrativa divertida, fazendo referências aos Vingadores e Thanos, para explicar conceitos como o comando sudo, o arquivo sudoers e a importância de permissões de usuário. Os espectadores são incentivados a praticar em um laboratório Linux gratuito oferecido pelo Hack The Box Academy, onde podem aplicar o que aprenderam. O vídeo é uma introdução essencial para quem deseja se aprofundar em Linux e hacking.
Takeaways
- 🖥️ Aprenda a criar e gerenciar usuários no Linux.
- 🔑 Entenda a diferença entre 'add user' e 'user add'.
- ⚡ Descubra como usar o comando sudo para permissões elevadas.
- 📂 Veja como listar todos os usuários do sistema.
- 📝 Conheça o arquivo sudoers e sua importância.
- 👥 Aprenda a adicionar usuários a grupos.
- ❌ Saiba como deletar contas de usuários.
- 👥 Crie grupos no Linux facilmente.
- 🔄 Use 'gpasswd' para gerenciar grupos.
- 🔍 Verifique a quais grupos um usuário pertence.
Timeline
- 00:00:00 - 00:05:00
Neste vídeo, o apresentador introduz a gestão de usuários no Linux, enfatizando sua importância para quem deseja se tornar um hacker ou trabalhar com Linux. Ele menciona que o episódio 4 abordará a criação, exclusão e modificação de contas de usuários, além de grupos e permissões, utilizando o comando sudo para obter privilégios elevados.
- 00:05:00 - 00:10:00
O apresentador orienta os espectadores a acessarem um laboratório Linux gratuito oferecido pela Hack The Box Academy, onde podem praticar a gestão de usuários. Ele demonstra como iniciar o laboratório e como verificar a identidade do usuário atual no sistema usando o comando 'who am i'.
- 00:10:00 - 00:15:00
O vídeo prossegue com a criação de um novo usuário, Thor, utilizando o comando 'add user'. O apresentador explica a diferença entre 'add user' e 'user add', destacando que o primeiro é mais interativo. Ele também menciona a importância do usuário root e como usar o sudo para obter permissões elevadas.
- 00:15:00 - 00:20:00
Após criar Thor, o apresentador mostra como visualizar todos os usuários do sistema através do arquivo '/etc/passwd'. Ele explica a estrutura desse arquivo e a importância do arquivo '/etc/shadow' para armazenar senhas de forma segura. O apresentador também demonstra como adicionar mais usuários, como Iron Man, e a diferença entre os comandos 'add user' e 'user add'.
- 00:20:00 - 00:28:19
O vídeo conclui com a criação de grupos e a adição de usuários a esses grupos, explicando como o comando 'sudo' permite que os usuários executem tarefas administrativas. O apresentador enfatiza a importância de gerenciar usuários e grupos no Linux, destacando que essas habilidades são essenciais para qualquer um que deseje trabalhar com o sistema.
Mind Map
Video Q&A
O que é o comando 'add user'?
O comando 'add user' é utilizado para criar uma nova conta de usuário no sistema Linux.
Qual a diferença entre 'add user' e 'user add'?
Ambos os comandos criam usuários, mas 'add user' é mais interativo e configura mais opções automaticamente, enquanto 'user add' é mais simples e não configura detalhes como senha.
O que é o comando 'sudo'?
O comando 'sudo' permite que um usuário execute comandos com permissões de superusuário, essencialmente dando acesso temporário a privilégios elevados.
Como posso ver todos os usuários no sistema?
Você pode ver todos os usuários no sistema usando o comando 'cat /etc/passwd'.
O que é o arquivo sudoers?
O arquivo sudoers define quais usuários têm permissão para usar o comando sudo e quais comandos eles podem executar.
Como adicionar um usuário a um grupo?
Você pode adicionar um usuário a um grupo usando o comando 'usermod -aG nome_do_grupo nome_do_usuario'.
O que faz o comando 'userdel'?
O comando 'userdel' é usado para deletar uma conta de usuário do sistema.
Como criar um grupo no Linux?
Você pode criar um grupo usando o comando 'groupadd nome_do_grupo'.
O que é o comando 'gpasswd'?
O comando 'gpasswd' é usado para adicionar ou remover usuários de grupos.
Como posso verificar a qual grupo um usuário pertence?
Você pode verificar a quais grupos um usuário pertence usando o comando 'groups nome_do_usuario'.
View more video summaries
Lição 9 - Nos Salmos - Parte 2
A POLÍTICA EDUCACIONAL BRASILEIRA APÓS A DITADURA MILITAR ATÉ OS DIAS ATUAIS
Como funciona o Novo Fundeb | De onde vem o dinheiro da educação? (Parte 18)
MOVIMENTO UNIFORME - FÍSICA BÁSICA (FÍSICA do ZERO) - Teoria e Exercícios - AULA 02
Sistema Económico Colombiano
Como NOMEAR e montar a FÓRMULA de ÁCIDOS, SAIS e BASES? | Aula 20 (Química I)
- 00:00:00managing users in linux this is
- 00:00:02essential you got to know this if you
- 00:00:03want to get into linux or become a
- 00:00:04hacker or do anything
- 00:00:06don't skip this so assemble the avengers
- 00:00:08we gotta stop thanos
- 00:00:14what
- 00:00:18welcome to linux for hackers and
- 00:00:20everyone because everyone
- 00:00:22needs to learn linux this is episode 4
- 00:00:24and you don't want to miss this when
- 00:00:25we're talking about user management user
- 00:00:27accounts and linux and we're pretty much
- 00:00:29going to cover everything from creating
- 00:00:30users deleting them changing them
- 00:00:32creating groups deleting those putting
- 00:00:34on the infinity gauntlet and giving
- 00:00:35yourself super godlike permissions
- 00:00:37which is also known as sudo or the
- 00:00:39sudoer's file we'll cover all that
- 00:00:41and yeah we're gonna assemble the
- 00:00:42avengers and stop thanos we're going to
- 00:00:44save the world and when i say we i mean
- 00:00:46we because you're going to do this with
- 00:00:47me you're getting a free
- 00:00:48linux lab right here in this video check
- 00:00:50the link in the description thanks to
- 00:00:52our sponsor
- 00:00:52hack the box academy it's seriously
- 00:00:54amazing free to sign up
- 00:00:55hack the box academy is basically a
- 00:00:57trading ground for hackers
- 00:00:59good hackers mind you so if you want to
- 00:01:00follow along with me learn how to manage
- 00:01:02users in linux and save the world
- 00:01:04then click the link below get signed up
- 00:01:05for free and you'll have a linux
- 00:01:07lab right here in your browser and then
- 00:01:09of course whatever else you want to
- 00:01:10learn regarding hacking it's there so
- 00:01:12check that out too also hack the box
- 00:01:13academy now has a student subscription
- 00:01:15and you get cpe credits for completing
- 00:01:18tier 1 modules or above
- 00:01:20kind of killer check it out link below
- 00:01:22to learn more have you hacked the
- 00:01:23youtube algorithm today let's make sure
- 00:01:25you do hit that like button subscribe
- 00:01:26comment
- 00:01:27notification bell let's hack youtube
- 00:01:28today ethically of course
- 00:01:30anyways no time to waste get your
- 00:01:32stinking coffee let's do this
- 00:01:35right now okay here we go we're going to
- 00:01:37learn nearly everything you need to know
- 00:01:38about managing users and linux
- 00:01:40and we're gonna have a bit of fun with
- 00:01:42it too so get your copy and let's go
- 00:01:44now first we gotta launch our lab our
- 00:01:46free linux lab from hack the box academy
- 00:01:49so go ahead and navigate out there
- 00:01:50hack the blogs account of me they are
- 00:01:52our sponsor and they're amazing it's
- 00:01:54completely free if you haven't already
- 00:01:55signed up we'll get signed up i've got a
- 00:01:56video walking you through that right
- 00:01:58here
- 00:01:58so log in to hack the box academy go and
- 00:02:00click on the linux fundamentals course
- 00:02:01to get started go ahead and open up the
- 00:02:03user management module right here and
- 00:02:05then to launch our free amazing phone
- 00:02:06box our lab
- 00:02:08scroll about halfway down and click on
- 00:02:09start instance and it's going to start
- 00:02:11quick coffee break just a little sip and
- 00:02:14it is ready go ahead and click on
- 00:02:15interact to uh
- 00:02:17interact with it and i've said it before
- 00:02:18this is amazing it's your free linux lab
- 00:02:20in your browser that you can mess with
- 00:02:22and break things and
- 00:02:23let's do this okay let's talk about
- 00:02:25users every computer system has a user
- 00:02:28including linux and you know what you're
- 00:02:30a user
- 00:02:32to be able to log into the server this
- 00:02:34linux box and do anything you have to be
- 00:02:36a user on the system which user are you
- 00:02:38let's see in a previous video we showed
- 00:02:40this already so let's go ahead and
- 00:02:41launch our terminal
- 00:02:42our green or yellow box up at the top
- 00:02:44here this is launching our shell
- 00:02:46if you don't know what that is we'll go
- 00:02:47back to the last video and watch that
- 00:02:48one we talk all about it to quickly see
- 00:02:50who you are you simply type in who
- 00:02:52am i and there you are your user account
- 00:02:55and you as user 86527 can log into this
- 00:02:58linux machine
- 00:02:58and do stuff you can launch programs
- 00:03:00play games hack
- 00:03:01create things delete things if you have
- 00:03:03the right permissions we'll cover that
- 00:03:04here in a moment
- 00:03:05you you can do a lot of stuff as a user
- 00:03:07of the system but not all users are the
- 00:03:09same now hey
- 00:03:10i've got some bad news we're under
- 00:03:12attack our system our linux
- 00:03:14box here we're being attacked by
- 00:03:17thanos that's his name right the bad guy
- 00:03:19from avengers yes thanos he's attacking
- 00:03:21us
- 00:03:21bad guy thanos is gonna snap his fingers
- 00:03:23and destroy all our user accounts and we
- 00:03:24won't be able to have fun on linux
- 00:03:26anymore
- 00:03:26we have to stop him but how do we do
- 00:03:28that avengers assemble we need the
- 00:03:30avengers right let's call them do they
- 00:03:32have like a bat signal i don't know how
- 00:03:33you call them
- 00:03:34they just know they need help right or
- 00:03:35that we need help but they're not in our
- 00:03:37system right now we have to create these
- 00:03:38user accounts to come and stop thanos
- 00:03:40before he
- 00:03:41snaps anyways let's start by adding the
- 00:03:44avengers to our system
- 00:03:45let's start with thor he's my favorite
- 00:03:47so the command will be
- 00:03:49add user thor and honestly it's that
- 00:03:52simple that's all we need
- 00:03:53the command add user will obviously add
- 00:03:55a user but it's not the only one that
- 00:03:57does this by the way just so you know
- 00:03:59there's add user and then confusingly
- 00:04:01there's another one called
- 00:04:02user add which they do both add a user
- 00:04:06but this command right here is a little
- 00:04:07lazy
- 00:04:08he doesn't do as much whereas this
- 00:04:09command will do a lot i'll show you the
- 00:04:11difference here real quick we'll bring
- 00:04:12in our other avengers
- 00:04:13anyways let's add thor real quick now
- 00:04:14i'm going to hit enter but it's not
- 00:04:16going to work
- 00:04:17watch only root may add a user a group
- 00:04:19to the system now what is a root
- 00:04:21i mean root's another user on the system
- 00:04:23if you watched our previous videos in
- 00:04:24the series you would know all about root
- 00:04:26not groot
- 00:04:27root but we're going to temporarily
- 00:04:28borrow some power from the root which
- 00:04:30he's also known as the super user um so
- 00:04:33what we're going to do here is hit the
- 00:04:34up arrow to get our command back in
- 00:04:35there add user thor we're going to go to
- 00:04:37the beginning of our command
- 00:04:38and type in sudo or it's also often
- 00:04:41pronounced soo do but it's spelt sudo so
- 00:04:43i want to say that
- 00:04:44this is kind of like saying please in
- 00:04:45linux please do this i'm getting super
- 00:04:47powers to do this
- 00:04:48again i'll explain more about that here
- 00:04:50in a moment but anyways this is gonna
- 00:04:51work
- 00:04:52okay cool we got a fun prompt here let's
- 00:04:54put a password in for thor i'm gonna say
- 00:04:56hammer type it in again hammer full name
- 00:04:58i think it's just thor
- 00:05:00it'll ask you for all this random
- 00:05:01information you don't have to put it all
- 00:05:02in just enter enter enter
- 00:05:03is it correct sure and thor's created he
- 00:05:05is now a user on the system but how do
- 00:05:08we know that where
- 00:05:09is he well to find out what users are on
- 00:05:12your system there's one simple place to
- 00:05:13look
- 00:05:13i'm going to clear my screen real quick
- 00:05:15by typing in clear or i can just do
- 00:05:16control
- 00:05:17l whoo nice and clean there's a file in
- 00:05:19the system that has a list of every user
- 00:05:20on this
- 00:05:21box or this system we're going to use
- 00:05:23the command cat which we learned before
- 00:05:25we're going to cat the forward slash
- 00:05:27etsy forward slash pass
- 00:05:28wd when we do that here's what happens
- 00:05:31boom bunch of users on our system i bet
- 00:05:33you're surprised like where all these
- 00:05:35users come from i mean the first two we
- 00:05:36recognize right i mean the last two
- 00:05:38uh this one right here is us user blah
- 00:05:40blah
- 00:05:41and then thor the one we just created
- 00:05:42there he is all these other entries are
- 00:05:44indeed
- 00:05:45user accounts on this system and they do
- 00:05:47serve a purpose a lot of these you can't
- 00:05:48log in
- 00:05:49with like right here it says no login on
- 00:05:51this account they do serve a purpose not
- 00:05:53the topic for another video anyways now
- 00:05:55real quick
- 00:05:55what does all this right here mean it's
- 00:05:58kind of gobbledygook right i mean the
- 00:05:59first bit we understand what it is the
- 00:06:01username
- 00:06:02thor and user blah blah blah but what's
- 00:06:04all the stuff after it well just after
- 00:06:06the username we have
- 00:06:07just an x sitting there all by himself
- 00:06:09in fact you'll see this on pretty much
- 00:06:10every user account appear
- 00:06:12x max and what the x indicates is that
- 00:06:14your password is stored in a separate
- 00:06:16file called the
- 00:06:17shadow file more specifically it's in a
- 00:06:19place called etsy
- 00:06:21shadow in linux we store our passwords
- 00:06:23in the shadows where they're hidden you
- 00:06:25can't see them but for real
- 00:06:26if we go to it real quick we can
- 00:06:27actually look at it let's do cat
- 00:06:29etc etsy shadow oh permission deny we
- 00:06:32need some
- 00:06:33listen please sudo there we go and right
- 00:06:35here next to the username thor we have
- 00:06:37his password which that's actually not
- 00:06:38his password
- 00:06:39that's the hashed version topic for
- 00:06:41another time anyways now just after x we
- 00:06:43have two numbers
- 00:06:44and they're the same we have one
- 00:06:45thousand one and one thousand one what
- 00:06:48are those
- 00:06:48well those are his ids the first one is
- 00:06:52his user id or a uid it's a number
- 00:06:55which you can obviously see it's 1001.
- 00:06:57the second one is his
- 00:06:59group id we'll cover groups here in a
- 00:07:00second but just know that when we create
- 00:07:02a user in linux
- 00:07:03we both create a user and a group for
- 00:07:06that user so we have a username named
- 00:07:07thor
- 00:07:08we also have a group named thor and the
- 00:07:10member of that group
- 00:07:11is thor and then after that we got some
- 00:07:13like random filler stuff like his name
- 00:07:15and comments and stuff
- 00:07:16and then after that we have his home
- 00:07:19directory where he gives his hammer and
- 00:07:21his
- 00:07:21chest plate i don't know what thor has
- 00:07:23his hair ties for thor his home
- 00:07:25directory is in
- 00:07:26the same place that a lot of people's
- 00:07:27home directories are home
- 00:07:30and then a directory called thor we'll
- 00:07:32look at that here in a moment and then
- 00:07:33just after that
- 00:07:34we have his default shell when thor logs
- 00:07:37into the system
- 00:07:37what shell is he going to be given again
- 00:07:39if you don't know what i'm talking about
- 00:07:40go look at our previous video
- 00:07:42but by default when we created his user
- 00:07:44account with the add user command
- 00:07:46it's going to be bash so that is what
- 00:07:48all that gobbledygook means now let me
- 00:07:49show you what the user add command does
- 00:07:51our
- 00:07:52alternative command which is kind of
- 00:07:54weird so we have thor he's pretty
- 00:07:56awesome but we need some extra help
- 00:07:57i think we need iron man yeah yeah let's
- 00:07:59get iron man in here so we'll do sudo
- 00:08:01and instead of add user we're gonna
- 00:08:03we're gonna do user
- 00:08:05add and same as before we'll just type
- 00:08:07in the user name iron man
- 00:08:09and watch what happens here it is
- 00:08:11different it's simple
- 00:08:13that's it so remember add user like asks
- 00:08:16hey put in his password
- 00:08:17uh what's his first name last name
- 00:08:19what's social security number
- 00:08:21favorite flavor ice cream like all that
- 00:08:22stuff this one just says
- 00:08:24okay you're like uh what else
- 00:08:27what do i do now that's what i meant by
- 00:08:29saying that command is lazy because he
- 00:08:30doesn't do anything but just say okay
- 00:08:32yeah here's a user account i'm not gonna
- 00:08:33do anything else like
- 00:08:34set the password for you like you can do
- 00:08:36that yourself um and i'll show you how
- 00:08:37to do that here in a second but right
- 00:08:38now
- 00:08:39iron man is created but you can't really
- 00:08:40do much with him so if we cat our
- 00:08:42password file again to see what user
- 00:08:44accounts we have in our system cat
- 00:08:45slash etsy pass wd he's there iron man
- 00:08:49is shown up
- 00:08:49but there's a few things missing now for
- 00:08:51example he has the x there saying that
- 00:08:53his password's in the shadow file but is
- 00:08:54it really because we didn't set a
- 00:08:55password did we also notice here that
- 00:08:58um his default shell is different it's
- 00:09:00sh for
- 00:09:01shell instead of bash so real quick i
- 00:09:03want to take a look at the shadow file
- 00:09:05to see if the stuff is there
- 00:09:06that's interesting you can see that he
- 00:09:08does have
- 00:09:09an entry in the shadow file but it
- 00:09:11doesn't seem to be a password
- 00:09:12and i don't think it is but we can set
- 00:09:14this password real quick command to set
- 00:09:16a password for someone or change a
- 00:09:17password for any username
- 00:09:18is going to be password without the o-r
- 00:09:22i'll show you so we'll we'll need super
- 00:09:24powers sudo command is p-a-s-s-w-d
- 00:09:28and then the user name so i'll type in
- 00:09:30iron man and now we can set his password
- 00:09:32jarvis there we go he's got a legit hash
- 00:09:34there so we know it's working now one
- 00:09:36thing the ad user command did not do for
- 00:09:37iron man is it did not give him a home
- 00:09:39he doesn't have a house right now he
- 00:09:40doesn't have a home directory if i
- 00:09:41navigate to the home directory well all
- 00:09:42the
- 00:09:43user directories live i go cd forward
- 00:09:45slash home
- 00:09:46and i type in ls i can see there are two
- 00:09:48directories there for thor and then for
- 00:09:50me
- 00:09:51but iron man he doesn't have a home dude
- 00:09:53and that's one downside of using the
- 00:09:55user ad command
- 00:09:56is again he's lazy he doesn't do this
- 00:09:57kind of stuff if i jump into the thor
- 00:09:59directory by doing cd
- 00:10:01thor and then lsing his contents
- 00:10:04yeah he's got a desktop he's got
- 00:10:05templates if i do ls
- 00:10:07dash al to reveal the hidden files he's
- 00:10:10got a bunch of stuff going on in there
- 00:10:11which we're not going to get into right
- 00:10:13now i mean it is important but right now
- 00:10:14we got to save the world
- 00:10:15thor is here and he's coming clear our
- 00:10:17screen now if we cap the password file
- 00:10:19again
- 00:10:20etsy pass wd i'm super annoyed that iron
- 00:10:23man's
- 00:10:24default shell is not the same as
- 00:10:25everyone else's it's just sh
- 00:10:27let's make sure it is bash we can modify
- 00:10:29user account new command time are you
- 00:10:31ready the command is
- 00:10:32user mod which stands for user
- 00:10:34modification and as you might expect it
- 00:10:36will modify a user account now there are
- 00:10:38a ton of things we can change if you do
- 00:10:40dash h for help to see like what can i
- 00:10:42do with this it'll tell you
- 00:10:44a lot of stuff and i'm not going to
- 00:10:46cover everything right now that take
- 00:10:47forever and
- 00:10:48thanos is here so i'll do sudo because
- 00:10:50we will need special permissions
- 00:10:52user mod and let's say i want to change
- 00:10:53that shell for iron man
- 00:10:55i'll do iron man say that's who i want
- 00:10:57to change it for
- 00:10:58dash dash shell and i'll say ben
- 00:11:02bash done and if we cap the user or the
- 00:11:05cat the password file once more welcome
- 00:11:07iron man you now are using bash just
- 00:11:09like everyone else
- 00:11:09and we can change other things too like
- 00:11:11maybe his name like sometimes iron man
- 00:11:13isn't iron man sometimes he's tony stark
- 00:11:15so if we do sudo user mod once more
- 00:11:18we'll use the switch
- 00:11:19dash l and then we'll put in the new
- 00:11:22information
- 00:11:23tony stark that's his new username and
- 00:11:25then the old one
- 00:11:26iron man done so if i cat the password
- 00:11:30file once more
- 00:11:30huh he's tony stark now but we don't
- 00:11:32need tony stark right now we need iron
- 00:11:33man let's change it back
- 00:11:35okay better okay here we go now again
- 00:11:37thanos is here and we need more than
- 00:11:38just two avengers
- 00:11:40avengers assemble let's create more
- 00:11:42right now real quick
- 00:11:43fast and that is where the user add
- 00:11:45command comes in handy because you can
- 00:11:46add things really quickly enough to go
- 00:11:47through a menu every single time so
- 00:11:49we'll just do it real quick
- 00:11:50and we also have switches to help us
- 00:11:51with that if i do user add dash h
- 00:11:53we can do a lot of the stuff that the
- 00:11:55add user command does just in one line
- 00:11:57so i'll do user add let's bring in
- 00:12:01hulk and i'll do a dash m which dash m
- 00:12:04will actually create a home directory
- 00:12:05form so whereas iron man didn't get one
- 00:12:07by default i almost forgot we need
- 00:12:09superhero permissions there we go let's
- 00:12:11get spider-man in here
- 00:12:13loki why not oh we can't forget captain
- 00:12:15america
- 00:12:16and i suppose we'll need doctor strange
- 00:12:18i don't like that movie that much
- 00:12:19didn't like it at all wasn't a fan but
- 00:12:21he kind of played a key role so we'll
- 00:12:22put him in here
- 00:12:23so now we have some avengers if i do uh
- 00:12:26cat
- 00:12:27etsy password file boom
- 00:12:31we got them they're here if you've seen
- 00:12:33the movies you know it doesn't go
- 00:12:35great at first thanos does get the power
- 00:12:37he gets the
- 00:12:38the gauntlet or what is it called ah
- 00:12:40okay the infinity gauntlet almost forgot
- 00:12:42actually i did forget i had to look it
- 00:12:43up thanos has the power and he does
- 00:12:46flick his fingers or snaps fingers and
- 00:12:48do some bad stuff
- 00:12:50now i'm gonna add the user account
- 00:12:52thanos
- 00:12:53we're bringing him in he's there i'm
- 00:12:55going to set his password real quick
- 00:12:57password inevitable let's see if he's
- 00:13:00here yep there's thanos
- 00:13:01now here in linux the infinity gauntlet
- 00:13:03that gives you super
- 00:13:04awesome powers and has all the stones
- 00:13:06and you can flick your fingers and
- 00:13:07everyone disappears
- 00:13:09in linux that's definitely the pseudo
- 00:13:11command
- 00:13:12or pseudo we haven't really dived into
- 00:13:14that deeply just yet
- 00:13:16but right now we are it's a command we
- 00:13:17use all the time it stands for
- 00:13:20super user do essentially every time we
- 00:13:22use that command it's like we're
- 00:13:23slipping on the infinity gauntlet
- 00:13:24the super powerful glove and this is the
- 00:13:26worst glove you'll ever see we slip that
- 00:13:28glove on and for one moment
- 00:13:30we have powers to do whatever we frickin
- 00:13:31want so the sudo command or the sudo
- 00:13:33command
- 00:13:34were able to grab the powers of the
- 00:13:36super user the root user
- 00:13:37and use them for that command now the
- 00:13:40super user in the system
- 00:13:41which is the root user he's the boss he
- 00:13:43can do whatever stinking wants on linux
- 00:13:45he can change all the settings
- 00:13:46he can delete all the settings he can
- 00:13:48ruin everything delete half your stuff
- 00:13:50rmrf man that's what thanos is gonna do
- 00:13:54and if you can use the pseudo command to
- 00:13:55impersonate him just for a moment
- 00:13:57that's a pretty stinking powerful
- 00:13:59command it's a command that you don't
- 00:14:00want to just give to anyone you want to
- 00:14:02restrict that access and by default it
- 00:14:04is pretty restricted
- 00:14:05now you can see that right now we've
- 00:14:07been using sudo all day
- 00:14:08we have the infinity gauntlet we can put
- 00:14:10that sucker on and use it whenever we
- 00:14:11want to
- 00:14:12but not everyone can use it for example
- 00:14:14iron man he can't use it we can actually
- 00:14:16pretend to be iron man real quick
- 00:14:17new command time you ready the command
- 00:14:19is s u
- 00:14:20s u allows us to impersonate another
- 00:14:22user we're actually switching
- 00:14:24users we're becoming this user so let's
- 00:14:26become iron man
- 00:14:27i've always wanted to be iron man let's
- 00:14:29do this so again the command is su
- 00:14:31we'll do a space a dash or a tick space
- 00:14:33and then the username of who we want to
- 00:14:34switch into
- 00:14:35now real quick by default if you don't
- 00:14:37put anything here just
- 00:14:38su space dash it's going to switch you
- 00:14:41to the root user
- 00:14:42which we can do like watch and i don't
- 00:14:44know the root password
- 00:14:46um actually but we can do this we can
- 00:14:49put our gauntlet on
- 00:14:50put the affinity gauntlet on sudo su
- 00:14:54space dash i just became the root user i
- 00:14:57just became the infinity gauntlet which
- 00:14:58is kind of weird
- 00:14:59you never want to become the infinity
- 00:15:00gauntlet never log in as root that's why
- 00:15:02we have sudo so i'm going to hit ctrl
- 00:15:04d or we can just type in exit or
- 00:15:07log out either of any of those so i'll
- 00:15:10just do ctrl d
- 00:15:11to become myself again but anyways back
- 00:15:13to becoming iron man so i'll do su
- 00:15:14space dash iron man now doing this
- 00:15:18without the gauntlet on i will have to
- 00:15:20know iron man's password this goes for
- 00:15:22any time you use the su command but if i
- 00:15:24were to use sudo
- 00:15:25and put my gauntlet back on i don't have
- 00:15:27to put a password in but anyways
- 00:15:29i'll become iron man put his password in
- 00:15:31jarvis
- 00:15:32i'm iron man now iron man is pretty
- 00:15:34powerful but he cannot use a pseudo
- 00:15:35command let's try it real quick
- 00:15:37i'll do sudo and i'll try to add a user
- 00:15:39user add
- 00:15:40let's try to bring in pepper potts his
- 00:15:42wife right yeah wife
- 00:15:43that's gonna ask for a pseudo password
- 00:15:45okay just type in jarvis
- 00:15:47things are looking pretty good right no
- 00:15:49we're in trouble
- 00:15:50you're not in the sudoers file this
- 00:15:52incident will be reported you're like
- 00:15:54you're grounded iron man you can't do
- 00:15:56this i do love that we're talking about
- 00:15:57marvel and we have this spider-man line
- 00:15:59that comes in
- 00:16:00anyways that's an overused line anyway
- 00:16:02um so real quick
- 00:16:03what is this right here the sue doers
- 00:16:06file which is a very very awkward phrase
- 00:16:09basically this file the sudor's file
- 00:16:11defines
- 00:16:12who can use sudo who can wear the
- 00:16:14gauntlet right now iron man
- 00:16:16is not in that file so we can't put it
- 00:16:18on so what do you say we go take a look
- 00:16:19at that file i know you're itching to so
- 00:16:20let's do it real quick now the scooters
- 00:16:22file is a very important file that you
- 00:16:23don't want to jack up
- 00:16:24and you can jack it up you can ruin your
- 00:16:26entire system by
- 00:16:27messing up the scenarios file but there
- 00:16:29are some checks in place to keep you
- 00:16:30safe now normally in linux
- 00:16:31to edit a file you might just use your
- 00:16:33default text editor right the one you
- 00:16:35love like we might use
- 00:16:36nano or them but with a suitor's file
- 00:16:39the best practice is to do but with the
- 00:16:40scooter
- 00:16:41but with these two doors file there's a
- 00:16:42certain way we have to do it now we will
- 00:16:44have to use sudo to do this so i'm going
- 00:16:45to stop being iron man for a second i'm
- 00:16:47going to
- 00:16:48ctrl d to log out of iron man okay i'm
- 00:16:50me again the command will be sudo
- 00:16:52and then right after that it'll be vi
- 00:16:56sudo this is the only best practice
- 00:16:58recommended way to
- 00:16:59edit the sudoers file so let's uh get in
- 00:17:02there and take a look and it's not a
- 00:17:03crazy big file either it's kind of
- 00:17:05simple in a way so i'll hit enter
- 00:17:07and we're in and then i'll scroll down
- 00:17:08through this document to
- 00:17:10about here right here is where we're
- 00:17:12able to see who's got permission to do
- 00:17:14what obviously root can use sudo and
- 00:17:16i'll explain what all this means here in
- 00:17:18a moment and then down here in this
- 00:17:19section we have allowed members of a
- 00:17:20group
- 00:17:21pseudo access or pseudo to execute any
- 00:17:23command and then just below that we have
- 00:17:25something else we have a percent sign
- 00:17:26and then
- 00:17:27pseudo this actually is a group and if
- 00:17:29you're a member of this group the sudo
- 00:17:31group
- 00:17:32well you can do all this and what this
- 00:17:34actually means is you can enter
- 00:17:35any command at all and you don't have to
- 00:17:37enter
- 00:17:39a password which is pretty dangerous
- 00:17:40kind of risky but
- 00:17:42it's okay so if you're in this file
- 00:17:45you have the power and thanos does have
- 00:17:47the power let's go ahead and add thanos
- 00:17:48real quick
- 00:17:49we'll pretend he's already in there so
- 00:17:51just under root i'm going to add thanos
- 00:17:53so we'll start with the username which
- 00:17:54is
- 00:17:55thanos the first option here is what
- 00:17:57systems
- 00:17:58can thanos have ultimate power on well
- 00:18:01it's the infinity gauntlet
- 00:18:02all systems and this would be if they're
- 00:18:04like multi-system situations but
- 00:18:06and then i'll do a space equals not plus
- 00:18:09sign
- 00:18:09equals all and that all stands for all
- 00:18:13commands now if you want to just give
- 00:18:15thanos options to do one thing like
- 00:18:16maybe add a user we might do forward
- 00:18:18slash
- 00:18:19sbn forward slash user add giving him
- 00:18:22access to that one command
- 00:18:24we don't want to do that thanos has all
- 00:18:26power
- 00:18:27oh and that's all we need i'm going to
- 00:18:29hit control
- 00:18:30x to say i want out of here don't want
- 00:18:32to save it hit y
- 00:18:33hit enter to write it to that file and
- 00:18:36thanos is there
- 00:18:37he's got the gauntlet on he can do
- 00:18:38whatever he wants let's see if he can
- 00:18:40we're going to become thanos for a
- 00:18:41second so i'll do sudo
- 00:18:44su space dash space thanos
- 00:18:47we're thanos right now so let's do sudo
- 00:18:49user ad what's another bad guy he uses
- 00:18:51oh yeah his daughter nebulous little
- 00:18:53spring nebula in here the stanos have
- 00:18:55access let's see
- 00:18:57what's his password inevitable yep
- 00:19:00it did it worked so let's cap the uh
- 00:19:03password file yep there's nebula
- 00:19:05so thanos has ultimate power he's got
- 00:19:07the gauntlet on
- 00:19:08and crap he's about to snap you ready
- 00:19:11he's going to delete half the
- 00:19:12population in our case half the avengers
- 00:19:14we have here to delete a user
- 00:19:16new new command time it's terrible but
- 00:19:19new command time coffee break
- 00:19:22okay i'm ready sudo user
- 00:19:25del or user delete as you might expect
- 00:19:28this command will
- 00:19:29delete a user and we'll take out thor
- 00:19:32thor is gone if we catch the password
- 00:19:35file
- 00:19:36thor he's gone pseudo user delete
- 00:19:39spider-man gone bye doctor strange
- 00:19:43gone and just like that with a snap of
- 00:19:44his fingers we're down to
- 00:19:46hulk loki and captain america oh and
- 00:19:49iron man two there he is
- 00:19:50and just when it seems hopeless just
- 00:19:52when it seems all is lost the avengers
- 00:19:54have a plan ant-man comes in somehow
- 00:19:56quantum stuff anyways we need the
- 00:19:57gauntlet we need pseudo access to be
- 00:19:59able to
- 00:20:00bring captain america back and all the
- 00:20:01other people got got deleted so let's do
- 00:20:03this right now so
- 00:20:04we're gonna explore a new concept we're
- 00:20:06going to create a group to do that
- 00:20:08new command time here we go we'll do
- 00:20:11sudo group
- 00:20:12add and as you might expect group add
- 00:20:14will simply add a new group i'll do a
- 00:20:16space i'll name my group
- 00:20:18infinite
- 00:20:21gauntlet does spell that right i don't
- 00:20:24care that's what it's going to be called
- 00:20:26and the group is there but how do we
- 00:20:28know where is that group at
- 00:20:29well just like we have a password file
- 00:20:31to look at our users in the system
- 00:20:33we have a file to look at the groups and
- 00:20:35it's much more self-explanatory it makes
- 00:20:37more sense
- 00:20:38i'm going to cat the etsy group
- 00:20:41file and there it is infinity gauntlet
- 00:20:45right there
- 00:20:45as well as every other group that was
- 00:20:47created for our users
- 00:20:49i told you whenever a user account is
- 00:20:50created also they have a group created
- 00:20:52for themselves as well
- 00:20:53now what i want to do is make sure that
- 00:20:54the members of the infinity gauntlet
- 00:20:56group
- 00:20:56do have ultimate power because you mean
- 00:20:58you should you have the infinity
- 00:21:00gauntlet on
- 00:21:00so we need to add the infinity gauntlet
- 00:21:02group to our sudoers file
- 00:21:04let's do that real quick so again we'll
- 00:21:05do sudo vi sudo to edit that file the
- 00:21:08only way to do it don't you ever do it a
- 00:21:09different way
- 00:21:10i'm just kidding but seriously um let's
- 00:21:13edit that file we're gonna scroll down
- 00:21:14to
- 00:21:15where we were and then right here right
- 00:21:17now we see that members of the sudo
- 00:21:19group
- 00:21:20can do whatever they want and actually
- 00:21:21real quick let me show you the reason we
- 00:21:23can do whatever we want
- 00:21:24is because we're members of the sudo
- 00:21:26group if i do
- 00:21:27actually new command time if you just
- 00:21:29type in group i'm sorry
- 00:21:31groups groot
- 00:21:34it'll tell you what groups you are a
- 00:21:36member of the current user account
- 00:21:37you're logged in as and here i'm a
- 00:21:38member of my own group user 86527
- 00:21:40and the pseudo group which gives me
- 00:21:43gauntlet
- 00:21:44access anyways let's make sure the
- 00:21:45gauntlet does have the appropriate
- 00:21:47permissions here so just under
- 00:21:49the sudo group i'm going to add percent
- 00:21:51infinity
- 00:21:54gauntlet make sure you spell it right
- 00:21:56i'll do a space and i'll pretty much
- 00:21:57copy the one just above it i'll say all
- 00:21:58which again is all systems
- 00:22:00space equal sign space i'll say no
- 00:22:02password which is nopa sswd like we see
- 00:22:05here
- 00:22:06i'll do a colon and say all essentially
- 00:22:08it's saying you can do everything you
- 00:22:09want
- 00:22:10all commands and you don't need a
- 00:22:11password you got all them stones
- 00:22:13anyways so i'm going to hit control now
- 00:22:16actually you know what real quick before
- 00:22:17i do that
- 00:22:18i'm going to mess it up like i mentioned
- 00:22:20before if you mess up your suitors file
- 00:22:22you can break the entire system
- 00:22:24there is some checks in there that'll
- 00:22:26keep you safe so i'll just go
- 00:22:29and i hit control x to get out of there
- 00:22:32yes to save hit enter it'll say whoa
- 00:22:35whoa whoa
- 00:22:36there is a syntax error right there not
- 00:22:38supposed to do that what are you doing
- 00:22:40what are you going to do now what do you
- 00:22:41want to do are you sure you want to save
- 00:22:42this if i hit enter it will give me some
- 00:22:44options
- 00:22:44and i love this it's like you might want
- 00:22:47to go edit it again hit e
- 00:22:48hit x to get out of there and don't save
- 00:22:50it just forget what you're doing you
- 00:22:51don't know what you're doing or says you
- 00:22:52know what if you're pretty confident
- 00:22:53just hit q and say you want to save it
- 00:22:55danger um let's be smart let's hit e to
- 00:22:59edit it
- 00:23:00and remove that crap we put in there and
- 00:23:02then we can hit ctrl
- 00:23:03x y and enter no errors we're good
- 00:23:07so the infinity gauntlet group does have
- 00:23:10ultimate sudo
- 00:23:11super user due powers and now what's
- 00:23:13left is the avengers have to somehow
- 00:23:15become part of that group
- 00:23:16put on the glove and change history and
- 00:23:18if you've seen the movie
- 00:23:19spoiler alert um iron man he does this
- 00:23:22so we need to somehow get iron man into
- 00:23:25the infinity gauntlet group let's do
- 00:23:26that right now now real quick let's
- 00:23:28demonstrate that iron man can't do crap
- 00:23:29right now so if i
- 00:23:30become iron man and i try to bring back
- 00:23:34spider-man i can't i don't have the
- 00:23:36glove i can't do it man iron man is
- 00:23:37helpless but let's add them to the group
- 00:23:39so to add a user to a group
- 00:23:40pretty simple we're going to use the
- 00:23:41same command we used earlier to modify a
- 00:23:43user the user mod command
- 00:23:45so we'll do sudo and keeping in mind i'm
- 00:23:47logged in as me now not ironman anymore
- 00:23:49i'll do sudo
- 00:23:50user mod and the switch is dash
- 00:23:53g now dash g by itself will add this
- 00:23:56user to a group
- 00:23:57but it will add it to that group and
- 00:23:59kind of eliminate all other groups
- 00:24:01you may not want to do that so we often
- 00:24:03want to change this to
- 00:24:04dash lowercase a capital g the a stands
- 00:24:08for append
- 00:24:08so this command here we're appending the
- 00:24:10groups that ironman
- 00:24:12is part of so just after dash ag we'll
- 00:24:15type in
- 00:24:16the group which is infinity gauntlet
- 00:24:19and then the user we want to add which
- 00:24:21will be iron man
- 00:24:22just like that iron man has the glove on
- 00:24:25we can actually see if that's happening
- 00:24:26by going to
- 00:24:27or catting the group file
- 00:24:30etsy group and here we can see the
- 00:24:33infinity gauntlet group
- 00:24:34the members over here on the right and
- 00:24:35there's iron man right there now again
- 00:24:37if you saw the movie you know that iron
- 00:24:38man and
- 00:24:39and thanos were kind of wrestling with
- 00:24:41the gloves so thanos was in the group
- 00:24:43too
- 00:24:43they kept going back and forth let me
- 00:24:45add thanos in there real quick
- 00:24:46so yes right now iron man and thanos are
- 00:24:48both part of this group they both have
- 00:24:49super awesome
- 00:24:50powerful pseudo access but eventually
- 00:24:53iron man does wrestle the
- 00:24:55glove off of thanos and puts it on
- 00:24:56himself so new command time how do you
- 00:24:58remove
- 00:24:59a user from a group this command is
- 00:25:01called g password
- 00:25:03the commands sometimes are weird um so
- 00:25:05we'll do sudo
- 00:25:06g pass wd we're gonna do dash d for
- 00:25:09delete specify the user we want to
- 00:25:11remove which will be
- 00:25:13thanos take that off take that take it
- 00:25:15and then we'll specify the group
- 00:25:17infinity gauntlet take that thanos look
- 00:25:20at the group once more
- 00:25:21no one's in there so anyways iron man he
- 00:25:23has the gauntlet
- 00:25:24he snaps his fingers and he creates the
- 00:25:27users we lost
- 00:25:28let me become iron man i am iron man
- 00:25:31pseudo
- 00:25:32user ad captain america pseudo
- 00:25:35user ad spiderman done we'll bring back
- 00:25:39doctor strange
- 00:25:40and i forgot who else but anyways you
- 00:25:41get the picture right iron man has the
- 00:25:43gauntlet on he has the power he's part
- 00:25:45of the group
- 00:25:46and he can now bring back everyone and
- 00:25:48shoot while he's at it let's defeat
- 00:25:50thanos right
- 00:25:51sudo user delete
- 00:25:55thanos here we go
- 00:25:58goodbye thanos and then finally iron man
- 00:26:00realizes the infinity gauntlet it's too
- 00:26:02powerful
- 00:26:03for anyone to possess so he destroys it
- 00:26:05i think that's what happens
- 00:26:06that's what we're going to do right now
- 00:26:07so using the principle of least
- 00:26:08privilege
- 00:26:09we're going to remove the the infinity
- 00:26:11gauntlet group we're going to delete
- 00:26:12that group by doing the
- 00:26:14group delete command in fact iron man
- 00:26:16will do it himself right now and he's
- 00:26:17going to
- 00:26:18delete his access to do it at the same
- 00:26:20time which is kind of weird right
- 00:26:21so sudo group delete uh new command time
- 00:26:25i forgot to sit man
- 00:26:26which obviously means we're gonna be
- 00:26:28deleting a group and the usage is pretty
- 00:26:30straightforward just after group delete
- 00:26:32we'll enter the name of the group
- 00:26:33infinity gauntlet now this does not
- 00:26:36delete any
- 00:26:37users in that group it just deletes the
- 00:26:39group and gone are also iron man's
- 00:26:41privileges to do anything special
- 00:26:42anymore
- 00:26:43for example if he got greedy and wanted
- 00:26:45to create the group once more
- 00:26:47sorry iron man you don't have it anymore
- 00:26:49and i think you have other problems to
- 00:26:50worry about
- 00:26:51we did it i think like we saved the
- 00:26:53world right i mean iron man's
- 00:26:54not okay but we we learned how to manage
- 00:26:57users and linux and in the process we
- 00:26:59assembled the avengers and took away the
- 00:27:01infinity gauntlet destroyed it and saved
- 00:27:03the world
- 00:27:04yeah but seriously we learned a lot
- 00:27:06today we learned how to manage users in
- 00:27:07linux
- 00:27:08add them delete them groups permissions
- 00:27:11all that
- 00:27:12and that's essential to managing a linux
- 00:27:13system to becoming a hacker to doing
- 00:27:16anything with linux now and
- 00:27:17pretty much every area of it involves
- 00:27:19linux and also if you want a quick
- 00:27:21review of what we covered in text form
- 00:27:23uh mosey on over to hack the box academy
- 00:27:25the page we were at the whole time
- 00:27:26and look it over they've got the
- 00:27:27commands we we talked about in text form
- 00:27:30and they also have a delightful quiz at
- 00:27:32the very bottom to test your knowledge
- 00:27:33and see how you do
- 00:27:34and if you get it right you earn cubes
- 00:27:36back which with the junk or cubes
- 00:27:38go watch episode one if you don't know
- 00:27:39what they are also if you want to test
- 00:27:41your skills even further
- 00:27:42i've got a quiz in the description below
- 00:27:44it's free click the link
- 00:27:45and uh let's see what you got and again
- 00:27:47huge shout out to our sponsor hack the
- 00:27:49box academy
- 00:27:50it's free to access right now to do what
- 00:27:52we've been doing here if you want to go
- 00:27:53further and learn how to hack wordpress
- 00:27:55and
- 00:27:55and do python stuff and just man just so
- 00:27:58many things
- 00:27:59check them out link below i'll catch you
- 00:28:01guys next time
- 00:28:03[Music]
- 00:28:17[Music]
- 00:28:18you
- Linux
- Gestão de Usuários
- Sudo
- Comando
- Hacking
- Hack The Box Academy
- Vingadores
- Thanos
- Administração de Sistemas
- Grupo de Usuários