In this lesson, I'll discuss adding users to Linux.
Adding users to Linux is a common task that system administrators
may perform over the course of managing a Linux system.
Now, depending on what scripts that you might have implemented on,
let's say a kickstart file, for example.
The integration that we have with maybe another directory,
like Active Directory, may do some of these tasks for you,
but let's go over them individually.
So I'll discuss the commands that we use to enter in users into Linux,
and some of the caveats that we have as well,
and what I've seen over the years.
Now, most Linux systems use a command called user add.
Now, if I type in sudo useradd and then the account that I want to create,
it's going to create not only the home directory,
but it's going to create the permissions for that home directory,
and also the shell that the user is going to have as well.
So I'm just going to enter this here,
and enter my password for Greg,
and now the account is created.
I can check that the account is created by doing one or two things.
Since I'm already in the home directory,
I can just list what files I have.
So here's my account gwilliams,
and gwilliams is the user and the group owners of that directory.
Additionally, I can go into the add see
password file and look to see if the account was created there.
But before I do that,
let's add a password for my gwilliams account.
So I'm going to type in sudo passwd gwilliams,
hit enter and in our password retype the password,
and it's created the password successfully.
So let's look at the etc password file for a minute.
Here we'll notice that we have three different users.
I've greg, greg test and gwilliams.
The X indicates that I've set a password for that user.
I have a user ID,
as well as my home directory,
and the shell that that user has.
Since some of the scripts,
because different distributions use user add in different ways,
let's look at a more mainstream Linux distribution such
as CentOS which is the binary equivalent of Redhat.
Typically, we're going to see this distribution
being used to worn in enterprise environment.
So let's get more familiar with what we can change for the defaults.
So I'll type in sudo vi /etc/default/useradd.
So here, I can change the group,
I can change the home directory, inactive,
I can make it active,
when the account expires in the shell and create mail spooler.
I can change or I can add several other attributes, if I would like.
But these are the most common that I'm going to use.
Now, let's go back into the /etc/ password field.