How to Install VirtualBox on Ubuntu Using the Command Line (2025 Guide)

VirtualBox is one of the most popular open-source virtualization tools used by developers, testers, and power users. Whether you’re setting up a virtual lab, experimenting with other OSes, or managing legacy systems, VirtualBox provides a powerful and flexible solution.

In this guide, we’ll walk through how to install VirtualBox on Ubuntu (22.04 or later) entirely through the command line.


Step 1: Update Your System

First, make sure your system is up to date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

You’ll need a few packages to handle repositories and keys:

sudo apt install -y wget gnupg2 software-properties-common

Step 3: Add the VirtualBox Repository

Oracle provides a Debian-based repository for VirtualBox. Add it like this:

Add Oracle GPG Key:

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox.gpg

Add VirtualBox Repository:

echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Step 4: Refresh Package List

Run the update command again to fetch packages from the new repo:

sudo apt update

Step 5: Install VirtualBox

To install the latest stable version (e.g. 7.0):

sudo apt install -y virtualbox-7.0

If you need a specific version (like 6.1), just replace the version number accordingly.


Optional: Install the Extension Pack

The Extension Pack enables USB 2.0/3.0 support, RDP, disk encryption, and more advanced features.

Download and install it as follows:

wget https://download.virtualbox.org/virtualbox/7.0.14/Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack

💡 Note: Make sure the version of the Extension Pack matches your installed VirtualBox version.


Final Step: Verify Installation

Check if VirtualBox is properly installed:

vboxmanage --version

If you see the version number, you’re good to go!


Bonus Tips

  • Start the GUI version (if needed): just run virtualbox in the terminal.
  • Headless VM management is also possible entirely through VBoxManage—ideal for servers.
  • Vagrant integration makes working with repeatable VMs even easier.

Conclusion

With just a few commands, you can install a full-featured VirtualBox setup on Ubuntu. Whether you’re testing Android builds, running Windows VMs, or simulating complex networks, VirtualBox gives you the flexibility to experiment safely.

Leave a Reply

Your email address will not be published. Required fields are marked *