How to install VirtualBox guest additions on Ubuntu 20.04 VM command line?

Here is a quick installation guide for VirtualBox Guest Addition installation.

Step #1: Preparing your Ubuntu VM with required packages

Install the guest addition pre-requisites using the command below,

sudo apt-get install gcc make perl

Here in a picture:

Enter your user password and give y when prompted for confirmation to continue.

Step #2: Insert the guest addition CD image

From your VirtualBox VM window, go to Devices Menu and Click on Insert the guest addition CD image

This will mount the VirtualBox guest addition Virtual CD Disk to your Ubuntu Guest OS.

Step #3 Running the installer

  1. Open a commandline terminal
  2. Run the command sudo su –
  3. Enter the password exen prompted
  4. Go to your installation directory, using the command, cd /media/devops/VBox_GAs_6.1.26/
  5. Please refer to the notes after the image below if step #5 is showing error.
  6. Run the installer as ./runasroot.sh
  7. After installation, reboot the system.

Commands used:

[email protected]:~$ 
[email protected]:~$ sudo su -
[sudo] password for devops: 
[email protected]:~# 
[email protected]:~# 
[email protected]:~# cd /media/devops/VBox_GAs_6.1.26/
[email protected]:/media/devops/VBox_GAs_6.1.26# 
[email protected]:/media/devops/VBox_GAs_6.1.26# 
[email protected]:/media/devops/VBox_GAs_6.1.26# ./runasroot.sh 

Here are the steps in the picture:

Note: the path contains the username and VBox versions, in this example the username is devops and the VBox version is VBox_GAs_6.1.26. You may have to change these values to suit your environment. You can get the VBox version using the below command (after mounting as given in Step #2):

[email protected]:/media/devops# ls -l /media/devops/
total 3
dr-xr-xr-x 5 devops devops 2408 Jul 28 22:04 VBox_GAs_6.1.26

VirtualBox Guest Addition features

You have successfully installed the guest addition software. With this, you will have some very useful features like:

  • Enabling Shared-Clipboard – copy-paste between guest and host (Detailed guide to enable copy paste)
  • Enable Drag and Drop – you would be able to drag and drop files between guest and host
  • Set custome screen resolution for the Ubuntu Guest (shown in the below image)

FAQ: Installing guest addition on VirtualBox Ubuntu Desktop

All these steps will work on the Ubuntu command line, tested using ubuntu-20.04.3-desktop-amd64

FAQ: Installing guest addition on VirtualBox Ubuntu Server

VirtualBox Ubuntu server installation may not require the guest additions, if you need for any specific reason, the steps given below should just work.

Do you have more questions, please feel free to ask.