DEV Community

Cover image for Linux Virtualization: Simple Guide for New Users
Aaditya Kediyal
Aaditya Kediyal

Posted on • Updated on

Linux Virtualization: Simple Guide for New Users

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 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 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.

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

  1. 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").
  2. 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

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

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

Choosing Hard Disk Type in VM

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

  2. 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

  1. 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

  1. Display Settings:

    • Screen: Allocate at least 128 MB of video memory.
    • Graphics Controller: Select VMSVGA.
  2. 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

  1. 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.
  1. 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

   sudo shutdown -r now
Enter fullscreen mode Exit fullscreen mode
  1. 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:
  sudo apt update
Enter fullscreen mode Exit fullscreen mode
  • Upgrade Installed Packages:
  sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode
  • Install New Software:
  sudo apt install <package_name>
Enter fullscreen mode Exit fullscreen mode
  • Navigate Directories:
  cd /path/to/directory
Enter fullscreen mode Exit fullscreen mode
  • List Directory Contents:
  ls
Enter fullscreen mode Exit fullscreen mode
  • Create a New Directory:
  mkdir <directory_name>
Enter fullscreen mode Exit fullscreen mode
  • Create a New File:
  touch <file_name>
Enter fullscreen mode Exit fullscreen mode
  • View File Contents:
  cat <file_name>
Enter fullscreen mode Exit fullscreen mode
  • Edit a File (using nano editor):
  nano <file_name>
Enter fullscreen mode Exit fullscreen mode

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!

Top comments (6)

Collapse
 
bobbyiliev profile image
Bobby Iliev

Great post! Your images are not loading though!

I recently wrote an introduction to Linux eBook in case that anyone wants to learn more:

Collapse
 
iaadidev profile image
Aaditya Kediyal

i'll update those links then...

Collapse
 
bobbyiliev profile image
Bobby Iliev

Sounds good! As this is what I see at the moment:

no images showing

Thread Thread
 
iaadidev profile image
Aaditya Kediyal

hey Bobby do check it now . i hope it's better than before

Thread Thread
 
bobbyiliev profile image
Bobby Iliev

Looks good!

Collapse
 
sloan profile image
Sloan the DEV Moderator

Hey, this article appears to have been generated with the assistance of ChatGPT or possibly some other AI tool.

We allow our community members to use AI assistance when writing articles as long as they abide by our guidelines. Please review the guidelines and edit your post to add a disclaimer.

Failure to follow these guidelines could result in DEV admin lowering the score of your post, making it less visible to the rest of the community. Or, if upon review we find this post to be particularly harmful, we may decide to unpublish it completely.

We hope you understand and take care to follow our guidelines going forward!