<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vptr</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vptr"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Vptr"/>
	<updated>2026-04-30T20:13:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_new_user&amp;diff=26655</id>
		<title>Setting up a new user</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_new_user&amp;diff=26655"/>
		<updated>2024-04-19T04:29:26Z</updated>

		<summary type="html">&lt;p&gt;Vptr: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; account should be used only for local administrative purposes that require elevated access permissions.&lt;br /&gt;
&lt;br /&gt;
This page shows how to create non-privileged user accounts. i.e. those used for daily work, including desktop use and remote logins.&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Creating user accounts provides users with their own {{path|$HOME}} directory and allows you (the root user) to limit the access those user accounts have to the operating system configuration files.&lt;br /&gt;
&lt;br /&gt;
Using them increases security, because they limit possible actions and thus possible damage (even from accidental errors).&lt;br /&gt;
&lt;br /&gt;
= Creating a new user =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|If using a &#039;&#039;&#039;&amp;quot;diskless&amp;quot; or &amp;quot;data&amp;quot; disk mode&#039;&#039;&#039; installation, it&#039;s important to make the &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt; directory persistent.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Either the &amp;lt;code&amp;gt;/home&amp;lt;/code&amp;gt; filesystem needs to be mounted from a writable partition, or&lt;br /&gt;
* the /home directories have to be added to the lbu backup, and a new local backup needs to be committed after creating the user:&lt;br /&gt;
{{Cmd| # lbu include /home&lt;br /&gt;
 # lbu commit&lt;br /&gt;
}} (Not recommended, as reverting to an older .apkovl will also revert the files in /home).&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Regular user accounts can be created with:&lt;br /&gt;
{{Cmd|# adduser [-g &amp;quot;&amp;lt;Full Name&amp;gt;&amp;quot;] &amp;lt;username&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
By default, &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt; will:&lt;br /&gt;
* prompt you to set a password for the new user&lt;br /&gt;
* create a home directory in {{Path|/home/&amp;lt;username&amp;gt;}}&lt;br /&gt;
* set the shell to the one used by the &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; account (ash by default)&lt;br /&gt;
* assign user ID and group ID starting at 1000&lt;br /&gt;
* set the GECOS (full name) field to &amp;quot;Linux User,,,&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{{Tip|The optional &amp;lt;code&amp;gt;-g &amp;quot;&amp;lt;Full Name&amp;gt;&amp;quot;&amp;lt;/code&amp;gt; above sets the GECOS field.&lt;br /&gt;
This can be very useful to specify. Setting this string - at least equal to the username - makes the user distinguishable, e.g. when they are listed at the login screen of a display manager.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If a user &#039;&#039;really must&#039;&#039; be allowed to have access to the root account&#039;&#039;&#039;, the &amp;lt;username&amp;gt; can be added to the &#039;&#039;&#039;wheel&#039;&#039;&#039; group and &amp;lt;code&amp;gt;{{Pkg|doas}}&amp;lt;/code&amp;gt; (&amp;quot;do as&amp;quot;) may be installed:&lt;br /&gt;
 # adduser -g &amp;quot;&amp;lt;username&amp;gt;&amp;quot; &amp;lt;username&amp;gt;&lt;br /&gt;
 # adduser &amp;lt;username&amp;gt; wheel&lt;br /&gt;
 # apk add doas&lt;br /&gt;
&lt;br /&gt;
You will want to allow members of the &#039;&#039;&#039;wheel&#039;&#039;&#039; group to use root privileges with &amp;lt;code&amp;gt;doas&amp;lt;/code&amp;gt;. To do this, open the &amp;lt;code&amp;gt;doas&amp;lt;/code&amp;gt; config file:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# &amp;lt;editor&amp;gt; /etc/doas.d/doas.conf}}&lt;br /&gt;
&lt;br /&gt;
Add the following line and save the file:&lt;br /&gt;
{{Cmd|permit persist :wheel}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|It&#039;s recommended to &#039;&#039;&#039;not&#039;&#039;&#039; run complete applications, like editors, as root just to modify administrative files.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* [https://github.com/AN3223/scripts/blob/master/doasedit &amp;lt;code&amp;gt;doasedit&amp;lt;/code&amp;gt;] or &amp;lt;code&amp;gt;sudoedit&amp;lt;/code&amp;gt;([https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.15.0#Move_from_sudo_to_doas being deprecated in favour of &amp;lt;code&amp;gt;doas&amp;lt;/code&amp;gt;]) enables starting an editor with a temporary copy of a file, which overwrites the original file after the user modifies and saves it. For example, &amp;lt;code&amp;gt;sudoedit /etc/apk/lbu.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Many desktop environments and file browsers support using &amp;lt;code&amp;gt;admin:///&amp;lt;/code&amp;gt; in their address bars, to access files through a local gvfs-admin mount.&lt;br /&gt;
}}&lt;br /&gt;
The &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; package is an alternative to using the BSD-like &amp;lt;code&amp;gt;doas&amp;lt;/code&amp;gt;, but is a much larger package.&lt;br /&gt;
It may be used as follows: adding a custom user configuration file to avoid having to deal with manually changing configuration files later during package upgrades.&lt;br /&gt;
 apk add sudo&lt;br /&gt;
 NEWUSER=&#039;yourUserName&#039;&lt;br /&gt;
 adduser -g &amp;quot;${NEWUSER}&amp;quot; $NEWUSER&lt;br /&gt;
 echo &amp;quot;$NEWUSER ALL=(ALL) ALL&amp;quot; &amp;gt; /etc/sudoers.d/$NEWUSER &amp;amp;&amp;amp; chmod 0440 /etc/sudoers.d/$NEWUSER&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no seat manager like [[elogind]] or [[seatd]] is being used and running, then users that want a graphical environment need the &#039;&#039;&#039;video&#039;&#039;&#039; and &#039;&#039;&#039;input&#039;&#039;&#039; groups:&lt;br /&gt;
 # adduser &#039;&amp;lt;username&amp;gt;&#039; video&lt;br /&gt;
 # adduser &#039;&amp;lt;username&amp;gt;&#039; input&lt;br /&gt;
&lt;br /&gt;
The above is highly discouraged. See {{Issue|15409}}.&lt;br /&gt;
&lt;br /&gt;
The new user gets listed in &lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/passwd|root:x:0:0:root:/root:/bin/ash&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;username&amp;gt;:x:1000:1000:&amp;lt;username&amp;gt;:/home/&amp;lt;username&amp;gt;:/bin/ash}}&lt;br /&gt;
&lt;br /&gt;
Now you should be able to issue the command &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and login to the new account.&lt;br /&gt;
&lt;br /&gt;
= Options =&lt;br /&gt;
&lt;br /&gt;
=== adduser ===&lt;br /&gt;
&lt;br /&gt;
Usage (from &amp;quot;man busybox&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;adduser [OPTIONS] USER [GROUP]&lt;br /&gt;
&lt;br /&gt;
Create new user, or add USER to GROUP&lt;br /&gt;
&lt;br /&gt;
     -h --home DIR           Home directory&lt;br /&gt;
     -g --gecos GECOS        GECOS field&lt;br /&gt;
     -s --shell SHELL        Login shell named SHELL by example /bin/bash&lt;br /&gt;
     -G --ingroup GRP        Group (by name)&lt;br /&gt;
     -S --system             Create a system user&lt;br /&gt;
     -D --disabled-password  Don&#039;t assign a password, so cannot login&lt;br /&gt;
     -H --no-create-home     Don&#039;t create home directory&lt;br /&gt;
     -u --uid UID            User id&lt;br /&gt;
     -k SKEL                 Skeleton directory (/etc/skel)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Tip|Multi-user collaboration&lt;br /&gt;
If &amp;lt;nowiki&amp;gt;--ingroup&amp;lt;/nowiki&amp;gt; isn&#039;t set, (default) the new user is assigned a new GID that matches the UID. If the GID corresponding to a provided UID already exists, adduser will fail.&lt;br /&gt;
&lt;br /&gt;
This ensures new users default to having a &amp;quot;user&#039;s private group&amp;quot; (UPG) as primary group. These allow the system to use a permission umask (002), which creates new files automatically as group-writable, but only by the user&#039;s private group. In special set-group-id (collaboration) directories, new files can be automatically created writable by the directory&#039;s group.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== addgroup ===&lt;br /&gt;
&lt;br /&gt;
Usage (from &amp;quot;man busybox&amp;quot;): &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;addgroup [-g GID] [-S] [USER] GROUP&lt;br /&gt;
&lt;br /&gt;
Create a group or add a user to a group&lt;br /&gt;
&lt;br /&gt;
    -g --gid GID    Group id&lt;br /&gt;
    -S --system     Create a system group&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Home directory permissions =&lt;br /&gt;
&lt;br /&gt;
`adduser` creates home directories with permissions `rwxr-sr-x`. This makes the directory readable by all other users on the system. If you prefer to not allow other users to read your home directory, the permissions can be changed:&lt;br /&gt;
&lt;br /&gt;
{{Cmd| chmod o-rx &amp;lt;path-to-directory&amp;gt;}}  &lt;br /&gt;
&lt;br /&gt;
= Legacy =&lt;br /&gt;
&lt;br /&gt;
=== Common permission groups ===&lt;br /&gt;
&lt;br /&gt;
{{Draft|Need to note a few security implications outlined on [https://wiki.debian.org/SystemGroups debian/wiki SystemGroups]}}&lt;br /&gt;
&lt;br /&gt;
Groups are needed for certain operations on your system.&lt;br /&gt;
&lt;br /&gt;
(Names taken from https://git.alpinelinux.org/alpine-baselayout/tree/group)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|adm         Used for system monitoring tasks.&lt;br /&gt;
disk        Raw access to disks.  &#039;&#039;&#039;Mostly equivalent to root access.&#039;&#039;&#039;&lt;br /&gt;
lp          Members of this group can enable and use printers.&lt;br /&gt;
wheel       Administrator group, members can use &#039;&#039;&#039;doas&#039;&#039;&#039; to run commands as root if enabled in the doas configuration.&lt;br /&gt;
floppy      Access to floppy drives and other removable (non-optical) drives (like USB flash drives).&lt;br /&gt;
audio       Direct access to sound hardware (the soundcard or a microphone).&lt;br /&gt;
cdrom       For access to disk writers and mounting DVD, BR or CD-ROM disk as normal user.&lt;br /&gt;
dialout     Full and direct access to serial ports.&lt;br /&gt;
input       Access to input devices.&lt;br /&gt;
tape        Needed to give a set of users access to a tape drive.&lt;br /&gt;
video       Access to video capture devices (like a webcam).&lt;br /&gt;
netdev      For network connections management as normal user.&lt;br /&gt;
kvm         Needed to use the KVM acceleration of virtual machines.&lt;br /&gt;
games       Access to some game software.&lt;br /&gt;
cdrw        Needed to write RW-DVD, RW-BR or RW-CD disk on a disk writing device.&lt;br /&gt;
usb         Needed to access special USB devices, deprecated group.&lt;br /&gt;
users       Needed if you plan to used common files for all users, mandatory as desktop usage.}}&lt;br /&gt;
&lt;br /&gt;
To add your user to a group use the following command:&lt;br /&gt;
{{Cmd|# adduser &amp;lt;username&amp;gt; &amp;lt;group&amp;gt;}}&lt;br /&gt;
{{Note|You need to log out for the group change(s) to take effect.}}&lt;br /&gt;
&lt;br /&gt;
To see what group(s) a &amp;lt;username&amp;gt; is in, use the following command:&lt;br /&gt;
{{Cmd|# id &amp;lt;username&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
= Old newbie notes =&lt;br /&gt;
&lt;br /&gt;
=== User creation and defaults ===&lt;br /&gt;
&lt;br /&gt;
The following commands will set up root environment login, then assign a new password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
cat &amp;gt; /root/.cshrc &amp;lt;&amp;lt; EOF&lt;br /&gt;
unsetenv DISPLAY || true&lt;br /&gt;
HISTCONTROL=ignoreboth&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /root/.cshrc /root/.profile&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;secret_new_root_password&amp;quot; | chpasswd&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, remote management cannot be done directly with the root account. Because of SSH security we need to set up a remote connection account that will be used to switch to the root user via the su command, once connected.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example: create user named &amp;quot;remote&amp;quot; and a user named &amp;quot;general&amp;quot;. We will set up a hardened, limited, user environment and create those two users:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /etc/skel/&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/skel/.logout &amp;lt;&amp;lt; EOF&lt;br /&gt;
history -c&lt;br /&gt;
/bin/rm -f /opt/remote/.mysql_history&lt;br /&gt;
/bin/rm -f /opt/remote/.history&lt;br /&gt;
/bin/rm -f /opt/remote/.bash_history&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/skel/.cshrc &amp;lt;&amp;lt; EOF&lt;br /&gt;
set autologout = 30&lt;br /&gt;
set prompt = &amp;quot;$ &amp;quot;&lt;br /&gt;
set history = 0&lt;br /&gt;
set ignoreeof&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /etc/skel/.cshrc /etc/skel/.profile&lt;br /&gt;
&lt;br /&gt;
adduser -D --home /opt/remote --shell /bin/ash remote&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;secret_new_remote_user_password&amp;quot; | chpasswd&lt;br /&gt;
&lt;br /&gt;
adduser -D --shell /bin/bash general&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;secret_new_general_user_password&amp;quot; | chpasswd&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Tip|&amp;quot;&#039;&#039;&#039;general&#039;&#039;&#039;&amp;quot; is the name of the user. That name MUST contain ONLY lowercase letters, NO spaces and NO symbols}}&lt;br /&gt;
&lt;br /&gt;
Note that those users are created with minimal privilege settings.&lt;br /&gt;
&lt;br /&gt;
== User management and system access ==&lt;br /&gt;
&lt;br /&gt;
By default, a newly created user will not have enough privileges for most desktop purposes.&lt;br /&gt;
&lt;br /&gt;
To add newly created users to groups that may come in handy for desktop useage, you run this command as root:&lt;br /&gt;
&lt;br /&gt;
{{cmd|for u in $(ls /home); do for g in disk lp floppy audio cdrom dialout video netdev games users; do addgroup $u $g; done;done}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/Users_and_groups Users and groups - Archwiki]&lt;br /&gt;
&lt;br /&gt;
[[Category: System_Administration]]&lt;/div&gt;</summary>
		<author><name>Vptr</name></author>
	</entry>
</feed>