Skip to content

Instantly share code, notes, and snippets.

@pacharanero
Last active January 6, 2024 11:56
Show Gist options
  • Save pacharanero/1468b8ce95d410da57f84e751d02e5e2 to your computer and use it in GitHub Desktop.
Save pacharanero/1468b8ce95d410da57f84e751d02e5e2 to your computer and use it in GitHub Desktop.
#!/bin/bash -x
set -e
# set a default new username
# if you set NEW_USERNAME="other_username" before running the script, it will use your value
NEW_USERNAME="${NEW_USERNAME:-marcus}"
# add update script
echo """doupdates () {
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get -y autoclean
}""" | sudo tee -a /etc/profile
source /etc/profile
# set unattended upgrades
dpkg-reconfigure -plow unattended-upgrades
# create new user
adduser $NEW_USERNAME
# add new user to sudo group
usermod -aG sudo $NEW_USERNAME
# add to sudoers file
echo "$NEW_USERNAME ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment