<?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=Maximium</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=Maximium"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Maximium"/>
	<updated>2026-04-30T23:12:18Z</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=21593</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=21593"/>
		<updated>2022-02-10T19:27:37Z</updated>

		<summary type="html">&lt;p&gt;Maximium: Use uppercase letter in addgroup -S option&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 $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;
&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, adduser 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;
&lt;br /&gt;
&#039;&#039;&#039;Only&#039;&#039;&#039; if &amp;lt;code&amp;gt;elogind&amp;lt;/code&amp;gt; is not being used and running, then X users would need to be added to the video and input groups to be able to work with a graphical display.&lt;br /&gt;
 adduser &#039;UserName&#039; video&lt;br /&gt;
 adduser &#039;UserName&#039; input&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 wheel group, &amp;lt;code&amp;gt;doas&amp;lt;/code&amp;gt; (&amp;quot;do as&amp;quot;) may be installed, and the group &amp;quot;wheel&amp;quot; can be allowed to become root:&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;
 apk add nano&lt;br /&gt;
 nano /etc/doas.conf&lt;br /&gt;
&lt;br /&gt;
Ensure that this file contains&lt;br /&gt;
 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;
* 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;
* [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;
}}&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 -d &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;
&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:Linux User,,,:/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;
= Legacy =&lt;br /&gt;
&lt;br /&gt;
=== Common permission groups ===&lt;br /&gt;
&lt;br /&gt;
(Taken from https://git.alpinelinux.org/alpine-baselayout/tree/group)&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;disk&#039;&#039;&#039;:x:6:root,adm  needed only for use vith virtual machines and access to other partitions.&lt;br /&gt;
* &#039;&#039;&#039;lp&#039;&#039;&#039;:x:7:lp  needed for printing services and printers management.&lt;br /&gt;
* &#039;&#039;&#039;wheel&#039;&#039;&#039;:x:10:root  Administrator group, members can use &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; to run commands as root if enabled in the sudo configuration.&lt;br /&gt;
* &#039;&#039;&#039;floppy&#039;&#039;&#039;:x:11:root  Backward compatible group. Use only if access to special external devices is needed.&lt;br /&gt;
* &#039;&#039;&#039;audio&#039;&#039;&#039;:x:18:  Needed for audio listening and management of sound volume as normal user.&lt;br /&gt;
* &#039;&#039;&#039;cdrom&#039;&#039;&#039;:x:19:  For access to CD/DVD/BR writers and mounting DVD, BR or CD rom disk as normal user.&lt;br /&gt;
* &#039;&#039;&#039;dialout&#039;&#039;&#039;:x:20:root  Needed for dialing private connections and use of modems as normal user.&lt;br /&gt;
* &#039;&#039;&#039;tape&#039;&#039;&#039;:x:26:root  Needed if you&#039;re planning to use special devices for backup. Rare. Ususally used only on servers.&lt;br /&gt;
* &#039;&#039;&#039;video&#039;&#039;&#039;:x:27:root  For usage of cameras, more than one GPU special features, as normal user.&lt;br /&gt;
* &#039;&#039;&#039;netdev&#039;&#039;&#039;:x:28:  For network connections management as normal user.&lt;br /&gt;
* &#039;&#039;&#039;kvm&#039;&#039;&#039;:x:34:kvm Only if a normal user will manage virtual machines via a GUI. Rare. Ususally used only on servers.&lt;br /&gt;
* &#039;&#039;&#039;games&#039;&#039;&#039;:x:35:  Needed if you want to play games. Especially if sharing scores between users.&lt;br /&gt;
* &#039;&#039;&#039;cdrw&#039;&#039;&#039;:x:80:  Needed to write RW-DVD, RW-BR or RW-CD disk on a disk writing device.&lt;br /&gt;
* &#039;&#039;&#039;apache&#039;&#039;&#039;:x:81: Needed if you do development as normal user and want to publish locally on web server.&lt;br /&gt;
* &#039;&#039;&#039;usb&#039;&#039;&#039;:x:85: Needed to access to special usb devices. Deprecated group.&lt;br /&gt;
* &#039;&#039;&#039;users&#039;&#039;&#039;:x:100:games Needed if you plan to use common files for all users. Mandatory for desktop usage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&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;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
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;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maximium</name></author>
	</entry>
</feed>