Setting up a new user

From Alpine Linux
Revision as of 07:04, 14 September 2019 by Innsill (talk | contribs) (+ Category:Newbie)

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.

Overview

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 --help
Usage: adduser [OPTIONS] USER [GROUP]
Create new user, or add USER to GROUP
-h DIR		Home directory
-g GECOS	GECOS field
-s SHELL	Login shell
-G GRP		Group
-S		Create a system user
-D		Don't assign a password
-H		Don't create home directory
-u UID		User id
-k SKEL		Skeleton directory (/etc/skel)

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,,,.

Example creating a user

adduser test

It will prompt to set a password for the new user

# 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.

TODO

Adding user to a group?, Privilege escalation with sudo?