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.
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:
Once at the VirtualBox Download webpage, download VirtualBox
After downloading VirtualBox, install it.
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:
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.”
To uninstall Hyper-V, open “Turn Windows features on or off”. You can do this by going to the start menu and typing “Turn”
Now uncheck Hyper-V and click “OK”. This will require a few restarts.
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.
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 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.
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.
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.
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.
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.
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
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.
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.
After you click “Start”, you should be prompted to install Ubuntu. Select “Install Ubuntu” button.
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.
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.
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.
Once Ubuntu starts, you should see a screen like the following. Ubuntu is now successfully installed.
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.
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
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”
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.
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.
Now enter your password “demo” in the Authenticate dialog to continue to install your software. Your password may be different.
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.
Now let’s install Visual Studio code. But first, we need to download it.
In Chrome or browser of choice, navigate to:
Select to download the .deb (Debian) version of VSCode
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.
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.
Now VSCode will launch.
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”.
Here’s the documentation to install NodeJS using a package manager. Go to the section “Debian and Ubuntu based Linux distributions”
In the Node documentation, it shows the following command to run to install Node
If you try to run the commands above, you get an error that ‘curl’ is not installed.
Let’s install Curl.
In the terminal enter the following
sudo apt install curl
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 –
Now to install Node, use the following command:
sudo apt-get install -y nodejs
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.
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
Enter the following to confirm that Git was installed:
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.
Comparison of platform virtualization software
How To Install Git on Ubuntu 16.04
Installing Node.js via package manager
Ubuntu – Package management with APT
Running VS Code on Linux