Commonly Used Tools
> sudo apt install mailutils mutt nmap vnstat build-essential
Configure Auto Update
Edit /etc/apt/apt.conf.d/50unattended-upgrades to enable the following:
- Install non-security updates
- Email notification after upgrade
- Auto remove unused kernel packages and dependencies
- Auto reboot if a reboot is required after upgrade
Configure Timezone
> sudo dpkg-reconfigure tzdata
PostgreSQL
> sudo apt install postgresql
create a regular user:
> sudo -u postgres psql template1 psql> create user cysun with createdb password 'abcd'; psql> create database cysun with owner=cysun; psql> \q
Leave out the createdb option in the CREATE USER statement if you do not want to grant the user the privilege to create databases.
Dotnet SDK
> wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb > sudo dpkg -i packages-microsoft-prod.deb > sudo apt update > sudo apt install dotnet-sdk-5.0
Nginx
For HTTP server I recommend Nginx over Apache as Nginx is not only faster, but for common setups Nginx configuration is also easier.
> sudo apt install nginx
Please check out Nginx Configuration on how to configure Nginx for various setups.
Java, Maven, and Tomcat
For Ubuntu Server, install openjdk-11-jdk-headless; for Ubuntu Desktop, install openjdk-11-jdk:
> sudo apt install openjdk-11-jdk-headless
Then install Maven and Tomcat 9:
> sudo apt install maven tomcat9
Edit /etc/default/tomcat9 to set min/max heap size, e.g.
JAVA_OPTS="-Djava.awt.headless=true -Xms512m -Xmx1500m"
The email server postfix should have already been installed after you installed the mailutils package, which allows you to send and receive emails.
You can set up aliases that allow one account to have multiple email addresses by editing /etc/aliases, then run the following command to inform postfix about the aliases:
> sudo newaliases
Another useful thing to do during development is to set up a catch-all email address to receive all the testing emails:
First edit /etc/postfix/main.cf to add the following line:
virtual_alias_maps = hash:/etc/postfix/virtual
Then create the file /etc/postfix/virtual with the following line (replace cysun with the account that serves as the catch-call address):
@localhost.localdomain cysun
Then make postfix aware of the changes:
> sudo service postfix reload
Now you can create many local email addresses (e.g. test1@localhost.localdomain, test2@localhost.localdomain and so on), and use one account to get all the emails.
Sudo and Environment Variables
Edit /etc/sudoers using visudo to add the following line:
Defaults env_keep += "HOME"
This will keep the HOME environment variable when using sudo. This is needed for running account management scripts on CS3 as the MySQL functions rely on authentication credentials stored in $HOME/.mylogin.cnf (see mysql_config_editor for more details).
User Management
Function | Command |
---|---|
Add a user | sudo adduser <username> |
Add a user to a groupo | sudo usermod -aG <group> <username> |
List the groups a user belongs to | groups <username> |
Remove a user | sudo deluser --remove-home <username> |