Virtualize Your Ubuntu Server Experience: A Hands-On Installation Guide

Step-by-Step Guide to Installing Ubuntu Server on VirtualBox

Virtualize Your Ubuntu Server Experience:  A Hands-On Installation Guide

Linux systems are among the most widely used and scalable operating systems currently available. If you become skilled in using Linux, many career opportunities will open up. The most common Linux system is Ubuntu. In this article, I will show you how you can spin up your Ubuntu 22.04 server in Virtual Box.

Introduction

There are a few ways you can install your Ubuntu OS, the most common one is installing it on a hard drive. It can be good in terms of performance as Ubuntu will use all the resources available. However, it is highly likely that you may make some mistakes and need to re-install the OS. Plus you have to free up a lot of space to install the OS. If you already have some experience with Linux this may be the suitable way. But if you are a beginner, a more robust way is preferable. For that, you can create a server in the cloud. Services like Digitial Ocean or Linode let you create a Linux server with minimum resources for $5 - $6 per month. However, I will recommend creating your virtual machine. Both Ubuntu Server and VirtualBox are free to download. You will have all the controls over the server. You can connect two or more computers to the same network and create your own Cloud Native Environment.

Download Links

Virtual Box

Ubuntu Server

Creating Virtual Machine

By default, a virtual machine will have 2GB Ram, 1 CPU, and a NAT network adapter. If you have >= 12GB of Ram, you can assign 4GB. Setting the VM with 2 CPU processors is important. With more computing power, Ubuntu Server can handle requests faster. You can run a service in one terminal and run your commands in another without any issues. Most importantly, change your network adapter from NAT to Bridge. If you are not sure, you can check it on your machine. Open terminal, in Windows type ipconfig /all and in Linux run ip addr to see the network adapter. When you create a new virtual machine, VirtualBox will automatically create a virtual network adapter called "NAT" that allows the virtual machine to access the internet, but not the host machine or other machines on the same network as the host. By creating a bridge adapter, you can connect the virtual machine to the same network as the host machine, allowing it to communicate with other machines on the network as well as the host machine.

Selecting the right adapter is very important. If not done correctly, you cannot access your VM from your host or any other device in the same network.

Steps

  1. Open virtual box manager

  2. Click on new

  3. Give a name to Virtual Machine Ubuntu Server

  4. Select the Ubuntu Server ISO image

  5. Click Next

  6. Give username ubuntu

  7. Set a password

  8. Set hostname Ubuntu

  9. Click Next

  10. Set Base Memory, 4096mb

  11. Processors 2 CPU

  12. Click Next

  13. Disk size 25 GB

  14. Click Next

  15. Review Summary

  16. Click Finish

  17. Close Virtual Machine. Need to setup network

  18. Select ubuntu Server virtual machine

  19. Click on Network

  20. In Adapter 1, change to Bridge Adapter from NAT

  21. Select your Machine's Driver in Name

  22. Click Ok

  23. Start virtual machine

Install Ubuntu Server

Write down the username and password in a text file, so that you don't need to remember them. You can note the IP address in the Network Connections setup screen. OpenSSH (Open Secure Shell) is a free, open-source implementation of the SSH (Secure Shell) protocol. SSH is a network protocol that allows for secure, encrypted connections between computers. Make sure you select the OpenSSH option. Once installed, you can configure the firewall to access Ubuntu Server through SSH from any device in the network. This is a cool feature, you can use apps like JuiceSSH, Termux, or ConnectBot to access the server from your mobile and practice your Linux skills.

Steps

  1. Select install Ubuntu Server

  2. Select your preferred language, English

  3. If an update is available, select Update to new installer

  4. Select preferred, then click Done

  5. Select Ubuntu Server, selected by default

  6. In Network connections screen, select Done. As Network Adapter is already selected as Bridge, the virtual machine will automatically select an IP address from the DHCP server. The host machine can connect to the virtual machine using this IP Address.

  7. If you have a proxy server in your network, then you need to add the proxy address. Let it remain empty, and click on Done.

  8. No need to change, Mirror address. Click Done

  9. Select Use an entire disk, selected by default. Click Done

  10. Review system summary

  11. Click Done

  12. Click Continue

  13. Fill out the form. Name Your Name, Server name: ubuntu, username: ubuntu, password: secret.

  14. Click Done

  15. Select Install OpenSSH Server, not selected by default. Click Done

  16. Click Done. No need to select any software

  17. Once the installation is finished, click Reboot Now

Verify Installation

  1. Login using username and password

  2. Run ping google.com . If installed properly, your Ubuntu Server should be able to connect to the internet and receive data from google.com

  3. Run in order sudo apt update, sudo apt install nginx, sudo systemctl status nginx or sudo systemctl is-active nginx, sudo fuw status, if the result is inactive then sudo ufw enable, sudo ufw allow http, sudo ufw reload

  4. Type ip addr to get the IP address. IP addresses always change so check each time a new Virtual Machine is created

  5. Open the IP address in the browser, Nginx welcome page should be visible

  6. To use SSH, need to know the PORT on which OpenSSH is running

  7. Run sudo apt install net-tools

  8. Run sudo netstat -ltnp | grep sshd to check on which PORT OpenSSH is running

  9. Run sudo ufw allow 22/tcp, assuming 22 is the port

  10. Run sudo ufw reload and sudo ufw app list to check 22 port is allowed

  11. Open terminal in Host. Run ssh ubuntu@your.vm.ip.addr and enter yes if prompted and then password to login to the system.