DEV Community

RockAndNull
RockAndNull

Posted on • Originally published at paleblueapps.com on

Spin up command-line Ubuntu VMs in (almost) seconds

Spin up command-line Ubuntu VMs in (almost) seconds

Sometimes, you need a clean and disposable Linux environment to test configuration changes, try out a new tool, or simply isolate your experiments from your main system. There's a lightning-fast and easy way to launch Ubuntu command-line virtual machines (VMs) on Windows, macOS, or even Linux.

This is a super quick primer on how you can get started quickly. In less than 10 minutes you can have your command line Ubuntu VM.

What is Multipass?

Developed by Canonical (the company behind Ubuntu), Multipass provides a streamlined way to manage Ubuntu VMs. With a single command, you can spin up a fresh Ubuntu instance, perfect for those quick testing scenarios.

Multipass VMs have a relatively small footprint, conserving your system resources.

Quick start

Firstly, head to the Multipass website and follow the installation instructions for your operating system.

Launch your first VM

multipass launch 

Enter fullscreen mode Exit fullscreen mode

That's it. This command downloads the Ubuntu image and boots up a VM. As soon the latest Ubuntu LTS (long-term support) image is downloaded and deployed, you will be entered into the shell.

Every time you run this command a new VM is created.

Launch an existing VM

mutlipass shell <vm-name>
Enter fullscreen mode Exit fullscreen mode

For follow-up runs, use this command to launch into the shell of an existing VM. If you only have 1 VM, you can omit vm-name.

Mount a host directory

multipass mount <source-path-on-host> <vm-name>:<mount-point-in-vm>

Enter fullscreen mode Exit fullscreen mode

The default name for the vm-name is primary.

Start/Stop/Delete/List VMs

multipass delete <vm-name> 


multipass start <vm-name>


multipass stop <vm-name>


multipass list

Enter fullscreen mode Exit fullscreen mode

Quite self-explanatory commands. With these, you can manage the VMs in your system.

Modify VM resources

Almost certainly, you will need to modify the resources of your VMs at some point. Fear not, you can do it quickly (documentation):

multipass set local.<vm-name>.cpus=4

multipass set local.<vm-name>.disk=60G

multipass set local.<vm-name>.memory=7G
Enter fullscreen mode Exit fullscreen mode

Alternatives for VMs with GUI

If you require a full-fledged Linux VM with a graphical desktop environment:

  • UTM (macOS): A streamlined VM solution tailored for macOS. Highly recommended, really polished, and easy to use.
  • VirtualBox (Windows, macOS, Linux): A powerful and versatile virtualization platform with more extensive configuration options.

Give Multipass a try the next time you need a quick and isolated Linux environment. Its simplicity and speed will make it an indispensable tool in your development workflow.

Happy hacking!

Top comments (0)