<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Beatriz Rodrigues</title>
    <description>The latest articles on DEV Community by Beatriz Rodrigues (@devbeatriz).</description>
    <link>https://dev.to/devbeatriz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F872747%2F1c3c59a2-5110-4958-9f76-7bd31b2b615d.jpg</url>
      <title>DEV Community: Beatriz Rodrigues</title>
      <link>https://dev.to/devbeatriz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devbeatriz"/>
    <language>en</language>
    <item>
      <title>🧪How to Build a Linux Lab Using Vagrant</title>
      <dc:creator>Beatriz Rodrigues</dc:creator>
      <pubDate>Sun, 22 Jun 2025 02:03:02 +0000</pubDate>
      <link>https://dev.to/devbeatriz/how-to-build-a-linux-lab-using-vagrant-5fbd</link>
      <guid>https://dev.to/devbeatriz/how-to-build-a-linux-lab-using-vagrant-5fbd</guid>
      <description>&lt;p&gt;Hello, folks! 👋&lt;br&gt;
I'm excited to share a tool I recently discovered that's been a game-changer for setting up Linux study labs: &lt;strong&gt;Vagrant&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At its core, Vagrant automates the creation and management of virtual machines. But here's a crucial point: it &lt;strong&gt;doesn't create the VM on its own&lt;/strong&gt;. It needs a provider to do that (like VirtualBox, VMware, Hyper-V, Docker, etc.).&lt;/p&gt;

&lt;p&gt;For this example, I'll be using &lt;strong&gt;VirtualBox&lt;/strong&gt;, and all commands were executed in &lt;strong&gt;PowerShell&lt;/strong&gt; on Windows.&lt;/p&gt;


&lt;h2&gt;
  
  
  Installing the Tools
&lt;/h2&gt;

&lt;p&gt;First things first, download and install these two:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.virtualbox.org/wiki/Downloads" rel="noopener noreferrer"&gt;VirtualBox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.hashicorp.com/vagrant/install" rel="noopener noreferrer"&gt;Vagrant&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Preparing Your Environment
&lt;/h2&gt;

&lt;p&gt;Once everything's installed, &lt;strong&gt;open PowerShell&lt;/strong&gt;. You can use the &lt;code&gt;Win + S&lt;/code&gt; shortcut, type "powershell," and run it as an administrator.&lt;/p&gt;

&lt;p&gt;Choose where you want to create your virtual machine. In my case, I'm using my second drive (D:), so I navigated to the folder with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;D:\labs&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Creating Your Machine
&lt;/h2&gt;

&lt;p&gt;You have two paths here. If you want to get straight to it, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;centos/7&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will automatically create the configuration file (&lt;code&gt;Vagrantfile&lt;/code&gt;) with the CentOS 7 box pre-configured. However, if you prefer to set things up manually (define memory, CPU, static IP, etc.), you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate an empty &lt;code&gt;Vagrantfile&lt;/code&gt; that you can then customize to your liking.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I won't delve into &lt;code&gt;Vagrantfile&lt;/code&gt; configuration in this post, as the goal is practicality. But if you're looking for something more tailored, a quick search will definitely help!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Bringing Up Your VM
&lt;/h2&gt;

&lt;p&gt;Now, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;up&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to access your machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And just like that, you're inside your VM! 😎&lt;/p&gt;




&lt;h2&gt;
  
  
  Some Distros You Can Try
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ubuntu/jammy64&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;debian/bookworm64&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;generic/rocky9&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find many more options here: &lt;a href="https://app.vagrantup.com/boxes/search" rel="noopener noreferrer"&gt;https://app.vagrantup.com/boxes/search&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Managing Your VM
&lt;/h2&gt;

&lt;p&gt;Beyond &lt;code&gt;vagrant up&lt;/code&gt; and &lt;code&gt;vagrant ssh&lt;/code&gt;, here are some other useful commands for managing your machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;halt&lt;/span&gt;&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="c"&gt;# gracefully shuts down the machine&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;suspend&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c"&gt;# suspends the VM and saves its current state&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;resume&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="c"&gt;# resumes the VM from where it was suspended&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;reload&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="c"&gt;# restarts the VM, applying changes from the Vagrantfile&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;vagrant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;destroy&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c"&gt;# completely destroys the VM, removing everything&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Final Tips
&lt;/h2&gt;

&lt;p&gt;While &lt;code&gt;vagrant ssh&lt;/code&gt; works fine, I personally prefer using &lt;strong&gt;PuTTY&lt;/strong&gt; or &lt;strong&gt;MobaXterm&lt;/strong&gt; to access the VM via SSH. I find them more stable and convenient than PowerShell.&lt;/p&gt;

&lt;p&gt;If you have any questions, feel free to drop them in the comments!&lt;br&gt;
&lt;strong&gt;Happy studying and happy testing!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>vagrant</category>
      <category>homelab</category>
    </item>
  </channel>
</rss>
