Skip to content

Instantly share code, notes, and snippets.

@1allen
Last active July 18, 2023 14:06
Show Gist options
  • Save 1allen/5815555 to your computer and use it in GitHub Desktop.
Save 1allen/5815555 to your computer and use it in GitHub Desktop.
ubuntu vps initial config
#!/bin/bash
# arrange sources.list if needed
# https://repogen.simplylinux.ch/
# cleanup & upgrade
sudo apt update
# in case of broken gpg keys
# W: GPG error: http://extras.ubuntu.com **** Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <key id>
# add missing and update once again:
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <key ids>
#sudo apt update
# go on
sudo apt install htop bash-completion mc nano deborphan -y
# make add-apt-repository available
sudo apt install python-software-properties
# or
#sudo apt install software-properties-common
sudo apt purge apache2* sasl2-bin sendmail* bind9* samba* xinetd* -y
sudo rm -rf /var/cache/bind /etc/bind /usr/share/bind9
sudo rm -rf /usr/share/doc/sendmail
sudo apt full-upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove --purge
sudo apt autoclean
# probably you'll need to repeat the following some times
sudo apt purge `deborphan --guess-all -n`
# locales stuff
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
# cleanup this
sudo apt install localepurge
#sudo dpkg-reconfigure localepurge
sudo localepurge
# timezone
sudo dpkg-reconfigure tzdata
# ssh security
sudo apt install sshguard
# exim instead of sendmail
# optional
#sudo apt install exim4
#sudo dpkg-reconfigure exim4-config
# rsyslogd instead of klogd/sysklogd
# optional
#sudo apt install rsyslog -y
# in case of 100% cpu utilization
#sudo sed -i '/^$ModLoad imklog/ s/^/#/' /etc/rsyslog.conf
#sudo service rsyslog restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment