Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create sudo account and automatically switch to it through a shell script. Must be run as root. Works on Ubuntu, Fedora and should work on other linux distros as well.
#!/usr/bin/env bash
#Add sudo user
echo "Enter account name to make sudo"
read account
adduser $account
echo "Done.."
#Adding username to sudo group
echo "Adding $account to sudo"
usermod -aG sudo $account
echo "Done.."
#Switching to sudo user
su - $account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.