This post is now deprecated

This post might have outdated content and is no longer maintained.

Set up inch perfect Linux Dev environment on Mac

I am a Linux user before I bought Mac to develop for iOS. I am a Mac user since 2011. That’s almost 5 years but still, whenever I get a hold of Linux anywhere, I just love it.

So, after struggling for a while with brew and the Mac OS X tool chain, I tried Vagrant but was not pleased. Vagrant is just an abstraction over what can be achieved with simple shell scripts and vanilla VirtualBox.

Following are the things I did to get up and running. My targets of this exercise were:

  1. Being able to SSH into a Linux machine (Virtual Machine).
  2. Being able to use host machine IDE / editors to edit text.
  3. Being able to use host browser to access guest machine web servers, if any.
  4. Decouple the VM up to an extent where in I can move it between different computers and SSH into it to feel home.
  5. Have the VM backup-able. This shall complete all the requirements that are fulfilled by using Vagrant without having to type Vagrant ever.

Here is how I got about it:

  1. Download VirtualBox ( )
  2. Download your Favorite Linux distro. Mine is Fedora
    ( ) but I will be using Ubuntu server [ I do not need GUI ] ( ) this time around. As I had a few apt-get scripts for quick installation.
  3. Install Ubuntu into VirtualBox.
  4. Next, open VirtualBox, run Ubuntu VM. To be able to ssh into this guest machine from host machine, install a ssh server using
    sudo apt-get install openssh-server
    Make it auto start when the VM runs ( ). This covers point 1 from requirements.
  5. Now, go to your VirtualBox setting for this VM and make the shared folder part look like this
    Then run this command to load the host machine folders in guest, this will cover up the point 2 from requirements.
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) host_machine ~/host_machine

Do something to run this command on all system starts, so this linking of host / guest file system is auto done (

VirtualBox Settings Mounting Hard Drive
VirtualBox Settings Mounting Hard Drive

6. Also, to be able to SSH into this VM and to serve point 3 from requirement list, I am sure there would be other ways but the easiest is port forwarding. Where in, we can use the host browser to open, say, localhost:8080 and it will open localhost:80 of guest VM. To do this, again open VirtualBox settings for this VM, go to port forwarding in Network section and make it look like

VirtualBox Settings Port Forwarding
VirtualBox Settings Port Forwarding

7. I think with all this, we are good to go. Start the VM in background using

VBoxManage startvm ubuntu14 — type headless

8. SSH into your brand new VM using

ssh -p 2222 <user>@localhost

Feel free to reach out to me for suggestions to improve this post @divyenduz
I did this weeks ago, today I just wrote the post at full speed. There may be a few quirks, If you find one, let me know, I will update the article accordingly. I find this way of working (dev env) very comfortable, even thought I have not yet done too much work this way.
Will share my experience of how this went after using the same for a few months :)

Happy coding ! :)