0

New Ubuntu virtual machine

Virtual machines are awesome, you can create and destroy entire pc setups, clone them, take snapshots, install software in a sandbox, all sorts of things. In learning python in a linux environment getting some VM software was a brilliant way to go and you can do it for free, personally I went with VirtualBox but fill your boots. Here’s a quick step by step of the process I went through – because I’ll need to do it again and this is the best place to put the notes!.

Operating system:

The virtual machines won’t come with one so what are you going to put on it? [link to ubuntu] is a good way to go, make sure that you grab the .iso filetype and you’ll be able to mount it directly to the machine’s virtual CD drive.

The console:

So yeah, Linux uses a console to enable the user to get around rather than making everything available through point and click interfaces and that’s awesome because it means that going through the install process for something like this is much easier than on a windows system. Here are the commands to download and install the basics.

Go go go!

  • The guest additions make a load of things work like a shared clipboard, shared folder with the host machine and lots of other things, to install VirtualBox guest additions:
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install build-essential module-assistant
    $ sudo m-a prepare
    $ sudo sh VBoxLinuxAdditions.run
    $ sudo apt-get install virtualbox-guest-dkms
    $ sudo reboot
  • Show Python3 version:
    $ python3 --version
  • Install Python if needed:
    $ apt-get update
    $ apt-get install python3.6
  • Install git:
    $ sudo apt install git
  • Configure git:
    $ git config --global user.name "Joi Baker"
    $ git config --global user.email "Joi_Baker@Hotmail.com"
  • Mount shared folder (I’ll write some more on this soon) where vmShare is the name of the shared folder that you create in Devices and ~/pcShare is the name of the folde you’ve created on the vm:
    $ sudo mount -t vboxsf vmShare ~/pcShare
  • grab a text editor – here I’ve gone for Notepadqq:
    $ sudo add-apt-repository ppa:notepadqq-team/notepadqq
    $ sudo apt-get update
    $ sudo apt-get install notepadqq

 
The next task is to make sure that the current git branch is displayed in the bash terminal – this can save all kinds of problems committing to the wrong branch etc and it’s nice to have a pretty interface.

  • First open your bashrc file, this file dictates the behaviour of your bash terminal and I’ll go into more detail another time. Do this by entering the following
    $ gedit ~/.bashrc
  • Ensure that the following is somewhere in your bash file above where PS1 gets set:
    # Add git branch if its present to PS1
    parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
    }
  • set your PS1 in the following way:
    if [ "$color_prompt" = yes ]; then
     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
    else
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
    fi
    unset color_prompt force_color_prompt

 
From here you’ll be wanting to install some software, for me I wanted a linux box to play around with python so I went with Komodo as my main IDE and from there I was ready to roll. Next steps were to clone all of the repos that I was interested in working on and I was away!

JBaker

Joi is an IT Development Analyst working in London and a consummate technophile. Whilst he isn't coding he can be found reacquainting himself with his guitars, spinning poi, looking for climbing walls or chasing the latest shiny thing to cross his field of vision.

Leave a Reply

Your email address will not be published. Required fields are marked *