User & Group Deletion (Demo)
Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or
Already have an account? Sign In »

Video Transcription
00:00
>> Hello there Cybrarians and welcome back to
00:00
the Linux Plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz and in
00:00
today's lesson we're going to be
00:00
discussing user and group deletion.
00:00
Upon completion of today's lesson
00:00
you're going to understand how to delete
00:00
users and groups by using
00:00
the userdel and groupdel commands.
00:00
The userdel command is used to
00:00
delete the user account. It's very well named.
00:00
In common, userdel commands are userdel,
00:00
which will just remove the user account,
00:00
or userdel -r, which deletes
00:00
the user and any of
00:00
the directories that are created for the user,
00:00
such as the home directory.
00:00
Now the groupdel command is
00:00
used to delete the group account.
00:00
We just use groupdel and
00:00
then the name of the group to delete the group.
00:00
But let's check out these two
00:00
commands with some demo time.
00:00
Here we are over in our CentOS environment
00:00
and the your del command is pretty simple,
00:00
but there are a few got us though.
00:00
For instance, let's delete the user tests,
00:00
let's do an id on the user test,
00:00
and we can see all of
00:00
the information about this user here.
00:00
Let's go to ls on the home directory,
00:00
and we can see that we have in test and test2.
00:00
Let's just do a userdel on test.
00:00
We need to be pseudo to do this.
00:00
Now if we do a id on test again,
00:00
we're going to see that there is no such user.
00:00
If we do an ls on home,
00:00
we still see tests.
00:00
Why do we still see tests there?
00:00
Well, this is because we didn't use
00:00
the dash r flag when we tried to remove a user.
00:00
Let's do this for test2.
00:00
If you do id test2,
00:00
we can see the user ID for this user account with 1003,
00:00
we can see as part of we'll group.
00:00
Let's do an ls on home.
00:00
We can see my account,
00:00
my home directory as well as test and test2.
00:00
But for test2 let's do userdel -r and specify test2.
00:00
We need to be pseudo to do this,
00:00
of course, here we go.
00:00
Now let's do an ls on home again.
00:00
Now we can see that test2 has been removed.
00:00
Remember, when you're doing a userdel,
00:00
you have to use this dash r option or
00:00
flag in order to
00:00
remove the user's home directory as well.
00:00
Now let's take a look at the groupdel command.
00:00
Let's clear the screen first.
00:00
By comparison, groupdel is very basic.
00:00
We just really run groupdel
00:00
and then the name of the group we want to remove.
00:00
In our case, let's get rid of that worst group.
00:00
If I do cat etc group,
00:00
we can see down here at the bottom we have worst with
00:00
the group ID is 666.
00:00
Let's do a groupdel.
00:00
I'll clear the screen, actually,
00:00
bring all the beltway back at the top.
00:00
If we do a groupdel on worst and then hit "Enter".
00:00
Now if we do a cat etc group again,
00:00
we don't see any down at the bottom,
00:00
if we do a grep for worst in etc group,
00:00
and we can't see anything there either,
00:00
so we've removed that group.
00:00
We've reached the end of this lesson.
00:00
In this lesson we covered
00:00
user and group deletion with
00:00
the commands userdel and groupdel.
00:00
Thank you so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next
Instructed By
Similar Content