Last active
June 22, 2021 21:36
-
-
Save amberj/7e141f6140a2f4932b93 to your computer and use it in GitHub Desktop.
Initial setup of hosted VPS (which comes with 'root' access by default)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc | |
echo "export LANG=en_US.UTF-8" >> ~/.bashrc | |
echo "export LC_CTYPE=en_US.UTF-8" >> ~/.bashrc | |
echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc | |
sudo locale-gen en_US.UTF-8 | |
sudo dpkg-reconfigure locales | |
# If the server is running some Ubuntu variant: | |
# Update APT database and install some essentials | |
sudo apt update | |
sudo apt install tmux nano wget curl elinks | |
# Run this command to see the Ubuntu version running: | |
sudo lsb_release -a | |
# Run this command to upgrade Ubuntu to newer version: | |
sudo apt update | |
sudo apt upgrade | |
sudo do-release-upgrade | |
# 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