# How to Install Oracle VirtualBox on Ubuntu 22.04

[Oracle VirtualBox](https://www.virtualbox.org/) is a powerful, open-source, cross-platform virtualization software. It allows users to run multiple operating systems simultaneously on a single physical machine. This capability is extremely useful in various domains, including [DevOps](https://aws.amazon.com/devops/what-is-devops/#:~:text=DevOps%20is%20the%20combination%20of,development%20and%20infrastructure%20management%20processes.) and [Systems Engineering](https://en.wikipedia.org/wiki/Systems_engineering#:~:text=Systems%20engineering%20is%20an%20interdisciplinary,organize%20this%20body%20of%20knowledge.), where it serves several critical functions.

VirtualBox is categorized as [Type2 hypervisor](https://aws.amazon.com/compare/the-difference-between-type-1-and-type-2-hypervisors/). It helps you to create guest operating systems (virtual machines) on a host operating system.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1704111947755/6652a199-06f4-4b89-85e2-09b56b5a4613.png align="center")

## VirtualBox Installation:

1. Download VirtualBox for [Ubuntu 22.04.03](https://releases.ubuntu.com/jammy/) from [https://www.virtualbox.org/wiki/Linux\_Downloads](https://www.virtualbox.org/wiki/Linux_Downloads)
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">The package architecture has to match the Linux kernel architecture, that is, if you are running a 64-bit kernel, install the appropriate AMD64 package (it does not matter if you have an Intel or an AMD CPU). Mixed installations (e.g. Debian/Lenny ships an AMD64 kernel with 32-bit packages) are not supported. To install VirtualBox anyway you need to setup a 64-bit chroot environment.</div>
    </div>
    
2. Add the following line to your `/etc/apt/sources.list`. For Ubuntu 22.04 and older, replace '`<mydist>`' with '`jammy`',
    
    ```bash
    deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib
    ```
    
3. The Oracle public key for verifying the signatures can be downloaded [here](https://www.virtualbox.org/download/oracle_vbox_2016.asc).
    
4. Convert a downloaded binary GPG key file (usually with the `.asc` extension) into a keyring format. (If needed, move to the folder where the `.asc` key is located before executing the following command or provide the full path)
    
    ```bash
    sudo gpg --dearmor oracle_vbox_2016.asc
    ```
    
    The keyring format is more suitable for use with APT (Advanced Package Tool) and package managers.
    
5. Move the formatted GPG key file into the following folder `usr/share/keyrings`.
    
    ```bash
    sudo mv oracle_vbox_2016.asc.gpg /usr/share/keyrings/oracle-virtualbox-2016.gpg
    ```
    
    The `/usr/share/keyrings/` directory is a common location for storing keyring files that APT can use to verify the authenticity of packages from specific repositories.
    
6. Before checking the fingerprint (a unique identifier for a GPG key that is used to verify its authenticity), import the GPG key from the `oracle_vbox_2016.asc` file into your GPG keyring using the command:
    
    ```bash
    gpg --import oracle_vbox_2016.asc
    ```
    
7. Once the key is imported, view its fingerprint with the command:
    
    ```bash
    gpg --fingerprint key_identifier
    ```
    
    In this case, the key identifier is `2980AECF`
    
    ![](https://i.imgur.com/8GexaEx.png align="center")
    
8. Finally, install VirtualBox with the command:
    
    ```bash
    sudo apt-get update
    sudo apt-get install virtualbox-6.1
    ```
    
9. To verify that VirtualBox has been correctly installed on Ubuntu 22.04, check VirtualBox Version with the command:
    
    ```bash
    virtualbox --help
    ```
    
    OR
    
    ```bash
    VBoxManage --version
    ```
    
10. For a more comprehensive check, you can create a new virtual machine and attempt to run it. If the VM starts correctly (even if it only displays a boot error message), VirtualBox is working as expected.
    
    ![](https://i.imgur.com/7T3ELP2.png align="center")
    

## References:

1. [Download VirtualBox for Linux Hosts](https://www.virtualbox.org/wiki/Linux_Downloads)
    
2. [Oracle® VM VirtualBox® User Manual](https://www.virtualbox.org/manual/)
