How to access guest VM in Virtualbox via port forwarding

How to access guest VM in Virtualbox via port forwarding

By  •  VirtualBox

You’ll not be able to directly access your guest virtual machine in Virtualbox via SSH or RDP if it’s under NAT network. For this you’ll have to configure port forwarding as detailed below;

  1. Go to Virtualbox‘s main interface and make sure the virtual machine that you want to configure is powered off.
  2. Select your virtual machine and click Settings icon on the top toolbar. Alternatively, right click on the virtual machine and click Settings.
  3. Click on the Network tab in Settings main interface.
  4. Look for and click on Advanced text at the bottom of the window.
  5. Click on Port Forwarding button.
  6. Click on the + icon on the upper right to add new port forwarding rule in Port Forwarding‘s main interface.
  7. Some of the fields are automatically filled up as the followings.
  8. Fill in the fields accordingly.

    In this example, port 2202 in the host machine will forward to port 22 of the guest machine whereby is the default IP for guest VM under NAT network.

  9. Test the forwarding rule.

    $ ssh -p2022  [email protected]
    Warning: Permanently added '[]:2022' (ECDSA) to the list of known hosts.
    [email protected]'s password:
    Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-83-generic x86_64)
     * Documentation:
     * Management:
     * Support:
    0 packages can be updated.
    0 updates are security updates.
    Last login: Fri Jul  7 09:29:30 2017
    [email protected]:~$

    SSH is used to test the forwarding rule as SSH is listening on port 22 of the guest VM.

How to display non-Javascript page for browser with no Javascript support

By  •  JavaScript

When a browser doesn’t support Javascript, or simply have it disabled, it’s best to include an alternative non-Javascript content for the page to remain functional.

This is made possible with the noscript tag, and the example below will pop up the alert if Javascript is enabled or supported, and display the text instead if it doesn’t.

<script type="text/javascript">
    window.alert("I support Javascript")
    I do not support Javascript

How to check hard-drive’s health status in Linux

By  •  Linux

SMART or Self-Monitoring, Analysis, and Reporting Technology is used to monitor the hard drives for reliability. Hard drive’s failure can be anticipated and appropriate action can be taken before the hard drive fail completely.

To check your hard drive’s health status in Linux, the tool smartctl can be used. It is available in the smartmontools package, and in Ubuntu running the command at the terminal will install the package

sudo apt-get install smartmontools

Assuming your hard drive is /dev/sda, running the following command will return the SMART’s health status of your hard drive

sudo smartctl -H /dev/sda

A healthy hard drive will return the following output

smartctl 5.40 2010-03-16 r3077 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen,

SMART overall-health self-assessment test result: PASSED

The following is an example output of a problematic hard drive

smartctl 5.40 2010-03-16 r3077 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen,

Log Sense failed, IE page [scsi response fails sanity test]

How to enable syntax highlighting in Vim

By  •  Vim

Vim can perform syntax highlighting for various file formats. You can enable it with these steps if it’s not currently enabled;

  1. Make sure full version of Vim with support for syntax highlighting is installed.

  2. Manually enable syntax highlighting while in Vim.
    1. Enter command mode by pressing Esc.
    2. Type :syntax on|off and press Enter.

      :syntax on
  3. Manually set syntax for file if required.
    1. Enter command mode by pressing Esc
    2. Type :set syntax=<filetype> and press Enter.

      :set syntax=php
    3. To view the list of supported file types, issue :echo getcompletion while also in the command mode.

      :echo getcompletion('' 'filetype')
  4. Permanently enable syntax highlighting by adding :syntax on in your ~/.vimrc file.

Hello world!

By  •  Uncategorized

Welcome to This is your first post. Edit or delete it, then start blogging!

How to track Google AdSense earnings in Google Analytics

Google Analytics is a great tool for web analytics. Its uses range from tracking the number of visitors to a site, to tracking effectiveness of online marketing campaign. One of the other feature of Google Analytics is to track earnings from Google AdSense program.

While Google AdSense has its own reporting tool, there are just things that Google Analytics can do better. This includes page-level details of earning tracking that is not available from the Google AdSense member page. Google AdSense reporting tools in the other hand has Custom channel and URL channel reporting option that’s not available in Google Analytics.

Both tools complement each other, and using them both would give better insight of your AdSense earnings and optimization strategy.

To start viewing Google AdSense data in Google Analytics, follow these steps.