While creating users and groups, different properties can be managed.
Users and their properties are stored in etcpasswd and common properties that you will
find are the user id. Every user has a unique numeric user id.
The gid in etcpasswd is the ID of the primary group.
In passwd, there is only space to hold one group membership and that's the primary group.
Then there is the GCOS field, which stands for General Electric Common Object subscription.
That's a definition that dates back to the 1970s. Nowadays, mostly we talk about comment field
and that is an optional description field for the user where you can enter additional information.
The home directory refers to the default home directory where the user will land after
logging in. So that will be the default environment where user has write permissions.
And shell is a program that is started after user login.
Now, if you want to list current password properties for a user, you can use grep on
the username on etcpasswd. Alternatively, you can also use getint, which will print these properties as well.
Passwords are not stored in etcpasswd. They are stored in the etc shadow command, which we will cover later.
If you want to change any of the properties for users, you use
usermod and passwd. Usermod is for the generic properties in etc. Passwd and
passwd is for the password which is stored in etc shadow.
Let's have a quick look before moving on.
So just one line from etc passwd last line and this is a line for user Anna.
So first field username, third field user id. Then we get the group id. The GCOS field
is empty, we do refer to home anna and bin bash is the default shell.
So what would happen if we use get and Anna?
Well, get and is giving me an error message, and that is because it doesn't
know about the database. Getent needs us to specify where we want to get the
information from and what do we see? We see the exact same information.
The interesting thing about getent is not to get information out of passwd, but if
ever your users are defined in an external system such as an LDAP server, GetAndPassWD
will also get the user information out of the external system. And that is why
getent in some environments might be useful. Anyway, let's talk about groups a little bit.
So groups are stored in the file etc. Group, and users that are a group member as a secondary
group are also administered in etc group. That's because in etc passwd there's only place for one group membership.
So that means that you need to get your group information out of two different files.
Now, managing group properties is simple. Groups don't have any significant other properties.
So the most important thing is to find the groups that the user is a member of.
And that's what you can do using the ID command that we have already seen a couple of times in this video course.