How to Set Up Linux on Your PC Using a Virtual Machine

20 minutes

If you are using Windows on your PC, it may be easier to code or program by running Linux or another Unix-based operating system alongside Windows. There are a few ways to do this including dual-booting, containerization, or using a virtual machine.

This guide will focus on how to set up Linux using a virtual machine. A virtual machine uses your current computer and software to emulate a second computer, all within the same physical device. When you run Linux (the guest OS) alongside, say, Windows (the host OS) you can create two operating systems in one device. The virtual machine functions separately from its own window, although it is possible to switch back and forth between the guest and host OS, such as for transferring files or taking snapshots.

There are many different applications you can download and use to run virtual machines, however one that is recommended is Oracle VirtualBox.

Posted in these interests:
h/linux41 guides
h/windows45 guides
h/virtualbox1 guide

You can download either the 64 or 32-bit version. Most modern computers have a 64-bit architecture. If your computer is very old, you may require 32-bit.

If 64-bit does not appear on the dropdown menu, you may have to enable virtualization through an advanced reboot. If you have an HP laptop, here is one resource which might be helpful.

As you click “next” through the installation process, you will see a number of prompts, the first of which is to decide which components you would like to install. I recommend leaving the default options selected.

The Custom Setup screen on the next page asks which folder you would like your VirtualBox to appear in. You may also be asked at some point for antivirus and firewall software permission and make sure to allow permission.

Create a virtual machine

Once you have opened Oracle VirtualBox, click on the “New” icon in the toolbar. You will be asked to provide a name for your virtual machine, which you can enter in the “Name” box.

Select “Linux” as the type and “Ubuntu” as the version (making sure to select 32-bit or 64-bit depending on your host computer).

After clicking “next”, you will be asked to select how much memory you would like to give to the virtual machine. Do not go below the minimum specified, and also you must be remember to leave enough memory for the host operating system, in this case Windows, to keep running.

This process allocates disk space to the virtual machine. First select “Create a virtual hard drive now”. Then click “Create”. The default VDI file type is native to VirtualBox, so you can select “VDI”.

You can choose to use a fixed size hard drive or a dynamically sized hard drive. I recommend a fixed sized disk if you have enough disk space, because it won’t increase the file size as required. Next you will be asked to specify how much disk space you will devote to the Ubuntu Virtual Machine. Do not go below the minimum set. A recommended size is 15 gigabytes.

Start the virtual machine

You can start the virtual machine by pressing the “Start” button on the toolbar. The first boot will require you to select a disk. You can do this by clicking the folder icon, navigating to the downloads folder, and selecting Ubuntu ISO. Then click start.

You will then be given the option to Try Ubuntu or Install Ubuntu. It is recommended to install however you can always install it later from the desktop if you choose to try it out first.

This article goes into more detail regarding settings upon installation, such as whether to install updates as you go or install 3rd party software.

Select “Erase disk and install Ubuntu”. Then click “Install now”. Remember you are not installing on a real hard drive, so this will not affect your host operating system.

Lastly, choose your location, keyboard layout, and create a user. When you create a user you will be asked for your name, a name for your virtual machine, a username, and a password. Reboot your machine to finish the installation.

If you're looking to experiment with Linux and would rather not dual-boot, one relatively inexpensive option is to use a Raspberry Pi. At this point, Raspberry Pi's are still fairly cheap but come with enough processing power and memory to do quite a bit. Learn how to install Ubuntu on your Raspberry Pi.

Zach Zach (248)
15 minutes

Part of being a web developer is testing things that will inevitably break in insane and unexpected ways in Internet Explorer.