/ mozey.co / blog

virtual box ubuntu 16.04 tutorial

May 19, 2017

🔗 Virtual Box

🔗 Disk

Use the VMDK disk format, it’s compatible with other virtualization software

Select dynamic size and split the disk into 2GB chunks

🔗 Install

Once the virtual machine has been created start it to select the ubuntu iso

Go through the installation manually

🔗 Networking

User NAT

Setup port forwarding for 2222 on host to 22 on guest, assuming OpenSSH was installed the following should now work on the host

ssh -p 2222 [email protected]

🔗 Shared folders

Add the share

Settings > Shared Folders > Machine Folders
# Auto-mount
# Make permanent

sudo reboot now

sudo usermod -a -G vboxsf USER

Create a symlink

cd ~/

ln -s /media/sf_SHARE SHARE

# User might have logout/login first

🔗 Software


🔗 Apache

Setup port forwarding, using prevents connections not originating on the host

Setting > Network > Advanced > Port Forwarding
# HTTP 8080 =>  80
# HTTPS 8443 => 443

Test from host, should show default apache page


Also see setting up virtual hosts


Ssh to VM then use mysql client to connect

mysql -u root -p

use mysql;

show tables;

select * from user\G

select Host, User from user;

MySQL tutorial

SQL tutorial


Tests it’s working

echo "<?php print(1+2);" | php

🔗 Python

Tests it’s working

echo "print(1+2)" | python

🔗 SQLite

Create a database

cd ~

sqlite3 file.db


create table monkey (id integer primary key, name text not null);


insert into monkey (name) values ('chris');
insert into monkey (name) values ('pj');

select * from monkey;


Delete the database

ls -lah file.db

rm file.db

🔗 Postgres


🔗 ELK stack

sudo apt-get install openjdk-8-jdk

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-5.x.list
sudo apt-get update && sudo apt-get install elasticsearch

# Set max mem available to ES by changing -Xms option, e.g. -Xms512m,
# as a rule of thumb make it half the system mem
sudo vi /etc/elasticsearch/jvm.options

Start ES service

sudo service elasticsearch start

Allow remote connections

sudo vi /etc/elasticsearch/elasticsearch.yml
# network.host:
sudo service elasticsearch restart

Port forwarding

Setting > Network > Advanced > Port Forwarding
# Elastic Search 9200 => 9200

Make sure firewall is disabled

sudo ufw disable

Confirm ES is running


🔗 Kibana

sudo apt-get install kibana
sudo service kibana start

Allow remote connections

sudo vi /etc/kibana/kibana.yml
# server.host: ""
sudo service kibana restart

Port forwarding

Setting > Network > Advanced > Port Forwarding
# Kibana 5601 => 5601

Confirm Kibana is running


🔗 Filebeat


🔗 Logstash


🔗 X-Pack

cd /usr/share/elasticsearch
sudo bin/elasticsearch-plugin install x-pack

Encrypting communication