Tuesday, 3 July 2012

VirtualBox + Lubuntu - proxies, guest additions and customization

Recently, I got to use Linux at work but because all the machines were Windows and I couldn't be bothered to wipe the drive and put linux on, I decided to use VirtualBox to run it in parallel.

I chose a lightweight version of Ubuntu, called Lubuntu. There is another lightweight one called Xubuntu as well, however, from what I have read when comparing those 2, lubuntu seems to use less system resource and maintain its usability.

I'm just going to list all the steps I took to setup proxies, install vbox guest additions and command prompt customizing. This post can serve as a reminder for myself if I ever going to do the same thing again.

My settings in vbox is as follow:

  • Linux | Other
  • 512 MB RAM
  • fixed 12GB VHD


1. Create a file called "95proxies" into /etc/apt/apt.conf.d - for updates in Lubuntu

vi /etc/apt/apt.conf.d/95proxies
Acquire::http::proxy "http://<user>:<password>@<proxy-url>:<port>/";

2. Update packages

sudo apt-get update
sudo apt-get upgrade


3. Install guest additions - copy & paste between Windows and scrolling enabled


sudo /media/[VBOXADDITIONS]/VBoxLinuxAdditions.run


4. Create a share folder between Windows and Lubuntu

Vbox Manager -> Settings -> Shared Folders -> Add



5. Mount the share folder

mount -t vboxsf [share] [mount-point]


6. Auto-mount of the share folder when start-up

vi /etc/fstab
[share]   [mount-point]   vboxsf

OR if it doesn't work, since there was a bug in my version of Lubuntu (12.04):

vi /etc/init.d/rc.local
mount.vboxsf -w [share] [mount-point]

7. Customizing command prompt - editing the bash file
vi ~/.bashrc
## Set the PS1 prompt#

colorsblue='\[\e[0;34m\]'

BLUE='\[\e[1;34m\]'

brown='\[\e[0;33m\]'

cyan='\[\e[0;36m\]'

CYAN='\[\e[1;36m\]'

GREEN_BR='\[\e[1\;32m\]'

green='\[\e[0;32m\]'

GREEN='\[\e[1;32m\]'

magenta='\[\e[0;35m\]'

MAGENTA='\[\e[1;35m\]'

RED_BR='\[\e[1\;31m\]'

red='\[\e[0;31m\]'

RED='\[\e[1;31m\]'

yellow='\[\e[1;33m\]'

NC='\[\e[m\]'

PATH=$PATH:/sbin

GPG_TTY=`tty`

PS1="${red}\t-${cyan}\w${NC}\n${BLUE}\u${NC}@${RED}\h${NC}\` if [[ \$? = 0 ]] ; then echo ${GREEN_BR}\\\>\\\:\\\)${NC}; else echo ${RED_BR}\\\<\\\:\\\(${NC}; fi \`"




alias ls='ls -p'


8. Set up proxy for Internet connections

Right click on Desktop -> Create New... -> Shortcut.
Set up shortcut as follow:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Chromium Browser
Name[en_AU]=Chromium Browser
Icon=chromium-browser
Exec=/usr/bin/chromium-browser --proxy-pac-url="<proxy-pac-url>"
Comment[en_AU]=Web Browser
vi ~/.bashrc
## Set proxy

function proxy(){

 echo -n "username:"

 read -e username

 echo -n "password:"

 read -es password

 export http_proxy="http://$username:$password@<host>:<port>/"

 export HTTP_PROXY="http://$username:$password@<host>:<port>/"

 export https_proxy="http://$username:$password@<host>:<port>/"

 export HTTPS_PROXY="http://$username:$password@<host>:<port>/"

 export ftp_proxy="http://$username:$password@<host>:<port>/"

 export FTP_PROXY="http://$username:$password@<host>:<port>/"

 echo -e "\nProxy environment variable set.\n"

}

function proxyoff(){

 unset username

 unset password

 unset HTTP_PROXY

 unset http_proxy

 unset HTTPS_PROXY

 unset https_proxy

 unset FTP_PROXY

 unset ftp_proxy

 echo -e "\nProxy environment variable removed.\n"

}
To start the proxy, just run "proxy" in the command prompt.
To turn it off, just run "proxyoff"
This way, I don't have to manage the password in 2 locations.



That's it! all done =)