Script to automate creating of new user and installing sudo on Debian 12
# Update APT cache
echo "Updating APT cache..."
apt update
# Install sudo
echo "Installing sudo..."
apt install -y sudo
# Prompt for new user
read -p "Enter the new username: " NEW_USER
# Check if user already exists
if id "$NEW_USER" &>/dev/null; then
echo "User $NEW_USER already exists. Exiting."
exit 1
fi
# Create the new user
adduser "$NEW_USER"
# Add user to sudo group
usermod -aG sudo "$NEW_USER"
echo "User $NEW_USER added to sudo group."
# Reboot
echo "Rebooting system..."
reboot