sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4

NetworkChuck
21 May 202128:19

Summary

TLDRThis video script is a fun and educational journey into Linux user management, presented through a 'hacking' lens with a Marvel Avengers theme. It covers creating and deleting users, changing user details, and understanding permissions with sudo. The tutorial uses a free Linux lab provided by Hack The Box Academy, allowing viewers to follow along and learn essential Linux skills while engaging with the entertaining narrative of assembling the Avengers to stop Thanos.

Takeaways

  • πŸ˜€ The video is an educational tutorial on managing users in Linux, covering creation, deletion, and modification of user accounts.
  • πŸ› οΈ The script introduces commands like 'adduser' and 'useradd' for creating users, with 'adduser' being more interactive and 'useradd' being quicker but less detailed.
  • πŸ”’ It explains the importance of the 'sudo' command, which provides superuser permissions for executing commands that require higher privileges.
  • πŸ€– The video uses a humorous analogy of assembling the Avengers to fight Thanos, relating to the process of adding users and granting them powers in a Linux system.
  • πŸ“ The script covers the significance of the '/etc/passwd' and '/etc/shadow' files, which store user account information and hashed passwords, respectively.
  • πŸ‘€ It discusses the concept of User IDs (UID) and Group IDs (GID), which are assigned to users and groups upon creation.
  • 🏠 The tutorial mentions the creation of home directories for users and how some commands, like 'useradd', do not create them by default.
  • πŸ”„ The script explains how to modify user accounts using the 'usermod' command, allowing changes to properties like shell preference and username.
  • πŸ‘₯ The importance of groups in Linux is highlighted, showing how users can be part of multiple groups and how to manage group memberships.
  • πŸ’ͺ The 'sudoers' file is introduced as the key configuration file that defines who can use 'sudo' and what commands they are allowed to execute.
  • πŸ—‘οΈ The process of deleting users and groups is covered, demonstrating how to remove accounts and groups using 'userdel' and 'groupdel' commands.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is managing users in Linux, including creating, deleting, and modifying user accounts, as well as understanding permissions and the sudo command.

  • What is the significance of the 'add user' and 'user add' commands in Linux?

    -The 'add user' command is used to create a new user account in Linux and it performs additional setup tasks such as creating a home directory and setting a default shell. The 'user add' command also creates a new user but does not perform these additional tasks, hence it's considered 'lazy'.

  • What does the 'sudo' command represent in Linux?

    -The 'sudo' command stands for 'super user do' and allows a permitted user to execute a command as the superuser or another user, effectively granting temporary root privileges for that command.

  • How can you check the list of users on a Linux system?

    -You can check the list of users on a Linux system by using the 'cat /etc/passwd' command, which displays the contents of the passwd file containing user account information.

  • What file stores the hashed passwords in Linux?

    -The hashed passwords in Linux are stored in the '/etc/shadow' file.

  • What is the purpose of the 'usermod' command in Linux?

    -The 'usermod' command is used to modify the details of an existing user account, such as changing the user's shell, home directory, or group memberships.

  • What does the 'su' command do, and how is it different from 'sudo'?

    -The 'su' command is used to switch to another user account, optionally becoming that user by providing their password. It is different from 'sudo', which allows a user to run a single command with the privileges of another user, typically the superuser.

  • What is the 'sudoers' file, and why is it important?

    -The 'sudoers' file defines policies for sudo command usage, specifying which users and groups can execute what commands and as what users. It is important because it controls who has the ability to perform administrative tasks on the system.

  • How can you delete a user in Linux?

    -You can delete a user in Linux using the 'sudo userdel' command followed by the username of the account you wish to remove.

  • What is the principle of least privilege mentioned in the script, and why is it important?

    -The principle of least privilege is a security concept where users are given the minimum levels of access necessary to perform their tasks. It is important because it reduces the risk of damage to the system in case of user account compromise.

  • How does the script relate the management of users in Linux to the Marvel's Avengers and the Infinity Gauntlet?

    -The script uses the theme of Marvel's Avengers and the Infinity Gauntlet as a metaphor to explain user management in Linux. It compares the sudo command to wearing the Infinity Gauntlet, granting superpowers, and the process of adding and deleting users to assembling and disassembling the Avengers team.

Outlines

00:00

πŸ§™β€β™‚οΈ Introduction to Linux User Management

The script starts with an introduction to the importance of user management in Linux, targeting hackers and enthusiasts. It humorously references the Avengers assembling to stop Thanos, a metaphor for tackling Linux challenges. The video promises a comprehensive guide on creating, modifying, and deleting user accounts and groups, as well as managing permissions through sudo. The sponsor, Hack The Box Academy, is introduced as a platform for learning and practicing Linux skills with a free lab environment. The video encourages viewers to engage with the content and subscribe for more.

05:00

πŸ”‘ Creating and Verifying User Accounts

This paragraph delves into the process of creating user accounts in Linux, using the 'add user' command, and the importance of the root user's permissions. It explains how to check the list of users with the 'cat /etc/passwd' command and the significance of the 'x' marker indicating password storage in the 'shadow' file. The script also clarifies the difference between 'add user' and 'user add' commands, highlighting the latter's lack of interactive setup for additional user details.

10:01

πŸ› οΈ Modifying User Accounts and Understanding File Structure

The script continues with how to modify existing user accounts using the 'usermod' command, including changing the default shell and updating usernames. It provides insights into the structure of the '/etc/passwd' and '/etc/shadow' files, explaining the meaning of user IDs, group IDs, and home directories. The paragraph also contrasts the 'add user' and 'user add' commands, noting the latter's omission of default settings like home directories and shell types.

15:03

πŸ€– Granting Superuser Permissions with sudo

This section introduces the concept of superuser permissions in Linux, symbolized by the 'sudo' command, likened to wearing the Infinity Gauntlet. It explains how 'sudo' allows temporary root user capabilities to perform administrative tasks. The script also covers the 'su' command for switching user accounts and the importance of the 'sudoers' file in defining who can use 'sudo'. It humorously adds the character Thanos to the 'sudoers' file, granting him all powers.

20:04

πŸ‘₯ Group Management and sudoers Configuration

The script discusses the creation of user groups and the assignment of sudo privileges to these groups. It details the steps to add a group to the 'sudoers' file, allowing members to execute any command without a password. The paragraph also demonstrates how to add and remove users from groups, emphasizing the power dynamics between characters like Iron Man and Thanos in the context of the Infinity Gauntlet.

25:06

πŸ’₯ Dealing with User and Group Deletions

The final paragraph covers the deletion of users and groups in Linux using 'sudo userdel' and 'groupdel' commands. It uses the narrative of Iron Man using the Infinity Gauntlet to restore deleted users, symbolizing the recovery of system resources. The script concludes with the principle of least privilege, emphasizing the importance of restricting powerful commands like 'sudo' to prevent misuse.

Mindmap

Keywords

πŸ’‘Linux

Linux is an open-source operating system that is widely used for servers, mainframes, and supercomputers. In the video, Linux is the platform where user management is being taught, and it's integral to the video's theme of learning system administration and potentially ethical hacking.

πŸ’‘User Management

User management in the context of the video refers to the process of creating, modifying, and deleting user accounts on a Linux system. It's a fundamental concept for controlling access and permissions, which is essential for system security and administration.

πŸ’‘Sudo

Sudo, short for 'superuser do', is a command in Linux that allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. In the video, sudo is likened to wearing the 'infinity gauntlet', symbolizing its power to grant temporary elevated privileges.

πŸ’‘Sudoers

The sudoers file in Linux is a configuration file that specifies which users and groups can use the 'sudo' command to gain superuser privileges. In the video, editing the sudoers file is a critical step in granting or restricting access to the 'infinity gauntlet' of system administration.

πŸ’‘User ID (UID)

A User ID, or UID, is a unique identifier for a user account on a Linux system. In the script, UIDs are mentioned as numerical identifiers that distinguish different users, with the 'add user' command automatically assigning a UID to new users.

πŸ’‘Group ID (GID)

Group ID, or GID, is a unique identifier for a group in a Linux system. Each user has a primary group with the same GID as the user's UID. In the video, GIDs are used to manage permissions and access control at a group level.

πŸ’‘Home Directory

A home directory is the personal space on a Unix-like operating system where a user's files are stored. In the video, creating a home directory for new users is part of the user creation process, providing them with a personal space to store their files.

πŸ’‘Shell

In the context of Linux, a shell is a user interface for access to an operating system's services. It is either a command-line interface (CLI) or a graphical user interface (GUI). The default shell for new users in the video is 'bash', which is a common choice for command-line interaction.

πŸ’‘Password Hashing

Password hashing is a security measure where passwords are transformed into a hash value for storage in a system. In the video, it is mentioned that the 'shadow' file stores hashed versions of passwords, ensuring that actual passwords are not exposed.

πŸ’‘Avengers

The Avengers are a group of superheroes from the Marvel Comics universe. In the video, they are used as a metaphor for assembling a team of users to manage a Linux system and fight against the 'Thanos' threat, which adds a fun narrative to the educational content.

πŸ’‘Hack The Box Academy

Hack The Box Academy is an online platform mentioned in the video for learning ethical hacking and cybersecurity. It is used as a sponsor and provides a free lab for practicing Linux user management, which is a key part of the video's educational content.

Highlights

Essential Linux user management skills for anyone interested in Linux or hacking.

Introduction to the concept of user accounts and permissions in Linux.

Explanation of creating, modifying, and deleting user accounts with 'adduser' and 'useradd' commands.

Difference between 'adduser' and 'useradd' commands in terms of functionality.

The importance of the 'sudo' command for gaining superuser permissions.

How to view and understand the /etc/passwd file for user account information.

The role of the /etc/shadow file in storing hashed passwords.

Creating user groups and the relationship between users and their groups in Linux.

Using 'usermod' to change properties of an existing user account.

The concept of the 'sudoers' file and its control over who can use 'sudo'.

How to edit the 'sudoers' file safely to grant or restrict 'sudo' access.

Demonstration of adding a user to the 'sudo' group to grant superuser permissions.

Using 'su' to switch between user accounts and the need for correct passwords.

The ability to delete users and the impact on system accounts.

Introduction to the concept of least privilege and its importance in system security.

How to create and manage groups with 'groupadd' and 'gpasswd' commands.

The process of adding users to a group to grant collective permissions.

Final thoughts on the importance of user management in Linux for security and system administration.

Transcripts

play00:00

managing users in linux this is

play00:02

essential you got to know this if you

play00:03

want to get into linux or become a

play00:04

hacker or do anything

play00:06

don't skip this so assemble the avengers

play00:08

we gotta stop thanos

play00:14

what

play00:18

welcome to linux for hackers and

play00:20

everyone because everyone

play00:22

needs to learn linux this is episode 4

play00:24

and you don't want to miss this when

play00:25

we're talking about user management user

play00:27

accounts and linux and we're pretty much

play00:29

going to cover everything from creating

play00:30

users deleting them changing them

play00:32

creating groups deleting those putting

play00:34

on the infinity gauntlet and giving

play00:35

yourself super godlike permissions

play00:37

which is also known as sudo or the

play00:39

sudoer's file we'll cover all that

play00:41

and yeah we're gonna assemble the

play00:42

avengers and stop thanos we're going to

play00:44

save the world and when i say we i mean

play00:46

we because you're going to do this with

play00:47

me you're getting a free

play00:48

linux lab right here in this video check

play00:50

the link in the description thanks to

play00:52

our sponsor

play00:52

hack the box academy it's seriously

play00:54

amazing free to sign up

play00:55

hack the box academy is basically a

play00:57

trading ground for hackers

play00:59

good hackers mind you so if you want to

play01:00

follow along with me learn how to manage

play01:02

users in linux and save the world

play01:04

then click the link below get signed up

play01:05

for free and you'll have a linux

play01:07

lab right here in your browser and then

play01:09

of course whatever else you want to

play01:10

learn regarding hacking it's there so

play01:12

check that out too also hack the box

play01:13

academy now has a student subscription

play01:15

and you get cpe credits for completing

play01:18

tier 1 modules or above

play01:20

kind of killer check it out link below

play01:22

to learn more have you hacked the

play01:23

youtube algorithm today let's make sure

play01:25

you do hit that like button subscribe

play01:26

comment

play01:27

notification bell let's hack youtube

play01:28

today ethically of course

play01:30

anyways no time to waste get your

play01:32

stinking coffee let's do this

play01:35

right now okay here we go we're going to

play01:37

learn nearly everything you need to know

play01:38

about managing users and linux

play01:40

and we're gonna have a bit of fun with

play01:42

it too so get your copy and let's go

play01:44

now first we gotta launch our lab our

play01:46

free linux lab from hack the box academy

play01:49

so go ahead and navigate out there

play01:50

hack the blogs account of me they are

play01:52

our sponsor and they're amazing it's

play01:54

completely free if you haven't already

play01:55

signed up we'll get signed up i've got a

play01:56

video walking you through that right

play01:58

here

play01:58

so log in to hack the box academy go and

play02:00

click on the linux fundamentals course

play02:01

to get started go ahead and open up the

play02:03

user management module right here and

play02:05

then to launch our free amazing phone

play02:06

box our lab

play02:08

scroll about halfway down and click on

play02:09

start instance and it's going to start

play02:11

quick coffee break just a little sip and

play02:14

it is ready go ahead and click on

play02:15

interact to uh

play02:17

interact with it and i've said it before

play02:18

this is amazing it's your free linux lab

play02:20

in your browser that you can mess with

play02:22

and break things and

play02:23

let's do this okay let's talk about

play02:25

users every computer system has a user

play02:28

including linux and you know what you're

play02:30

a user

play02:32

to be able to log into the server this

play02:34

linux box and do anything you have to be

play02:36

a user on the system which user are you

play02:38

let's see in a previous video we showed

play02:40

this already so let's go ahead and

play02:41

launch our terminal

play02:42

our green or yellow box up at the top

play02:44

here this is launching our shell

play02:46

if you don't know what that is we'll go

play02:47

back to the last video and watch that

play02:48

one we talk all about it to quickly see

play02:50

who you are you simply type in who

play02:52

am i and there you are your user account

play02:55

and you as user 86527 can log into this

play02:58

linux machine

play02:58

and do stuff you can launch programs

play03:00

play games hack

play03:01

create things delete things if you have

play03:03

the right permissions we'll cover that

play03:04

here in a moment

play03:05

you you can do a lot of stuff as a user

play03:07

of the system but not all users are the

play03:09

same now hey

play03:10

i've got some bad news we're under

play03:12

attack our system our linux

play03:14

box here we're being attacked by

play03:17

thanos that's his name right the bad guy

play03:19

from avengers yes thanos he's attacking

play03:21

us

play03:21

bad guy thanos is gonna snap his fingers

play03:23

and destroy all our user accounts and we

play03:24

won't be able to have fun on linux

play03:26

anymore

play03:26

we have to stop him but how do we do

play03:28

that avengers assemble we need the

play03:30

avengers right let's call them do they

play03:32

have like a bat signal i don't know how

play03:33

you call them

play03:34

they just know they need help right or

play03:35

that we need help but they're not in our

play03:37

system right now we have to create these

play03:38

user accounts to come and stop thanos

play03:40

before he

play03:41

snaps anyways let's start by adding the

play03:44

avengers to our system

play03:45

let's start with thor he's my favorite

play03:47

so the command will be

play03:49

add user thor and honestly it's that

play03:52

simple that's all we need

play03:53

the command add user will obviously add

play03:55

a user but it's not the only one that

play03:57

does this by the way just so you know

play03:59

there's add user and then confusingly

play04:01

there's another one called

play04:02

user add which they do both add a user

play04:06

but this command right here is a little

play04:07

lazy

play04:08

he doesn't do as much whereas this

play04:09

command will do a lot i'll show you the

play04:11

difference here real quick we'll bring

play04:12

in our other avengers

play04:13

anyways let's add thor real quick now

play04:14

i'm going to hit enter but it's not

play04:16

going to work

play04:17

watch only root may add a user a group

play04:19

to the system now what is a root

play04:21

i mean root's another user on the system

play04:23

if you watched our previous videos in

play04:24

the series you would know all about root

play04:26

not groot

play04:27

root but we're going to temporarily

play04:28

borrow some power from the root which

play04:30

he's also known as the super user um so

play04:33

what we're going to do here is hit the

play04:34

up arrow to get our command back in

play04:35

there add user thor we're going to go to

play04:37

the beginning of our command

play04:38

and type in sudo or it's also often

play04:41

pronounced soo do but it's spelt sudo so

play04:43

i want to say that

play04:44

this is kind of like saying please in

play04:45

linux please do this i'm getting super

play04:47

powers to do this

play04:48

again i'll explain more about that here

play04:50

in a moment but anyways this is gonna

play04:51

work

play04:52

okay cool we got a fun prompt here let's

play04:54

put a password in for thor i'm gonna say

play04:56

hammer type it in again hammer full name

play04:58

i think it's just thor

play05:00

it'll ask you for all this random

play05:01

information you don't have to put it all

play05:02

in just enter enter enter

play05:03

is it correct sure and thor's created he

play05:05

is now a user on the system but how do

play05:08

we know that where

play05:09

is he well to find out what users are on

play05:12

your system there's one simple place to

play05:13

look

play05:13

i'm going to clear my screen real quick

play05:15

by typing in clear or i can just do

play05:16

control

play05:17

l whoo nice and clean there's a file in

play05:19

the system that has a list of every user

play05:20

on this

play05:21

box or this system we're going to use

play05:23

the command cat which we learned before

play05:25

we're going to cat the forward slash

play05:27

etsy forward slash pass

play05:28

wd when we do that here's what happens

play05:31

boom bunch of users on our system i bet

play05:33

you're surprised like where all these

play05:35

users come from i mean the first two we

play05:36

recognize right i mean the last two

play05:38

uh this one right here is us user blah

play05:40

blah

play05:41

and then thor the one we just created

play05:42

there he is all these other entries are

play05:44

indeed

play05:45

user accounts on this system and they do

play05:47

serve a purpose a lot of these you can't

play05:48

log in

play05:49

with like right here it says no login on

play05:51

this account they do serve a purpose not

play05:53

the topic for another video anyways now

play05:55

real quick

play05:55

what does all this right here mean it's

play05:58

kind of gobbledygook right i mean the

play05:59

first bit we understand what it is the

play06:01

username

play06:02

thor and user blah blah blah but what's

play06:04

all the stuff after it well just after

play06:06

the username we have

play06:07

just an x sitting there all by himself

play06:09

in fact you'll see this on pretty much

play06:10

every user account appear

play06:12

x max and what the x indicates is that

play06:14

your password is stored in a separate

play06:16

file called the

play06:17

shadow file more specifically it's in a

play06:19

place called etsy

play06:21

shadow in linux we store our passwords

play06:23

in the shadows where they're hidden you

play06:25

can't see them but for real

play06:26

if we go to it real quick we can

play06:27

actually look at it let's do cat

play06:29

etc etsy shadow oh permission deny we

play06:32

need some

play06:33

listen please sudo there we go and right

play06:35

here next to the username thor we have

play06:37

his password which that's actually not

play06:38

his password

play06:39

that's the hashed version topic for

play06:41

another time anyways now just after x we

play06:43

have two numbers

play06:44

and they're the same we have one

play06:45

thousand one and one thousand one what

play06:48

are those

play06:48

well those are his ids the first one is

play06:52

his user id or a uid it's a number

play06:55

which you can obviously see it's 1001.

play06:57

the second one is his

play06:59

group id we'll cover groups here in a

play07:00

second but just know that when we create

play07:02

a user in linux

play07:03

we both create a user and a group for

play07:06

that user so we have a username named

play07:07

thor

play07:08

we also have a group named thor and the

play07:10

member of that group

play07:11

is thor and then after that we got some

play07:13

like random filler stuff like his name

play07:15

and comments and stuff

play07:16

and then after that we have his home

play07:19

directory where he gives his hammer and

play07:21

his

play07:21

chest plate i don't know what thor has

play07:23

his hair ties for thor his home

play07:25

directory is in

play07:26

the same place that a lot of people's

play07:27

home directories are home

play07:30

and then a directory called thor we'll

play07:32

look at that here in a moment and then

play07:33

just after that

play07:34

we have his default shell when thor logs

play07:37

into the system

play07:37

what shell is he going to be given again

play07:39

if you don't know what i'm talking about

play07:40

go look at our previous video

play07:42

but by default when we created his user

play07:44

account with the add user command

play07:46

it's going to be bash so that is what

play07:48

all that gobbledygook means now let me

play07:49

show you what the user add command does

play07:51

our

play07:52

alternative command which is kind of

play07:54

weird so we have thor he's pretty

play07:56

awesome but we need some extra help

play07:57

i think we need iron man yeah yeah let's

play07:59

get iron man in here so we'll do sudo

play08:01

and instead of add user we're gonna

play08:03

we're gonna do user

play08:05

add and same as before we'll just type

play08:07

in the user name iron man

play08:09

and watch what happens here it is

play08:11

different it's simple

play08:13

that's it so remember add user like asks

play08:16

hey put in his password

play08:17

uh what's his first name last name

play08:19

what's social security number

play08:21

favorite flavor ice cream like all that

play08:22

stuff this one just says

play08:24

okay you're like uh what else

play08:27

what do i do now that's what i meant by

play08:29

saying that command is lazy because he

play08:30

doesn't do anything but just say okay

play08:32

yeah here's a user account i'm not gonna

play08:33

do anything else like

play08:34

set the password for you like you can do

play08:36

that yourself um and i'll show you how

play08:37

to do that here in a second but right

play08:38

now

play08:39

iron man is created but you can't really

play08:40

do much with him so if we cat our

play08:42

password file again to see what user

play08:44

accounts we have in our system cat

play08:45

slash etsy pass wd he's there iron man

play08:49

is shown up

play08:49

but there's a few things missing now for

play08:51

example he has the x there saying that

play08:53

his password's in the shadow file but is

play08:54

it really because we didn't set a

play08:55

password did we also notice here that

play08:58

um his default shell is different it's

play09:00

sh for

play09:01

shell instead of bash so real quick i

play09:03

want to take a look at the shadow file

play09:05

to see if the stuff is there

play09:06

that's interesting you can see that he

play09:08

does have

play09:09

an entry in the shadow file but it

play09:11

doesn't seem to be a password

play09:12

and i don't think it is but we can set

play09:14

this password real quick command to set

play09:16

a password for someone or change a

play09:17

password for any username

play09:18

is going to be password without the o-r

play09:22

i'll show you so we'll we'll need super

play09:24

powers sudo command is p-a-s-s-w-d

play09:28

and then the user name so i'll type in

play09:30

iron man and now we can set his password

play09:32

jarvis there we go he's got a legit hash

play09:34

there so we know it's working now one

play09:36

thing the ad user command did not do for

play09:37

iron man is it did not give him a home

play09:39

he doesn't have a house right now he

play09:40

doesn't have a home directory if i

play09:41

navigate to the home directory well all

play09:42

the

play09:43

user directories live i go cd forward

play09:45

slash home

play09:46

and i type in ls i can see there are two

play09:48

directories there for thor and then for

play09:50

me

play09:51

but iron man he doesn't have a home dude

play09:53

and that's one downside of using the

play09:55

user ad command

play09:56

is again he's lazy he doesn't do this

play09:57

kind of stuff if i jump into the thor

play09:59

directory by doing cd

play10:01

thor and then lsing his contents

play10:04

yeah he's got a desktop he's got

play10:05

templates if i do ls

play10:07

dash al to reveal the hidden files he's

play10:10

got a bunch of stuff going on in there

play10:11

which we're not going to get into right

play10:13

now i mean it is important but right now

play10:14

we got to save the world

play10:15

thor is here and he's coming clear our

play10:17

screen now if we cap the password file

play10:19

again

play10:20

etsy pass wd i'm super annoyed that iron

play10:23

man's

play10:24

default shell is not the same as

play10:25

everyone else's it's just sh

play10:27

let's make sure it is bash we can modify

play10:29

user account new command time are you

play10:31

ready the command is

play10:32

user mod which stands for user

play10:34

modification and as you might expect it

play10:36

will modify a user account now there are

play10:38

a ton of things we can change if you do

play10:40

dash h for help to see like what can i

play10:42

do with this it'll tell you

play10:44

a lot of stuff and i'm not going to

play10:46

cover everything right now that take

play10:47

forever and

play10:48

thanos is here so i'll do sudo because

play10:50

we will need special permissions

play10:52

user mod and let's say i want to change

play10:53

that shell for iron man

play10:55

i'll do iron man say that's who i want

play10:57

to change it for

play10:58

dash dash shell and i'll say ben

play11:02

bash done and if we cap the user or the

play11:05

cat the password file once more welcome

play11:07

iron man you now are using bash just

play11:09

like everyone else

play11:09

and we can change other things too like

play11:11

maybe his name like sometimes iron man

play11:13

isn't iron man sometimes he's tony stark

play11:15

so if we do sudo user mod once more

play11:18

we'll use the switch

play11:19

dash l and then we'll put in the new

play11:22

information

play11:23

tony stark that's his new username and

play11:25

then the old one

play11:26

iron man done so if i cat the password

play11:30

file once more

play11:30

huh he's tony stark now but we don't

play11:32

need tony stark right now we need iron

play11:33

man let's change it back

play11:35

okay better okay here we go now again

play11:37

thanos is here and we need more than

play11:38

just two avengers

play11:40

avengers assemble let's create more

play11:42

right now real quick

play11:43

fast and that is where the user add

play11:45

command comes in handy because you can

play11:46

add things really quickly enough to go

play11:47

through a menu every single time so

play11:49

we'll just do it real quick

play11:50

and we also have switches to help us

play11:51

with that if i do user add dash h

play11:53

we can do a lot of the stuff that the

play11:55

add user command does just in one line

play11:57

so i'll do user add let's bring in

play12:01

hulk and i'll do a dash m which dash m

play12:04

will actually create a home directory

play12:05

form so whereas iron man didn't get one

play12:07

by default i almost forgot we need

play12:09

superhero permissions there we go let's

play12:11

get spider-man in here

play12:13

loki why not oh we can't forget captain

play12:15

america

play12:16

and i suppose we'll need doctor strange

play12:18

i don't like that movie that much

play12:19

didn't like it at all wasn't a fan but

play12:21

he kind of played a key role so we'll

play12:22

put him in here

play12:23

so now we have some avengers if i do uh

play12:26

cat

play12:27

etsy password file boom

play12:31

we got them they're here if you've seen

play12:33

the movies you know it doesn't go

play12:35

great at first thanos does get the power

play12:37

he gets the

play12:38

the gauntlet or what is it called ah

play12:40

okay the infinity gauntlet almost forgot

play12:42

actually i did forget i had to look it

play12:43

up thanos has the power and he does

play12:46

flick his fingers or snaps fingers and

play12:48

do some bad stuff

play12:50

now i'm gonna add the user account

play12:52

thanos

play12:53

we're bringing him in he's there i'm

play12:55

going to set his password real quick

play12:57

password inevitable let's see if he's

play13:00

here yep there's thanos

play13:01

now here in linux the infinity gauntlet

play13:03

that gives you super

play13:04

awesome powers and has all the stones

play13:06

and you can flick your fingers and

play13:07

everyone disappears

play13:09

in linux that's definitely the pseudo

play13:11

command

play13:12

or pseudo we haven't really dived into

play13:14

that deeply just yet

play13:16

but right now we are it's a command we

play13:17

use all the time it stands for

play13:20

super user do essentially every time we

play13:22

use that command it's like we're

play13:23

slipping on the infinity gauntlet

play13:24

the super powerful glove and this is the

play13:26

worst glove you'll ever see we slip that

play13:28

glove on and for one moment

play13:30

we have powers to do whatever we frickin

play13:31

want so the sudo command or the sudo

play13:33

command

play13:34

were able to grab the powers of the

play13:36

super user the root user

play13:37

and use them for that command now the

play13:40

super user in the system

play13:41

which is the root user he's the boss he

play13:43

can do whatever stinking wants on linux

play13:45

he can change all the settings

play13:46

he can delete all the settings he can

play13:48

ruin everything delete half your stuff

play13:50

rmrf man that's what thanos is gonna do

play13:54

and if you can use the pseudo command to

play13:55

impersonate him just for a moment

play13:57

that's a pretty stinking powerful

play13:59

command it's a command that you don't

play14:00

want to just give to anyone you want to

play14:02

restrict that access and by default it

play14:04

is pretty restricted

play14:05

now you can see that right now we've

play14:07

been using sudo all day

play14:08

we have the infinity gauntlet we can put

play14:10

that sucker on and use it whenever we

play14:11

want to

play14:12

but not everyone can use it for example

play14:14

iron man he can't use it we can actually

play14:16

pretend to be iron man real quick

play14:17

new command time you ready the command

play14:19

is s u

play14:20

s u allows us to impersonate another

play14:22

user we're actually switching

play14:24

users we're becoming this user so let's

play14:26

become iron man

play14:27

i've always wanted to be iron man let's

play14:29

do this so again the command is su

play14:31

we'll do a space a dash or a tick space

play14:33

and then the username of who we want to

play14:34

switch into

play14:35

now real quick by default if you don't

play14:37

put anything here just

play14:38

su space dash it's going to switch you

play14:41

to the root user

play14:42

which we can do like watch and i don't

play14:44

know the root password

play14:46

um actually but we can do this we can

play14:49

put our gauntlet on

play14:50

put the affinity gauntlet on sudo su

play14:54

space dash i just became the root user i

play14:57

just became the infinity gauntlet which

play14:58

is kind of weird

play14:59

you never want to become the infinity

play15:00

gauntlet never log in as root that's why

play15:02

we have sudo so i'm going to hit ctrl

play15:04

d or we can just type in exit or

play15:07

log out either of any of those so i'll

play15:10

just do ctrl d

play15:11

to become myself again but anyways back

play15:13

to becoming iron man so i'll do su

play15:14

space dash iron man now doing this

play15:18

without the gauntlet on i will have to

play15:20

know iron man's password this goes for

play15:22

any time you use the su command but if i

play15:24

were to use sudo

play15:25

and put my gauntlet back on i don't have

play15:27

to put a password in but anyways

play15:29

i'll become iron man put his password in

play15:31

jarvis

play15:32

i'm iron man now iron man is pretty

play15:34

powerful but he cannot use a pseudo

play15:35

command let's try it real quick

play15:37

i'll do sudo and i'll try to add a user

play15:39

user add

play15:40

let's try to bring in pepper potts his

play15:42

wife right yeah wife

play15:43

that's gonna ask for a pseudo password

play15:45

okay just type in jarvis

play15:47

things are looking pretty good right no

play15:49

we're in trouble

play15:50

you're not in the sudoers file this

play15:52

incident will be reported you're like

play15:54

you're grounded iron man you can't do

play15:56

this i do love that we're talking about

play15:57

marvel and we have this spider-man line

play15:59

that comes in

play16:00

anyways that's an overused line anyway

play16:02

um so real quick

play16:03

what is this right here the sue doers

play16:06

file which is a very very awkward phrase

play16:09

basically this file the sudor's file

play16:11

defines

play16:12

who can use sudo who can wear the

play16:14

gauntlet right now iron man

play16:16

is not in that file so we can't put it

play16:18

on so what do you say we go take a look

play16:19

at that file i know you're itching to so

play16:20

let's do it real quick now the scooters

play16:22

file is a very important file that you

play16:23

don't want to jack up

play16:24

and you can jack it up you can ruin your

play16:26

entire system by

play16:27

messing up the scenarios file but there

play16:29

are some checks in place to keep you

play16:30

safe now normally in linux

play16:31

to edit a file you might just use your

play16:33

default text editor right the one you

play16:35

love like we might use

play16:36

nano or them but with a suitor's file

play16:39

the best practice is to do but with the

play16:40

scooter

play16:41

but with these two doors file there's a

play16:42

certain way we have to do it now we will

play16:44

have to use sudo to do this so i'm going

play16:45

to stop being iron man for a second i'm

play16:47

going to

play16:48

ctrl d to log out of iron man okay i'm

play16:50

me again the command will be sudo

play16:52

and then right after that it'll be vi

play16:56

sudo this is the only best practice

play16:58

recommended way to

play16:59

edit the sudoers file so let's uh get in

play17:02

there and take a look and it's not a

play17:03

crazy big file either it's kind of

play17:05

simple in a way so i'll hit enter

play17:07

and we're in and then i'll scroll down

play17:08

through this document to

play17:10

about here right here is where we're

play17:12

able to see who's got permission to do

play17:14

what obviously root can use sudo and

play17:16

i'll explain what all this means here in

play17:18

a moment and then down here in this

play17:19

section we have allowed members of a

play17:20

group

play17:21

pseudo access or pseudo to execute any

play17:23

command and then just below that we have

play17:25

something else we have a percent sign

play17:26

and then

play17:27

pseudo this actually is a group and if

play17:29

you're a member of this group the sudo

play17:31

group

play17:32

well you can do all this and what this

play17:34

actually means is you can enter

play17:35

any command at all and you don't have to

play17:37

enter

play17:39

a password which is pretty dangerous

play17:40

kind of risky but

play17:42

it's okay so if you're in this file

play17:45

you have the power and thanos does have

play17:47

the power let's go ahead and add thanos

play17:48

real quick

play17:49

we'll pretend he's already in there so

play17:51

just under root i'm going to add thanos

play17:53

so we'll start with the username which

play17:54

is

play17:55

thanos the first option here is what

play17:57

systems

play17:58

can thanos have ultimate power on well

play18:01

it's the infinity gauntlet

play18:02

all systems and this would be if they're

play18:04

like multi-system situations but

play18:06

and then i'll do a space equals not plus

play18:09

sign

play18:09

equals all and that all stands for all

play18:13

commands now if you want to just give

play18:15

thanos options to do one thing like

play18:16

maybe add a user we might do forward

play18:18

slash

play18:19

sbn forward slash user add giving him

play18:22

access to that one command

play18:24

we don't want to do that thanos has all

play18:26

power

play18:27

oh and that's all we need i'm going to

play18:29

hit control

play18:30

x to say i want out of here don't want

play18:32

to save it hit y

play18:33

hit enter to write it to that file and

play18:36

thanos is there

play18:37

he's got the gauntlet on he can do

play18:38

whatever he wants let's see if he can

play18:40

we're going to become thanos for a

play18:41

second so i'll do sudo

play18:44

su space dash space thanos

play18:47

we're thanos right now so let's do sudo

play18:49

user ad what's another bad guy he uses

play18:51

oh yeah his daughter nebulous little

play18:53

spring nebula in here the stanos have

play18:55

access let's see

play18:57

what's his password inevitable yep

play19:00

it did it worked so let's cap the uh

play19:03

password file yep there's nebula

play19:05

so thanos has ultimate power he's got

play19:07

the gauntlet on

play19:08

and crap he's about to snap you ready

play19:11

he's going to delete half the

play19:12

population in our case half the avengers

play19:14

we have here to delete a user

play19:16

new new command time it's terrible but

play19:19

new command time coffee break

play19:22

okay i'm ready sudo user

play19:25

del or user delete as you might expect

play19:28

this command will

play19:29

delete a user and we'll take out thor

play19:32

thor is gone if we catch the password

play19:35

file

play19:36

thor he's gone pseudo user delete

play19:39

spider-man gone bye doctor strange

play19:43

gone and just like that with a snap of

play19:44

his fingers we're down to

play19:46

hulk loki and captain america oh and

play19:49

iron man two there he is

play19:50

and just when it seems hopeless just

play19:52

when it seems all is lost the avengers

play19:54

have a plan ant-man comes in somehow

play19:56

quantum stuff anyways we need the

play19:57

gauntlet we need pseudo access to be

play19:59

able to

play20:00

bring captain america back and all the

play20:01

other people got got deleted so let's do

play20:03

this right now so

play20:04

we're gonna explore a new concept we're

play20:06

going to create a group to do that

play20:08

new command time here we go we'll do

play20:11

sudo group

play20:12

add and as you might expect group add

play20:14

will simply add a new group i'll do a

play20:16

space i'll name my group

play20:18

infinite

play20:21

gauntlet does spell that right i don't

play20:24

care that's what it's going to be called

play20:26

and the group is there but how do we

play20:28

know where is that group at

play20:29

well just like we have a password file

play20:31

to look at our users in the system

play20:33

we have a file to look at the groups and

play20:35

it's much more self-explanatory it makes

play20:37

more sense

play20:38

i'm going to cat the etsy group

play20:41

file and there it is infinity gauntlet

play20:45

right there

play20:45

as well as every other group that was

play20:47

created for our users

play20:49

i told you whenever a user account is

play20:50

created also they have a group created

play20:52

for themselves as well

play20:53

now what i want to do is make sure that

play20:54

the members of the infinity gauntlet

play20:56

group

play20:56

do have ultimate power because you mean

play20:58

you should you have the infinity

play21:00

gauntlet on

play21:00

so we need to add the infinity gauntlet

play21:02

group to our sudoers file

play21:04

let's do that real quick so again we'll

play21:05

do sudo vi sudo to edit that file the

play21:08

only way to do it don't you ever do it a

play21:09

different way

play21:10

i'm just kidding but seriously um let's

play21:13

edit that file we're gonna scroll down

play21:14

to

play21:15

where we were and then right here right

play21:17

now we see that members of the sudo

play21:19

group

play21:20

can do whatever they want and actually

play21:21

real quick let me show you the reason we

play21:23

can do whatever we want

play21:24

is because we're members of the sudo

play21:26

group if i do

play21:27

actually new command time if you just

play21:29

type in group i'm sorry

play21:31

groups groot

play21:34

it'll tell you what groups you are a

play21:36

member of the current user account

play21:37

you're logged in as and here i'm a

play21:38

member of my own group user 86527

play21:40

and the pseudo group which gives me

play21:43

gauntlet

play21:44

access anyways let's make sure the

play21:45

gauntlet does have the appropriate

play21:47

permissions here so just under

play21:49

the sudo group i'm going to add percent

play21:51

infinity

play21:54

gauntlet make sure you spell it right

play21:56

i'll do a space and i'll pretty much

play21:57

copy the one just above it i'll say all

play21:58

which again is all systems

play22:00

space equal sign space i'll say no

play22:02

password which is nopa sswd like we see

play22:05

here

play22:06

i'll do a colon and say all essentially

play22:08

it's saying you can do everything you

play22:09

want

play22:10

all commands and you don't need a

play22:11

password you got all them stones

play22:13

anyways so i'm going to hit control now

play22:16

actually you know what real quick before

play22:17

i do that

play22:18

i'm going to mess it up like i mentioned

play22:20

before if you mess up your suitors file

play22:22

you can break the entire system

play22:24

there is some checks in there that'll

play22:26

keep you safe so i'll just go

play22:29

and i hit control x to get out of there

play22:32

yes to save hit enter it'll say whoa

play22:35

whoa whoa

play22:36

there is a syntax error right there not

play22:38

supposed to do that what are you doing

play22:40

what are you going to do now what do you

play22:41

want to do are you sure you want to save

play22:42

this if i hit enter it will give me some

play22:44

options

play22:44

and i love this it's like you might want

play22:47

to go edit it again hit e

play22:48

hit x to get out of there and don't save

play22:50

it just forget what you're doing you

play22:51

don't know what you're doing or says you

play22:52

know what if you're pretty confident

play22:53

just hit q and say you want to save it

play22:55

danger um let's be smart let's hit e to

play22:59

edit it

play23:00

and remove that crap we put in there and

play23:02

then we can hit ctrl

play23:03

x y and enter no errors we're good

play23:07

so the infinity gauntlet group does have

play23:10

ultimate sudo

play23:11

super user due powers and now what's

play23:13

left is the avengers have to somehow

play23:15

become part of that group

play23:16

put on the glove and change history and

play23:18

if you've seen the movie

play23:19

spoiler alert um iron man he does this

play23:22

so we need to somehow get iron man into

play23:25

the infinity gauntlet group let's do

play23:26

that right now now real quick let's

play23:28

demonstrate that iron man can't do crap

play23:29

right now so if i

play23:30

become iron man and i try to bring back

play23:34

spider-man i can't i don't have the

play23:36

glove i can't do it man iron man is

play23:37

helpless but let's add them to the group

play23:39

so to add a user to a group

play23:40

pretty simple we're going to use the

play23:41

same command we used earlier to modify a

play23:43

user the user mod command

play23:45

so we'll do sudo and keeping in mind i'm

play23:47

logged in as me now not ironman anymore

play23:49

i'll do sudo

play23:50

user mod and the switch is dash

play23:53

g now dash g by itself will add this

play23:56

user to a group

play23:57

but it will add it to that group and

play23:59

kind of eliminate all other groups

play24:01

you may not want to do that so we often

play24:03

want to change this to

play24:04

dash lowercase a capital g the a stands

play24:08

for append

play24:08

so this command here we're appending the

play24:10

groups that ironman

play24:12

is part of so just after dash ag we'll

play24:15

type in

play24:16

the group which is infinity gauntlet

play24:19

and then the user we want to add which

play24:21

will be iron man

play24:22

just like that iron man has the glove on

play24:25

we can actually see if that's happening

play24:26

by going to

play24:27

or catting the group file

play24:30

etsy group and here we can see the

play24:33

infinity gauntlet group

play24:34

the members over here on the right and

play24:35

there's iron man right there now again

play24:37

if you saw the movie you know that iron

play24:38

man and

play24:39

and thanos were kind of wrestling with

play24:41

the gloves so thanos was in the group

play24:43

too

play24:43

they kept going back and forth let me

play24:45

add thanos in there real quick

play24:46

so yes right now iron man and thanos are

play24:48

both part of this group they both have

play24:49

super awesome

play24:50

powerful pseudo access but eventually

play24:53

iron man does wrestle the

play24:55

glove off of thanos and puts it on

play24:56

himself so new command time how do you

play24:58

remove

play24:59

a user from a group this command is

play25:01

called g password

play25:03

the commands sometimes are weird um so

play25:05

we'll do sudo

play25:06

g pass wd we're gonna do dash d for

play25:09

delete specify the user we want to

play25:11

remove which will be

play25:13

thanos take that off take that take it

play25:15

and then we'll specify the group

play25:17

infinity gauntlet take that thanos look

play25:20

at the group once more

play25:21

no one's in there so anyways iron man he

play25:23

has the gauntlet

play25:24

he snaps his fingers and he creates the

play25:27

users we lost

play25:28

let me become iron man i am iron man

play25:31

pseudo

play25:32

user ad captain america pseudo

play25:35

user ad spiderman done we'll bring back

play25:39

doctor strange

play25:40

and i forgot who else but anyways you

play25:41

get the picture right iron man has the

play25:43

gauntlet on he has the power he's part

play25:45

of the group

play25:46

and he can now bring back everyone and

play25:48

shoot while he's at it let's defeat

play25:50

thanos right

play25:51

sudo user delete

play25:55

thanos here we go

play25:58

goodbye thanos and then finally iron man

play26:00

realizes the infinity gauntlet it's too

play26:02

powerful

play26:03

for anyone to possess so he destroys it

play26:05

i think that's what happens

play26:06

that's what we're going to do right now

play26:07

so using the principle of least

play26:08

privilege

play26:09

we're going to remove the the infinity

play26:11

gauntlet group we're going to delete

play26:12

that group by doing the

play26:14

group delete command in fact iron man

play26:16

will do it himself right now and he's

play26:17

going to

play26:18

delete his access to do it at the same

play26:20

time which is kind of weird right

play26:21

so sudo group delete uh new command time

play26:25

i forgot to sit man

play26:26

which obviously means we're gonna be

play26:28

deleting a group and the usage is pretty

play26:30

straightforward just after group delete

play26:32

we'll enter the name of the group

play26:33

infinity gauntlet now this does not

play26:36

delete any

play26:37

users in that group it just deletes the

play26:39

group and gone are also iron man's

play26:41

privileges to do anything special

play26:42

anymore

play26:43

for example if he got greedy and wanted

play26:45

to create the group once more

play26:47

sorry iron man you don't have it anymore

play26:49

and i think you have other problems to

play26:50

worry about

play26:51

we did it i think like we saved the

play26:53

world right i mean iron man's

play26:54

not okay but we we learned how to manage

play26:57

users and linux and in the process we

play26:59

assembled the avengers and took away the

play27:01

infinity gauntlet destroyed it and saved

play27:03

the world

play27:04

yeah but seriously we learned a lot

play27:06

today we learned how to manage users in

play27:07

linux

play27:08

add them delete them groups permissions

play27:11

all that

play27:12

and that's essential to managing a linux

play27:13

system to becoming a hacker to doing

play27:16

anything with linux now and

play27:17

pretty much every area of it involves

play27:19

linux and also if you want a quick

play27:21

review of what we covered in text form

play27:23

uh mosey on over to hack the box academy

play27:25

the page we were at the whole time

play27:26

and look it over they've got the

play27:27

commands we we talked about in text form

play27:30

and they also have a delightful quiz at

play27:32

the very bottom to test your knowledge

play27:33

and see how you do

play27:34

and if you get it right you earn cubes

play27:36

back which with the junk or cubes

play27:38

go watch episode one if you don't know

play27:39

what they are also if you want to test

play27:41

your skills even further

play27:42

i've got a quiz in the description below

play27:44

it's free click the link

play27:45

and uh let's see what you got and again

play27:47

huge shout out to our sponsor hack the

play27:49

box academy

play27:50

it's free to access right now to do what

play27:52

we've been doing here if you want to go

play27:53

further and learn how to hack wordpress

play27:55

and

play27:55

and do python stuff and just man just so

play27:58

many things

play27:59

check them out link below i'll catch you

play28:01

guys next time

play28:03

[Music]

play28:17

[Music]

play28:18

you

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Linux ManagementUser AccountsHacking TutorialAvengers ThemeEthical HackingSudo PowersGroup PermissionsScript GuideHack the BoxEducational Content