Learn

Now that we’ve covered how different Linux users can coexist, let’s learn about users, groups, and their IDs!

On a Linux system, all users added are assigned a name, unique user identification (UID), group, and group identification (GID). When a user is initially created, a new UID and matching GID are assigned.

UID and matching GID numbers are assigned based on the type of user:

  • Administrator (root): UID and GID = 0
  • System user (computer-generated): UID and GID assigned from 1 to 999
  • Normal users (real people): UID and GID = 1000 or greater, incremented with every new user

The new user is by default assigned a matching group name (and typically a matching GID) so that the user will be a member of their own group. For example, a user stephen (UID = 1000) will also be assigned to the group stephen (GID = 1000).

We can create groups and add users to them. For example, in our diagram, we have a group called Business that includes the user Tony. Users can also exist in more than one group as well.

We can use the id and groups commands in the terminal to check our uid and gid.

terminal output of ‘id’ command

terminal output of ‘groups’ command

Admin users can also view and modify the user and group information stored in the read-only /etc/passwd and /etc/group files.

terminal output of `/etc/passwd file`

terminal output of `/etc/group file`

Up next, we’ll talk about how users and groups relate to file permissions.

Instructions

1.

Let’s use the id command in the terminal to see our own UID, GID, and group memberships. Currently, our username is ccuser.

2.

Now, let’s use the groups command in the terminal to see a list of groups that we are members of. So far, ccuser should be the only group.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?