User and Group Management
User and Group Management
Linux is designed to support multiple user accounts. Each user has their own home directory, settings and permissions.
For security reasons, it is recommended to use a regular user account for everyday activities instead of working as the root user.
MocaccinoOS uses standard Linux user and group management utilities to create and manage accounts.
Checking the current user
To display the username of the currently logged-in user, run:
|
|
To display the user ID (UID), primary group and supplementary groups:
|
|
To display the groups associated with a specific user:
|
|
Replace username with the account you want to inspect.
Creating a user account
To create a new user account, use useradd.
For example, to create an account called john, run:
|
|
The -m option creates a home directory for the new user under /home.
Next, assign a password:
|
|
You will be prompted to enter and confirm the new password.
Adding a user to groups
Groups determine which resources and operations a user can access.
To add a user to a supplementary group, use usermod.
For example, to add the user john to the wheel group:
|
|
The -aG options append the specified group to the user’s existing supplementary groups.
Important: Always use -a together with -G when adding supplementary groups. Without -a, the user’s existing supplementary group memberships will be replaced.
Some commonly encountered groups include:
| Group | Description |
|---|---|
| wheel | Allows users to use su and, when configured, administrative tools such as sudo. |
| audio | Provides direct access to audio devices. |
| video | Provides access to certain video devices and hardware resources. |
| usb | Provides access to USB devices. |
Group membership changes generally require the user to log out and log back in before they take effect.
Removing a user from a group
To remove a user from a supplementary group, use gpasswd.
For example, to remove john from the wheel group:
|
|
You can verify the user’s group membership with:
|
|
Changing a user’s password
To change your own password, run:
|
|
To change another user’s password, administrative privileges are required:
|
|
Changing user account information
The usermod command can also be used to modify existing user accounts.
To change a user’s login name:
|
|
To change a user’s default shell:
|
|
To change a user’s home directory:
|
|
The -m option moves the contents of the existing home directory to the new location.
Removing a user account
To remove a user account while keeping its home directory:
|
|
To remove the account together with its home directory:
|
|
Warning: The -r option permanently removes the user’s home directory and its contents. Make sure that important personal files have been backed up before proceeding.
Administrative privileges
Administrative operations require elevated privileges.
MocaccinoOS uses the sudo utility to allow authorized users to execute commands with administrative privileges.
To execute a command with elevated privileges, prefix it with sudo:
|
|
For example, to update the system repositories:
|
|
To check which commands your account is allowed to execute with sudo:
|
|
Membership in the wheel group does not automatically guarantee sudo access. The system’s sudoers configuration must also authorize the group.
Additional information
For more information about user and group management, consult the following manual pages:
|
|
You can also consult the Gentoo Handbook: