Skip to content

Instantly share code, notes, and snippets.

@codarrenvelvindron
Created March 20, 2018 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codarrenvelvindron/a313b1c53b9411c8fda9f40acd2c5403 to your computer and use it in GitHub Desktop.
Save codarrenvelvindron/a313b1c53b9411c8fda9f40acd2c5403 to your computer and use it in GitHub Desktop.
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