Password-less Sudo Instructions
Here's how to add a user and configure passwordless sudo on Debian and Ubuntu:
Adding a User
bash
# Add a new user (replace '<username>' with desired username)
sudo adduser <username>
# Or use useradd for more control
sudo useradd -m -s /bin/bash <username>
The adduser command is more user-friendly and will prompt you to set a password and user details. The useradd command with -m creates a home directory and -s /bin/bash sets the default shell.
Configuring Passwordless Sudo
Add user to sudo group
bash
# Add the user to the sudo group
sudo usermod -aG sudo <username>
# Configure passwordless sudo for the new user
sudo visudo
In the visudo editor, add this line at the end:
<username> ALL=(ALL:ALL) NOPASSWD:ALL
Verification
Test the configuration
# Switch to the new user
su - <username>
# Test sudo without password
sudo whoami
This should return "root" without prompting for a password.