This article provides a high-level guide for an installation of an Ubuntu based Linux server. It is the basis for many projects we are covering.
For all our guides, be aware that these are AIRIX.NET internal and are not suitable for absolute beginners.
Prerequisites
Starting point is that you are having an Ubuntu server up and running with Ubuntu Linux 24.04 LTS, be it in the cloud or on-premise at your home.
The cloud server we are using is hosted with Amazon's AWS Lightsail offering (What is Amazon Lightsail?). But there are several cloud providers on the market and you can choose the one that fits best to your demands.
Before going through the next steps about how to setup your own base server with Ubuntu Linux, you need to have a fully installed Ubuntu Server ready and running. If you do need to install a server with Ubuntu Linux first and want to set it up in the cloud, a high-level guide for Amazon's AWS Lightsail is available here: Create a Virtual Private Server on Amazon AWS Lightsail.
You should also have access to your server by SSH, e.g. with PuTTY and WinSCP (how to do this with Amazon Lightsail, you may refer to the article: Access to Your Amazon Lightsail Cloud Instance with PuTTY and WinSCP). For PuTTY and WinSCP you can also check this article: PuTTY - Telnet and SSH Client for Windows.
And, of course, you need basic Linux command line knowledge.
Update Ubuntu packages to the latest version
As soon as your server instance has been created or your home server has been connected to the Internet, it is available worldwide through its IP address. You should be aware that it may be attacked almost immediately. I remember that with one of my previous installations of a virtual private server in the cloud it took not more than 12 minutes before somebody tried to get access. But it can even be faster to have visitors at your door step trying to get in.
You can SSH into your Ubuntu system console and check the auth.log for suspicious entries. Enter nano /var/log/auth.log and scroll through the log:

And a newly created Linux server bit it from the a distribution or as a cloud instance based on a blueprint or template does probably not include the latest version of all programs and applications. Therefore, make an Update of your Ubuntu Linux immediately to get the latest version with all bug and security fixes.
For the update SSH into your Ubuntu Linux system and enter:
sudo apt update
sudo apt dist-upgrade
The apt command updates the packet information and the dist-upgrade runs the upgrade of the system. Especially when you have done this system upgrade for the first time or if a "reboot" is mentioned on the command line, do a reboot of your instance:
sudo reboot
Important: I recommend to do an package update and dist-upgrade quite frequently. I do it at least once a week (I create a snap shot from within the Amazon Lightsail console before and then keep it for one week, do the updates and delete the snap shot from the previous week) and, in addition, do the same before I begin working on the command line to install new programs and applications.
Setting the internal host name of Ubuntu Linux
SSH into your system and enter:
sudo hostnamectl set-hostname myhost
myhost is the new host name you want to set. Pick a name that is meaningful for you.
To activate the new host name, restart the server instance:
sudo reboot
Create & activate SWAP file on Ubuntu Linux
A swap file enables an operating system to utilize hard disk space to simulate additional RAM memory. Effectively, as the system goes on the low-memory mode, it swaps a certain section of the RAM that an idle program may be using onto the hard disk to release memory capacity for other vital programs. Subsequently, when the user returns to the swapped out program, it swaps places with another program in RAM. This intelligent mix of RAM and swap files allows the system to run a far greater number of programs than possible using only the built-in RAM.
The information written to disk will be significantly slower than information kept in RAM, but overall, having swap space as a fall back for when your system's RAM is depleted can be a good safety net against out-of-memory exceptions.
To use a swap file is the preferred approach, because we do not need to buy additional drive memory and can use the system disk already provided. My understanding is that there is no difference between using a swap partition or a swap file performance-wise - at least as long as the disk is not fragmented.
How much swap to create?
It seems that there is no exact answer to that. For the Ubuntu system I used the advice given here https://help.ubuntu.com/community/SwapFaq as an orientation:
For systems with less than 1 GB RAM, the swap space can be twice the amount of RAM.
For system with more than 1 GB RAM, the swap space should be at a minimum be equal to your physical memory (RAM) size and a maximum of twice the amount of RAM.
Create and enable Swap
You can start and check if swap space is already activated on your system. PuTTY into your system and enter:
sudo swapon --show
If you do not get back any information about swap, this means your system does not have swap space available currently.
1. To create a 1 GB (= 1024 MB) swap file with filename "swapfile" in directory /var:
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1024
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
The swap file has been created now. As a next step we add the swap file details to /etc/fstab, so it will be available at bootup:
2. Open /etc/fstab in editor nano:
sudo nano /etc/fstab
3. Add the following entry in /etc/fstab:
/var/swapfile swap swap defaults 0 0
Save the file (Ctrl-O) and exit Nano (Ctrl-X)
4. Enable swap:
sudo swapon -a
When everything worked fine, the swap file is available and activated.
When I set up my system the last time, I copied the line from above and pasted it into /etc/fstab. When I executed swapon, I got an error sapon: /etc/fstab: parse error. If you are having the same issue, check the section swapon: /etc/fstab: parse error below.
5. Check it with:
sudo swapon --show
It should give you information about the newly created swap file:

swapon: /etc/fstab: parse error
![]()
When you see the error swapon: /etc/fstab: parse error some control characters may have sneaked in when copy/paste.
From the command line enter:
cat /etc/fstab -v
and make sure that no suspicious characters are in there. After cleaning up, execute sudo swapon -a again.
Next Steps
At this point your Ubuntu Linux server is setup and ready. There are some more steps you may like to execute now, but they are optional and may not be relevant for all your use cases.
Install Midnight Commander File Manager
Midnight Commander is a file manager running under Linux Ubuntu. It is a clone of the Norton Commander from the early MS-DOS years that helps in navigating through the file system and supports several file management activities.
I normally install it on my Linux systems as it makes some file management easier: Midnight Commander File Manager Tool on Linux
Intrusion Prevention with Fail2Ban
As soon as your server is connected to the internet you can assume that it is under attack from somebody. Make sure that your firewall is configured and does not open anything which is not needed. Always ensure that your system is updated to its latest version.
As an additional measure, you can install Fail2Ban on your Linux server. Fail2Ban is an intrusion prevention software framework that protects computer servers from brute-force attacks. It checks the log files for specific patterns and bans IP addresses temporarily.
Refer to this article for more details: Intrusion prevention with Fail2Ban
Congratulations
Congratulations! Now you are having your Base Server with Ubuntu Linux up and running! This is now the foundation and starting for additional services and projects.
Related Articles