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

VirtualBox install guest additions ubuntu command line guide

CodeTryout provides version specific articles to install VirtualBox guest additions installation steps. vbox guest additions Ubuntu 22.04 and vbox guest additions Ubuntu 20.04. Please choose the article according to your Ubuntu version.

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

Step #1: Preparing your Ubuntu VM with the required packages

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

sudo apt-get install gcc make perl

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 command-line terminal
  2. Run the command sudo su –
  3. Enter the password, when prompted
  4. Go to your installation directory, using the command, cd /media/devops/VBox_*/
  5. Please refer to the notes after the image below if step #5 is showing an error.
  6. Run the installer as ./runasroot.sh
  7. After installation, reboot the system.

Commands used:

devops@codetryout:~$ 
devops@codetryout:~$ sudo su -
[sudo] password for devops: 
root@codetryout:~# 
root@codetryout:~# 
root@codetryout:~# cd /media/devops/VBox_GAs_*/
root@codetryout:/media/devops/VBox_GAs_6.1.26# 
root@codetryout:/media/devops/VBox_GAs_6.1.26# 
root@codetryout:/media/devops/VBox_GAs_6.1.26# ./runasroot.sh 

Note: Ignore the version number shown above, your VBox guest version could be different from the above.

Demo:

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):

root@codetryout:/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

Step #4 VirtualBox guest additions check if installed

You can verify whether your VBox addition steps were successful, by running the following command

lsmod | grep vbox

A successful installation would display the output of the command as shown here:

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 custom screen resolution for the Ubuntu Guest (shown in the below image)

FAQs

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 them for any specific reason, the steps given below should work.

FAQ: Installing guest additions in older versions of Ubuntu, such as Ubuntu 22.04?

Codetryout has another page explaining the steps required for VirtualBox guest additions on Ubuntu 22.04 VM

FAQ: How to enable files or folders copy-pastes between Virtualbox Host and guests?

We have another experiment explaining this, please refer to How to enable copy-pastes in Virtualbox Ubuntu VM

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

FAQ: Error [SOLVED] ..attempt to execute command with root privileges displaying description if possible.

If in case you are getting this error while running the script, ./runasroot.sh, try the below:


devops@codetryout:~$ 
devops@codetryout:~$ sudo su -
[sudo] password for devops: 
root@codetryout:~# 
root@codetryout:~# 
root@codetryout:~# cd /media/devops/VBox_GAs_*/
root@codetryout:/media/devops/VBox_GAs_6.1.26# 
root@codetryout:/media/devops/VBox_GAs_6.1.26# 
root@codetryout:/media/devops/VBox_GAs_6.1.26# ./VBoxLinuxAdditions.run

All other steps remain the same.

FAQ: What are the latest changes and features added to VBox Guest addition packages?

You can check this page for the detailed changelog: VirtualBox User Manuel – ChangeLog

Related: How to install Ubuntu 22.04 VM using the VirtualBox 7 unattended method