Files
linux-workspace/scripts/sudo-user.sh
2024-09-10 06:10:01 +02:00

15 lines
331 B
Bash
Executable File

#!/bin/bash
# oneliner for quick copy
# echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$USER
set -E -o errexit -o nounset -o pipefail
USER_FILE="/etc/sudoers.d/$USER"
if [[ -f $USER_FILE ]]; then
echo "Sudo file $USER_FILE already exists!"
exit 1
fi
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee $USER_FILE