Set Up Virtual Machine (VM) and Experiment with Linux (Ubuntu) DevOps Commands

Utsav Desai
5 min readApr 11, 2023

--

Manually set up any virtual machine:

Here are the steps you can follow:

1. Download and install VirtualBox

  • VirtualBox is a free and open-source virtualization software that allows you to create and run virtual machines on your computer.
  • Download the appropriate version of VirtualBox for your operating system from the official website: https://www.virtualbox.org/wiki/Downloads
  • Follow the installation instructions provided by the installer.

2. Download the Ubuntu ISO file

  • Go to the official Ubuntu website and download the latest LTS (Long-Term Support) version of Ubuntu ISO file: https://ubuntu.com/download/desktop
  • Save the downloaded file to a location on your computer that you can easily access later.

3. Create a new virtual machine in VirtualBox

  • Open VirtualBox and click on the “New” button in the top left corner of the window.
  • Enter a name for your virtual machine (e.g. “Ubuntu DevOps VM”) and select “Linux” as the type and “Ubuntu (64-bit)” as the version.
  • Allocate at least 2GB of RAM to the VM, and create a virtual hard disk with at least 20GB of storage space.
  • Follow the prompts to create the VM.

4. Install Ubuntu on the virtual machine

  • In VirtualBox, select the newly created VM and click on the “Start” button.
  • When prompted, select the Ubuntu ISO file you downloaded earlier as the bootable media for the VM.
  • Follow the prompts to install Ubuntu on the virtual machine.

5. Install necessary packages on Ubuntu

  • Once Ubuntu is installed, open a terminal window.
  • Run the following commands to update the package lists and install the necessary packages:
sudo apt-get update
sudo apt-get install git curl ssh

6. Experiment with DevOps commands

  • Now that your VM is set up and configured for DevOps experimentation, you can experiment with common DevOps commands like git clone, curl, and ssh.
  • For example, you can run the following commands to clone a Git repository, download a file using curl, and connect to a remote server using ssh:
git clone https://github.com/user/repo.git
curl -O https://example.com/file.txt
ssh user@hostname
  • Note that you’ll need to replace the URLs and usernames/hostnames in these commands with your own.

Vagrant to set up any virtual machine:

Complete instructions are provided for setting up our virtual computer.

1. Install Vagrant on your host machine.

Run the following command to install Vagrant:

$ vagrant.msi

2. Create a new directory for your project and navigate to it in the command line.

$ mkdir vagrant_project
$ cd ~/vagrant_project

3. Visit the website and choose your VagrantBox (built-in virtual environment image of an operating system).

$ vagrant init ubuntu/trusty64

4. Modify the generated Vagrantfile to specify the virtual machine configuration you want.

For example, you can change the virtual machine ubuntu/trusty64 to ubuntu/focal64.

config.vm.box = "ubuntu/focal64"

5. Start the virtual machine by running the command.

$ vagrant up

6. Connect to the virtual machine using the command.

$ vagrant ssh

7. When you’re finished, exit the virtual machine and shut it down by running the command.

$ vagrant halt

8. To destroy the current Vagrant environment, run the following command.

$ vagrant destroy

9. To reload the Vagrant environment, run the following command.

$ vagrant reload

10. To verify that the environment has been reloaded successfully, you can run the following command.

$ vagrant status

Practical: Set Up VM and Experiment with DevOps Commands

Here are the steps you can follow:

1. Install Chocolatey

  • Chocolatey is a package manager for Windows that allows you to easily install and manage software packages.
  • Open a PowerShell terminal as an administrator (right-click on the PowerShell icon and select “Run as administrator”).
  • Run the following command to install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  • Check whether Chocolatey is installed or Not.

2. Install Vagrant using Chocolatey

  • Once Chocolatey is installed, you can use it to install Vagrant.
  • In the same PowerShell terminal, run the following command to install Vagrant:
choco install vagrant
  • After the installation, you can verify whether Vagrant is installed or Not.

3. Create a Practical Project Folder

  • Perform this command and create a project using git bash
mkdir vagrant_project
cd vagrant_project
  • Output for performing the above Command

4. Creates a new Vagrantfile in the current directory and configures it to use the “ubuntu/trusty64” box as the base image for a new Vagrant environment.

vagrant init ubuntu/trusty64

5. Start the virtual machine by running the command.

vagrant up
  • Before Performing the vagrant up command VM VirtualBox be like:
  • After Performing the vagrant up command VM VirtualBox be like:

6. Connect to the virtual machine using the command.

7. experiment with common DevOps commands like git clone, curl, and ssh.

  • Clone a Git repository using git clone.
git clone <repository_url>
  • Download a file using curl.
  • Run the following command in the terminal to retrieve the real-time Bitcoin price using the CoinGecko API:
curl "https://api.openweathermap.org/data/2.5/weather?q=Budapest&appid=a457e758ed0d9ab3fcc40xxxe&units=metric"

This guide will get you started using DevOps commands. If you can execute the other command, then execute the Command as we have done previously with Git and Curl.

What’s Next?

We are going to study some other DevOps practices.

“Success is the sum of small efforts — repeated day in and day out.”

--

--

Utsav Desai
Utsav Desai

Written by Utsav Desai

Utsav Desai is a technology enthusiast with an interest in DevOps, App Development, and Web Development.

No responses yet