Now when we're creating users, we're going to use the command, useradd.
We can provide just the minimum amount of
information, that being the login name.
The rest are going to come from the default settings.
But, where, just where, are those default settings stored? Well as
we go through, let's elevate our privileges,
create a new user, remember, saying just the minimum, so
I'm creating the user here called u1.
We can go through and check the id. Checking the id will be able to show
me the group memberships of the u1, among other things.
When we go through and take a look at getent passwd, searching for the user, u1,
we'll see all of those settings coming from the user account, and this will
include things like the default shell and the home location.
If we want to look at the user default,
we can see some of the user default using useradd ‑D.
Others we can go through and search for from a file called etc/login.defs.
Now one of these settings is the user group enabled.
If that is enabled each time we create a new user account, it is
going to create a group based on the username.
This is known as a private group, and it will be the user's primary group.
The group membership itself will be maintained through the
etc/passwd file, and not the normal groups file.
We also have complimentary groups. Complimentary groups are our normal
group membership and often called secondary groups.
The group membership for this is stored within the etc/group file.
All groups are stored in the etc/group file,
but it's only the membership of complimentary groups that is
maintained through the group file itself.
Remember, with primary groups,
the membership is maintained through the etc/passwd file.
The reality is, though, there are many default settings that we can
adjust, the option ‑N will specify that we are not creating a private
group. So you can see that we're specifying it here,
so we're going to belong to the default group as our primary group,
which would be users.
The ‑G is specifying our secondary group membership.
This is then the wheel group, we're being added to the wheel group as a
secondary group, setting a full name or comment through to user two, and we've
got a remarkably well‑named user account of u2, itself.
But don't forget,
the real way to learn is to get some hands‑on, and also to go through
and take a look at our man page, or manual pages, so we get an idea of
all of the options that are available. Are you up for this?