Top 4 Things To Do On A Fresh Ubuntu Server

A fresh and newly provisioned server is a clean slate for a lot of ideas and projects. Here are the various things you can do on a new Ubuntu server to ensure smooth project setup.

Update and upgrade

Install the latest security patches and upgrades to the existing applications.

$ sudo apt-get update
$ sudo apt-get upgrade

Add a new sudo-er user

With a newly provisioned server you will be given a default user account. This account usually have access to root or is a sudo-er. The user you add here requires you to use an SSH key instead of password. You need to create your own keys using tools or CLI.

If you already have your key pair, you can continue to step 5

01. To generate a key-pair in your terminal, execute the following. An email address is usually provided as the comment for the key.

08. Update the swappiness factor if preferred. This value determines the behavior if it should put it into swap rather than RAM. The lower the value, the less chance it will put into swap. The value ranges from 0 to 100. With the default swappiness value of 60.

Set the swappiness by running the following command

Format

$ sudo sysctl vm.swappiness={{swappiness-value}}

Example

$ sudo sysctl vm.swappiness=10

To make it permanent, update the /etc/sysctl.conf file.

$ sudo nano /etc/sysctl.conf

And add the following add the bottom

Format

$ vm.swappiness={{swappiness-value}}

Example

$ vm.swappiness=10

09. Verify the swap using the following command

$ free -hm

Add timestamp to your bash history

01. Switch OS user you want to add timestamp

$ sudo su - {os-user}

02. Run the following to update the bashrc file.

$ echo 'export HISTTIMEFORMAT="%y %m %d %T "' >> ~/.bashrc

03. Then apply the changes made

$ source ~/.bashrc

04. Check the bash history if it has been updated. It should now output the history with date and time info. Note that commands executed before this process is not the actual date and time. But for the new commands, it will reflect the date and time when it is executed.