= Create a Linux Virtual Machine on Your Computer =
In this day and age, cloud computing power is prevalent and cheap. You donÃÂ¢ÃÂÃÂt need to look hard to find free or affordable hosting options for app development, databases or data science projects. Regardless of online availability, there are many reasons to set up custom environments on your own hardware; chief among them: security.
== WhatÃÂ¢ÃÂÃÂs a Virtual Machine (VM)? ==
Using OracleÃÂ¢ÃÂÃÂs free VirtualBox software, setting up a virtual machine (VM) on your own PC is super easy, safe and allows you to run multiple operating systems at the same time!
== What Is a Virtual Machine? ==
A virtual machine is like having a computer inside your computer. Through hardware virtualization, another operating system shares your host computerÃÂ¢ÃÂÃÂs resources. Each VM has its own operating system (OS) that works separately from the host OS. Likewise, each VM has its own processors, RAM, disk, and so on. Through virtualization, you essentially create two different machines.
In this article, IÃÂ¢ÃÂÃÂll explain how to load the free Linux OS, Ubuntu Server, onto a VM using Windows as my host machine operating system. Like a virtual machine in the cloud, itÃÂ¢ÃÂÃÂs even possible to set up secure shell (SSH) making it easy to remote in safely.
== Download and Install VirtualBox ==
VirtualBox is not only free, but also a feature-rich application thatÃÂ¢ÃÂÃÂs fairly easy to set up. It has a large and helpful community that keeps updating and enhancing the functionality. Additionally, it supports a variety of host operating systems (Windows, Linux, Macintosh, Solaris) and is available under the terms of the GNU General Public License (GPL).
Go to the downloads page and select the version you need for your host OS. For example, IÃÂ¢ÃÂÃÂm using Windows so I download the Windows option.
Also be sure to download the Oracle VM VirtualBox Extension Pack further down the page.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/1_linux-vm_0.png)
*Note: When youÃÂ¢ÃÂÃÂre installing VirtualBox, the system warns you about a hiccup in the network connectivity, so make sure you arenÃÂ¢ÃÂÃÂt doing anything that canÃÂ¢ÃÂÃÂt be interrupted. *
Going through the process to install it is fairly simple; I used the defaults. Refer to the documentation for issues with the installation. IÃÂ¢ÃÂÃÂll walk through actually creating the VM after downloading Ubuntu.
== Download Ubuntu ==
Ubuntu is a free and easy to install flavor of the Linux operating system, and itÃÂ¢ÃÂÃÂs for desktops and servers. A lot of technologies used for the web, data science and software development are designed for Linux. You can run them using command-line. IÃÂ¢ÃÂÃÂve used Ubuntu when creating and hosting web pages, setting up SQL databases and Elasticsearch clusters, and managing containers with Docker.
Download Ubuntu Server on the downloads page.
*Note: An .iso file downloads. When the VM loads, youÃÂ¢ÃÂÃÂll select the image to install the Ubuntu OS.*
== Managing Virtual Machines ==
Take note of your host machineÃÂ¢ÃÂÃÂs specs before setting up virtual machines. If you afford the VM too much RAM or CPU, the VM can impact the performance of your host machine dramatically.
I set up a VM to use 14 of my 16 gigs of RAM and then ran machine learning models on large data sets. My host machine functioned as well as a clogged pipe while the model transformed the data! Always pay attention to the resources you assign to the virtual machine.
After installing VirtualBox and downloading Ubuntu, itÃÂ¢ÃÂÃÂs time to create a virtual machine and install Ubuntu. When starting VirtualBox, youÃÂ¢ÃÂÃÂll see a screen like this:
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/2_linux-vm_0.png)
Notice I already have two VMs created:
Edgewhich uses Windows Server 2016 as its OS elasticwhich uses Ubuntu Server 18.04 as its OS
The Oracle VM VirtualBox Manager is the graphical user interface (GUI) through which one creates and manages virtual machines.
== Create a Virtual Machine ==
There are only a few steps to get the VM running. Keep in mind, itÃÂ¢ÃÂÃÂs possible to change most of these settings if, for example, you need to adjust the number of processors or RAM. Click the settings button to adjust anything after youÃÂ¢ÃÂÃÂve created the VM.
Click new to create the Ubuntu VM.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/3_linux-vm_0.png)
- Enter a
- Select Linux as the
- Select Ubuntu (64-bit) as the
- Set the
memory size. IÃÂ¢ÃÂÃÂm allocating two gigs of memory, but you should allocate memory according to whatÃÂ¢ÃÂÃÂs available in your system.
Select create a virtual hard disk now as the hard disk option so the VM has dedicated storage space.
Click create once the options have been configured. The Create Virtual Hard Disk editor displays if you selected that hard disk option.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/4_linux-vm_0.png)
Select a file location. Consider how much space you need to allocate. For example, I have two drives in my computer and always use the larger one for my VM disk space.
Set a file size. The default size is 10 gigs, but I recommend 20. Consider how large the operating system is and make sure to select a disk that has enough space on it! For example, Windows can take 10 gigs or more.
Select one of the Storage on physical hard disk options:
dynamically allocated filegrows as needed and will approach the maximum file size over time.
fixed-size fileimmediately reserves the total space allocated for file size. If youÃÂ¢ÃÂÃÂre using the default settings, this option creates a 10 gig file.
I prefer to use a fixed-size file since it tends to perform a little better because it uses less overhead than the dynamically allocated file.
Select the default hard disk file type. This option determines the type of container used when creating the storage. Some options are more compatible with other virtual machine programs.
Click create and the VM will start generating.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/5_linux-vm_0.png)
The virtual machine will appear in the VirtualBox Manager once youÃÂ¢ÃÂÃÂve created it:
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/6_linux-vm_0.png)
== Install Ubuntu on the VM ==
Once youÃÂ¢ÃÂÃÂve created the VM, it has all the resources it needs to install an operating system and act like a regular computer. Make sure to remember where the Ubuntu .iso file downloaded since youÃÂ¢ÃÂÃÂll need it in these next steps.
Click start to start the new VM.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/7_linux-vm_0.png)
When the VM first starts, it will prompt you to select a disk image. Select the Ubuntu iso file.
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/8_linux-vm_0.png)
Click start after selecting the iso file.
ItÃÂ¢ÃÂÃÂs possible to change the selected image or re-select the image by following
**device > optical drives > choose disk image ![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/9_linux-vm_0.png)
From there, select your language and follow the prompts to install Ubuntu. The system will prompt you to set up a username and password; once you do that, it will install the OS!
![ linux vm](httpsbuiltin.com/sites/www.builtin.com/files/styles/ckeditor_optimize/public/inline-images/10_linux-vm_0.png)
== Ready, Set, Code! ==
Now that the VM has an operating system installed, itÃÂ¢ÃÂÃÂs ready for your projects! Install the desired tech and start coding. There are tons of tutorials online to get Docker, Git, Python, Elasticsearch, Mysql, FTP, and much more installed on Linux.
Using OracleÃÂ¢ÃÂÃÂs VirtualBox software, itÃÂ¢ÃÂÃÂs easy to create and manage virtual machines using your own hardware and different operating systems. Since Linux is free and supports the tech stacks I need, it pairs perfectly with VirtualBox.