DEV Community

Zaki Arrozi Arsyad
Zaki Arrozi Arsyad

Posted on • Edited on

linux : running on mac machine

This is how I run linux in my machine.
I'm using brew for the installation.

1. Make sure brew is installed

hit brew --version in the terminal to see if brew is installed already. If there is no brew installed, let’s just add it into our machine.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Enter fullscreen mode Exit fullscreen mode

2. Install VirtualBox

Run this command to add VirtualBox in our machine

brew install cask virtual box
Enter fullscreen mode Exit fullscreen mode

Then check the installation using this command vboxmanage --version

3. Install Vagrant

Next, we will need Vagrant to help us running and getting in to the linux machine.

brew install vagrant
Enter fullscreen mode Exit fullscreen mode

Then check the installation using vagrant --version

4. Let’s start the linux machine

These are the main things to run linux.

- Creating a Virtual Machine

vagrant init <boxpath>
Enter fullscreen mode Exit fullscreen mode

You can choose linux version that you want. go to this source here.
In case we want to use ubuntu1804, we can type vagrant init ubuntu/bionic64 .
This command will generate a Vagrantfile for us.

- Starting a Virtual Machine

vagrant up
Enter fullscreen mode Exit fullscreen mode

This command will start our linux machine in virtualbox. We can see if our machine is up already by typing this command.

vagrant status
Enter fullscreen mode Exit fullscreen mode

- Getting into a Virtual Machine

vagrant ssh <boxname>
Enter fullscreen mode Exit fullscreen mode

In this case, we only use default Vagrantfile which is generated from vagrant init <boxpath> instead of set the box name. We can simply run vagrant ssh to get into out VM.
Welcome to linux machine !!

- Stoping a Virtual Machine

vagrant halt
Enter fullscreen mode Exit fullscreen mode

This will stop the VM. We can simply run vagrant resume to start the VM again.

- Cleaning up a Virtual Machine

vagrant destroy
Enter fullscreen mode Exit fullscreen mode

This command will delete the VM, and we need to run vagrant up if we want to run the Linux machine again.

Top comments (0)