VirtualBox on Windows (Host)

Hi there!

In this post, we will setup VirtualBox on Windows with Linux as a Guest OS. Follow the steps to begin:

Downloading and Installing VirtualBox

Download the virtual box setup from here. Under VirtualBox binaries, select package for Windows Hosts. Also, download VirtualBox Extension Pack, we will need it later for when we setup our Guest OS.

Also we need to download our favorite Linux distro. I am using Ubuntu latest version (as of this date), you can get it from here.

We will run VB setup wizard and install VirtualBox on our drive (you can specify the location where you want to install it).

Install Extension Pack

Run VirtualBox for the first time. Go to File > Preferences or use shortcut key (Ctrl + G). In the Preferences dialog box, go to Extensions.

Add the extension pack that we downloaded earlier. We can do so by either Right Click > Add Package or pressing the button (Add New Package) on the right hand side of the window.

Once weagree to the terms of conditions, we’ll able to install the extension pack.

Press Ok to close the Preferences dialog box.

Creating a New Virtual Machine

Click on New button to create a new virtual machine (VM). It will open up a wizard to create a VM. Enter the name for our VM (I’m using ‘Ubuntu 16.04.2’ same as the version of my Ubuntu). Click Next.

Select the amount of RAM we want to assign to this VM. I’ve assigned 8GB as I have 32GB but you can assign as per your preference. Click Next.

It will ask us whether we want to add virtual hard disk to this machine or not. We will make sure to select ‘Create a virtual hard disk now‘ option before we click Create button. Select the size of the hard disk and then we are done.

Installing OS on VM

Right click on the VM we just created and select Settings. In General Settings, go to Advanced tab, change ‘Shared Clipboard‘ and ‘Drag’n’Drop‘ to Bidirectional.

In Storage settings, we can see that under Controller: IDE it shows Empty. Select this Empty option and we will see that Attributes on the right hand side changes. Click on the CD icon next to the Optical Drive option and select the Choose Virtual Optical Disk File option to choose Ubuntu Iso we downloaded.

Check Live CD/DVD option below that as well. And then Press Ok to close the Settings.

Start the VM by right clicking and selecting the Start > Normal Start.

Now we can install Ubuntu on this Machine.

Setting things in Ubuntu (Guest)

Once we have installed Ubuntu on our VM, we will start it. Now go to Devices > Insert Guest Additions CD Image. It will ask to run, then enter your password to install it. Then restart Ubuntu after it is installed.

Go to Devices > Shared Folders > Shared Folders Settings. Right click and then select Add Shared Folder. Select the folder path that we want to share. Make sure you select Auto mount and Make Permanent and press Ok.

Shut down the Ubuntu OS.

Restart your VM, and voila your system is ready with Shared Folder

Note: If you get Permission denied error on accessing the shared folder, just add your username to vboxsf group using command:
sudo adduser <username> vboxsf

Connect to Wi-Fi Network through Ubuntu Terminal

Lot many people end up in a situation where they want to use internet while in console mode. It’s not that difficult task to connect to the Wi-Fi from the terminal.
There are some simple steps that you need to follow.

  1. Open the terminal.
  2. Type ifconfig wlan0 and press Enter. You will not see any output in the terminal, as this command just turns your wireless card on. Most wireless cards are designated wlan0. If yours has a different designation, use that instead.
  3. Type iwconfig wlan0 essid name key password and press Enter. Replace name with the actual network name, and replace password with the actual security key for the network. If your wireless network does not require a security key, do not enter key password.
    Note: If you want to type the ASCII password, you would use iwconfig wlan0 essid name key s:password.
  4. Type dhclient wlan0 and press Enter to obtain an IP address and connect to the WiFi network.


Enhancing your Vim in Ubuntu!

NOTE: This tutorial is for the people using Ubuntu 12.04 or above.

Hello and welcome to this tutorial for enhancing your favourite text editor Vim. ^_^
For those who don’t know what Vim is, check out its official website or this wikipedia page.

And those who are already familiar with it, lets advance to enhance. 😀
Lets see what we are going to do today. We will be updating our VIm with a plugn known as YouCompleteMe (YCM).

YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vim. It has several completion engines: an identifier-based engine that works with every programming language, a semantic, Clang-based engine that provides native semantic code completion for C/C++/Objective-C/Objective-C++ (from now on referred to as “the C-family languages”), a Jedi-based completion engine for Python, an OmniSharp-based completion engine for C# and an omnifunc-based completer that uses data from Vim’s omnicomplete system to provide semantic completions for many other languages (Ruby, PHP etc.).

Ok now moving on first we ensure that our Vim is compatible for this plugin.
Open your Vim, if not installed then you can skip this step, type

If the version of the Vim is atleast 7.3.584 then its fine otherwise you may have to build it from source which is very easy to do.
So if you found out that your version of Vim is not upto-the-mark, then we have to remove it first before building it again.
Run the following commands in your terminal:
sudo apt-get remove vim vim-runtime gvim
and also
sudo apt-get remove vim-tiny vim-common vim-gui-common
These will remove the Vim installation from your system.

Now the next step is to build it from the source. Run these commands:
cd ~
hg clone
cd vim
./configure --with-features=huge \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-perlinterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim74a
sudo make install

We have now successfully build the newer version of Vim on our system and now the next step is to install YCM plugin.
Type :echo has('python') in Vim. The output should be 1. This tells us that our Vim has Python support which is required for our plugin.

Now we will install YCm using Vundle. Its a Vim plugin manager.
To download Vundle run the following commands:
git clone ~/.vim/bundle/vundle
and then we must configure our bundles in .vimrc file. If you can’t find the file in your home folder then you may need to create it with following content:

set nocompatible ” be iMproved
filetype off ” required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

” let Vundle manage Vundle
” required!
Bundle ‘gmarik/vundle’

” My Bundles here:

” original repos on github
Bundle ‘tpope/vim-fugitive’
Bundle ‘Valloric/YouCompleteMe’
Bundle ‘Lokaltog/vim-easymotion’
Bundle ‘rstacruz/sparkup’, {‘rtp’: ‘vim/’}
Bundle ‘tpope/vim-rails.git’
” vim-scripts repos
Bundle ‘L9’
Bundle ‘FuzzyFinder’
” non github repos
Bundle ‘git://’
” git repos on your local machine (ie. when working on your own plugin)
Bundle ‘file:///Users/gmarik/path/to/plugin’
” …

filetype plugin indent on ” required!

” Brief help
” :BundleList – list configured bundles
” :BundleInstall(!) – install(update) bundles
” :BundleSearch(!) foo – search(or refresh cache first) for foo
” :BundleClean(!) – confirm(or auto-approve) removal of unused bundles

” see :h vundle for more details or wiki for FAQ
” NOTE: comments after Bundle command are not allowed..

You can see that I’ve added a bundle for YCM too.
Now open your Vim and run

This will install all the bundles. 🙂

And we are done! ^_^
If you get the ycm_core library not compiled error then you need to recompile it by following commands.
cd ~/.vim/bundle/YouCompleteMe
./ --clang-completer

Also ensure that you have python headers installed if not then install by
sudo apt-get install python-dev

Two most common errors

  1. Lock error:
    E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?The reason is quite obvious from the error itself “another process using it”.The idea would be to look for another application which is being installed or update it. Wait for it to finish the installation or cancel it. If you cannot see the application then try running this command in the terminal to solve this error:
    $ sudo rm /var/lib/apt/lists/lock

    Any other type of lock can be removed using:
    $ sudo rm <address of error>


  2. 0%[waiting for headers]:
    Try restarting your system, and if the problem still presists then, run following commands in terminal
    $ sudo apt-get clean
    $ sudo apt-get update
    P.S- You can run upgrade command after update as “apt-get upgrade” upgrades what you have on the system already but doesn’t introduce new packages unless absolutely necessary.