User and Group Management

Manage user accounts, passwords and group memberships in MocaccinoOS.

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:

1
$ whoami

To display the user ID (UID), primary group and supplementary groups:

1
$ id

To display the groups associated with a specific user:

1
$ groups username

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:

1
$ sudo useradd -m john

The -m option creates a home directory for the new user under /home.

Next, assign a password:

1
$ sudo passwd john

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:

1
$ sudo usermod -aG wheel john

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:

1
$ sudo gpasswd -d john wheel

You can verify the user’s group membership with:

1
$ groups john

Changing a user’s password

To change your own password, run:

1
$ passwd

To change another user’s password, administrative privileges are required:

1
$ sudo passwd john

Changing user account information

The usermod command can also be used to modify existing user accounts.

To change a user’s login name:

1
$ sudo usermod -l newname oldname

To change a user’s default shell:

1
$ sudo usermod -s /bin/bash john

To change a user’s home directory:

1
$ sudo usermod -d /home/newhome -m john

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:

1
$ sudo userdel john

To remove the account together with its home directory:

1
$ sudo userdel -r john

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:

1
$ sudo command

For example, to update the system repositories:

1
$ sudo luet repo update

To check which commands your account is allowed to execute with sudo:

1
$ sudo -l

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:

1
2
3
4
5
6
$ man useradd
$ man usermod
$ man userdel
$ man passwd
$ man groups
$ man gpasswd

You can also consult the Gentoo Handbook:

Last modified November 29, 2026: Update SFTP (f553589)