Kick-start: Create a Linux(Ubuntu) Environment for Windows Developers using VirtualBox, VSCode, Git, NodeJS

I enjoy working with Visual Studio Code (VSCode). Since it’s available for Linux and Mac, I thought I would give it a try in a different environment. As a Windows developer, I’ve wanted to try out Linux. In the past when I have attempted to work in Linux, I was overwhelmed with all the tools, configuration and such that must be learned to be productive.

I had a very difficult time finding beginner information that is current of setting up a Linux development environment. I found bits and pieces but nothing that showed end-to-end of how to get started.

In this post, I will describe how to setup a development environment in Linux (Ubuntu). The main technologies I will work with are the following:

  • Oracle VirtualBox – 5.1.14
  • Linux Ubuntu 64-bit: 16.04
  • Visual Studio Code (VSCode): 1.9.1
  • NodeJS: 6.9.5
  • Git: 2.7.4

This post is about setting up a basic Linux (Ubuntu) development environment.  I assume that the user is familiar with Windows and has very basic knowledge of hypervisor software to manage virtual machines.

I’m using Windows 10 as my host system. I don’t believe it should matter what host you are using, because other than VirtualBox, everything in this post will be installed on Linux Ubuntu.

Installing VirtualBox

We need somehow to run Ubuntu. To do this we need a Hypervisor. A hypervisor is software that runs virtual machines. There are many hypervisors available (Hyper-V, VMWare, VirtualBox, etc). I have selected Oracle VirtualBox for the following reasons:

  • Runs on Windows
  • Free for personal use
  • Easy to use
  • Very popular
  • Large Community

Let’s install VirtualBox by going to VirtualBox webpage:

https://www.virtualbox.org/wiki/Downloads

VirtualBaox Download
VirtualBaox Download

Once at the VirtualBox Download webpage, download VirtualBox

After downloading VirtualBox,  install it.

VirtualBaox Install
VirtualBaox Install

 Download Linux Ubuntu Desktop

When we create our virtual machine using VirtualBox we will need an image (iso) of Ubuntu to install. We will get this iso from Ubuntu’s website. It’s important that you download the desktop version of Ubuntu. Download Ubuntu Desktop from here:

https://www.ubuntu.com/download/desktop

Ubuntu Desktop Download
Ubuntu Desktop Download

Note: We will be running Ubuntu 64-bit. If you are running Windows 10, you may have issues installing 64-bit version of Ubuntu. I’m not sure if Hyper-V is installed by default on Windows 10, but if it is installed, you will need to uninstall it if you want to run 64-bit virtual machines.

Note: While investigating Docker for Windows, I stumble across this
“Docker for Windows requires Microsoft Hyper-V to run. After Hyper-V is enabled, VirtualBox will no longer work, but any VirtualBox VM images will remain.”

Docker for Window and Hyper-V
https://docs.docker.com/docker-for-windows/install/#/what-to-know-before-you-install

To uninstall Hyper-V, open “Turn Windows features on or off”. You can do this by going to the start menu and typing “Turn”

Turn Windows features on or off for Hyper-v
Turn Windows features on or off for Hyper-v

Now uncheck Hyper-V and click “OK”. This will require a few restarts.

Turn off Hyper-v in Windows
Turn off Hyper-v in Windows

Installing Ubuntu Virtual Machine

Now let’s get to the fun part. Lets install Ubuntu as a virtual machine on VirtualBox. Start VirtualBox. Once VirtualBox starts, you should see something like the following image.

Oracle VM VirtualBox Manager
Oracle VM VirtualBox Manager

To create a virtual machine (VM), select the button “New”. You should see a form to create a new Virtual Machine (see image below). In the form enter a Name. The name I used is “UbuntuDemo”. Once you type “Ubuntu”, notice the “Type” and “Version” is automatically selected. Also, notice that the version is “64-bit”. If you do not see “64-bit” then refer to the note above about Windows 10 & Hyper-V.

Note: Here, were are not installing Ubuntu on the virtual machine.  This will be done later. Here are just configuring and setting-up the virtual machine.

Note: Ubuntu Minimum and Recommended System Requirements

Ubuntu Desktop 16 Minimum System Requirements
https://help.ubuntu.com/community/Installation/SystemRequirements
Ubuntu Desktop 16 Recommend System Requirements
https://www.ubuntu.com/download/desktop

Ubuntu will run on 2 GB of memory, but that is the recommended requirements. I went ahead and set the memory for this Ubuntu virtual machine to 4 GB.

Set the Hard disk option to “Create a virtual hard disk now” and select “Create” button.

Create Virtual Machine
Create Virtual Machine

Now let’s create the hard disk. On the next form, for the most part, you can keep all the defaults except for the “File Size” option. Ubuntu recommended requirement is 25 GB for the disk size. To be safe and so that I can install additional software on the Ubuntu virtual machine, I set the file size to 30 GB.

I leave everything else as default. Now select the “Create” button.

 Create Virtual Hard Disk
Create Virtual Hard Disk

Update: I just looked at VirtualBox Virtual Media Manager for the actual size of disk spaced used by Ubuntu.  It was only 4.86 GB.

VirtualBox Virtual Media Manager

Configure Ubuntu Virtual Machine

Here we will make some basic changes to the virtual machine configuration. We will change the number of processors the virtual machine uses and enable the ability to share the clipboard between our Windows 10 host and the Ubuntu virtual machine.

Note: For these changes to take affect the virtual machine will need to be stopped or if the virtual machine is running, it will need to be restarted.

Note: In the following images for Oracle VM VirtualBox Manager, there are two virtual machines. Please ignore the first “ubuntu” vm.  We will be creating the “UbuntuDemo” vm.

To change virtual machine settings, select “UbuntuDemo” from Virtual Box, and then select “Settings” button.

 Configure Oracle VM VirtualBox Managaer Settings
Configure Oracle VM VirtualBox Managaer Settings

To enable the ability to enable clipboard sharing, select the “General” from the left navigation. Then select the “Advanced” tab. Now change the settings for “Shared Clipboard” and “Drag’n Drop” to Bidirectional.

This feature comes in handy when you want to copy and pasted text from your host to the virtual machine or visa-verse.

Configure Oracle VM VirtualBox Manager Settings Shared Clipboard & Drag n' Drop
Configure Oracle VM VirtualBox Manager Settings Shared Clipboard & Drag n’ Drop

By default, the Ubuntu virtual machine is configured to use only one processor. On my computer the Ubuntu VM runs a little sluggish with only one processor, so I went ahead and up the processor to 3. Depending on your computer, you may want to change this setting.

To change the number of processors, in settings dialog select the “System” in the left-side navigation. Then select the “Processor” tab. At this point, you can change the number of processors that the VM will use

Configure Oracle VM VirtualBox Manager Settings Processor Count
Configure Oracle VM VirtualBox Manager Settings Processor Count

Installing Ubuntu

Now that we have the virtual machine configured, let’s start the VM and install Ubuntu.

To start a virtual machine, in VirtualBox Manager select “UbuntuDemo” and then select the “Start” button.

Start Ubuntu Virtual Machine from Oracle VM VirtualBox Manager
Start Ubuntu Virtual Machine from Oracle VM VirtualBox Manager

The virtual machine will start in a new window. The first screen you will see is a dialog to select the start-up disk. This is where we install Ubuntu on the virtual machine. We need to tell the virtual machine where the Ubuntu Desktop installation file is located.

On “Select start-up disk” dialog, select the small folder icon in the bottom right corner. Another dialog (not shown) will be displayed to select the Ubunto .iso file to install. My iso file was called “ubuntu-16.04.2-desktop-amd64.iso”; the name of your file may be a little different.

Once you find the Ubuntu .iso file, select the “Start” button.

Select Ubuntu file image to install on Virtual Machine
Select Ubuntu file image to install on Virtual Machine

After you click “Start”, you should be prompted to install Ubuntu. Select “Install Ubuntu” button.

Setup Ubuntu Welcome
Setup Ubuntu Welcome “Install Ubuntu

The following dialogs are fairly straight forward. I will not step you through these next few dialogs, but for your convenience, I have included the screenshots of the dialogs.

 Ubuntu setup and Install - Preparing to install Ubuntu
Ubuntu setup and Install – Preparing to install Ubuntu
Ubuntu setup and Install - Installation Type
Ubuntu setup and Install – Installation Type
Ubuntu setup and Install - Installation Type confirmation
Ubuntu setup and Install – Installation Type confirmation
Ubuntu setup and Install - Where are you
Ubuntu setup and Install – Where are you
Ubuntu setup and Install - Keyboard Layout
Ubuntu setup and Install – Keyboard Layout
Ubuntu setup and Install - Who Are you
Ubuntu setup and Install – Who Are you
Ubuntu setup and Install - Welcome to Ubuntu
Ubuntu setup and Install – Welcome to Ubuntu
Ubuntu setup and Install - Installation Complete - Restart
Ubuntu setup and Install – Installation Complete – Restart

After you select “Restart Now”, you may get a message “Please remove the installation medium…”. If you get this message, it means that the Ubuntu .iso file is still attached to the virtual machine optical drive. If you continue without detaching the Ubuntu .iso file from the virtual machine, you will go through the installation process again.

VirtualBox Ubuntu. Please remove installation medium, then press ENTER
VirtualBox Ubuntu. Please remove installation medium, then press ENTER

To detach (remove) the Ubuntu .iso from the virtual machine, on the virtual machine window select “Devices” –> “Optical Drives” –> “Remove disk from virtual drive”. Now press “Enter” on your keyboard. Now Ubuntu will start.

How to remove installation medium from VirtualBox
How to remove installation medium from VirtualBox

Once Ubuntu starts, you should see a screen like the following. Ubuntu is now successfully installed.

Ubuntu installation complete first screen
Ubuntu installation complete first screen

Note: To shut down Ubuntu from Ubuntu, in the top right corner of the desktop is the current time, misc buttons, and a power button. Selecting the power button will show you a menu with “Shut Down” as an option.

Ubuntu Power Button
Ubuntu Power Button
Ubuntu shut down
Ubuntu shut down

Installing Google Chrome

First thing I do after I install Ubuntu is to install Google Chrome browser. Firefox is installed by default on Ubuntu, but you can install another browser if you want. By installing Google Chrome, I present some of the dialogs that will be show when installing software on Ubuntu.

Google Chrome Desktop Download

https://www.google.com/chrome/browser/desktop/

Download Google Chrome
Download Google Chrome

Once you select download, you will prompted to select what type of Linux you are running. We are running a derivative of Debian. Therefore, select the option that includes “.deb”

Download Google Chrome for Linux - 64 bit .deb for Debian and Ubuntu
Download Google Chrome for Linux – 64 bit .deb for Debian and Ubuntu

Once you select “Accept and install”, you will be prompted what to do with the file. I usually just open the file, but if you want, you can save the file.

Since I don’t expect I will need to install Google Chrome again, I will select the “Open with” option.

Chrome Download options
Chrome Download options

When installing software, Ubuntu will prompt you to confirm that you trust the software you are installing. If you do trust the software you are installing, select the “install” button.

 Confirm installing software
Confirm installing software

Now enter your password “demo” in the Authenticate dialog to continue to install your software. Your password may be different.

Authenticate installing software
Authenticate installing software

Run Applications – Google Chrome

I want to install Visual Studio Code (VSCode). But to do this I need to download it first using Chrome. There are a few ways to start an application. I’m going to show you the main way I start programs that are not on the application bar.

In the top left corner of the desktop, there is a purple icon (see image below). This icon opens “Dash”. Dash provides the ability to search for applications, files, music and etc. Since we want to start Chrome, select the “Dash” icon and type “chrome” in the text box. An icon for Chrome will display. Select the Chrome icon to start Chrome.

Note: You can open “Dash” search prompt by using the win key on your keyboard.

Note: The icons that are displayed can be dragged-n-dropped to the application toolbar.

Run Chrome Application with Ubuntu Dash
Run Chrome Application with Ubuntu Dash

Install Visual Studio Code (VSCode)

Now let’s install Visual Studio code. But first, we need to download it.

In Chrome or browser of choice, navigate to:

https://code.visualstudio.com/download

Select to download the .deb (Debian) version of VSCode

Download Visual Studio Code (VSCode) for Ubuntu .dib
Download Visual Studio Code (VSCode) for Ubuntu .dib

The installation process of VSCode is the same as installing Chrome, which we did above. I will go ahead and provide images of the installation process.

Ubuntu Install Application
Ubuntu Install Application
Authenticate installation with password
Authenticate installation with password

Now that VSCode is installed, we can now run it. The process to run VSCode is the same as running any other application. Open “Dash” search and type “Code” in the text box.

Run Visual Studio Code (VSCode) in Ubuntu using Dash
Run Visual Studio Code (VSCode) in Ubuntu using Dash

Now VSCode will launch.

Installing Node.js

Node.js is very popular these days. I use Node in most of my web development. Since this is a common tool, let’s install it.

Instead of downloading and installing from a website, we will use a tool similar to Windows Command Prompt or PowerShell to install Node. In Ubuntu, this tool is called Terminal.

To start the application Terminal. Open “Dash” search, type terminal in the text box. You may get multiple results, but select the application named “Terminal”.

Ubuntu terminal using Dash
Ubuntu terminal using Dash

Here’s the documentation to install NodeJS using a package manager. Go to the section “Debian and Ubuntu based Linux distributions”

https://nodejs.org/en/download/package-manager/

In the Node documentation, it shows the following command to run to install Node

Using Curl to install nodejs on Ubuntu
Using Curl to install nodejs on Ubuntu

If you try to run the commands above, you get an error that ‘curl’ is not installed.

Error running curl in Ubuntu terminal
Error running curl in Ubuntu terminal

Let’s install Curl.

In the terminal enter the following

sudo apt install curl

installing curl using terminal in ubuntu
installing curl using terminal in ubuntu

Now that curl is installed, now we can try to install Node.

First, we need to select what version of Node we want, this is done using Curl. Use the following command in Terminal.

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash –

using curl using to download nodejs on Ubuntu
using curl using to download nodejs on Ubuntu

Now to install Node, use the following command:

sudo apt-get install -y nodejs

install nodejs using sudo and apt-get on Ubuntu
install nodejs using sudo and apt-get on Ubuntu

Now let’s validate that Node was installed successfully.

In Terminal, type “node”. This will show the “>”. Now type “4+4” and then enter. The answer of 8 should be returned. We have now confirmed that Node is installed. To exit node press [ctrl]+C twice.

confirming Nodejs was installed successfully on Ubuntu
confirming Nodejs was installed successfully on Ubuntu

Install Git

Another common tool that is used by developers, is Git. Git is a source code repository.

We are going to install Git similarly to how we installed Node, but without using Curl. To install Git, enter the following:

sudo apt-get install git

installing git using terminal, sudo, and apt-get on Ubuntu
installing git using terminal, sudo, and apt-get on Ubuntu

Enter the following to confirm that Git was installed:

git –version

confirming git install successfully using git --version on Ubuntu
confirming git install successfully using git –version on Ubuntu

Conclusion

If you never have used Linux and want to get started developing in a Linux environment, it can be difficult. Hopefully this post has helped you kick-start your software development in Linux Ubuntu.

Resource

Comparison of platform virtualization software
https://en.wikipedia.org/wiki/Comparison_of_platform_virtualization_software

How To Install Git on Ubuntu 16.04
https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-16-04

Installing Node.js via package manager
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

Ubuntu – Package management with APT
https://help.ubuntu.com/community/AptGet/Howto

Running VS Code on Linux
https://code.visualstudio.com/docs/setup/linux

Leave a Reply

Your email address will not be published. Required fields are marked *