How to Install VirtualBox on Fedora 41 with dnf5

Create a Repository File

Use your favorite text editor (e.g., nano or vi) to create a new .repo file:

sudo nano /etc/yum.repos.d/virtualbox.repo

Add Repository Information

Add the following lines to the file:

[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
baseurl=https://download.virtualbox.org/virtualbox/rpm/fedora/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc

Save and Exit

If you're using nano, press Ctrl+O, hit Enter to save, and then Ctrl+X to exit.

Clean and Update Repositories

Run the following commands:

sudo dnf clean all
sudo dnf makecache

Verify the Repository

Confirm the repository is added:

sudo dnf repolist

Install VirtualBox

Finally, install VirtualBox:

sudo dnf install VirtualBox