1. Launch VirtualBox and power on the Ubuntu Server virtual machine. When the server boots, log in to access the virtual machine.
2. Once logged into the terminal of the virtual machine, click the ‘Devices’ tab at the top of the virtual machine’s terminal. Select ‘Insert Guest Additions CD Image’ from the dropdown.
3. The VirtualBox Guest Additions CD Image will now be inserted into the virtual cd drive of the virtual machine. The virtual CD-ROM must be mounted before we can see the contents of the CD image. Mount the device with the following command:
sudo mount /dev/cdrom /mnt
4. The CD image is now mounted at /mnt. To enter the directory, enter the following command:
5. Enter the following command to view the contents of the VirtualBox Guest Additions CD Image:
6. Before installing the Guest Additions package, we must make sure that all dependencies that are required are installed. To install the dependencies, enter the following command:
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
7. Once the necessary packages finish installing, switch to the root user by entering the following command followed by your sudo password:
8. Now that we are using the root user, we have the necessary permissions to execute the VirtualBox Guest Additions installer. To execute the installer, enter the following command into the terminal:
9. VirtualBox Guest Additions will begin installing. We are notified that the process may take a while. We are then prompted to restart the machine to apply the changes.
10. Now that VirtualBox Guest Additions are installed, restart the virtual machine by entering the following command:
11. The Ubuntu Server 18.04 LTS virtual machine will reboot and apply the VirtualBox Guest Additions package. Congratulations! The installation of VirtualBox Guest Additions in the Ubuntu Server 18.04 LTS virtual machine is complete. Log in to your virtual machine after it reboots and begin reaping all of the benefits of the Guest Additions package.