While the options for Ubuntu are many, getting a simple, solid foundation is important. This how-to will explain setting up a Ubuntu 20.04 server using VirtualBox on your LAN (local area network).
If you don’t know what VirtualBox is, it is a virtualization program you can install on Windows and Linux desktops that allow you to run another operating system (or the same) as it a VM (virtual machine) in it’s own “container” if you will. So, for example, if you have a Windows computer and you want to try out Ubuntu Linux, you could create that VM in VirtualBox and you can use it as if it were it’s own computer.
Pre-Setup: That being said, we need a few things to get started with this.
- First, you need to download and install a copy of Oracle VM VirtualBox. This article is going to assume you are using Windows, but the setup for Linux isn’t a lot different.
- You will also need to download a operating system to install. Again, this how-to is explaining Ubuntu 20.04 server, but you can install a wide variety of operating systems in VirtualBox.
- You will need to make sure that you have adequate hard disk space to deploy the VM as well as sufficient memory to allocate to the VM. It should be noted that these VM’s use the current computers resources. So if you have a 500GB hard drive and 8GB of RAM and allocate 400GB disk space and 6GB of RAM, things will run slowly.
- You will also need a working internet connection on the computer your are setting up VirtualBox. There are updates and other pertinent downloads that will be required when setting up Ubuntu.
That is pretty much it. Now, let’s get on with setting things up.
- It is assumed you have successfully installed, launched VirtualBox and created a VM for Ubuntu Server. If you have not, you can follow the instructions HERE.
- The next step is to install Ubuntu server and then finish with tightening up the installation.
- Select the Ubuntu Server VM you created and click the green Start arrow icon to launch it.
- Next, select your language and hit ENTER, then select Done and hit ENTER again
- The next screen will configure your network with DHCP. Use your TAB key to select Done and then hit ENTER.
- In most cases you can hit enter at the next screen, but if you require a proxy address, you can enter it here, select Done and then hit ENTER.
- The next screen is for the default Ubuntu mirror address, you can hit ENTER here.
- For the purposes of this tutorial, we are using the entire virtual disk we created during setup. You can do custom configurations here, but that is beyond the scope and need of this tutorial, so use your TAB key to select Done and then hit ENTER.
- At this screen select Done and hit ENTER. TAB to the Continue option and hit ENTER.
- On the next screen enter your default user information, password and system name. Be aware Linux is case-sensitive, so use all lowercase and no spaces in you server name and username. Once you have all the fields filled out, TAB to Done and hit ENTER.
- If you have a Ubuntu Advantage Token enter it here, otherwise select Done and hit ENTER.
- Leave the box UNCHECKED to install OpenSSH server. We will be doing this later. TAB to Done and hit ENTER.
- You can install a LOT of options, but again, for this tutorial, we will TAB to Done and hit ENTER.
- Now, sit back, grab some coffee and wait as the system begins to install itself.
- When the “Reboot Now” appears at the bottom, TAB to it and hit ENTER to reboot. You will get a failure saying it cannot remove the CD media. Hit ENTER and the reboot will continue.
- Next you will see the login. However, wait a few minutes as the system has to catch-up and will continue to install additional items. When you see “Reached target Cloud-init targe.” Hit ENTER and you will see the login prompt.
- Type in the username you created and hit ENTER. Type in the password you created and hit ENTER.
- You should now be logged into a working Ubuntu Server environment.
The account you are logged into is not a root account. In Linux you do not want to use the root account for normal operations. Your created account is part of a group called “sudoers” which allows you to install and configure things with elevated privileges. You do this by typing sudo then the command you wish to execute. It will prompt you for your password and then execute the command.
This is important because we will be installing things that will require the use of sudo almost every time. Ubuntu server is command-line only, there is GUI (Graphical User Interface) like Windows or the desktop version of Ubuntu. You will do EVERYTHING from the command-line.
**NOTE** In the code below you will a $ at the beginning of the code. This is just to show the beginning of the command line. You do NOT type that in when entering the code. If you copy and paste the code, do not copy the $ symbol.
We will now begin installing some basic items that will be necessary for functional server, that satisfy various future application dependencies, and will give you a much more controlled and tightened operating system.
The preferred method for install things in Debian-based (this includes Ubuntu) Linux systems is with apt. There are other methods (such as yum and dpkg) but apt is by far the normal way to install/uninstall things.
The first thing we need to do is update apt.
$ sudo apt updateOnce that has completed we are going to install SSH. The benefit of using SSH is that we can open a local command prompt in Windows (or Terminal in Linux) and connect to the VM via SSH. This makes copying and pasting a breeze as well as allowing you access the VM from a different computer on your network. To do this, type in the following:
$ sudo apt install sshNow, from the command line you will type in ip a which will allow us to see what IP address was assigned to the VM. Usually this is the second interface (many times identified as something similar to enp0s3) and is the second line (inet – not inet6). In my case, my DHCP server uses the 192.168.0.x/24 subnet so I know to look for that type of IP address. This is a fairly common router DHCP configuration, however, yours might something different. Do NOT use the 127.0.0.1, that is the loopback IP.
Once you have your IP address open a command prompt on your Windows computer and type in the following:
ssh -l <yourusername> <youripaddresshere>
You will get prompted about the authenticity of the host. Type in yes and then hit ENTER. You will then be required to enter the password for your Ubuntu user account. Enter it and then hit ENTER. You will now be at the command line of your Ubuntu server VM.
Now, lets move on and configure some essential items.
The first is “build-essential” which includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software. At the command line type in:
$ sudo apt install build-essentialNet we will install “software-properties-common” which provides an abstraction of the used apt repositories. It allows you to easily manage your distribution and independent software vendor software sources.
$ sudo apt install software-properties-commonNext up is “network-manager” which is a system network service that manages your network devices and connections, attempting to keep active network connectivity when available.
$ sudo apt install network-managerFinally, we will install “zip” and “unrar” both of which are compression tools to aid in handling compressed files using the .zip and .rar compression techniques.
$ sudo apt install zip unrar-freeThe last thing we want to install ensures everything that has been installed is up to date. To do this enter the following:
$ sudo apt upgradeAnd that is it… You could at this point install other things, all depending on how you plan on using your Ubuntu server.
But let’s do one last thing!
Now that you have a working, updated and fully functional base Ubuntu server we should use VirtualBox to take a snapshot of this current state. The reason behind this is that if you begin installing things, making configuration changes and things start to go south on you, you have a way to restore back to this pristine state and you can start again.
**NOTE** Be aware that this uses up hard drive space on your host system. So you need ensure you have enough disk space before creating a snapshot.
Here are the steps involved in taking a snapshot of a VM
- First, go back to VirtualBox and select your VM
- On that highlighted VM you will see an icon that is three dots and three dashes, click that and then choose “Snapshots”
- At the top, click the camera with the green plus symbol that has “Take” below it
- You can name the snapshot whatever you wish. I would also suggest putting some information in the Snapshot description such as “base install with basic utilities installed” for future reference. Click OK.
And that is it!
You now have a working Ubuntu server system, accessible via SSH, with a clean snapshot for original restoration purposes. At this point you can begin to determine what you plan on doing with the server – whether it is install Apache, PHP and mySQL to server webpages, setting up a server to host Minecraft, configuring a file sharing server, or installing Docker and learning about containers, etc.
I hope this how-to was useful. If you find any errors, typos or have any questions, feel free to leave me a comment. Thanks!!

Comments
Post a Comment