Linux Virtualization: Simple Guide for New Users
Tags: linux, virtualmachine, virtualization, tutorial
Published: 2024-06-11 04:51:01

## Linux Virtualization: A Comprehensive Guide for Non-Linux Users

Virtualization has revolutionized the way we use and manage computing resources. It allows you to run multiple operating systems on a single physical machine, offering immense flexibility, efficiency, and cost savings. One popular application of virtualization is running Linux virtual machines (VMs) on a non-Linux host, such as a Windows or macOS computer. This guide will walk you through the basics of Linux virtualization and provide a step-by-step tutorial on how to set up a Linux VM on your host machine.

## Table of Contents

1. Introduction to Virtualization
2. Benefits of Running Linux VMs
3. Choosing the Right Virtualization Software
4. Step-by-Step Guide to Setting Up a Linux VM
    1. Installing VirtualBox
    2. Downloading a Linux ISO
    3. Creating a New Virtual Machine
    4. Configuring VM Settings
    5. Installing Linux on the VM
5. Basic Linux Commands for Beginners
6. Conclusion

## 1. Introduction to Virtualization

### What is Virtualization?

Virtualization is the process of creating a virtual version of a physical computer's hardware, allowing multiple operating systems to run concurrently on a single physical machine. Each virtual machine (VM) operates as a separate entity, with its own operating system, applications, and resources, while sharing the physical hardware of the host machine.

### Types of Virtualization

- **Full Virtualization:** Uses hypervisors like VMware or VirtualBox to create fully isolated VMs.
- **Paravirtualization:** Requires modifications to the guest OS to optimize performance.
- **Containerization:** Uses containers (e.g., Docker) to run isolated applications without full OS virtualization.

## 2. Benefits of Running Linux VMs

Running Linux VMs on a non-Linux host offers several advantages:

- **Flexibility:** Test and run different Linux distributions without altering your main system.
- **Development:** Ideal for software development and testing in a Linux environment.
- **Security:** Isolate potentially risky applications or services.
- **Learning:** Great for learning Linux without dedicating a separate physical machine.

## 3. Choosing the Right Virtualization Software

Several virtualization tools are available, but this guide will focus on Oracle's VirtualBox due to its user-friendly interface and cross-platform compatibility.

### Other Popular Virtualization Software

- **VMware Workstation Player:** A robust and popular choice, especially in enterprise environments.
- **Parallels Desktop:** Optimized for macOS, but it is a paid software.
- **QEMU/KVM:** Advanced virtualization tools for Linux users.

## 4. Step-by-Step Guide to Setting Up a Linux VM

### Prerequisites

- A host machine running Windows or macOS.
- Internet access for downloading software and Linux ISO files.
- Basic knowledge of your host operating system.

### 1. Installing VirtualBox

#### For Windows

1. **Download VirtualBox:**
   Go to the [VirtualBox download page](https://www.virtualbox.org/wiki/Downloads) and download the Windows installer.

2. **Run the Installer:**
   Double-click the downloaded executable file to start the installation process. Follow the on-screen instructions to complete the installation.

#### For macOS

1. **Download VirtualBox:**
   Visit the [VirtualBox download page](https://www.virtualbox.org/wiki/Downloads) and download the macOS installer.

2. **Install VirtualBox:**
   Open the downloaded DMG file and double-click the VirtualBox.pkg file to start the installation. Follow the prompts to install VirtualBox.

### 2. Downloading a Linux ISO

You'll need an ISO file of the Linux distribution you wish to install. Popular choices include Ubuntu, Fedora, and Debian.

1. **Download the ISO:**
   Visit the official website of your chosen Linux distribution and download the ISO file. For example, you can download Ubuntu from [ubuntu.com](https://ubuntu.com/download).

### 3. Creating a New Virtual Machine

1. **Open VirtualBox:**
   Launch VirtualBox from your Applications or Start menu.

2. **Create a New VM:**
   Click the "New" button to start creating a new virtual machine.

   

![Creating new VM screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ssagvzdhbea8qt7m6dxq.png)

3. **Name and Operating System:**
   - **Name:** Enter a name for your VM (e.g., "Ubuntu VM").
   - **Type:** Select "Linux."
   - **Version:** Select the appropriate version of your Linux distribution (e.g., "Ubuntu 64-bit").

   

4. **Memory Size:**
   Allocate memory (RAM) for your VM. A good starting point is 2GB (2048 MB), but you can adjust based on your system's capacity.


![Allocating RAM in VM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/296e25h58jq78x4k8yhw.png)

5. **Hard Disk:**
   Select "Create a virtual hard disk now" and click "Create."

6. **Hard Disk File Type:**
   Choose VDI (VirtualBox Disk Image) and click "Next."


![Choosing Hard Disk Type in VM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlkni8y8ss7endcbwptq.png)

7. **Storage on Physical Hard Disk:**
   Select "Dynamically allocated" to allow the disk to grow as needed, and click "Next."



8. **File Location and Size:**
   Choose the location and size for your virtual disk. 20GB is a reasonable size for a basic installation.

   ![Choosing File Location and size](https://www.virtualbox.org/manual/images/guest-additions-windows-start.png)

9. **Create Virtual Disk:**
   Click "Create" to finish the VM creation process.

### 4. Configuring VM Settings

1. **Select VM:**
   In VirtualBox, select your newly created VM and click "Settings."

2. **System Settings:**
   - **Motherboard:** Ensure "Floppy" is unchecked.
   - **Processor:** Allocate at least 2 CPUs if your host machine has multiple cores.
   - **Acceleration:** Ensure both "VT-x/AMD-V" and "Nested Paging" are enabled.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6c8ge49guacukj1vrjs.png)

3. **Display Settings:**
   - **Screen:** Allocate at least 128 MB of video memory.
   - **Graphics Controller:** Select VMSVGA.

4. **Storage Settings:**
   - **Controller: IDE:** Click the empty optical drive, then click the disk icon to choose a virtual optical disk file.
   - **Select ISO:** Browse and select the downloaded Linux ISO file.

   ![Attach ISO](https://www.virtualbox.org/manual/images/guest-additions-windows-start.png)

5. **Network Settings:**
   - **Adapter 1:** Ensure "Enable Network Adapter" is checked and set to "NAT."

### 5. Installing Linux on the VM

1. **Start the VM:**
   Select your VM and click "Start."

2. **Boot from ISO:**
   The VM will boot from the attached ISO file. Follow the on-screen instructions to install Linux. This process will vary slightly depending on the distribution, but typically involves:

   - **Select Language:** Choose your preferred language.
   - **Installation Type:** Select "Install" or equivalent.
   - **Disk Setup:** Choose default options for automated partitioning.
   - **User Setup:** Create a username and password.

3. **Complete Installation:**
   Once the installation is complete, the VM will prompt you to remove the installation medium. Go to "Devices" > "Optical Drives" > "Remove disk from virtual drive," then restart the VM.


![Running VM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wabhv49t5abdqfbxpagr.png)

   ```bash
   sudo shutdown -r now
   ```

4. **Log In:**
   After rebooting, log in with the username and password you created during installation.

## 5. Basic Linux Commands for Beginners

Congratulations on setting up your Linux VM! Here are some basic commands to get you started:

- **Update Package List:**
  ```bash
  sudo apt update
  ```

- **Upgrade Installed Packages:**
  ```bash
  sudo apt upgrade
  ```

- **Install New Software:**
  ```bash
  sudo apt install <package_name>
  ```

- **Navigate Directories:**
  ```bash
  cd /path/to/directory
  ```

- **List Directory Contents:**
  ```bash
  ls
  ```

- **Create a New Directory:**
  ```bash
  mkdir <directory_name>
  ```

- **Create a New File:**
  ```bash
  touch <file_name>
  ```

- **View File Contents:**
  ```bash
  cat <file_name>
  ```

- **Edit a File (using nano editor):**
  ```bash
  nano <file_name>
  ```

## 6. Conclusion

Virtualization opens up a world of possibilities for both learning and professional development. By following this guide, even a non-Linux user can successfully set up and run a Linux virtual machine on their host machine. With the power of Linux at your fingertips, you can explore new software, develop applications, or simply learn more about this versatile operating system. Happy virtualizing!