In this article you are going to work through setting up a Linux Virtual Box environment to run your code locally. You will work through the process by:
- Downloading and Installing Virtual Box
- Downloading and Mounting Learn Linux Virtual Drive (Lubuntu 32-bit)
- Setting Up GIT and SHH with Github
- Testing out a Learn lab
- Cool Tricks
This tutorial assumes you are using a Windows PC, if you are wanting a local dev environment for MAC (go to http://help.learn.co/workflow-tips/local-environment/mac-osx-manual-environment-set-up) or Linux (go to https://github.com/learn-co-curriculum/linux-env-setup)
- 2 GB of Ram (4GB Recommended)
- Dual Core CPU (4 core Recommended)
Step 1: Downloading and Installing Virtual Box
For this step you will be installing Oracle's Virtual Box software. This is a free piece of software that allows you to run a virtual Linux machine by sharing some of your systems hard drive space, RAM and CPUs. To download Virtual Box click the link below:
This will download version 5.2.4 (This guide is using 5.2.4, so please make sure to use the 5.2.4 version from the link above)
You should find the downloaded VirtualBox.exe file in your Downloads folder at C:\Users\Username\Downloads (or wherever your browser places the download).
Please click on the VirtualBox.exe file to start the Setup Wizard.
This should start up the Setup Wizard with a screen saying welcome.
Please click on the "Next" button and proceed to the first Custom Setup page.
The first Custom Setup page will ask for some custom setup options. Leave the default settings and click on the "Next" button.
The second Custom Setup page will ask for some quick launch bar and shortcut options.
Please make sure all of the boxes are selected and click the "Next" button.
The next screen will deal with Network Interfaces.
The Virtual Box needs access to the PC's network interface so go ahead and click "Yes" on this screen.
The next page will ask if your ready to install the Virtual Box software.
Go ahead and click on "Install" to start the installation process.
If a window pops up asking, “Do you want to allow this app to make changes to your device?” Click the “Yes” button.
After the installation process, you should see a Installation is Complete screen.
Please check the “Start Oracle VM VirtualBox 5.2.4 (Or the version you downloaded) after installation” checkbox and click on "Finish" to launch the Virtual Box application. You will leave the Virtual Box application alone for now, as you need to download and mount the Learn virtual box image first.
Step 2: Downloading and Mounting the Learn Linux Virtual Drive (Lubuntu 32-bit)
For this step you will be downloading a version of Linux that is setup to use with Learn.co. This will be relatively easy to setup and can be customized for performance if you feel comfortable with power user settings in the Virtual Box settings.
Please go to https://s3.amazonaws.com/linux-virtual-environment/LearnLubuntu-v1.12.ova and start the download for the LearnLubuntu Virtual Machine image.
Once this is downloaded you should be able to find the LearnLubuntu virtual machine in your C:\Users\Username\Downloads folder.
Please open up the Virtual Box Image, if it's not already open, and click on the tab File -> Import Appliance.
You will need to select the appliance image on this screen. Please click on the yellow folder button with the green ^ arrow and find the LearnLubuntu.ova appliance image you downloaded.
Select the LearnLubuntu file and click on the "Open" button.
This should then show the LearnLubuntu.ova file in the Appliance to import file location:
For the line c:\Users\Username\Downloads\LearnLubuntu.ova make sure to replace "Username" with your Windows User account name.
For example: c:\Users\Rukku\Downloads\LearnLubuntu.ova
Then click the "Next" button and proceed to the "Appliance Settings" screen.
Please just leave these as defaults (It should set these automatically for you with your system settings), and click on the "Import" button.
It should then start the importing process:
This should take between 5-60 minutes depending on the speed of your machine.
Once this completes, you should see the LearnLubuntu machine in the Virtual Box Manager toolbar, as shown below.
Select the LearnLubuntu image, if not already selected and click the "Start" button. This should start the application.
Note!! You might have an issue with network configurations on your first attempt to run the virtual machine. If you see this error:
Click on the "Change Network Settings", which should bring up this screen:
Make sure that the Attached to: has "Bridged Adapter" chosen, and the virtual box should automatically detect your Network Adapter, it will most likely not be the same as this screenshot, but should work the same. Once you verify the settings, click on the "OK" button and it should restart the Linux virtual machine and may ask for login info (typically this does not appear).
If it asks for login credentials, they are:
Make sure to change these settings in your linux box!!
Congratulations you now have a Virtual Linux Development Environment. The environment comes packaged with the LXTerminal, Visual Studio Code (text editor) and Kate (text editor if Visual Studio Code is slowing down your machine).
Installation Issues with Black Screen, No Network, System Restarting, Hyper-V, etc..
A majority of black Screen, no network, system restarting, and Hyper-V issues are caused by Hyper-V being enabled by default on most Windows 8/10 machines. If your encountering this issue please disable it by following this guide:
- Open Windows Features
- Look for Hyper-V in the list.
3. Click on the checkbox next to Hyper-V and make sure it is not checked
4. Next Click on "OK".
5. Restart the computer when you get a prompt. This does require a restart to work correctly.
Step 3: Setting up GIT and SSH with Github
Now that you have the Linux environment working you will probably want to connect it to your Github account, so that you can fork, clone and push up repos from Github.
You can follow the instructions for setting Github Email and Username at https://help.github.com/articles/set-up-git/ & or follow along below.
First let's verify that you have git on your machine. Please run:
This should return the current version.
If you do not have it installed, you can install it by running:
sudo apt-get install git-all
Once you have verified that you have git we need to setup your git info. Make sure you know your Github username and email for this step.
Setting up Github Email:
git config --global user.email "firstname.lastname@example.org"
Replacing "email@example.com" with your Github login email address.
Setting up Github Username:
git config --global user.name "Username"
Replacing "Username" with your Github username.
Setting up SSH with Github
For setting up the SSH key please use Github specific directions at https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux
With these steps completed you should be able to fork, clone and push up repos from Github. We will test this in the next step.
Step 4: Testing Out A Learn Lab
For this step you will try out a lab to verify everything is working.
On this page click on the "Clone or download" button followed by the "Clone with SSH" button and then the "Copy to clipboard" icon to the right of
ctrl + c to copy the git address. Then open up the Linux terminal and run:
Note to paste or copy from the terminal in linux you need to run the commands shift + ctrl + v (Paste) or shift + ctrl + c (Copy)! Let's clone down the repo now:
Note!! The first time you run a git clone it might state that it can establish connection with RSA key fingerprint. Ignore this warning and type "yes" and enter/return.
Once the clone is downloaded to the machine go ahead and type the following commands:
Find your OAuth token at the bottom of your learn.co profile screen then copy and paste it into your terminal window and type "return/enter" on your keyboard. This should authenticate learn for you. Go ahead and type
learn in the terminal again and you should see something like this:
Congratulations!! You are ready to work on your local Linux Virtual Machine Environment.
Step 5: Cool Tricks
For best performance, use Chrome on your Windows PC. If you are using
shotgun, rails server, yarn start, npm start, etc.. you will be able to open up the application in Chrome on windows by going to your virtual machine ip address followed by the localhost number. For example
rails server will start an application at localhost:3000, but to open it in your native Window's Chrome app you will have to go to
10.0.0.24:3000 . The
10.0.0.24 in this example is your virtual machine's hosted server. To find out what this ip address is type
ifconfig -a and look for the
inet addr: line that has a
Mask address as well. Please check out the following image for an example:
Notice how the 2nd line has
inet addr:10.0.0.26 Bcast:10.0.0.255 . Mask:255.255.255.0 . That is the ip address for this virtual machine (your's might be a different address). Write this ip address down somewhere or remember this command so that you can easily access your web apps in Chrome.
Note for Rails 4 Labs
For Rails 4, you'll need to bind the IP address of your server to 0.0.0.0 in order to access it using the IP address you got from
ifconfig -a in the previous step. If you're just installing VB now, you should be able to run
rs from your terminal (this is a bash alias for
rails s -b 0.0.0.0 ).
If you've already gone through the installation and you're referring back to this article, you can add this to your bash profile:
alias rs="rails s -b 0.0.0.0" . You can run
code ~/.bash_profile to open the file in VS Code.
After you've added the line and saved the file, you'll need to open a new terminal window or run
source ~/.bash_profile in an open terminal window before the
rs alias will be available to you.
Visual Studio Code Editor:
This Virtual Box Machine comes with Visual Studio Code built in (https://code.visualstudio.com/) to access Visual Studio Code at anytime you can click on the desktop shortcut or in the terminal type
code . Notice the
. is one space after
code this is very important! This command will open up the Visual Studio Code application with the current directories files.
To open a specific file in terminal type
code followed by the file name. For example if you had a file called tic_tac_toe.rb you would type
code tic_tac_toe.rb .
One thing cool about the Virtual Box is you can run the Linux applications in seamless mode to make them feel like native apps on your Host OS. To start this mode open up your terminal in the LearnLubuntu Virtual Box and then use the key combo:
right CTRL + L
This will switch you to seamless mode and make your day instantly brighter.
To exit seamless mode type
right CTRL + L again.
Full Screen Mode:
To enter full screen mode and do all of your dev work in Linux type:
right CTRL + F
To exit full screen mode type
right CTRL + F again.