These commands create a new user, set their password, add them to the wheel group, and enable sudo access.
Run them as root or from an account that already has sudo access.
Copy and paste the entire block:
read -P "Username: " username
read -sP "Password: " password
echo
sudo useradd -m -G wheel -s /bin/bash $username
echo "$username:$password" | sudo chpasswd
sudo sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
echo
echo "User '$username' created successfully."
echo "The user has sudo access through the wheel group."If you are already logged in as root, remove sudo from the commands:
read -P "Username: " username
read -sP "Password: " password
echo
useradd -m -G wheel -s /bin/bash $username
echo "$username:$password" | chpasswd
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
echo
echo "User '$username' created successfully."
echo "The user has sudo access through the wheel group."Copy and paste the entire block:
read -rp "Username: " username
read -rsp "Password: " password
echo
sudo useradd -m -G wheel -s /bin/bash "$username"
echo "$username:$password" | sudo chpasswd
sudo sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
echo
echo "User '$username' created successfully."
echo "The user has sudo access through the wheel group."If you are already logged in as root:
read -rp "Username: " username
read -rsp "Password: " password
echo
useradd -m -G wheel -s /bin/bash "$username"
echo "$username:$password" | chpasswd
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
echo
echo "User '$username' created successfully."
echo "The user has sudo access through the wheel group."After creating the account, verify that it belongs to wheel:
id usernameYou should see wheel in the groups.
Then switch to the new user:
su - usernameTest sudo:
sudo whoamiIt should output:
root
The wheel group must have this line enabled in /etc/sudoers:
%wheel ALL=(ALL:ALL) ALL
It is safer to edit /etc/sudoers with visudo if you are manually changing it:
sudo visudoThen uncomment:
%wheel ALL=(ALL:ALL) ALL
If your Arch installation already has this line enabled, you don't need to modify /etc/sudoers at all.