Virtualbox can be installed on Arch Linux via pacman, which is the default package manager for Arch Linux, and via yay, which is an AUR helper that you can use to download packages from the AUR repository.
In this tutorial, you will learn how to install Virtualbox on Arch Linux, by using two different ways.
Install Virtualbox with Pacman
To install virtualbox with pacman, launch your terminal and run the following command
sudo pacman -S virtualbox
Next, you will be prompted to choose which Virtualbox host module you want to install.
Press 1
to install the default Virtualbox host module virtualbox-host-dkms

Next, you need to confirm that you want to install virtualbox. Simply answer with y
on this prompt, and press enter to continue installing virtualbox

And the installation of virtualbox should begin

Once virtualbox has been successfully installed on your computer, you will see the following output on your terminal

Install Virtualbox with Yay
Just like pacman, yay can also be used to install virtualbox on Arch Linux. To install virtualbox with yay, open a terminal and run the following command
yay -S virtualbox
You will get this prompt "There are 2 providers available for Virtualbox-host-modules", on your terminal.
On this step you need to choose which host module you want to install, enter your choice and press enter.

And the installation process should begin

Uninstall Virtualbox with Pacman
To uninstall virtualbox with pacman, you can do so by using the -R
option.
sudo pacman -R virtualbox
Once you execute the uninstall command, you need to confirm with yes in order to remove virtualbox from your system.

Confirm with yes, and virtualbox will be uninstalled

Uninstall Virtualbox with Yay
In yay you can also use the -R
option to remove a package from your system. So, to remove virtualbox from Arch Linux,
yay -R virtualbox
Confirm the removal of virtualbox, press y then enter.

And virtualbox should be removed from your system

Conclusion
In this tutorial, you learned how to install and uninstall Virtualbox on Arch Linux, by using pacman and yay.