Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Initial setup of hosted VPS (which comes with 'root' access by default)
#!/bin/bash
# ABOUT:
#
# Use this set of commands to:
# - Change password of root account
# - Create a new user account, set it's password and grant sudo privileges
# on Ubuntu Linux.
# Change password of currently logged in 'root' account:
passwd
# Enter new password twice!
# Create new user 'user'
# -d means set the user's home directory to '/home/user'
# -m enforces useradd to create the home directory
sudo useradd -d /home/user -m user -s /bin/bash
# Set password for 'user'
sudo passwd user
# Enter password twice!
# Grant 'sudo' privileges to 'user'
sudo usermod -a -G sudo user
# Fix locale settings
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
# Now exit the root account using 'exit' command and then re-ssh as 'user'
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.