{"id":9975,"date":"2025-09-05T17:32:30","date_gmt":"2025-09-05T17:32:30","guid":{"rendered":"https:\/\/namastedev.com\/blog\/?p=9975"},"modified":"2025-09-05T17:32:30","modified_gmt":"2025-09-05T17:32:30","slug":"installing-linux-in-a-vm-virtualbox-wsl-2","status":"publish","type":"post","link":"https:\/\/namastedev.com\/blog\/installing-linux-in-a-vm-virtualbox-wsl-2\/","title":{"rendered":"Installing Linux in a VM (VirtualBox\/WSL)"},"content":{"rendered":"<h1>Installing Linux in a VM (VirtualBox\/WSL)<\/h1>\n<p>As a developer, having access to multiple operating systems can be a game-changer. Whether you\u2019re looking to build applications in a Linux environment while primarily using Windows, or you simply want the flexibility that Linux offers, installing Linux in a virtual machine (VM) is an excellent solution. In this article, we will explore two popular methods to set up a Linux environment: using VirtualBox and Windows Subsystem for Linux (WSL). Below, we\u2019ll explain the benefits of each method, step-by-step installation guides, and tips for optimizing your new Linux environment.<\/p>\n<h2>Why Use a Virtual Machine?<\/h2>\n<p>A virtual machine allows you to run a guest operating system on top of your host operating system. Here are some reasons developers choose to work within a virtualized environment:<\/p>\n<ul>\n<li><strong>Isolation:<\/strong> Run Linux applications without affecting your host OS.<\/li>\n<li><strong>Testing:<\/strong> Experiment with different distributions, configurations, and applications.<\/li>\n<li><strong>Version Management:<\/strong> Easily switch between different versions of software or libraries.<\/li>\n<li><strong>Backup and Snapshots:<\/strong> Create a backup of your VM and take snapshots for quick restoration.<\/li>\n<\/ul>\n<h2>Setting Up Linux with VirtualBox<\/h2>\n<p>VirtualBox is one of the most popular cross-platform virtualization applications. Here\u2019s a step-by-step guide to setting up Linux using VirtualBox:<\/p>\n<h3>Step 1: Download and Install VirtualBox<\/h3>\n<p>1. Visit the <a href=\"https:\/\/www.virtualbox.org\/\">VirtualBox website<\/a>.<br \/>\n2. Download the VirtualBox installer suitable for your operating system (Windows, macOS, or Linux).<br \/>\n3. Run the installer and follow the prompts to complete the installation.<\/p>\n<h3>Step 2: Download a Linux ISO<\/h3>\n<p>Choose a Linux distribution to install. Some popular options include:<\/p>\n<ul>\n<li><strong>Ubuntu:<\/strong> User-friendly and great for beginners.<\/li>\n<li><strong>Fedora:<\/strong> Offers cutting-edge technology.<\/li>\n<li><strong>Debian:<\/strong> Known for its stability and security.<\/li>\n<\/ul>\n<p>Go to the official website of your chosen distribution and download the latest ISO file.<\/p>\n<h3>Step 3: Create a New Virtual Machine<\/h3>\n<p>1. Open VirtualBox.<br \/>\n2. Click on <strong>New<\/strong> to create a new VM.<br \/>\n3. Enter a name (e.g., &#8220;Ubuntu VM&#8221;) and select the type as <strong>Linux<\/strong> and version accordingly (e.g., <strong>Ubuntu<\/strong> (64-bit)).<br \/>\n4. Allocate memory (RAM) &#8211; the recommended minimum is 2048 MB for Ubuntu.<br \/>\n5. Create a new virtual hard disk &#8211; use default settings to create a dynamically allocated VDI disk. Recommended size is at least 20GB.<\/p>\n<h3>Step 4: Configure VM Settings<\/h3>\n<p>Once the VM is created:<\/p>\n<ol>\n<li>Select the VM and click <strong>Settings<\/strong>.<\/li>\n<li>Go to <strong>System<\/strong> and adjust boot order; ensure <strong>Optical<\/strong> is at the top.<\/li>\n<li>In the <strong>Storage<\/strong> section, click on <strong>Empty<\/strong> under Controller: IDE, then click the disk icon on the right side to load your Linux ISO.<\/li>\n<\/ol>\n<h3>Step 5: Start the VM and Install Linux<\/h3>\n<p>1. Click on <strong>Start<\/strong> to power on the VM.<br \/>\n2. The VM should boot from the ISO. Follow the on-screen instructions to install Linux.<br \/>\n3. Configure system settings (time zone, keyboard layout, etc.) and create a user account.<\/p>\n<h3>Step 6: Install VirtualBox Guest Additions<\/h3>\n<p>This step improves performance and supports additional features such as shared folders and better video performance:<\/p>\n<ol>\n<li>Once you\u2019re in your Linux desktop, navigate to <strong>Devices<\/strong> in the VM menu and select <strong>Insert Guest Additions CD image\u2026<\/strong>.<\/li>\n<li>Open a terminal and run the following commands:<\/li>\n<\/ol>\n<pre><code>sudo apt update\nsudo apt install build-essential dkms\nsudo sh \/media\/cdrom\/VBoxLinuxAdditions.run\n<\/code><\/pre>\n<p>Reboot the VM to apply changes.<\/p>\n<h2>Using Windows Subsystem for Linux (WSL)<\/h2>\n<p>If you prefer a more integrated approach, WSL allows you to run a Linux file system directly on Windows without requiring a VM. This is particularly useful for developers who want to use the command line tools available in a typical Linux environment.<\/p>\n<h3>Step 1: Enable WSL Feature<\/h3>\n<p>1. Open PowerShell as Administrator.<br \/>\n2. Run the command:<\/p>\n<pre><code>wsl --install\n<\/code><\/pre>\n<p>3. Restart your computer if prompted. This command installs WSL and the default Linux distribution (usually Ubuntu).<\/p>\n<h3>Step 2: Install a Different Linux Distribution (Optional)<\/h3>\n<p>If you want a distribution other than the default, you can find alternatives in the Microsoft Store:<\/p>\n<ol>\n<li>Open the Microsoft Store.<\/li>\n<li>Search for the Linux distribution of your choice (e.g., Debian, Fedora).<\/li>\n<li>Click <strong>Install<\/strong>.<\/li>\n<\/ol>\n<h3>Step 3: Set Up Your Linux Environment<\/h3>\n<p>Once the installation is complete, you can launch your Linux environment either via the Start menu or by typing <code>wsl<\/code> in PowerShell or Command Prompt.<\/p>\n<h3>Step 4: Update Packages<\/h3>\n<p>Once you&#8217;re in the Linux shell, it\u2019s a good practice to update the package list and upgrade installed packages:<\/p>\n<pre><code>sudo apt update\nsudo apt upgrade\n<\/code><\/pre>\n<h3>Step 5: Configure Development Tools<\/h3>\n<p>You can now install development tools such as:<\/p>\n<pre><code>sudo apt install build-essential git\n<\/code><\/pre>\n<h2>Comparing VirtualBox vs WSL<\/h2>\n<p>Both VirtualBox and WSL have their unique advantages and disadvantages:<\/p>\n<table border=\"1\">\n<tr>\n<th>Feature<\/th>\n<th>VirtualBox<\/th>\n<th>WSL<\/th>\n<\/tr>\n<tr>\n<td>Isolation<\/td>\n<td>Complete isolation from host system<\/td>\n<td>Very close to host system, sharing the kernel<\/td>\n<\/tr>\n<tr>\n<td>Performance<\/td>\n<td>May require more resources<\/td>\n<td>Generally faster, especially with I\/O operations<\/td>\n<\/tr>\n<tr>\n<td>GUI Applications<\/td>\n<td>Full GUI support<\/td>\n<td>Limited but improving<\/td>\n<\/tr>\n<tr>\n<td>Setup Complexity<\/td>\n<td>More complex<\/td>\n<td>Simple setup<\/td>\n<\/tr>\n<tr>\n<td>Backup &amp; Snapshots<\/td>\n<td>Simple management of snapshots<\/td>\n<td>No snapshots; depends on file system<\/td>\n<\/tr>\n<\/table>\n<h2>Conclusion<\/h2>\n<p>Choosing between installing Linux in a VM using VirtualBox or using WSL largely depends on your development needs and workflow. If you require full isolation and are working with graphical applications, VirtualBox might be your best bet. However, for a lightweight and efficient solution integrated into Windows, WSL offers an excellent alternative.<\/p>\n<p>Regardless of the method you choose, the ability to leverage Linux tools enhances your productivity and the overall development experience. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing Linux in a VM (VirtualBox\/WSL) As a developer, having access to multiple operating systems can be a game-changer. Whether you\u2019re looking to build applications in a Linux environment while primarily using Windows, or you simply want the flexibility that Linux offers, installing Linux in a virtual machine (VM) is an excellent solution. In this<\/p>\n","protected":false},"author":97,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1140],"tags":[959,1163,842,1164],"class_list":["post-9975","post","type-post","status-publish","format-standard","category-introduction-installation","tag-installation","tag-linux","tag-setup","tag-virtualization"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/9975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/users\/97"}],"replies":[{"embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/comments?post=9975"}],"version-history":[{"count":1,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/9975\/revisions"}],"predecessor-version":[{"id":9976,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/posts\/9975\/revisions\/9976"}],"wp:attachment":[{"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/media?parent=9975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/categories?post=9975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/namastedev.com\/blog\/wp-json\/wp\/v2\/tags?post=9975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}