oobe: Let the user know they're in wheel and have passwordless sudo

Also include the command to set a password, if they wish.
This commit is contained in:
Jeremy Cline 2025-02-18 10:23:35 -05:00
parent 3fb3ab214e
commit aae108edd0
No known key found for this signature in database

View File

@ -25,7 +25,11 @@ read -r -p 'Enter new UNIX username: ' username
/usr/sbin/useradd -m -G wheel --uid $DEFAULT_USER_ID "$username" /usr/sbin/useradd -m -G wheel --uid $DEFAULT_USER_ID "$username"
cat > /etc/sudoers.d/wsluser << EOF cat > /etc/sudoers.d/wsluser << EOF
# Ensure the WSL initial user can use sudo # Ensure the WSL initial user can use sudo without a password.
#
# Since the user is in the wheel group, this file can be removed
# if you wish to require a password for sudo. Be sure to set a
# user password before doing so with 'sudo passwd $username'!
$username ALL=(ALL) NOPASSWD: ALL $username ALL=(ALL) NOPASSWD: ALL
EOF EOF
@ -36,3 +40,6 @@ cat >> /etc/wsl.conf << EOF
[user] [user]
default = "$username" default = "$username"
EOF EOF
echo 'Your user has been created, is included in the wheel group, and can use sudo without a password.'
echo "To set a password for your user, run 'sudo passwd $username'"