Setting up a new user

From Alpine Linux
Revision as of 13:32, 15 November 2019 by Mckaygerhard (talk | contribs) (link to new users creation)
Jump to: navigation, search

Creating a user is an important step when first configuring a Linux system. Generally root account is used for administration only as it has access to the operating system and its configuration.


When Alpine Linux is first installed by default it comes with the user root with no password set. For security reasons it's always a good idea to either set a password to the user root or disabling the login to the user, which its why is suggested to run setup-alpine to change root password.

Creating an account allows it to have it's own $HOME directory and allows you to limit access to the configuration of the operating system for security reasons.

Creating a new user

Using the command adduser will allow you to create a new user in the system.

adduser <username>

It will prompt to set a password for the new user, by example let's create a new user with session name "test"

# adduser test
Changing password for test
New password: 
Retype password: 
passwd: password for test changed by root

The new user can be seen in

Contents of /etc/passwd

root:x:0:0:root:/root:/bin/ash . . . test:x:1000:1000:Linux User,,,:/home/test:/bin/ash

You can now exit and login to the new account.

User management commands

Alpine at install comes only with busybox user management commands and the following are standar for all linux distributions

If no OPTIONS is set, by default when creating a new user, it will create a home directory in /home/<username>, with the shell set that uses the root account (ash by default), user ID and group ID 1000+, and the GECOS field Linux User,,,.




Create new user, or add USER to GROUP

  • --home DIR Home directory
  • --gecos GECOS GECOS field
  • --shell SHELL Login shell named SHELL by example /bin/bash
  • --ingroup GRP Group (by name)
  • --system Create a system user
  • --disabled-password Don't assign a password so cannot login in
  • --no-create-home Don't create home directory
  • --uid UID User id

Those options only work for newer versions:

  • -k SKEL Skeleton directory (/etc/skel)

One thing to note is that if


isn't set then the GID is assigned to match the UID. If the GID corresponding to the provided UID already exists adduser will fail.



addgroup [-g GID] [-S] [USER] GROUP

Add a group or add a user to a group

  • --gid GID Group id
  • --system Create a system group

Alpine base groups permissions, check for base layout package:

See also: