Introduction
For someone wanting to learn and use linux and you have a windows machine, You most likely won’t want to remove the windows OS on your laptop and lose all your files.
Maybe you want to learn Linux for a course you are running or something else, the good news is you can enable a virtual machine on your windows machine.
What is a virtual machine and what does it do? A virtual machine is a software that emulates your physical computer. You can see it as a box(software) that allows you have another computer inside your physical computer (host machine) without messing up the files on it or having to delete anything.
You can run multiple virtual machines with multiple OS on your host machine. Each separate machine behaves like a computer on its own with its own CPU, OS, memory and network interface.
What is Vagrant?
This is a software or tool that helps us simplify the process of creating and configuring a virtual machine. you basically tell it, “this is the kind of virtual machine we want", and it creates it for you automatically. It can manage all the virtual machines you create.
In this article I will walk you through setting up a virtual machine in your windows computer where you can run a Linux OS
Prerequisites
The tools you need to download and install on your computer for this article are:
- Enable Virtualization on your computer via the BIOS
- Command line or Terminal. I prefer Git Bash
- Vagrant
- Oracle VirtualBox 7.0
- Microsoft visual C++ 2019
And of course you need an internet connection for this.
Steps to Run a Linux(Ubuntu) Virtual Machine on Your Computer
So now that you have all your tools installed, the following steps are used to provision a Linux Ubuntu machine on your laptop and it will run virtually.
Create a new folder on your desktop or anywhere in your computer (your computer will be called local machine from here on out). Now you can do this via your normal windows desktop by right clicking on your desktop screen and create a new folder
After creating the folder, right click on the folder and click “open git bash here” and you will get the output below
- On the git bash terminal, type the command
vagrant init ubuntu/focal64
and press enter. NB: the commands should all be in lowercase. This places a vagrant file which contains the configuration of the Linux(ubuntu) OS inside the folder your created.
- The next step is to type
vagrant up
and press enter. This command is to start your virtual machine. It is more like booting up your local machine but this time you are booting up your virtual machine!!!
- The next step is for you to be able to access the Linux OS you created so you can be able to do…well just about anything you want to do there. So the next command to run is
vagrant ssh
and press enter. And that is it!!! You are now on your Linux(ubuntu) server!!!
From the picture above, you can see that path on your terminal before the vagrant ssh
is a path on your local machine, but after that command, it welcomes you to Ubuntu 20.04.6. Below the screen you can see the time and date of your login, which means your are logged in to the ubuntu server. And there is also the "Vagrant@ubuntu-focal" before the prompt which means at the moment you are logged into the ubuntu-focal server as vagrant. These are how you know you are inside your linux virtual machine.
Conclusion
So after reading through this article, you have learnt what virtual machines and vagrant are, you have installed all the softwares needed to boot up a virtual machine with vagrant and you have seen the steps of how to boot up a virtual machine on your local machine running a Linux(ubuntu) OS with vagrant on your computer
Top comments (1)
What a detailed article....Thanks bro
Dominic.