Installing VirtualBox on Ubuntu is a straightforward process that enables users to run multiple operating systems on a single machine. This guide provides a step‑by‑step tutorial on how to install vbox on ubuntu, covering prerequisites, download methods, configuration tips, and troubleshooting common issues That alone is useful..
Introduction
VirtualBox is a powerful open‑source virtualization application that allows you to create and manage virtual machines (VMs) on Ubuntu. Whether you need to test software in different environments, run legacy applications, or experiment with Linux distributions, VirtualBox offers a reliable platform. Understanding how to install vbox on ubuntu is essential for anyone looking to use this flexibility without the cost of commercial software.
Why Choose VirtualBox?
- Free and Open‑Source: No licensing fees, and the code is auditable.
- Cross‑Platform: Supports Windows, macOS, Linux, and Solaris guest OSes.
- Performance: Uses hardware virtualization extensions (VT‑x/AMD‑V) for near‑native speed.
- Community Support: Large user base and extensive documentation.
Prerequisites
Before proceeding, ensure your system meets the basic requirements:
- Ubuntu Version: 20.04 LTS or later (the steps work on 18.04 as well).
- Processor: Must support hardware virtualization (Intel VT‑x or AMD‑V). You can verify this in the BIOS/UEFI settings.
- RAM: At least 2 GB for a minimal installation; 4 GB or more is recommended for comfortable VM usage.
- Disk Space: Approximately 500 MB for the package itself; additional space is needed for each VM you create.
If your CPU lacks virtualization support, you will encounter errors during installation or when starting a VM.
Step‑by‑Step Installation Guide
System Requirements (H3)
- Confirm virtualization is enabled: open a terminal and run
grep -E '(vmx|svm)' /proc/cpuinfo. If you see output, the feature is active. - Update your package list to avoid outdated dependencies:
sudo apt update.
Method 1: Installing via APT Repository (H3)
This is the simplest and most maintainable way, as Ubuntu’s package manager handles updates automatically That's the whole idea..
- Add the Oracle VirtualBox repository
sudo apt install -y apt-transport-https wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.virtualbox.org/virtualbox/6.1/ubuntu $(lsb_release -cs) stable" - Update the package index
sudo apt update - Install VirtualBox
sudo apt install -y virtualbox-6.1 - Install the Extension Pack (optional but recommended for USB 2.0/3.0 and RDP support)
wget https://download.virtualbox.org/virtualbox/6.1.38/Oracle_VM_VirtualBox_Extension_Pack-6.1.38.vbox-extpack sudo VBoxManage extpack install --replace --auto Oracle_VM_VirtualBox_Extension_Pack-6.1.38.vbox-extpack
Important: The version number (6.1) may change; replace it with the latest stable release available on the VirtualBox website Simple, but easy to overlook..
Method 2: Installing via .deb Package (H3)
Use this method if you prefer a manual download or need a specific version not present in the repository Easy to understand, harder to ignore..
- Download the .deb package
Visit the official VirtualBox download page and locate the Ubuntu .deb package for your architecture (usually amd64). Example command:wget https://download.virtualbox.org/virtualbox/6.1.38/virtualbox-6.1_6.1.38-158379~Ubuntu~bionic.deb - Install the package
If you encounter dependency errors, run:sudo dpkg -i virtualbox-6.1_6.1.38-158379~Ubuntu~bionic.debsudo apt -f install - Install the Extension Pack (same steps as in Method 1).
Verifying Installation (H3)
After installation, launch VirtualBox from the application menu or run:
VBoxManage --version
You should see the version number, confirming that how to install vbox on ubuntu has been completed successfully Simple, but easy to overlook. Nothing fancy..
Configuring VirtualBox
Network Settings (H3)
VirtualBox defaults to NAT networking, which allows out
Network Settings (continued)
VirtualBox’s default NAT configuration lets the guest reach the internet by routing traffic through the host’s network stack, but it also isolates the VM from inbound connections. For scenarios that require the guest to be reachable from other machines — such as hosting a web server or participating in a LAN‑based game — you’ll want to switch to one of the alternative modes:
Counterintuitive, but true.
| Mode | Typical Use‑Case | How to Enable |
|---|---|---|
| Bridged Adapter | The VM appears as a separate device on the physical LAN; it receives its own IP address from the router. On the flip side, | In Network, add a Host‑Only adapter, then enable it under Attached to → Host‑Only. |
| NAT Network | Extends NAT with port‑forwarding rules, offering a middle ground between NAT and Bridged. , enp3s0), and confirm. In practice, |
Create an Internal Network under File → Host Network Manager, then attach it to the VM’s NIC. |
| Host‑Only Adapter | Creates an isolated network that only the host and the VM can see; ideal for testing internal services without exposing them externally. g.Day to day, | |
| Internal Network | Similar to Host‑Only but the VMs communicate only with each other, not with the host. | Enable NAT Network in File → Host Network Manager, then attach the VM to it and configure forwarding via VBoxManage modifyvm. |
This is where a lot of people lose the thread.
Regardless of the chosen mode, you can fine‑tune connectivity with VBoxManage:
# Example: enable port forwarding for NAT
VBoxManage modifyvm "MyVM" --natpf1 "guestssh,tcp,,2222,22"
This rule forwards host port 2222 to the guest’s SSH port 22, allowing remote login without opening the guest firewall.
Storage Configuration
A virtual machine needs at least one virtual hard disk. You can create, attach, or detach disks using either the GUI or the command line:
# Create a 20 GB dynamically allocated VDI
VBoxManage createhd --filename "$HOME/VirtualBox VMs/MyVM/MyVM.vdi" --size 20480 --dynamically allocated
# Attach the new disk to the VM’s SATA controller
VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$HOME/VirtualBox VMs/MyVM/MyVM.vdi"
If you plan to install an operating system from an ISO image, mount the ISO as a virtual optical drive:
VBoxManage storageattach "MyVM" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /path/to/ubuntu-22.04.iso
Display and Input Settings
Modern guest operating systems benefit from increased video memory and optional 3D acceleration:
- Video Memory – In Settings → Display, slide the Video Memory bar to 128 MB or higher, depending on the guest’s graphical demands.
- Acceleration – Tick Enable 3D Acceleration for Windows guests or any application that relies on hardware‑accelerated graphics. This setting leverages the host’s GPU through OpenGL/Vulkan.
- Scale Factor – Adjust the Scale Factor to make the guest’s display appear larger on high‑DPI monitors without altering the guest’s resolution.
USB and Peripheral Integration
If you need the VM to interact with USB devices (e.g., flash drives, smartphones), enable the USB controller:
- Controller Type – Choose USB 1.1 (OHCI), USB 2.0 (EHCI), or USB 3.0 (xHCI) based on the device’s capabilities. USB 3.0 is recommended for modern peripherals.
- Add a Filter –
Add a Filter – click the USB icon with a plus sign in Settings → USB, select the device from the list, and confirm. But the VM will then capture that device on startup or when it becomes available. To remove a filter, select it and click the minus icon.
Command-line equivalent:
VBoxManage usbfilter add 0 --target "MyVM" --name "MyFlashDrive" --vendorid 0x0781 --productid 0x5567
Replace the vendor and product IDs with those reported by lsusb (Linux) or Device Manager (Windows).
Shared Folders
To exchange files between host and guest without configuring network shares, use VirtualBox Shared Folders:
- On the host, create a directory you want to share (e.g.,
~/vbox-share). - In Settings → Shared Folders, click Add, choose the folder path, assign a share name (e.g.,
hostshare), and optionally enable Auto-mount and Make Permanent. - Start the VM and install Guest Additions (see below). The shared folder can then be mounted inside the guest:
# Linux guest example
sudo mount -t vboxsf -o uid=1000,gid=1000 hostshare /mnt/hostshare
Guest Additions
For optimal performance and integration—seamless mouse integration, shared clipboard, dynamic screen resolution, and time synchronization—install VirtualBox Guest Additions:
1
-
Download and Install – While the VM is powered on, go to the VirtualBox menu bar and select Devices → Insert Guest Additions CD image…. The guest should automatically mount the virtual ISO, or you can mount it manually if autorun is disabled. Then run the installer from the mounted media:
- Linux guest:
sudo mount /dev/cdrom /mnt sudo /mnt/VBoxLinuxAdditions.run - Windows guest:
RunVBoxWindowsAdditions.exeas Administrator. - macOS guest:
Open the mountedVBoxDarwinAdditionsinstaller and follow the prompts.
- Linux guest:
-
Reboot the Guest – After the installation finishes, restart the VM. This step is essential because the Guest Additions kernel modules must be loaded for full functionality And it works..
-
Verify the Installation – Once the VM boots again, check that the integration features are active. Seamless mouse integration, shared clipboard, dynamic screen resolution, and time synchronization should now work as expected Worth knowing..
With Guest Additions installed, the VM gains near-native performance for graphics, file system access, and input handling. The core VirtualBox configuration is now complete, and the VM is ready for practical use Most people skip this — try not to..
Conclusion: By continuing through the Guest Additions setup, you have completed the essential configuration for a functional and integrated VirtualBox virtual machine. From here, you can proceed to network configuration, snapshots, or advanced resource allocation, confident that the foundation is properly in place. The VM is now fully prepared for productive tasks, testing environments, or development workloads.