Do not disable remote root access or change sudo policy before testing the new user in a second session.
1. Create the user
useradd -m -s /bin/bash adminuser
passwd adminuser
2. Add to wheel group
usermod -aG wheel adminuser
id adminuser
3. Configure sudo
Always edit with visudo:
visudo
Enable the wheel line (typical example):
%wheel ALL=(ALL:ALL) ALL
The
/etc/sudoers file can vary. Use visudo to avoid syntax errors.4. Privilege test
su - adminuser
sudo -v
sudo whoami
If
sudo whoami returns root, the base configuration is correct.5. Best practices
- Use strong passwords
- Avoid daily root logins
- Log administrative activity via sudo/logs
- Limit who is in the wheel group
6. Common errors
- User not in
wheelgroup - Wheel line not enabled in sudoers
- Editing sudoers with a regular editor (broken syntax)
Quick checklist
[ ] Admin user created
[ ] Wheel group assigned
[ ] sudoers edited with visudo
[ ] sudo -v / sudo whoami tested
[ ] Direct root access limited (if desired)