DOKK Library

Linux Voice [Issue 4]

Authors Linux Voice

License CC-BY-SA-3.0

Plaintext
The magazine that gives back to the Free Software community

July 2014                                                                             115 PAGES
RASPBERRY PI               SERVER HARDENING          CUSTOM HARDWARE                  OF NEURAL
WILDLIFE                  SECURITY                   FPGAs                            ENHANCEMENT!
Spy on badgers with        Keep one step ahead       Program a sound chip
the Pi’s camera module     of the script kiddies     for crunchy 8-bit bleeps




UBUNTU
14.04
RESPINS
The world’s biggest
distro has spawned
a new breed – find
your favourite!




                                                                                34+ PAGES OF TUTORIALS
ACER C720 Chromebooks: now officially a great laptop
                                                                                        July 2014 £5.99 Printed in the UK




CODE CLUB Teach the world to code, one child at a time
JOHN VON NEUMANN The man who invented your processor

 RASPBERRY PI                                GAMES

 ROBOTICS                                    STEAM OS
 Make a start on                             Install it now and level
 your cyborg army                            up your Linux gaming
                                                                                                                              WELCOME



Linux for human beings
The July issue



Linux Voice is different.
Linux Voice is special.
Here’s why…                                                                              GRAHAM MORRISON
                                                                                         A free software advocate
      At the end of each financial                                                       and writer since the late
 1
      year we’ll give 50% of our                                                         1990s, Graham is a lapsed
profits to a selection of                                                                KDE contributor and author
organisations that support free                                                          of the Meeq MIDI step
software, decided by a vote among                                                        sequencer.
our readers (that’s you).


                                          W
                                                       here would we be without Ubuntu? Even if you don’t
       No later than nine months                       agree with the direction it’s taken in recent years, there’s
   2
       after first publication, we will                very little doubt in my mind that Linux would be much,
relicense all of our content under        much worse off had Mark Shuttleworth not decided to spend
the Creative Commons CC-BY-SA             a proportion of his Thawte windfall going to space creating the
licence, so that old content can          Ubuntu Foundation. It transformed public expectation of what Linux
still be useful, and can live on even     was and could be, making it easy to install and making Ubuntu
after the magazine has come off           as close to a standard for commercial and hardware vendors as
the shelves.                              possible. This has had a positive effect on all Linux distributions.
                                             Anyone can build on the good work of both the Debian and
      We’re a small company, so           Ubuntu teams to create their own distributions, and it’s this
 3
      we don’t have a board of            initiative and diversity that we’re celebrating in issue 4. Each
directors or a bunch of                   Ubuntu derivative has a unique reason for being different, and         SUBSCRIBE
shareholders in the City of London
to keep happy. The only people
                                          the success or failure of these derivatives depends entirely on
                                          how effective those distributions are at communicating and             ON PAGE 60
that matter to us are the readers         implementing their ideas. I can’t think of a more democratic
(you again).                              system for success, and it only happens with Free Software.

                                          Graham Morrison
THE LINUX VOICE TEAM                      Editor, Linux Voice
Editor Graham Morrison
graham@linuxvoice.com
Deputy editor Andrew Gregory
andrew@linuxvoice.com                     What’s hot in LV#004
Technical editor Ben Everard
ben@linuxvoice.com
Editor at large Mike Saunders
mike@linuxvoice.com
Games editor Liam Dawe
liam@linuxvoice.com
Creative director Stacey Black
stacey@linuxvoice.com
Malign puppetmaster Nick Veitch
nick@linuxvoice.com
Editorial contributors:
                                          ANDREW GREGORY                       BEN EVERARD                        MIKE SAUNDERS
Mark Crutch, Josette Garcia, Juliet
Kemp, John Lane, Vincent Mealing,         Code Club is having a very real      It’s wonderful to be able to       Ben is very much keeping the
Simon Phipps, Jonathan Roberts,           and positive effect on how IT is     welcome Chris Brown to Linux       spirit of Colin Pillinger alive with
Mayank Sharma, Valentine Sinitsyn         taught to children in the UK. This   Voice, and he kicks off with an    his own Mars Rover project made
                                          makes me happy. p30                  ace guide to processes. p64        from an ice cream carton! p78



                                                            www.linuxvoice.com                                                                      3
             CONTENTS


                                                                                                                          July LV004
Beauty is truth, truth beauty. That is all ye need to know.
     18
                                                                                                SUBSCRIBE
                                                                                                ON PAGE 60

     UBUNTU
     14.04                                                                         REGULARS
                                                                                   06    News

     RESPINS
                                                                                         In the wake of Heartbleed,
                                                                                         OpenSSL forks. DON’T PANIC!

                                                                                   08    Distrohopper
                                                                                         What’s going to be on your
                                                                                         Linux box in 2015.

                                                                                   10    Gaming
                                                                                         The latest AAA-grade titles
                                                                                         are coming your way!

                                                                                   12    Speak your brains
                                                                                         Let us know what’s going on in
                                                                             30          your precious grey matter.


     CODE CLUB:                                                                    16    LV on tour
                                                                                         Epistles from Lisbon,
                                                                                         Dubrovnik and Lincolnshire.



     THE NEXT                                                                      40    Interview
                                                                                         We visit England’s Maker Belt
                                                                                         to speak to Pimoroni.



     GENERATION                                                                    54    Group test
                                                                                         The best terminal emulators
                                                                                         to help you Get Stuff Done.
                                                                                         Sysadmin
      Inspire the kids of today to achieve                                         62
                                                                                         Turn your ever-waking eye on
      great things. You can be their Yoda!                                               the logs. Intruders, fear me!

                                                                                   64    Core technologies
                                                                                         Linux Voice welcomes a
                                                                                         new writer: Dr Chris Brown.

                                                                                   68    FOSSpicks
                                                                                         Only the hottest free software
                                                                                         makes it into these pages.

                                                                                   102   Code ninja
                                                                                         Error correction: because
                                                                                         only Ben Everard is perfect.

                                                                                   110   Masterclass
                                                                                         Media players of the graphical
                                                                                         and command line flavour.
34
     STEAMOS                  38
                                   FAQ LLVM/Clang: the    26   KANO                114   My Linux desktop
                                                                                         We peek into the control room
     How Valve is shaking          future of compiling         Make computers as         of gamingonlinux.com.
     up the world of games.        code on Linux.              easy as Lego.


4                                                  www.linuxvoice.com
                                                                      REVIEWS
TUTORIALS
  76                                78




                                                                      46   Acer C720 Chromebook
                                                                           With one hand Google gives
                                                                           excellent hardware. With the
Make your own typeface            Raspberry Pi:                            other it takes our privacy…
with BirdFont                     Build a Mars Rover
Design software has never         Create robots programmable
been more accessible. Now         in Python quicker than you can
go and brand something!           say “Sarah Connor”.

  84                                86



                                                                      48   Ubuntu 14.04 The latest Long
                                                                           Term Support version of the
                                                                           world’s biggest distro has
                                                                           quietly enthused us. Shhhh!
                                                                      49   TBS Matrix An ARM box that
                                                                           doubles as a smart TV device,
                                                                           running XBMC and Tvheadend.
Raspberry Pi: Monitor             SSH, Apache & Tiger:                     Sounds good to us!
woodland creatures                Secure your servers
Keep tabs on your local badger    Stay one step ahead of the script
population with a remote,         kiddies who want to vandalise
home-brewed wildlife camera.      your web servers.


  90                     94                     FPGAs: Build
                                               98

                                              your own custom         50   BitScope BS10 Electronics
                                              sound chip                   tinkerers, rejoice: you have
                                                                           nothing to lose but your
                                              Dip your toe into            ignorance of current through a
                                              chip design                  given component.

VirtualBox: Keep John von                        Android:
                                               104                    52   Books Fresh reading matter to
                                                                           further enhance your neurons.
Windows XP       Neumann:                     Develop your
after migration… EDVAC & IAS                  first application
… should you wish      The Manhattan project Fun and frolics on a
to, that is.           bore strange fruit…   free phone OS.



                                         www.linuxvoice.com                                                 5
     ANALYSIS




NEWSANALYSIS
The Linux Voice view on what’s going on in the world of Free Software.
Opinion



Lessons for Open Source from Heartbleed
The armageddon has been and gone – let’s not waste a good crisis

                           Simon Phipps             OpenSSL in other projects. There’s been         exist with a proprietary solution. Engaging
                           is president of the      speculation why. An obvious explanation is      would need permission and bureaucracy,
                           Open Source Initiative
                                                    that the cryptographic complexity of the        and many contributors would just say no.
                           and a board member
                           of the Open Rights       code meant that non-specialists were not
                           Group and of Open        effective as community participants, but US     Should I make donations?
                           Source for America.      government open source specialist David A       So what’s the right way to react? Fork the
                                                    Wheeler has speculated that the unusual         code? No, that’s been done, and probably
                                                    licensing arrangement for OpenSSL – a           just increases the problem by removing
                                                    custom open source licence with non-GPL-        potential expert participants from the
                                                    compatible copyleft effects and potentially     OpenSSL pool. Re-implement it? That’s been



W
             e’ve had a while for the shock of      challenging advertising clauses – also          tried as well. Even with various forks and
             the Heartbleed announcement to         discouraged community involvement.              re-implementations, OpenSSL remains
             sink in and there’s a lot to              Exploit detection turned off: What can a     widely used, because the problem is
consider. While the first impressions might         small community do to spot uninitialised        complex and the experts are few. Those new
be about the serious, exploitable bug and the       memory and buffer over-run errors? String       projects are unlikely to surpass in a few
repercussions of its abuse, the incident            handling libraries today often include          months what OpenSSL has largely
casts light on both the value and risks of          detection at compile-time or even run-time      succeeded at doing over a decade. Donate
open source. All programmers make                   for such errors, and the OpenBSD code used      money? While cash donations to a project
mistakes, so there’s no huge surprise that it       by OpenSSL for this purpose is no exception.    can be a short-term fix, in the long term it is
happened in OpenSSL. But why did it go              But according to Theo de Raadt, leader of       unlikely to help unless it leads to more
undetected for so long? There are several           the OpenSSH project, these detection            developers both writing and testing the
contributing factors.                               capabilities had been turned off at compile     code. The best fix would be for the
   It’s hard to spot error in complex code:         time in the OpenSSL build for performance       companies most dependent on OpenSSL to
First, the OpenSSL code is huge, years old          reasons long ago and had never been turned      hire experts and pay them to join the
and implements a set of algorithms that             on again, despite the performance issues        community and work on the code.
need specialist cryptographic knowledge to          being addressed in the code.                       This, after all, is the key to open source. It’s
understand them. Reading someone else’s                                                             not about free stuff; rather, open source
code in this context is difficult, dull and time    Would proprietary be better?                    delivers the liberties that enable developers
consuming. That’s not a recipe for scrutiny         Doing this with proprietary code would be       with differing motivations and origins to
even with a large paid team.                        unlikely to make things better. Hiding a        collaborate on a codebase without needing
   Community too small: There is no large,          development team behind NDAs and                to ask permission from anyone other than
paid team. The whole community                      corporate secrecy, having their priorities      each other, and even then only out of social
developing and maintaining OpenSSL was              driven by unseen managers and keeping           effectiveness. Throwing money at an open
no larger than 11 people before Heartbleed,         code invisible to potential users all           source project doesn’t automatically make
with only one of them working full-time on          constitute an anti-pattern for security         anything better; that takes people with
the code. Despite being widely deployed, the        software. In addition, the ability of open      actual skills.
community did not receive regular                   source to bring all the best hands to the          Heartbleed has shown us that open
participation from developers using                 problem once it’s identified would simply not   source is no guarantee of invulnerability.
                                                                                                    Fortunately, the crisis has highlighted a set
                                                                                                    of needs that are being met in a way no
“Throwing money at an open source project doesn’t                                                   other approach would have allowed. Looking
automatically make anything better.”                                                                past the crisis, it’s possible Heartbleed is
                                                                                                    actually making things become better, faster.



6                                                              www.linuxvoice.com
                                                                                                               ANALYSIS




CATCHUP                                     Summarised: the eight biggest news
                                            stories from the last month

          OpenSSL has been forked:                  Linus Torvalds wins                           Firefox 29 sports a
   1      say hello to LibreSSL              2      yet another award                      3      redesigned interface
           After all the fun and                      Not content with having won                  This has been massively
games of the OpenSSL Heartbleed           the Technology Academy of Finland’s           controversial, but then any major UI
vulnerability, which made vast swathes    Millennium Technology Prize, NEC’s            update for a well-used app always is.
of the internet open to cracking, the     C&C Prize, the Takeda Award for Social/       Firefox 29 features a trimmed-down
OpenBSD team (see news item 8) has        Economic Well-Being, the British              interface that “makes it easy to focus on
had enough. A bunch of developers         Computer Society’s Lovelace Medal             web content”. In addition the redesigned
has forked OpenSSL into LibreSSL,         and the Electronic Frontier Foundation        tab bar is “sleek and smooth to help you
and they’re going through the code        Pioneer Award, everyone’s favourite           navigate the web faster”. Sounds a bit
discovering some truly horrendous         narky kernel hacker has another to add        buzzwordy to us… www.mozilla.org
holes and coding errors. Right now the    to the list: the 2014 IEEE Computer
website is in Comic Sans with blink       Society Computer Pioneer Award. For
tags, but donations should fix that:      his contributions to computing, Linus
www.libressl.org                          can expect a bronze medal in the post.




          Canonical puts Ubuntu for                 Band releases album as a                      It’s official: Edward
   4      Android project in limbo           5      Linux kernel module                    6      Snowden is a Linux user
           Ubuntu maker Canonical is                This is charmingly silly.                       Many people suspected
ambitious with its plans to have the      Netcat, a Seattle-based band that             this all along, but now it has been
Unity interface everywhere: on phones,    “explores the intersection between            confirmed that leaker extraordinaire
tablets, TVs and desktops. One part of    technology, complexity and free               Edward Snowden used Linux in his data
this convergence strategy has been        improvisation” has just kicked out a new      gathering antics. Specifically, he used
kicked into the long grass though:        album. But listening to it is a challenge:    the Tails distribution, a highly paranoid
Ubuntu on Android. This was supposed      you have to build a custom kernel             flavour of Linux that routes all of its
to provide a regular Android experience   module that creates a /dev/netcat             internet traffic through Tor and stores
on your mobile devices, but when you      device node that you can then pipe into       everything in RAM (thereby leaving no
plugged them into a TV or monitor,        an audio player. But be warned: if you        trace of activity on a computer’s hard
you’d get the full Unity experience.      decide to go this far, you’ll need “several   drive). We still don’t know if he prefers
Canonical has said it isn’t dead, but     gigabytes of memory” to build it. See:        Vim over Emacs though. Tails’ site:
they’ll focus on Ubuntu phones for now.   http://tinyurl.com/netcatmod                  https://tails.boum.org




          New consortium that                                                                     Ultra-secure Unix flavour
   7      includes Microsoft to                                                            8      OpenBSD 5.5 released
          fund core FOSS projects                                                                 Hang on – this isn’t Linux!
More fall-out after the Heartbleed                                                      True, but we like to support our other
fiasco: a bunch of big-name                                                             FOSS brethren in the operating system
companies including Amazon, Dell,                                                       world too. OpenBSD is a lot like Linux,
Facebook, Google, IBM, Intel and                                                        offering oodles of advanced security
Microsoft have teamed up with the                                                       features but not so much desktop
Linux Foundation to offer financial                                                     hardware compatibility. It’s superb
support for “critical open source                                                       for small servers and routers though.
projects”. And guess which project                                                      The 5.5 release brings about a 64-bit
will receive funds first? Yes, OpenSSL.                                                 time_t, which means that the operating
Finally, the big companies that use                                                     system’s clock won’t overflow until
FOSS realise it doesn’t grow on trees.                                                  Sunday, 4 December in the year.
http://tinyurl.com/lrlmzh4                                                              292,277,026,596. www.openbsd.org




                                                    www.linuxvoice.com                                                              7
     DISTROHOPPER




DISTROHOPPER
We’ve tapped GCHQ’s communications to find out what’s going on in distro land.


KaOS
A simple and elegant KDE.


K
          aOS is about providing a simple,
          clean KDE experience. In order to
          achieve this, the developers have
slimmed the repositories to just over 2,000
packages. This is a minuscule number by
most distros’ standards, but it provides
everything most people will need.
   By reducing the amount of software
available, KaOS creates a consistent
environment containing only what the
distro’s creators think are the best
applications for each task. In some cases it
enables you to deviate your environment
from pure Qt, so Firefox and LibreOffice are
available (though not installed by default).
   The KDE interface is quite different from
the standard, and the focus seems to be on
keeping things simple. The developers have         We can’t think of a less appropriate name than KaOS for such a refined KDE experience.
managed to build a unique and slick desktop
without getting sucked into the pitfall of         little difficult for new users to get to know       full-time, as there just isn’t enough software
adding too many graphical effects – a trap         the system. It is, however, a minor gripe on        for us. It’s not aimed at us though – it’s
that’s all too common on KDE distros. Our          an otherwise excellent interface.                   intended to be a lean distribution, and that’s
only criticism of the user interface is the lack       Ultimately, we enjoyed experimenting with       what it is, as well as being probably the
of tooltips on the menu. This may make it a        KaOS, but we would struggle to use it               best-looking KDE distro we’ve used.




Deepin
Deepin is more than just a great software centre.


T
         he English-speaking Linux world has       of the screen, a little like the way that
         been a little slow to cotton on to the    Android settings slide down from the top.
         fact that Deepin has been a fantastic       The biggest let-down for this reviewer was
distro for a few years now (it’s Chinese). It      the Launcher (similar to Gnome’s Dash). It
was among the first to feature a software          spread the application icons out too thinly         The slide-out settings and browser home page
centre for finding, reviewing, and installing      and made it take too long to find what we           are both great, innovative features.
software. The Deepin Software Centre has           were looking for. Additionally, we wouldn’t
always been one of our favourite apps in this      recommend Deepin for lower-powered                  setup for easily selecting to search in Google
area, and the newest version is no exception.      machines, as the performance is just a little       or Bing for websites, videos, places, etc.
  Deepin has its own desktop environment           on the slow side.                                     Deepin deserves more praise than it gets
built on web technologies, and it looks great.       We really liked the attention to detail in        for producing some cracking pieces of
The best feature for us was the settings           some areas. For example, the home screen            software. If it could just sort out that pesky
menu. This slides out of the left-hand edge        of the web browser (Chrome) has a nice              launcher, it would be a top distro.



8                                                              www.linuxvoice.com
                                                                                                                                     DISTROHOPPER



Makulu
A quirky distro for quirky people.


M
            akulu comes with a number of
            different desktops, including the
            most recent release of Mate. All
of them are heavily themed with cartoon-y
icons and earthy colours, which give the
distro a pleasant, informal feel. Underneath
all this, Makulu is built on Debian, so there is
of course all the usual underlying Debian
software (plus a host of other repositories
including the ones from Mint, SolydXK,
Opera, Skype, various Google projects, Mate
and its own ones). In other words, there’s
loads of the latest software available.                   Makulu means ‘chief’ in Zulu – a fact that helps explain the distro’s styling.
    On launching Makulu, the first thing we
noticed was the office suite: Kingsoft. You               thing about Kingsoft is that it has an                 are also notifications for most popular social
may not have heard of this, but it’s been                 interface similar to MS Office’s ribbons. This         networks.
around for a while (though the Linux version              is a little controversial, but it could help             Makulu isn’t as polished as some distros,
is new. In fact, it’s still considered in Alpha).         newer Windows refugees feel at home. For a             and its strong personality will put some
It’s not open source, but it is free (no cost)            Linux user, a far more serious criticism of            people off, as will the inclusion of non-free
for the basic version. The most noticeable                this office suite (other than the fact that it’s       (as in speech) and social media software.
                                                                        closed source) is that it doesn’t        However, the developers have made some
                                                                        support ODF files.                       bold choices, and that’s refreshing to see. If
“The Makulu developers have                                                The web browser is Chrome,            you’re bored with mainstream distros and

made some bold choices, and                                             but with a number of extensions
                                                                        to make it a little more friendly.
                                                                                                                 looking for something a bit new and fresh,
                                                                                                                 Makulu is worth a look, if only to see what
that’s refreshing to see.”                                              Adblock Plus is probably the             can be done when a development team tries
                                                                        most notable of these, but there         something a little out of the ordinary.


  NexentaStor 4.0 Where ZFS feels at home

  NexentaStor isn’t Linux. It’s not even a BSD. It’s
  based on the Illumos kernel, which is derived
  from Solaris (via OpenSolaris), even further
  back in the Unix family tree. This is the branch
  of Unix where ZFS started life. This filesystem is
  the distro’s reason for living. In fact, the heart of
  NexentaStor is a web interface for managing
  ZFS data stores.
     For this purpose, it’s fast and hugely
  powerful. It’s perhaps better suited to managing
  enterprise storage solutions than setting up a
  home NAS system, but that doesn’t mean that
  you can’t use it for either task.
     After freely downloading distros of Linux and
  BSD, it felt a little weird to have to register for a
  licence to use NexentaStor. It is free (as in beer)
  for the community version, but it doesn’t feel
  very FLOSS-y to have to type in a licence code in
  order to get it to work.
     Once you get past this, there’s a powerful
  HTML interface for managing and configuring a
  mind-boggling array of options that remind you          Network storage isn’t everyone’s idea of a good time, but it can be quite an eye opener to see all
  that it’s not a plug-and-play system for quickly        the options laid out in NexentaStor’s absurdly powerful HTML interface.
  adding a backup server to your home network,
  but an enterprise-ready storage system for              designed to integrate well with OpenStack, the        about the ZFS filesystem, then using it on its native
  handling networked computers storing                    enterprise cloud platform that all big businesses     kernel is a good place to start. Likewise, if you’re
  terabytes of information. To this end, it’s             love these days. If you’re interested in learning     managing a data centre, it’s a useful option.




                                                                       www.linuxvoice.com                                                                               9
     GAMING ON LINUX




GAMING ON LINUX
The tastiest brain candy to relax those tired neurons

 GNAEUS JULIUS AGRICOLA
                                            Star Conflict
                                            Like being a real space pilot, without the risk of death.


                                            B
                                                     ig news space fans!
                                                     Star Conflict, a free-to-                                                         The action
                                                                                                                                    takes place in
                                                     play spaceship combat
                                                                                                                                   Sector 1337 of
                                            MMO has officially launched its
                                                                                                                                      the galaxy…
                                            Linux version as promised. This
                                            is one of our first major free-to-
                                            play titles that’s been released
 Liam Dawe is our Games Editor and
 the founder of gamingonlinux.com,          from outside Valve.
 the home of Tux gaming on the web.            The graphics are simply
                                            fantastic, which is surprising


 W
              ine enables us Linux users    for a free game. It also doesn’t
              to run Windows                shove anything into your
              applications under Linux
                                            face about paying for in-app
 without the need for a Windows
 licence. It sounds great, but it does      purchases – it’s all perfectly         The game starts you off           This is the first Linux game
 come with its own set of drawbacks,        optional, which is again very        slowly to not overwhelm you      from Star Gem Inc, and we
 such as poor performance in certain        surprising. You can buy extra        with a few tutorials showing     hope it will only be the start for
 games; and some games may refuse           credits for ships and paint jobs     you basic flight and combat,     them. See you in space!
 to work without a lot of tinkering.
                                            or buy downloadable content          which it makes really painless   http://store.steampowered.
    A problem has arisen now that
 Linux is gaining a foot-hold in the        (DLC) packs from Steam.              for you.                         com/app/212070/
 gaming market: “Wine Ports”,
 developers who bundle their game
 with a copy of Wine and call it a day. I
 know what you’re thinking: “That’s not
 a Linux port!”, and you are right. It
 seems some developers are trying to
                                            Counter Strike: Global Offensive
 short-cut their way onto Linux like        The next-generation of what was originally just a mod.
 they do on Mac OS X.



                                            D
    Sometimes bottling Wine along                     o you see yourself as a
 with a Windows game can be
                                                      counter-terrorism hero?
 acceptable, if, for example the source
 code to an older title has been lost;                Or do you see yourself
 we can live with that. This situation is   as an evil terrorist? Well now
 good because of two things: it gives       you’ll get the opportunity, as
 us a game we wouldn’t otherwise get,       Counter Strike Global Offensive
 and it counts as a Linux sale to the
                                            is coming to Linux. The news
 developers to show them interest for
 futures titles to be ported.               comes as a result of the Reddit
    The problem is when developers          “Ask Me Anything” that Gabe
                                                                                                                              The AK-47 remains
 look to cut corners and shoehorn a         Newell (the owner of Valve and                                                     a favourite among
 Linux version out the door without         Steam) did recently. There is no
 looking into porting it natively. This
                                                                                                                            discerning terrorists.
                                            ETA, but Gabe assured us that
 can be a problem, as these developers
 could see poor sales due to using          it is coming. With Valve’s
 Wine and Linux users being wise to         notorious “Valve Time” it could      shooter boasting improved        Game” where you swap guns
 that fact, the developers can then         still be a while before it comes     graphics, new game modes,        on each kill. The last weapon is
 easily claim Linux doesn’t sell.           to our beloved platform, so we       support for weapon               a knife, which doesn’t make it
    So I ask you dear readers, how do
                                            just have to be patient for a        customisation and a lot more.    easy, but it does make it
 you feel about Wine Ports? Let us
 know on the Linux Voice forum.             little while longer.                   One of the best parts of       interesting…
 http://forums.linuxvoice.com                   CS:GO is a next-generation       CS:GO is the frantic and         http://store.steampowered.
                                            police vs terrorists first-person    fun new mode called “Gun         com/app/730/



10                                                               www.linuxvoice.com
                                                                                                             GAMING ON LINUX


Luftrausers                                                                                   ALSO RELEASED…
Take on the Nazis in a crazy-coloured world.


L
        uftrausers is an arcade-style aerial
        combat game with some over-the-
        top action from the well-respected
developer Vlambeer.
   The game features over 125
combinations of weapons, bodies, and
propulsion systems offering you a lot of
customisation to keep you coming back                                                         Beatbuddy: Tale of the Guardians
for more. It also opens up different ways                                                     Your ears are in for a real treat with Beatbuddy:
to play each level as you try different                                                       Tale of the Guardians. The game is an
combinations to beat it, you can unlock                                                       exploration/puzzle game that involves music in
different colour-sets to play the game in to                                                  everything you do, with fantastic results. The
                                                                                              levels are all hand-painted giving it that extra
keep you interested.                                                                          loving touch, and it really is a beautiful-looking
   The game won’t bring your PC to a                                                          game. Stop the evil Prince Maestro from
crawl either, so it should work on some                                                       stealing all the music!
older computers. As it uses so little in teh                                                  http://store.steampowered.com/app/231040
way of system resources, you only need a       Luftrausers’ simplistic graphics and frantic
graphics card that has OpenGL 2.1, which       gameplay remind us of 80s arcade machines.
is quite old now.
   Luftrausers is a great timewaster for the   and more. It lacks the glitz of a modern
armchair general to sit back comfortably       FPS, but it’s full of charm.
with a game-pad in hand and annihilate         http://store.steampowered.com/
some enemy planes, submarines, ships           app/233150/




Unvanquished                                   Xonotic
You might want to keep one eye to the          The direct successor of the Nexuiz
                                                                                              Unreal Engine 4
                                                                                              Epic Games has unleashed hell on Linux as it
ceiling in this one.                           first-person shooter project.                   has announced that Unreal Engine 4.1+ will
                                                                                              support Linux officially. Unreal Engine is an
                                                                                              extremely popular engine with big-name
                                                                                              developers, so this is some of the best news
                                                                                              we have had since Steam on Linux. Epic is
                                                                                              offering the engine at a low price with source
                                                                                              code access too.
                                                                                              www.unrealengine.com/blog/41-update-
                                                                                              preview




Unvanquished is a hybrid of first-person       Xonotic is another free and open source
shooter and real-time strategy wrapped in      shooter; this time, rather than pitting
a good-looking package for open source         humans versus aliens, it’s war between
fans. The game is now in its early alpha       humans in fast-paced game modes.
stages, but it is already playable and         Xonotic is similar to the famed Unreal
looking really slick. It pits human marines    Tournament series of games only with no
versus vicious aliens in all-out war. The      price tag attached to it. It features many
game improves dramatically with each           weapons, each with their own secondary         CryEngine
new release, and the team are always           fire mode, and there are plenty of game        Crytek (the developer behind such games as
looking for help with programming and          modes to keep you going. If lots of            Crysis) has ported its CryEngine games engine
translations for anyone to get involved.       weapons aren’t enough for you it also has      to Linux. This means in future we will be able
                                                                                              to see games as graphically amazing as Crysis
   The game is a fork of another open          18 different maps, all wrapped up in a neat
                                                                                              on Linux, and who doesn’t want that to
source game, named ‘Tremulous’, which          free package.                                  happen? The free SDK is looking like it will add
sadly seems to have died out, but the             The game has its own statistics system      Linux support too, so onwards and upwards
survival of Unvanquished is what makes         integrated with it, so you can even keep       from here for all of us.
open source great.                             track of how terrible you are!                 www.crytek.com
www.unvanquished.net                           www.xonotic.org



                                                             www.linuxvoice.com                                                                11
     MAIL




                           YOUR LETTERS
                             Got something to say? An idea for a new magazine feature?
                             Or a great discovery? Email us: letters@linuxvoice.com



             LINUX VOICE STAR LETTER
  LOOK! IT’S A BABY READING A MAGAZINE!
  Hello guys. I hope you’re           children whilst allowing the
  settling into the new digs.         grown ups unrestricted use.
  OK, great start on the new          Mark Skinner
  magazine. I’m writing to            PS. I’ve attached a little
  suggest a feature article,          snapshot of the Linux
  after a recent addition to my       trainee, Jacob, reading his
  family got me thinking about        favourite magazine. You
  parental controls. It’s quite a     might think I’m getting ahead
  broad topic with lots to write      of myself, but there’s no such
  about yet there seems to be         thing as being too prepared,
  a lack of people out there          right?
  writing good how-to articles        Mike says: There’s a lot of
  on it. So my question to you        parental controls built-in to
  is: Can you consider writing        Linux through the permissions
  a beginner friendly article on      system. In a large organisation
  how to protect children on          a sysadmin can control what
  their computers, breaking           the users do on a machine,
  the jargon down into easy           and likewise a parent can use
  to understand segments?             the same system to limit (for
  The main thing I would like         example) access to the internet.
  to know about is, how to            We’ll look into a tutorial and
  filter out mature content for       present our findings.              Parental advisory – keep children away from the beer brewing tutorial
                                                                         with Raspberry Pi on page 76. Alcohol is bad for you, kids!




KERNEL HACKING
I picked up my first issue of Linux      Andrew says: You’ll be pleased
Voice [LV002] and was happily            to learn that we have at least two
reading through it when I came           more tutorials in the pipeline from
upon Dr Sinitsyn’s article on            Dr Sinitsyn, on programming USB
kernel modules. What a wonderful         devices and using PyParted. There’s
piece; clear, concise but still          not much documentation for PyParted
comprehensive.                           out there at the moment, so we’re
   Please, please give us more           going to release that one as CC-BY-
articles like this – it was a            SA as soon as we’ve published it, to
wonderful gateway into the most          enable more people to bask in his
fascinating part of the Linux            awesomeness. And to everyone who
experience: the ability to tinker        missed the kernel tutorial, we’ve just
with the kernel.                         put it up on www.LinuxVoice.com for        Our introduction to kernel hacking took a scary subject and made
Pedro Pinto                              your perusal.                              it accessible, as you can see over at www.linuxformat.com.



12                                                             www.linuxvoice.com
                                                                                                                                             MAIL



BAD DANGER                                                                                                         CODE WANTED
My credit card was blocked today                                                                                   I’m a long time Linux user and
due to suspicious charges on my                                                                                    FOSS advocate, and I’m about
bill and the agent at my credit                                                                                    to start a small business that
card company suggested that I                                                                                      will need a custom application
upgrade my anti-virus and firewall.                                                                                written. Unfortunately, I can’t
He thought that my card might                                                                                      code. What’s the best way to hire
have been compromised as I made                                                                                    someone that’s active in the FOSS
some online donations three days                                                                                   community to write and maintain
before the odd charges. I made the                                                                                 an application, including managing
donations using Iceweasel 24.4.0,                                                                                  things like (potential) code
and I can’t say that I checked to                                                                                  contributions?
make sure there was an SSL/TLS            there’s one built into the Linux Kernel.      Not every dodgy site       Noah
lock on the websites when I made          Simply keeping up with the latest             is as blatant as this
                                                                                        fake PayPal verification
the donations.                            software in your distro’s repositories                                   Andrew says: First of all, you’re asking
                                                                                        screen.
   Is there anything I could have         should be sufficient in most cases,                                      in the wrong place: forums such as
done to provide greater security          although you’ll have to take a few                                       forums.linuxvoice.com are much
for myself during the donations,          more precautions if you run any                                          better for getting a question in front
barring double-checking the               public servers on the computer. You                                      of many eyeballs and many brains
security lock? I’m using Debian           probably shouldn’t do internet banking                                   quickly, and getting a prompt anwer.
Testing and I’m not running an            on a computer that’s running a public                                       Second, you may want to look in the
anti-virus or firewall.                   server anyway.                                                           direction of www.linuxrecruit.co.uk.
Roy Birk, Maryland, USA                       The second part is when the data                                     There’s a vacancy advertised on there
                                          is in transit. Here, it really is essential                              at the time of writing for a System
Ben says: Ultimately, there are three     to check that the site is being served                                   Administrator at £400 a day, with
parts to the security of an online        over SSL (this will give the lock icon                                   essential skills listed as Amazon Web
transaction: that part on your            in the browser’s URL bar). If there                                      Services, Puppet, Red Hat/centOS,
computer, the part where the data is      are any browser warnings at all, you                                     Jenkins and designing scalable
sent and the part where the data is on    should be very suspicious of the site.                                   infrastructure – all of which we’ve
the recipient’s computer. Each of them        Finally, there’s the part where it’s on                              covered in Linux Voice.
is secured in different ways.             the other company or organisation’s
   Most Linux distros are pretty secure   servers. Once you send your credit
by default, and there are no real         card details, they will then store and
malware concerns, so we don’t run         process them. If their servers have
antivirus software, and don’t know        been compromised, then your details
any Linux users that do. Although         could be lost. Unfortunately, there’s
you say you’re not running a firewall,    not a lot you can do about this other
you almost certainly are (unless          than only sending your details to                                        Enhance your neurons as well as your
you’ve deliberately disabled it), as      organisations you trust.                                                 job prospects by learning Linux.




                                                                   www.linuxvoice.com                                                                   13
     MAIL



            FEATURE REQUESTS
            Greetings from Down Under!
            Well don on avoiding the
            patronising “Point here; click
            here; to save the file, go to File,
            then click on Save” mentality that
            you see elsewhere. I certainly
            don’t want to sit down to read a
            magazine only to be told things        An army of killer robots await,
            that I could have worked out           powered by Linux and Raspberry Pi.
            for myself, as I consider myself
            to have at least half a brain. I       brilliant, but I want more… give us
            managed to install Linux didn’t        robots, give us supercomputers –
            I, and that was before Mandrake        just keep it coming!
            came along and made it easy, and
            before Ubuntu came along and           Andrew says: Thanks Sarah – just
            made everything work. The comet        for you there’s a Mars rover-style
            hunting tutorial in LV003 was          bobotics tutorial on page 78.




            SPENDING MONEY FOR FUN
            I’m completely baffled by the          knackered old printers that are no
            UK government’s decision to            doubt being used by councils up
            pay Microsoft £5.5m to prolong         and down the land
            support for Windows XP. It’s           3/ What on earth are we doing
            puzzling on so many levels…            paying for Windows in the first
            1/ Why are so many government          place? Every year we see to hear
            machines still running XP in the       a new pledge from somebody or
            first place? We knew when support      other about how we’ve moving
            was going to end. If it were my        across to open data. How can this
            money I’d make damn sure that I        be true if we’re locked into .doc
            had a solution in place well before    format, or even worse, .docx?
            time. Oh wait, it is my money…         James Taggart, Dundee
            2/ What are these XP machines
            being used for? 99% of office          Graham says: James, we feel your
            work is emails, spreadsheets and       frustration and share your bafflement.
            writing letters. Sure, some printers   The good news from a long-term point
            don’t work too well with Linux, so     of view is that if the city of Munich
            you might have to stick with XP        managed to switch to Linux, then we
            to safeguard some old hardware,        might one day too. We’ll be writing to
            but with £5.5m we could have paid      our MPs to kindly ask them to spend
            for some open drivers for all the      our taxes more wisely.




            The Palace of
            Westminster,
            where the
            Chanel No5 in
            the executive
            washrooms
            never stops
            flowing.



14
                                                                                                                                     MAIL



PIE TIME                                 HEARTBLEED
                                                                                                                         QR code readers were
                                                                                                                         a flash in yesterday’s
                                                                                                                         pan, butare still useful
I agree that jEdit isn’t pretty and      Forgive my presumption, but isn’t
                                                                                                                         for relaying important
deserves to finish last on that          it obvious that I’m going to scan
                                                                                                                         messages.
count alone [in our Group Test of        the QR code on LV003 page 7?!
text editors, in LV002], but it is an    Surely any self-respecting pot-o-
extremely powerful cross-platform        gold special-prize hunter is going
editor. I installed it on my Linux       to go about scanning random
Mint box, though in the past I’ve        QR codes as quickly as possible,
run it on both Linux and Windows         in pre-release PDFs no less, to
machines just by unpacking the           discover that ever-elusive secret
portable archive and directly            hidden present… or maybe that’s
running the appropriate executable       just me? Imagine my excitement
file -- no installation required.        when I find out that you guys love       need to change my password on
   In trying to keep an open             me! Especially as I love you all too.    their system.
mind, I tried Kate. Yes, it’s good          Ooh, on that same page there’s           What they neglected to mention
looking, but within two minutes,         an alert to a GnuTLS bug? so not         is that they are not actually
I hit a roadblock editing a Latex        only did we have heartbleed this         running any SSL-protected parts
book I’m working on: it can only         month in OpenSSL, but GnuTLS             of their site! No, in fact all pages
handle folding at \begin...\end          was also broken to such an extent        and forms, including privileged
blocks. With jEdit I have the option     that connections are vulnerable          information about a visitor’s
of enabling built-in folding on          to man in the middle attacks!            housing arrangements along with
indent levels or explicit folding        No wonder OpenBSD has forked             passwords etc. are transmitted
using {{{...}}} markers, or folding      OpenSSL to create LibreSSL in an         in-the-clear.
using the Sidekick plugin, which         attempt to improve the playing              I have emailed them using
recognises \chapter{}, \section{},       field for secured communications         their contact-us form to request
\subsection, etc.                        in *ix systems…                          that they follow-up their email
   Why am I using jEdit instead             Related to Heartbleed I received      announcing Heartbleed-
of Texmaker? Texmaker doesn’t            an email from www.homeswapper.           invulnerability with another email
appear able to do hard line              co.uk, who I signed up to many           announcing their “everyone and
wrapping on long lines of cut-n-         moons ago and then promptly              their dog, especially MITMs,
pasted text, so I’m using jEdit to do    ignored/forgot. The email in             vulnerability”.
that. I expect I could do everything     question says that Heartbleed               I have yet to hear back.
I need with jEdit, but I haven’t had     “only affects Nginx and Apache           Daniel Llewellyn
the time or inclination to explore       web-servers running OpenSSL” and
the options as I have a project to       that their system runs neither of        Graham says: Heartbleed has the
finish. So I’m using both Texmaker       those two (they’re actually hosted       bejeesus out of a lot of people,
and jEdit on the same files. jEdit       on Windows/IIS+ASP servers from          but there are things that we can
lets me know when the file has           what I can tell based on browsing        do to protect ourselves. As users,
been changed on disk, whereas I          around) and therefore they are           we can use a different password
must remember to reload it under         unaffected.                              for each site we visit. And as
Texmaker – yes, it’s a mess, an             Because of this lack of               administrators, we can follow the
expedient mess.                          vulnerability, they claim I don’t        steps in Mike’s tutorial on p86.
   On my Mint box, jEdit seems to
run quite happily with OpenJDK.

                                         GAMES
However, sometimes the display
doesn’t refresh properly and needs                                                                                             Linux has finally
to be forced.                            May I offer a vote of thanks for                                                     come of age as a
   I’ve done a lot of HTML with          your games coverage. Those of us                                                     gaming platform.
jEdit, of which this is an example:      who remember SuperTux as the                                                                Praise be!
   http://oklanature.com/                highlight of gaming on Linux are
docentnews/DNL-201403.html               revelling in the number of quality
Andrew Shead                             games on Linux today.
                                         Dave Evans, Pontypridd
Mike says: And this is the real reason
free software is so good: we can         Graham says: You’re right there.
choose what we like, and use what we     We’re hoping that the Steam box in
want to create what we want. Jedit is    particular will tempt people away from
still ugly as sin, mind.                 Windows and into the fold.



                                                               www.linuxvoice.com                                                                   15
     LUGS ON TOUR




LUGS ON TOUR
SAPO Codebits
Josette Garcia has been in Portugal. It’s a tough life sometimes…


F
        or the seventh time I went     a 3D scanner (yes, a 3D scanner,
        to sunny Portugal to attend    the one thing that 3D printers are
        SAPO Codebits. I am always     missing).
surprised by the creativity of the        The core of Codebits is a 48-hour
organizers. So what was in store for   competition; people assemble
attendees this year?                   in groups and hack together an
   There were 64 talks overall, and    original idea in just 48 hours;
while there were talks on very         throughout the event, these groups
diverse subjects, one could find       are interviewed by the jury, which
unofficial tracks of 4–6 talks on      selects the best projects for the final
one subject (gaming, security,         stage presentation on the last day.
hardware, etc); there were also two       This year the winning project
panels: one on game development        was an open source Knee Lock
and another one on Portuguese          for polio patients so that they can
                                                                                 For three days, 24 hours
Makers, at the end of which the        walk safely without the typical                                       Codebits; these included a three-
                                                                                 a day, 900 geeks were
organisers announced the first         metallic gears that were once used;       immersed in dozens of       hour CTF security competition,
Portuguese Maker Faire, to be held     the project was even featured on          activities in the MEO       a very funny geek quiz show, a
in September.                          Wired (www.wired.co.uk/news/              Arena in Lisbon.            zip-line crossing the venue, and
                                       archive/2014-04/25/codebits-                                          even a competition of Nuclear Chili
Babbage rides again!                   nelo); the project used a lot of things                               made with Bhut Jolokia, which is
Among the speakers were Christian      that were present at the event: 3D                                    one of hottest chili peppers in the
Heilmann (Mozilla Foundation) and      printers, Arduinos, gyroscopes,                                       world (rated at more than 1 million
John Graham-Cumming (who is            etc. Other projects delved into                                       Scoville heat units, roughly 400
currently involved in a project to     the realms of biosignals, VOIP                                        times hotter than Tabasco sauce).
build Charles Babbage’s Analytical     solutions, stock markets, automatic                                      All of this put together, along with
Engine – see plan28.org), along        localisation for product managers,                                    ~1,000 free meals every lunch and
with talks on building robots,         a multiplayer version of the 2048                                     dinner and snacks and beverages
cryptocurrencies, web design, 5G,      game and, of course, a version of                                     available around the clock make
creating an OS, etc. There were also   Flappy Bird hacked together with a                                    Codebits an extraordinary event.
two sessions of Lightning Talks,       Kinect that had the players jumping                                      The website: https://codebits.eu
from freelancing to building arcade    up and down in real life!                                                The event calendar:
machines, via subjects as diverse         There were also about a dozen                                         https://codebits.eu/s/calendar
as Tor, pair programming, and even     satellite activities at this year’s                                      Some videos of the event https://
                                                                                                                codebits.eu/s/page/videos.


                                                                                                               TELL US ABOUT YOUR LUG!
                                                                                                               Chances are that you are already a
                                                                                                               member of a Linux User Group (LUG).
                                                                                                               LUGs are all over the world and each
                                                                                                               one has its own unique selling point,
                                                                                 Codebits 2014 featured        which draws its members to meet
                                                                                                               and discuss their favourite topic. We
                                                                                 panels on games
                                                                                                               want to know more about your LUG
                                                                                 development and               or hackspace, so please write to us at
                                                                                 Maker culture in, leading     lugs@linuxvoice.com and we might
                                                                                 to the announcement           send one of our roving reporters to
                                                                                 of Portugal’s first           your next LUG meeting
                                                                                 Maker Faire.


16                                                           www.linuxvoice.com
                                                                                                                              LUGS NEWS



Lincolnshire LUG
Dave Rice has news of a new user group.


L
        incolnshire LUG is a new,         away to reach, were left without a
        virtual, online, user group       LUG to call their own.
                                                                                                                             Lincolnshire’s
        and is probably the first of         After a year or two, Dave Rice and                                              geographical spread
its type!                                 Iain Baker, members of the original                                                makes an online LUG
   Lincolnshire is the second largest     LincsLUG had a thought that                                                        a sensible option.
county in the UK covering nearly          because of the distances involved
7,000 square km, with over 1 million      it might be worth a try re-launching     being the website, it will, hopefully,
inhabitants. It has a wide variety of     the LincsLUG but as an online entity,    become a source of information for
people living there; from farmers         enabling Linux users in all parts of     home users and businesses to find
to large agricultural industry,           the county to get together using the     information about Linux and how it
metropolitan areas to tiny hamlets        internet to discuss their favourite OS   can help them as well as find a
and, of course, it’s the home of the      and the issues surrounding it.           support network they can access at
Royal Air Force. With such a diverse                                               no cost.
economy the county can benefit            Here there and everywhere                   Lincolnshire is a beneficiary of
in so many ways with a larger             The new LincsLUG website is the          the rural broadband initiative – the
understanding of Free and Open            focal point of the group and is in the   whole county should have super
Source Software.                          process of being put together using      fast broadband by 2016, and many
   The LincsLUG was initially set         tools that encourage online              local businesses are becoming
up many years ago to cater for the        cooperation and enabling users to        more reliant on the internet as
needs of the county’s Linux users.        communicate and have meetings.           a means of doing business. So
It struggled, however, to become a        We currently have a forum and an         getting more Linux users will help
widely used asset mainly because          integrated Facebook page. There is       keep business costs down and
its members were all located large        an aspiration to have an embedded        productivity up. With a successful
distances from each other and real        IRC channel and collaborative tools      LUG as an advocate to business
meetings were difficult to organise.      to enable common file storage and        and providing a support network
Unfortunately, the LUG fell into dis-     remote desktop help and support.         Lincolnshire may well become a
use and membership faded. Linux              We still aim to have real             huge user of FOSS systems.
users in the City of Lincoln itself set   meetings, but they will be less             If you live in Lincolnshire, or just
up the superb Lincoln LUG, which          frequent and hopefully in                want to help us in our endeavours
is going strong; but the rest of the      conjunction with existing LUGs in        please visit http://lincslug.org.uk
county, where Lincoln is too far          the area. With the central point         and join us.




OpenSUSEConf 2014
Free Software makes it to King’s Landing.


A
          pril marked the latest          things; Technology development,
          OpenSUSE conference, held       and the much under-appreciated
          on the glittering shores of     Community and Project thread.
the Adriatic at at the campus of the      This included a look at how
University of Dubrovnik in Croatia.       OpenSUSE can market itself more
Free Software can be a lonely             effectively; so we’ll venture our
furrow to plough, so it’s essential for   opinion here and say: more SUSE
projects to meet up regularly.            beer please!
  OpenSUSEConf 2014 comprised
four tracks: Business, which              Video stars
concerened itslf mostly with              The conference included 50
implementation of OpenStack and           sessions, so even if you were there
OpenSUSE on ARM (we saw a                 you probably missed something –
sneak preview of this at FOSDEM           but you’ve not missed out, thanks
earlier in the year); End User,           to the OpenSUSE YouTube channel,
with sessions covering the Jolla          where you can see videos of the          Once home to a medieval trading republic to rival Venice,
smartphone OS, among other                even’t talks.                            Dubrovnik is now best known as a filming location in a TV show.



                                                               www.linuxvoice.com                                                                    17
     FEATURE UBUNTU 14.04 RESPINS




                                UBUNTU
                                14.04 RESPINS
             Love Ubuntu, but hate feature X? Mayank Sharma shows you
            over a dozen different spins that make Ubuntu enjoyable again.


           E
                   veryone has their favourite Ubuntu feature      the distro’s installer, which is one of the best tools
                   they dislike. Privacy-conscious users loathe    for the job, and Canonical is also responsible for
                   the Lenses feature. Desktop users get           unleashing ideas, such as the Software Centre
           irritated with the window controls on the wrong         and Ubuntu One, that have helped change the
           side of the window and the overlay scrollbars. And      perception of Linux as a desktop OS.
           Gnome 2 users can’t bring themselves to forgive            As the distro unveils its next Long Term Support
           the distro for ruining their usability with the Unity   release, we introduce you to some of the distros
           desktop and the lack of customisation options.          that have stood on the shoulder of giants, remixing
              But for every feature that’s rubbed users the        the best of Ubuntu with the much wider open
           wrong way, Ubuntu has contributed several useful        source community to create several refreshing new
           ones that’ve benefitted the community. There’s          flavours of what Linux can be.



18                                                     www.linuxvoice.com
                                                                                                UBUNTU 14.04 RESPINS FEATURE


                 Ultimate Edition
                 Do you want one with everything?
The aptly-named Ultimate Edition distro is              Avidemux video editor and Blender for 3D
loaded with tons of Free and proprietary                modelling. For package management, the
software. The latest version is based on                distro bundles the Ubuntu Software Centre
Ubuntu 14.04 and uses the Mate desktop                  along with the Synaptic package manager.
with custom theme, icons and pointers.
  The distro has multiple apps for                      Script customisation
accomplishing the same task. In some                    The most unusual aspect of the distro is its
cases, the multiple applications cater to               collection of custom scripts for performing
users with different experience level –                 certain desktop-oriented tasks. The scripts
for example, there’s Google Chrome for                  can all be accessed from the right-click
regular desktops and Elinks for advanced                context-menu, and you can use them to
users. Users with ninja-level skills can use            quickly shuttle files to another pre-defined
ImageMagick instead of firing up Gimp                   location, convert images to different
to tweak images. There’s also LibreOffice,              formats, mount ISO images, search for files
Blender, multiple screen recorders, VLC                 in the current folder, and browse the current      The latest version of Ultimate Edition is built
media player, XBMC media centre, the                    folder as the root user.                           from a debootstrapped Ubuntu 14.04 release.


                                                                                   PinguyOS
  PeppermintOS
  If you have dumped offline apps and    and the featherweight Guayadeque          PinguyOS is different from the       which combines features of
  can work with the current staple       music player for MP3s.                    others in many ways. For             both the modern and the
  of online apps, PeppermintOS is a           Another lightweight app is the       starters, it tags its six-monthly    traditional application menu.
  wonderful alternative to ChromeOS.     Mirage image viewer. The distro also
                                                                                   releases based on the current        PinguyOS also includes Ubuntu
  It’s fast and is equipped with the     includes several online tools such as
  necessary tools to get the job done.   Editor by pixlr.com and a bunch of        Ubuntu release as Beta releases.     Tweak and the Gnome Tweak
      The current stable version is      games. There’s also PeppermintOS’s        Only PinguyOS releases based         tool to help you configure many
  based on Ubuntu 13.04 but the          home-brewed app called Ice, which         on an Ubuntu LTS are                 different aspects of the desktop.
  next version, Peppermint Five with     is a simple app that can turn web         considered stable.
  be based on Ubuntu 14.04. “We          sites into web apps and roll them
  base each version of Peppermint        into the menu.
                                                                                      PinguyOS is designed to           Game management
  on the April release of Ubuntu.             For package management the           appeal to users who are new to       Gamers will enjoy the inclusion
  While we don’t follow a strict         distro relies on Mint’s Software          Linux. The developer has             of the Steam client, PlayOnLinux
  release schedule, new versions of      Manager. Weaver and his team              modified the default Gnome           front-end for Wine and the DJL
  Peppermint can usually be expected     prefer the interface and user             installation with some               game manager, with which you
  each May or June”, explains            experience of Mint’s software
                                                                                   extensions. Thanks to these you      can download and install several
  PeppermintOS’s lead-developer          manager as compared with
  Kendall Weaver.                        Ubuntu’s. Weaver would also               can place icons and folders on       free, freeware and shareware
      The distro uses the Chromium       consider Lubuntu’s software centre        the desktop, and can minimise        games. The distro also includes
  web browser equipped to handle         if it weren’t for the ratings, reviews,   windows. The distro has also         several proprietary applications,
  Flash content. Multimedia duties are   and ease of categorisation of Mint’s      swapped Gnome’s Activities           such as Dropbox, Skype and
  handled by Gnome MPlayer for video     software manager.
                                                                                   Overview with the GnoMenu,           TeamViewer.


    PeppermintOS uses a Site                                                                                                           The latest release
    Specific Browser (SSB) to run                                                                                                     of PinguyOS based
    applications on your desktop.                                                                                                        on Ubuntu 14.04
                                                                                                                                      will feature the Plex
                                                                                                                                        media server and
                                                                                                                                    make sure that Netflix
                                                                                                                                     works out of the box.




                                                                        www.linuxvoice.com                                                                   19
     FEATURE UBUNTU 14.04 RESPINS


               What’s new in Ubuntu 14.04
                A whistle-stop tour of the latest release.
As far as the official Ubuntu versions go, the
Long Term Support releases aren’t all that
exciting. They introduce no new features
and fuffle no feathers, and are generally a bit
boring; but that’s a good thing, because
stability is a feature. The goal of the LTS
releases is to provide users with a steady
base that they can continue to use for a
long time.
   Ubuntu 14.04 LTS (codename: Trusty
Tahr) is no different. Released on schedule
two years after the last LTS release, most of
the changes in this release are fairly
conservative in nature, and mostly hidden
out of view embedded deep with the code.
As with every release, all the default
applications and core components have
been updated to their latest stable versions.     One of the strongest points of Ubuntu is its easy-to-use installer.
There’s Firefox 28, Thunderbird 24.4.0,
LibreOffice 4.2.3, Rhythmbox 3.0.1, Nautilus      would display a frame with the new window                 One of the most prominent additions in
3.10.1, and the distro is powered by Linux        size, and the change would only happen                 Ubuntu 14.04 LTS is the ability to turn off the
kernel 3.13.                                      after you were done resizing the window.               global menu bar at the top of the screen. It’s
   At first glance, the Unity desktop in Trusty                                                          been a mainstay of the Unity desktop since
doesn’t look any different from the one in the    More usable Unity                                      its introduction in Ubuntu 11.04, and despite
previous Saucy Salamander release.                The release also fixes a couple of long-               several changes over the years, hasn’t
However there are minor visual tweaks that        standing usability issues. You can now                 managed to impress all users. In the latest
long-time users will notice (and appreciate)      right-click on the global menu even when a             release there is finally the option for locally
as soon as they start using the distro.           window is maximised. This displays the                 integrated menus (LIM) in an app’s title bar.
   For starters, instead of the Compiz            same menu that’s available when you                    By default, menus appear in the top panel.
decorations, Unity has switched to GTK 3          right-click on the titlebar of an unmaximised          To move them closer to the app, head to the
CSS-themed window decorations. You’ll             window. Also, you can now tweak the                    Behaviour section under the Appearance tab
                                                                                                         in the System Settings panel and click on
                                                                                                         the Local Menus option.
“One of the most prominent additions to the latest                                                          Once enabled, the app menus are
Ubuntu LTS version is the ability to turn off the                                                        embedded directly in the window decoration
                                                                                                         and continue to save the screen real estate.
global menu bar at the top of the screen.”                                                               When the menus are wider than the
                                                                                                         available space, the extra items are tucked
notice that windows in Unity aren’t bounded       behaviour of windows when you click on                 underneath a small drop-menu at the corner
by a one-pixel black line and are now             their icon in the Launcher. You can, for               of the window. The new menus don’t have
completely borderless. Another benefit of         example, set this action to minimise an open           any impact on the usability of the windows
the move from Compiz to GTK 3 is that the         window. However, this feature is                       – you can still move them just as before.
window corners are now antialiased.               implemented as an “unsupported” extra and                 When you step away from the computer,
   Also you can now resize windows in real        you’ll need to grab the CCSM app from the              Ubuntu will trigger the new Unity lock
time. Until now, resizing windows in Unity        Software Centre to enable it.                          screen, and the Unity Spread view (which is
                                                                                                         triggered when you click on an app’s icon in
                                                                                                         the Launcher with open windows) now lets
                                                                                                         you filter the windows by their titles.
                                                                                                            On a sombre note, Ubuntu 14.04 LTS will
                                                                                                         also be the first release to ship without the
                                                                                                         Ubuntu One cloud storage service.
                                                                                                         Canonical pulled the plug on the online
                                                                                                         storage service along with the Ubuntu One
                                                                                                         Music service, a couple of weeks before the
Users can now turn off global menus. Hurrah!      Ubuntu ships with more lenses than ever before.        final release.



20                                                             www.linuxvoice.com
                                                                                               UBUNTU 14.04 RESPINS FEATURE

                                                                                 Zorin OS
 LinuxLite                                                                       Zorin OS isn’t the first distro        the best desktop operating
  LinuxLite is designed for people       to run Steam. LinuxLite is one of       that’s aimed at easing Windows         system for Linux newcomers,
  who are new to Linux, and is ideal     the few distros that includes a Help    users into a Linux distro.             with emphasis on Windows
  for under-powered machines. The        Manual complete with an illustrated
                                                                                 Lindows and Linspire are               users making the switch to
  distro is intuitive to use and is      installation and post-installation
  based on Ubuntu LTS releases. To       user guide.                             probably the best-known                Linux,” explains Zorin’s lead-
  acclimatise users, LinuxLite runs a       While the distro uses the            examples of distros that have          developer Artyom Zorin.
  heavily modified version of the XFCE   Synaptic Package Manager, it also       tried (and failed) to put a familiar      Zorin OS is based on the
  desktop environment.                   includes menu entries to quickly        face on top of a Linux distro.         latest Ubuntu release. The idea,
     Despite its name, LinuxLite ships   install frequently used apps and
                                                                                    But Zorin OS, with its Gnome        Artyom explains, is to “build
  with lots of software – including      packages. You can, for example,
  Thunderbird, Gimp and Firefox with     install individual pieces of software   desktop modified to resemble           on the greatest that Linux has
  the Flash plugin – and in the Games    such as the Deluge torrent client,      Windows 7, does an admirable           to offer and package it into a
  menu you get links to buy Humble       the Steam client and VirtualBox, as     job of lowering the learning           system that anyone can use
  Bundle games, along with an entry      well as bundles such as the games       curve for new users. “Zorin OS         without learning anything new
  that displays essential information    pack, IA-32 libs, multimedia codecs
                                                                                 was built with the goal of being       thanks to its familiar interface.”
  about the hardware requirements        and more.


                                                      Linux Lite is a tiny                                                  Zorin OS’s Look Changer app
                                                       distro that can be                                               enables the distro to emulate the
                                                    quickly turned to do                                                 look of other operating systems
                                                     some heavy lifting.                                                               with a single click.




                 ElementaryOS
                 But of course!
If you think Linux distros can’t be pretty,             many free desktops are highly customised
check our ElementaryOS. The distro uses                 setups. Another example he highlights is
custom icons, custom themes and custom                  that of the Granite library that hosts
apps to produce a beautiful Gnome-based                 commonly used complex widgets that
desktop. The distro includes apps like the              hadn’t made their way into GTK, like the
Shotwell photo manager, Empathy IM,                     TabBar, search bar, popovers, etc. This
Totem movie player, and Gparted and quite               ensured consistency across apps and
a few custom apps including the Scratch                 centralised the development of UI elements.
text editor and the Geary mail app.
   The first Elementary app was its file                Dedication to beauty
browser, which was created because “we                  Elementary’s Gala window manager is built
simply weren’t happy with the interface and             on LibMutter, which offers the developers          ElementaryOS will appeal to new as well as
features provided by the available browsers”,           more control and better performance than           regular Linux desktop users.
explains the distro’s lead developer Daniel             Compiz. They wrote the stylish top panel
Foré. “The same story played out for our                they wanted to be in the same ecosystem            GTK+ apps, which is why we don’t ship
Music player, Calendar, and the prototype               as the Ubuntu app indicators without using         apps like LibreOffice, Firefox, Thunderbird,
mail app we started work on before Yorba                Unity. “In short” says Foré, “we end up writing    etc.” Package management is handled by
came out with Geary.”                                   apps because we’re just not happy with the         Ubuntu’s Software Centre. The distro uses
   According to Foré, the customisation also            quality or architecture of existing solutions”.    Ubuntu’s repos, but also has a PPA of its
extends behind the scenes. The project                     One surprising element in the distro is         own for providing updates for the custom
created a service called Contractor because             the use of the Midori web browser instead          apps, as well as for apps and libraries that
the team wanted the apps to be                          of a more mainstream browser like Firefox          the developers think are important. “In
interconnected and extendable without                   or Chromium. “We have a strict dedication          contrast with Ubuntu, we continue to make
requiring developers to know which other                to providing a consistent, native experience       both bugfix and feature releases of apps
apps were installed on a system, since so               in elementary”, explains Foré. “We only ship       throughout the life cycle of the OS release.”



                                                                       www.linuxvoice.com                                                                 21
     FEATURE UBUNTU 14.04 RESPINS


                 Centrych
                  Get the best of both worlds.
Here’s a distro that lets you run KDE apps                 The distro uses the Xfce desktop
but has the footprint of an Xfce distro.                 environment with two distinct profiles. The
Centrych OS lets you run both Qt and GTK                 default profile has the look of KDE along
apps but without the usual bloat that                    with the Oxygen theme, while the other
accompanies these libraries.                             provides the GTK look of Xubuntu together
    Explaining his motivation for labouring              with the Greybird theme.
on the distro, Centrych’s developer Jack                   Centrych has also swapped out the
Radigan says: “I felt that there was an unmet            default Xfce menu with the Whisker menu.
need for an easy-to-use, single desktop                  Radigan also hopes that the distro appeals
designed to support applications written                 to XP users who’d rather not toss their
for either the Gnome/GTK and KDE/Qt                      hardware investment after Microsoft halts
environments. KDE can support both, but                  security support.                                   With Centrych you can use popular KDE and
it’s a much more complex environment                                                                         Gnome apps on machines that can’t power the
and I wanted to provide a simpler, more                  KDE and Gnome                                       full desktop environments.
accessible alternative.”                                 Both profiles give you access to the best of
    “I’m targeting a mindset rather than any             Qt and GTK apps. There’s the Clementine             He also provides updates for the nearly
specific audience”, says Radigan. “There’s               music player and Kopete IM along with               300 packages that have been modified for
quite a few capable productivity applications            Gimp, Gnome System Monitor, VLC media               Centrych. For everything else, he relies on
today, some written for Gnome, some for                  player, LibreOffice and Firefox. For package        updates from upstream Ubuntu.
KDE. Those who prefer using the best from                management you get both Synaptic and the              Radigan is currently working on the
both worlds should give Centrych a try.”                 Ubuntu Software Centre.                             next version based on the Ubuntu 14.04
    Radigan started the project with the                   The distro is based on the Ubuntu 12.04           LTS release. “This release is about refining
intention of creating a lightweight GTK-                 LTS release, but Radigan makes sure that            what’s currently in place, since it’s only been
based distro that could run a few Qt apps                users get the latest versions of certain “high-     about a half year since the first release
without running into dependency issues.                  profile” apps such as Gimp or LibreOffice.          came out.”

                                                                                  Zentyal
 Bodhi                                                                            Zentyal has all the components          management tools. Zentyal
  If you like to build your distro by     the Enlightenment desktop               you need to run a gateway               goes the extra mile to help you
  hand, but don’t want to go the          environment, which manages to be        server, an office server and a          configure the different servers
  extreme of Arch or Gentoo, then         both responsive and beautiful at
                                                                                  communication server. It’s got          and services without mucking
  Bodhi Linux is for you. It ships with   the same time. According to Bodhi’s
  a small number of apps, and you         Jeff Hoogland, Enlightenment “has       the Apache web server,                  about with configuration files.
  can add more using the distro’s         resource usage that is comparable       OpenLDAP directory server, Bind            Once the distro is installed,
  web-based software installation tool    to LXDE/Openbox while being far         DNS server, Jabbered2 IM                it will start a configuration
  called AppCenter. Using the tool you    easier to customise… By building        Server, Zarafa groupware,               wizard to help you setup the
  can also download packages on any       on top of Ubuntu LTS releases
                                                                                  Asterisk VoIP and DansGuardian          server. From here you can install
  machine and then bring them over        Bodhi allows users to have a rock
  to Bodhi for installation.              solid base operating system that        for content-control                     individual server packages, or
      Bodhi uses the current Ubuntu       doesn’t need a reinstall or a massive   management and a lot more.              modules in Zentyal’s parlance,
  LTS release as a base and adds          upgrade every six months.”                You can monitor and control           or select predefined groups
                                                                                  the various components of the           such as Gateway, Infrastructure,
                                                                                  server using the distros custom         Office, and Communications.




                                         Bodhi Linux is perhaps the best
                                    integrated Enlightenment distro and
                                ships with a bunch of profiles optimised
                                         for different types of hardware.
                                                                                  You can also install Zentyal on top of an Ubuntu Server installation by
                                                                                  adding and pulling packages from Zentyal’s repository.



22                                                                     www.linuxvoice.com
                                                                                           UBUNTU 14.04 RESPINS FEATURE


                 Official Ubuntu spins
                 Unity ain’t for everyone.
Choice is the hallmark of open source
software. Even though it focuses its efforts
on the home-brewed Unity interface,
Canonical supports other desktop
environments as well. In addition to the main
Ubuntu distro, the project has several official
spins that swap out the Unity desktop with
other popular desktop environments.
However, the developers of these official
spins go the extra mile and introduce other
changes as well to suit their target audience.

Ubuntu Gnome
The Gnome 3-based spin is the latest
addition to the Ubuntu stable of official
derivatives. It includes popular apps such as
LibreOffice, Evolution, Shotwell, Rhythmbox
and Totem. However, instead of shipping
Gnome’s default Epiphany web browser
(now rechristened simply as Web) Ubuntu
Gnome includes Firefox. The distro is also
missing some other Gnome tools like the
Boxes virtualisation app. To help you
                                                    Over the years Xubuntu has become the go-to distro for Gnome 3 and Unity refugees.
customise its Gnome desktop, the distro
includes the Gnome Tweak Tool app.
   Ubuntu Gnome 14.04 is the first LTS              Calligra Office suite and instead ships the        which can play most popular formats
release for the project and will be supported       more popular LibreOffice.                          including MP3s, AVIs and MP4s.
for three years as opposed to the five years          The latest release, Kubuntu 14.04, is               The developers of Lubuntu have created a
for Kubuntu. This latest release will ship with     based on KDE 4.13. One of the many                 lightweight version of the Ubuntu Software
Gnome 3.10, which was released back in              improvements in this release is that the           Centre called the Lubuntu Software Centre.
September. If you’re interested in the latest       Additional Drivers app has been replaced           The tool also has an Expert mode for
Gnome 3.12 release, you can upgrade to it           with the all new Driver Manager, which             installing individual libraries. Lubuntu 14.04
using the Ubuntu Gnome team’s PPA.                  enables you to install and select the              will be the distro’s first Long Term Support
                                                    drivers you want to use. The built-in              release and will be supported for three years.
Kubuntu                                             recommendation software will notify you
This is the oldest and one of the most              when better drivers are available for your         Xubuntu
popular spins of Ubuntu, offering the KDE           hardware, including proprietary ones.              Another spin that’s designed for relatively
desktop. The distro includes KDE apps                                                                  older hardware is the Xfce-based Xubuntu.
including Kmail, K3b, Amarok and Dragon             Lubuntu                                            The 14.04 release of Xubuntu uses the Xfce
Player in Kubuntu as well as ther popular           If you want Ubuntu goodness on an                  project’s latest desktop manager, Xfdesktop
apps such as Firefox. It skips the KDE office       under-powered computer, there’s Lubuntu,           4.11. This release will use the Mugshot user
                                                    which is based on the LXDE desktop                 account profile editor and the Light-locker
                                                    environment. The distro also replaces              screen lock instead of Xscreensaver.
                                                    heavyweight apps with lighter alternatives.            The distro will also switch to the Whisker
                                                    This is why Lubuntu includes AbiWord and           menu launcher. Not surprisingly, Xubuntu
                                                    Gnumeric instead of LibreOffice.                   doesn’t include a full-fledged office suite, but
                                                       Lubuntu ships with some GTK apps such           rather the AbiWord word processor and
                                                    as the Evince document viewer, Archive             Gnumeric spreadsheet. Surprisingly though
                                                    Manager and mtPaint image editor along             it includes Gimp and other popular apps
                                                    with featherweight apps that go with its           such as Firefox, Thunderbird, Pidgin and
                                                    LXDE desktop, such as the Leafpad text             Transmission. There are some lesser known
                                                    editor and PCManFM file manager.                   apps as well, such as the gmusicbrowser
                                                       Lubuntu also has the Sylpheed email             jukebox, Parole media player, and Ristretto
Lubuntu is the lightest official Ubuntu spin that   client as well as the Firefox web browser. It’s    image viewer. The distro uses the Ubuntu
performs well on older hardware.                    also got Audacious and Gnome MPlayer,              Software Centre for package management.



                                                                www.linuxvoice.com                                                                  23
     FEATURE UBUNTU 14.04 RESPINS


                Netrunner
                 The drop-in Ubuntu replacement.
Don’t let its name fool you. Although the
distro has tools to consume online
information, Netrunner can be used
productively offline as well. In fact, the
distribution does a pretty nice job of
bundling the new online apps that run within
a web browser and need a connection to the
internet along with traditional offline apps
for regular heavy-duty desktop tasks.
   Netrunner is based on KDE, but that
doesn’t mean it’s just another Ubuntu-based
distro that has bolted KDE in the place of
Unity. Unlike Kubuntu, which ships with
more or less a stock KDE release, Netrunner
has exploited the desktop’s customisability
to the hilt and ships with a much more
attractive and functional environment.
   The developers put in considerable effort
to chip away the rough edges of the default
KDE environment and make the desktop
appealing to new users. The Netrunner
desktop follows the standard desktop
metaphor with a few refinements. Instead of
switching to a revolutionary new desktop,       The distro has all the usual sources for dispensing help and also publishes an online magazine
Netrunner has introduced subtle
refinements to the existing elements.           volume), an analog clock and the media              2GB of free space that you can use to store
   The distro uses a modified version of the    player, which can playback any media even           data, pictures, contacts, calendars, and
Homerun launcher, known as the Homerun          when hidden. You can bring up the side              stream music via its Android app.
Kicker. Unlike the full-screen Homerun          panel with a pre-defined gesture. Netrunner         Netrunner’s Webaccounts app helps you
launcher, Homerun Kicker resembles a            also includes the Easystroke tool, with which       integrate Runners-ID to the respective native
traditional launcher menu and is designed to    you can define your own custom actions              KDE app. In addition to Runners-ID, you can
be operated by the mouse, keyboard and          and gestures to activate them.                      also use the Webaccounts app to connect to
even touch. Along with the traditional                                                              and pull in data from other online services
cascading popup menus, Homerun Kicker           Full-service distro                                 such as Facebook, Google, and OwnCloud.
also includes a sidebar strip where you can     You can use Netrunner straight out of the              If you need to flesh out the default
pin your favourite apps. There’s also a         box. The distro is chock full of apps, both         software in Netrunner, you can do so using
search box that mines several different         Free Software and proprietary. There’s              its three package managers. Experienced
sources of data.                                Skype, Dropbox, Thunderbird for email, and          users can use the old school Synaptic
   Another useful feature is the side panel.    the Firefox web browser is equipped with            Package Manager and new users can use
This is a normal Plasma Panel that includes     plugins to play Flash, Java as well as the          Muon Discover or the web-based JackNJoe
the Veromix widget (to control sound            AdBlockPlus and DownloadHelper add-ons.             service to install packages.
                                                   The distro also ships with codecs to play
                                                all sorts of audio and video content and            A magazine about Linux!
                                                includes the Clementine music player as             Help on the distro is dispensed via online
                                                well as VLC. Along with the LibreOffice suite       forum boards on its website, which also
                                                there’s also Calligra Flow. Netrunner also          includes quite a few demonstration videos
                                                includes the Wine compatibility software for        and screencasts. The developers behind the
                                                running Windows apps, and the Wine Tricks           distro also publish an online magazine called
                                                utility, which can download and install             Netrunner-Mag.
                                                several popular proprietary apps. For the             The Netrunner distro is perhaps one of the
                                                gamers out there, Netrunner includes the            most underappreciated ones, lying at the
                                                Steam installer.                                    #59 on Distrowatch.com. All things
                                                   One of the best cloud-oriented features of       considered, Netrunner is a polished KDE
Netrunner ships with a beautiful rendition of   the distro is the integration of its Runners-ID     offering and offers one of the smoothest
the KDE desktop.                                cloud storage service. The service offers           user experiences.



24                                                          www.linuxvoice.com
                                                                                                UBUNTU 14.04 RESPINS FEATURE

                                                                                   UberStudent
  Trisquel                                                                         UberStudent uses the Xfce            Open Library. Another category
  A typical Ubuntu installation           LXDE desktop. The distro is based        desktop and includes a               is Personal Finances, which
  has several proprietary bits and        on the Ubuntu 12.04 LTS release. It      wonderfully curated                  points to the online Mint
  blobs, mostly to support the latest     uses Gnome 3.4.2 and runs in the
                                                                                   combination of hosted apps and       Personal Financial Manager app
  hardware – particularly graphics        fallback mode to offer the traditional
  cards. Not surprisingly, the Free       desktop experience.                      online ones. For example, the        and also helps you keep costs in
  Software Foundation has guidelines          Trisquel has all the apps that       Books menu points to the only        check by pointing to websites
  that define a free distro. There are    you’ll find in other distros, such       installed app, which is the          that let you buy used books, rent
  a couple of distros that adhere to      as Evolution, Pidgin, Gwibber,           FBReader ebook reader. The           new ones, and even search for
  those strict guidelines at the cost     Transmission, LibreOffice, Gimp, etc.
                                                                                   other entries in the menu are to     deals on Air fares. The distro
  of usability. Trisquel, however, is a   The one oddity is the web browser:
  wonderful exception.                    Trisquel ships with Abrowser, which      various online resources where       also has a handful of games and
     Trisquel is available in several     is the unbranded version of the          you can find ebooks, such as         other general-purpose utilities.
  editions. The main release is a         Firefox web browser. The developers
  700MB installable CD, which uses        have also modified the browser to
  the Gnome desktop. There’s also         fetch add-ons from Trisquel’s own
  a 500MB mini edition designed for       repository instead of Mozilla’s, which
  older hardware, which uses the          houses some non-free add-ons.


                                                   Trisquel is one of the
                                                very few distros that are
                                                endorsed and promoted
                                                              by the FSF.




                                                                                                                       You can support UberStudent by
                                                                                                                      making online purchases on select
                                                                                                                          stores from within the distro.




                  Emmabuntüs
                  The kitchen sink flavour.
Emmabuntüs was designed to ship with                     make the distro suitable for young users
reconditioned computers assembled by                     who’ll also enjoy the plethora of educational
humanitarian organisations from donated                  apps and games, including the OOo4Kids
pieces of hardware, and owes its name to                 office suite for children.
the French Emmaüs charitable movement.
However, it’ll fit snugly on any desktop.                All about choice
   The current version of the distro is based            The distro also does a nice job of educating
on Xubuntu 12.04.4. Since many of the                    its users about the proprietary components
intended users of the distro wouldn’t have               before installing them. Emmabuntüs
access to the internet, the distro is                    bundles the proprietary apps but doesn’t
overflowing with apps. Emmabuntüs                        install them by default. The Cairo Dock is
includes virtually every popular open source             one of the highlights of the distro, according    Emmabuntüs can easily install proprietary
app and also includes all sorts of proprietary           to its lead developer Patrick. The distro ships   software without a connection to the internet.
codecs and apps. No wonder then that it is               with three variants of the dock and you can
available as a huge 3.3GB ISO image.                     switch between them from within the distro        on Xubuntu 14.04.” Once the new version is
   In addition to regular desktop apps such              itself. The default “Simple” version is           out, the previous release will get updates
as LibreOffice, Gimp, VLC media player,                  designed for new Linux users, a “Kids”            every six months until April 2017.
OpenShot video editor, RecordMyDesktop                   version is meant for children and a “Full”           Xfce desktop and the Cairo-Dock make
screencasting app, there are apps for power              version for experienced Linux users.              the desktop very approachable to a far wider
users such as BootRepair and VirtualBox as                  According to Patrick, the team will            userbase than its intended audience – a bit
well as Wine, WineTricks and PlayOnLinux.                maintain the current version, Emmabuntüs 2,       like the way every Ubuntu spinoff in this
The distro’s two web browsers, Firefox and               for another year with release updates every       feature has taken the fantastic features of
Chromium, ship with lots of plugins to block             three months. “During that year we will           Ubuntu to a wider audence than Ubuntu
ads and prevent phishing attacks. This helps             stabilise Emmabuntüs 3, which will be based       could have reached on its own.



                                                                        www.linuxvoice.com                                                                  25
     FEATURE KANO TO ENABLE?




               TO ENABLE?
                    What is the Kano project, and how does it enhance what
                    the Raspberry Pi is already doing? Les Pounder finds out.


          T
                   he Raspberry Pi has been with us for over two    educational environment and enable children to learn
                   years, and in this time there have been many     more about computing.
                   projects created using this board. Projects        However Kano approaches this issue in a different
          such as Pi Supply, MotorPiTX and PiGlow have aided        manner by creating an intuitive “computer lab” in a
          many hackers in their quest to build something new        box, that is built around the Raspberry Pi. The design
          with their Pi. And herein lies an issue that resides at   and production of the Kano products, such as the
          the heart of the Raspberry Pi Foundation. The original    accessories, step by step book and stylised packaging
          goal of the Raspberry Pi                                                                 has stood the project out
          and the Foundation itself,
          was to create a low-cost
                                     “Kano creates an intuitive                                    in a sea of many
                                                                                                   derivatives but the Kano
          educational tool enabling  computer lab in a box, that is                                project has also
          children around the world
          to learn computer
                                     built around the Raspberry Pi.”                               polarised the Raspberry
                                                                                                   Pi community, with
          science, programming                                                                     some seeing the project
          and electronics. Its success in this goal is steadily     as riding on the success of the Raspberry Pi, while
          being realised by an ever-growing education team, and     others are looking forward to using the kit in their next
          at the start of April 2014, the Foundation updated its    project. Read on and decide for yourself…
          website and included a series of tutorials, written for
          absolute beginners to follow. This update was also        History of the project
          supported by a series of training sessions, called        Just over a year and a half ago Alex Klein was
          Picademy, for 24 teachers from across the UK. These       completing his graduate studies in computer science
          sessions sought to spread the concept of using the Pi     at Cambridge University and working as a writer for
          in education via a carefully curated lesson plan.         Newsweek and The Daily Beast in the US. During this
             The Kano team have a similar goal to the Raspberry     time he ran into Eben Upton. Eben and Alex got to
          Pi Foundation: they wish to use the Pi in an              know each other bit and they discussed how




26                                                     www.linuxvoice.com
                                                                                                 KANO TO ENABLE? FEATURE

essentially the Raspberry Pi had been introduced to
meet the decline in students opting to study
Computer Science, but that Eben had never expected
it to sell more than 20,000 to 30,000 units. Eben also
told Alex that the core social intent of the project was
to get kids and beginners interested in coding again.
Alex looked at the user base at that time and most of
the users were around 44 years of age and male so
the Raspberry Pi was, at that early stage, not reaching
the target demographic that they wished for. Instead it
was being adopted by users of a generation that
remembered the BBC Micro, ZX80 etc. Other groups
were also using the Raspberry Pi in all manner of
maker-style projects, such as home automation and
low power home server projects.

Democratisation
“We’re living in a time where a small Linux board is       model, something which is inherently intuitive for          On the last weekend of
cheaper than a textbook, you can get internet              children to follow. In the book, Kano covers simple         July 2014, 16,000 people in
anywhere and you can learn almost anything for free        steps and projects such as how to connect your              87 countries will open up
online and yet I look around to my younger siblings        Raspberry Pi, how to run your first script and how to       an end-to-end, Raspberry
                                                                                                                       Pi-powered kit, with a
and friends and realise that we have no idea what is       watch a video from YouTube. The book uses a simple
                                                                                                                       Debian Linux brain and
going on inside our devices and these devices control      vocabulary to ensure that any level of reader could
                                                                                                                       dozens of projects to get
almost every aspect of our lives,” Alex later told us      follow the steps.                                           them started right away.
about his early inspiration.
  Alex’s older cousin Saul introduced him to Yonatan       Testing the project
Raz-Fridman, who would become another Kano                 The Kano project began to make kits, comprising the
co-founder. They picked up some Raspberry Pis, and         book as well as the SD card with custom Kano OS,
wanted to see how a real life kid would use the kit so     keyboard and all the cables to connect a Pi to a
they went to Alex’s little cousin Micah and asked          monitor. Once they were in a position to beta test they
“What do you want to build with this?” to which he         took early prototype kits to schools around the UK.
replied “A Computer”. Alex and Yonatan tried to do that    Their goal was not to teach a lesson, but to see if their
with him, but it was really quite difficult and Micah      kit was intuitive enough for children to learn via
was quickly flummoxed. Alex and Yonatan asked              discovery. Alex and his team would walk in and say to
themselves about what could be done about this, and        the kids “In the next hour you are going to build a
Micah replied “Make this as simple to use as Lego”.        computer, make games and make music. And guess
  That led the project to start writing a step by step     what? I won’t need to teach you how to do it, you are
book similar to those used when building a Lego            going to do it by yourself using these kits”
                                                              After the first workshop using these early
                                                           prototypes, it was clear that it was a success and that
                                                           children enjoyed using the kit. Alex happily recalls
                                                           receiving feedback from one of the children “A child
                                                           named Khalid who was nine years old said to Alex and
                                                           the Kano team “Adults believe that we are incapable
                                                           because we are young, but today we made a
                                                           computer so that makes us Super Children””.
                                                              Kano believe that this kind of learning will help
                                                           children “to find a way to make open source and
                                                           hardware hacking feel to them, not like a chore, but
                                                           like a game.” Alex went on to say: “We felt that it
                                                           should be like crossing a Commodore 64 with a
                                                           Nintendo 64 with the benefits that each brings.”
                                                              From here Kano worked with industrial designers to
                                                           create the physical aspects of the kit, like the speaker
                                                           and modular case. Alex goes on to say “We had what
                                                           we thought was a pretty sexy piece of kit, and we then
                                                           took it to Kickstarter to help fund our growth. We
                                                           wanted to make around 1,000 kits, which would cost
Alex Klein, computer scientist and Kano founder, proudly   us £95 to make. So we wanted to crowdfund the
wields the Kano’s speaker module.                          investment necessary to build this many kits.”



                                                             www.linuxvoice.com                                                                27
     FEATURE KANO TO ENABLE?


Alex says of the                                                                         responsibility to bring something new, fun and truly
Kano OS interface:                                                                       pedagogically sound to market.”
“We basically put a                                                                        Kano’s operating system is based on the rock-solid
little extra polish and                                                                  base of the Raspbian team’s hard work. Pretty much
usability in a sort of                                                                   everything that you can do with Raspbian, you can do
Ubuntu style fashion                                                                     using Kano. Alex was keen to tell us more about the
on an already                                                                            user interface.
excellent stack,
Raspbian”.
                                                                                         Kano OS
                                                                                         “From a user perspective the interface is different to
                                                                                         Raspbian. We have a beautiful apps layer with apps
                                                                                         that are very much catered to beginners, but they are
                                                                                         also a lot of fun to use. Kano also comes with a suite
                                                                                         of user-friendly tools to make your first project a little
                                                                                         bit more simple. The simplicity enables you to focus
                                                                                         more on the code rather than the application.”
                                                                                            Kano is also the first project to integrate a visual
                                                                                         programming language with Minecraft, using the
                                                                                         Minecraft API to enable the use of Python to create
                                                                                         new content in the Minecraft world. The process is
                                                                                         similar to the functionality of Scratch, where you drag
                                                                                         code blocks to build your program. These blocks are
                                 On 19 November 2013 the Kano team had a launch          then translated in to Python or JavaScript which is
                              party with friends and family. Alex talks about            then output via the Minecraft API to the Minecraft
                              launching the Kickstarter “During the party we decided     world. Alex explains “So with this you are getting this
                              to press the button on our Kickstarter campaign and        really cool side-by-side view of what you are coding,
                              something wonderful happened. The demand was               be it a building or a volcano, and you can see the code
                              fantastic: we wanted $100,000 and we managed to            that made it possible.”
                              raise that in 19 hours. After 30 days we raised $1.5M         But Kano is not just a shiny new interface and some
                              including support from Steve Wozniak, co-founder of        simple applications: the back-end of Kano OS has
The Kano kit has 21 unique
components, all of which      Apple, and Yancey Strickler, the co-founder of             other improvements, Alex explains “Behind the scenes
are either designed top-to-   Kickstarter.” Alex then goes on to say “At this stage we   we’ve really increased the speed of Kano with a 50%
bottom or reskinned.          were blown away, but knew that we had a                    increase in speed for the browser, GTK, Linpack and in
                                                                                         the overall boot time, compared to stock Raspbian”.
                                                                                         Kano also simplifies the configuration across the
                                                                                         operating system, from Wi-Fi, to the desktop manager,
                                                                                         to keyboard and audio configuration. These
                                                                                         simplifications are welcome to new users who just
                                                                                         want to experiment with the platform or are unfamiliar
                                                                                         with a Linux distribution.

                                                                                         Open source
                                                                                         These improvements are not exclusive to Kano, as the
                                                                                         team intend to share their work with the community.
                                                                                         As Alex explained about the team’s plans, “We are an
                                                                                         open source software company and our
                                                                                         improvements will be pushed upstream to the Debian
                                                                                         kernel. We’ll also share our projects and educational
                                                                                         content back upstream.”
                                                                                            The team have already opened most of their GitHub
                                                                                         repositories, and the full OS source is readily viewable
                                                                                         in the image. During the course of our conversations
                                                                                         with Alex it came across very clearly that Alex and his
                                                                                         team are giving back to the Raspberry Pi community
                                                                                         – despite what some have said.
                                                                                            Alex explained, “We’re giving back with apps – a
                                                                                         beautiful desktop manager, intuitive system settings,
                                                                                         a smart package system, etc – that significantly
                                                                                         develop the platform, as well as games and projects
                                                                                         that are accessible and awesome.”



28                                                           www.linuxvoice.com
                                                                                                           KANO TO ENABLE? FEATURE

  Alex is also keen to promote open source to
children “To help children engage with open source, it          Kano and the Raspberry Pi community
has to be presented to them in a playful, “Lego” kind of        In recent time there was a small issue in the     status between Kano and the Foundation.
a way. There is a playful and an educational aspect to          Raspberry Pi community, when one of the           “We support anyone (and there are quite a
the project and we are trying to promote this kit to the        Kano team, Alejandro Simón, claimed via           few examples, including our first-tier partners
                                                                anecdotal evidence that “It wasn’t friendly for   RS Components and Premier Farnell, and
mainstream under that pedagogical context.”
                                                                the teachers,” he said. “They received            Foundation favourites like Pimoroni and
                                                                [Raspberry Pi] kits and massive instruction       ModMyPi) who bundles the Raspberry Pi with
The future of the project                                       books and they weren’t prepared for it – so       an education-focused kit of peripherals. To
The Kano project is moving towards an investment                they were gathering dust.” This statement         give him his due, Alex realised that Alejandro
round (where companies seek investment from                     caused some polarisation in the community,        overstepped the mark in claiming, without
                                                                but when we spoke to Eben Upton, from the         evidence, that significant numbers of
venture capitalists), which would make Kano the first
                                                                Raspberry Pi Foundation, he clarified the         Raspberry Pis were ending up in drawers”
Raspberry Pi-based company to receive VC
investment. It has recently put in a major order to
Farnell for 18,000 Raspberry Pis, which makes Kano            used simple vocabulary to ensure that any level of
the largest purchaser of Raspberry Pi in the world.           reader could follow the steps.” The book’s vocabulary
   At this time the Kano project is a singular kit, but the   is squarely aimed at children and is grouped into
team have plans to expand the Kano brand via a                “Levels” with level 1 being the easiest task. These
series of hardware and software products. Alex                books are easy to use, and are intended to encourage
explains: “We see Kano as a creation kit for many             learning via discovery.
levels. The basic kit, which is building a basic
computer, is what we have at this time and it comes           Self-guided learning
with many hours of learning and enjoyment, but just           Alex discussed this topic at great length, and it was
like video gaming there will be expansion pack.”              clearly a passionate subject: “We have the kit, which is
   He goes on to explain what the packs will consist of       self contained, and we want the kit to be as easy to
“These expansion packs will constitute both software          use as Lego not just for children, but for their parents
and hardware components, such as a project to build           and teachers. We want teachers and parents to be
a battery and LED to make your Kano portable, then            involved in the learning and not just spectate, so our
the next expansion pack could be a screen to plug in          documentation must reflect the goals of the projects
and make your own tablet, and then a future                   and illustrate them clearly in a story-like way. So what
expansion to use the camera with your tablet.” There          we are going to be doing is a companion book, which
ha been a co-ordinated effort between Kano, industrial        is not necessarily a curriculum guide or a set of lesson
designers and Farnell to roll out these expansion             plans but will be a support framework from which
packs in a timely fashion.                                    teachers can build their
   But Kano is not just about the technology and the
packaging; there’s also an educational element to the
                                                              own lesson plans. An
                                                              example of the support          “Kano’s intention to share work
project via the Kano Book and a companion guide.              framework is in the             with the larger Raspberry Pi
The book, initially written by Alex, is a simple step-by-
step guide to using the Kano kit, as Alex elaborates “I
                                                              main Kano book: Level
                                                              1 of Kano is to make a          community is to be applauded.”
started writing a step-by-step book similar to those          computer, which is all
used when building a Lego model. In the book we               about setting up your Raspberry Pi and GPIO (General
cover simple steps and projects such as how to                Purpose Input Output) to power your speaker. But
connect up your Raspberry Pi, how to run your first           rather than using complicated terminology we treat
script and how to watch a video from YouTube. We              the process of setting up your Raspberry Pi like a
                                                              story with 15 to 20 words per step in the process. This
                                                              Level 1 task is also documented in the companion
                                                              book, which is filled with further details and history so
                                                              that a teacher can elaborate to the class at their own
                                                              pace.” The books are translated into Spanish, French,
                                                              German, Mandarin, Hindi, and Arabic and are freely
                                                              available from the Kano website.
                                                                 The Kano project has produced some wonderful
                                                              products that are sure to electrify the imagination of
                                                              many children around the world, and its intention to
                                                              share work with the larger Raspberry Pi community is
                                                              to be applauded. Putting the Raspberry Pi in the
                                                              hands of children and teachers is the true goal of the
                                                              Raspberry Pi project, and the intuitive approach taken
                                                              by Kano is sure to provide a useful and entertaining
The Minecraft API enables users to see features they have     method of delivery. Expect to hear a lot more about
programmed in the game, in real time.                         this little project over the next few years.



                                                                www.linuxvoice.com                                                                                  29
        FEATURE CODE CLUB
                                                 mid!Gdivnw|
                                                                             avklnoavhiejbnv
                                                                              n!@+inowhvqo;j
                                                `œ¨˙][«owpe_
                                      icoeqwj%ioejoias&¶#√˙–




  CODE CLUB:                                                           a§jkb  bmnlknio;÷~§k
                                                                                ≤lmno;ala§jkb
                                                                                  mid!Gdivnw
  THE NEXT
                                                            `œ¨˙][«owpe_     a§jkb

                                                                                 `œ¨˙][«owpe_
                                                             icoeqwj%ioe
                                                                      mid!Gdivnw|
                                                                     `œ¨˙][«owpe_




 nowhvqo;jbmnlknio
  GENERATION
                                                                                  icoeqwj%ioe
                                                                            icoeqwj%ioe




                  ≤lmno;ala§jkb
                    mid!Gdivnw|
   Nine-year-olds`œ¨˙][«owpe_
                    are getting theavklnoavhiejbnvn!@+inowhv
                                     chance


 §k `œ¨˙][«o mid!Gd
   to learn programming – and they love qo;jbmnlknio;÷~§k
   it. But for everyone to get a chance,
                    icoeqwj%ioe                  ≤lmno;ala§jkb
   more volunteers are needed, finds               mid!Gdivnw|



 kb avklnoavhiejbnv`œ¨˙][«o
   Richard Smedley.                               `œ¨˙][«owpe_
                                                   icoeqwj%ioe




nw| bmnlknio;÷~§k icoeqw
      n!@+inowhvqo;j

pe_ I mid!Gdivnw|
        ≤lmno;ala§jkb
                  f you’re reading this magazine, then you most        more than a decade, but with a much more limited




 oe
                  probably know the value of code, of people being     audience. Campaigners such as Clare Sutcliffe and


         `œ¨˙][«owpe_
                  able to code, and – perhaps most importantly – of    Linda Sandvik, who came up with an idea for giving
             understanding that coding is a creative activity,         “every child between the ages of nine and 11 the



          icoeqwj%ioe
             bringing frustration and joy, and the chance to fail      opportunity to learn coding”: Code Club.
             safely. Now, imagine every child getting the chance to       The essence of Code Club is an after school club (in
             find that out at a young age.                             school, or another safe environment like a library), for
                Coding in schools                                                                      nine and ten year-olds,
             became a hot topic a
             couple of years ago,
                                        “Imagine every child getting                                   with a volunteer
                                                                                                       programmer using
             famously with Google       the chance to find out about the                               freely-licensed teaching
             chairman Eric Schmidt
             giving the 2011            value of code at a young age.”                                 materials.
                                                                                                          Code Club is an
             MacTaggart lecture at                                                                     organisation that’s in the
             the Edinburgh Television Festival, where he said: “I      right place at the right time, and its rapid growth has
             was flabbergasted to learn that today computer            been in large part due to word-of-mouth advertising of
             science isn’t even taught as standard in UK schools.      how well kids take to its lessons. They’re designed to
             Your IT curriculum focuses on teaching how to use         draw children in, and get them being creative, learning
             software, but gives no insight into how it’s made. That   the coding side by osmosis as they have fun.
             is just throwing away your great computing heritage.”        To check this theory we asked a ten-year-old Code
                This gave a valuable boost to campaigners in the       Club participant what she liked so much about it. She
             tech industry who’d been saying the same thing for        told us: “It’s fun. You get to make games, like Flappy



   30                                                     www.linuxvoice.com
                                                                                                                      CODE CLUB FEATURE

 v
 j                                                                 MIT Scratch



k
                                                                   Scratch is a deceptively simple visual         both of new FOSS projects, and new FOSS
                                                                   programming language and multimedia            coders. How many learners will go on to
                                                                   authoring tool developed at the MIT Media      become Free Software programmers is not



 b
                                                                   Lab. Platform neutral, and GNU GPL licenced,   really the point (although some undoubtedly
                                                                   it enables learners to “mix” chunks of code    will); rather, Scratch immerses young people
                                                                   before they’ve really learned what they’re     into a community where sharing (and



w|
                                                                   doing, giving instant results. Colourful       re-mixing) code is seen as natural, and is
                                                                   graphic sprites and amusing sound effects      a great antidote to more than a decade of
                                                                   add to the fun.                                schools teaching PowerPoint and Excel.


 _
                                                                       Yet this is no dumbed-down language:
                                                                   building on Squeak/Smalltalk roots, it’s a




o;÷~§k
                                                                   fully-featured and powerful language, and as


 e
                                                                   children go through projects, experimenting,
                                                                   they start to pick up code in a similar way
                                                                   to an earlier generation did by typing in
     Soho Parish School and volunteer Simon Wharton, who
                                                                   program listings from 8-bit micro mags.
     started one of the first Code Clubs.
                                                                       As well as all of the open source Code




la§jkb
                                                                   Club projects, the Scratch website hosts
     Bird. You get to learn lots of new stuff. There’s lots of     over 5,000,000 projects. Any young learner
     stuff to explore and it’s fairly easy, because anyone         can click a button in the Scratch interface    Right from the first lesson, kids are
     can start it.” She actually used the phrase “it’s fun”        to upload their project and CC-license it –    using event-driven, Object-Oriented
                                                                   making Scratch perhaps the largest creator     programming.
     several times, so we’re happy to take Code Club at its




divnw|
     word on this point.

     Growing Up                                                  appointing a full-time Curriculum Developer: “We are
     Code Club’s growth has been rapid – passing 2,000           currently improving our web development curriculum




owpe_
     schools by its second anniversary this spring – but it’s    and adding some exciting JavaScript stuff in. We are
     matched by its ambition for the future. “One of Code        also writing lots more Python projects!” Laura Kirsop,
     Club’s missions is to get Code Clubs into 25% of            Code Club’s Managing Director told Linux Voice.
     primary schools by the end of 2015, which is a huge            Materials should also get a rejig to allow less linear
     target,” says Sam Milsom, Code Club’s General               progression, so children can join more easily mid-way




wj%ioe
     Manager. The demand is there, with 700 schools              through term, and, Milsom tells us, “volunteers can
     signed on that are still waiting for a volunteer. In        pick and choose” what to teach. In fact, volunteers are
     response to this, Code Club has accelerated the             already generating great material of their own, from
     release of all of its teaching materials under a Creative   those bringing in Arduinos and MakeyMakey boards
     Commons licence: “which will allow teachers to use          (with the celebrated banana keyboard www.youtube.
     them themselves; it will allow parents to use them to       com/watch?v=rfQqh7iCcOU), to more “unplugged”
     teach their kids at home, and so on.”                       exercises. One volunteer developed a coding role-
        Terms 1 and 2 use Scratch to teach the basics of         playing game, Sam Milsom tells us, where “for one
     programming. Term 3 teaches the basics of web               lesson the children didn’t even sit at a computer. He
     development using HTML, CSS, and a little JavaScript.       developed an RPG and they’d speak out and act out
     Term 4 teaches Python. As we go to press, the               the programming language. And he said it was
     possible content of term 5 and 6 is still under             incredible, because it got them to think about it in a
     discussion, as Code Club is in the process of               different way, rather than just following instructions,
                                                                 and typing things in, they were really enacting it.”
                                                                    Milsom adds: “Our first two terms of Scratch were
                                                                 sort of crowd-sourced, and our third and fourth terms
                                                                 we had one person working on them. Obviously we
                                                                 use GitHub to host all of our projects, so the
                                                                 community do contribute, and we’re hoping now that
                                                                 we’ve opened up our projects that will happen a lot
                                                                 more. Not just in terms of updates, but suggestions,
                                                                 and a lot of the community create their own projects,
                                                                 so again the opening of the projects will allow this to
                                                                 happen a lot more.”

                                                                 Volunteer effort
                                                                 “We’ve got an abundance of schools wanting Code
     Code Club Pro trains teachers for the new IT curriculum     Clubs,” Milsom tells us. The problem “is finding
     – but still keeps much of the fun that after-school Code    volunteers to go into the schools. We’re hoping to get
     Clubs have put into the subject.                            students from Manchester Metropolitan University



                                                                   www.linuxvoice.com                                                                            31
     FEATURE CODE CLUB

                                                                                                        Code Clubs are free of charge for children and
                                                                                                        participating schools.
                                                                                                           For many teachers, supervising the after-school
                                                                                                        clubs has been a welcome chance to see what all the
                                                                                                        fuss is about before changes in the UK national
                                                                                                        curriculum force them to learn something about
                                                                                                        coding. Milsom says that: “One of the benefits of Code
                                                                                                        Club – which is a happy accident – is that if you’re a
                                                                                                        volunteer and you go in, you have to have a teacher
                                                                                                        from the school present, and we realised that actually
                                                                                                        this is really a good thing: because it’s not just about
                                                                                                        the volunteers – industry professionals – teaching the
                                                                                                        kids. It also enables teachers to brush up on their
                                                                                                        skills, to get a good look [at teaching coding].”
Back to school: now
                                    (MMU), and other tech companies – basically trying
it’s the adults’ turn, as
volunteers learn how to             to get them to volunteer for us.”                                   Teaching teachers
train the teachers in the             We talked to Sam Milsom just before he spoke to a                 The abolition of the current UK schools IT curriculum,
new curriculum at Code              collection of Code Club volunteers, in Manchester:                  which essentially taught children how to use MS
Club Pro’s first training           “We’re starting quite a big partnership in Manchester,              Office, was announced during the early days of Code
workshop.                           between companies like CTI Digital, Manchester                      Club, whose close contact with schools allowed them
                                    Digital Development Agency, MMU, and the Council                    to see teachers’ reactions to this, as well as to the
                                    themselves – and, of course, our current volunteer                  announcement of the more rigorous, code-led
                                    base in Manchester, which is the second largest                     curriculum being introduced this September.
                                    hotspot of Code Clubs in the UK.”                                     “One of the reasons that we’ve opened up our
                                      This is a strong reflection of the tech industry and              projects is for teachers to have a look. I’m not saying
                                    community in Manchester. London has the large                       our projects are going to be anything like the national
                                    companies, Silicon Roundabout, and Code Club’s own                  curriculum – far from it – but I think, hopefully, it does
                                    offices, but outside of the UK capital, Manchester is               demystify; they start to realise that coding in Scratch
                                    the second largest tech city in Europe, with a vibrant              isn’t as scary as you think it is,” Milsom told us.
                                    start-up culture, and a strong Free Software and open                 We suggested to Milsom that press coverage of the
                                    hardware scene. But while Code Club has grown in                    new curriculum as being only about “back-to-basics”
                                    the UK, groups have started to form in dozens of other              coding had done it a disservice: “I’d completely agree
                                    countries, from the USA to Ukraine, and Code Club                   with that. From day one we never expected that every
                                    has responded with Code Club World.                                 child who went to Code Club would go off and
                                                                                                        become some great programmer who’d change the
                                    Winning formula                                                     world. Not every child is going to grow into the next Sir
                                    Wherever they set up, Code Clubs follow the same                    Tim Berners-Lee. What’s interesting is that it goes
                                    simple formula of a volunteer programmer using the                  beyond computational thinking: it’s simple problem-
                                    CC-licensed materials, working with a teacher (or                   solving; it’s trial-and-error; and personally, I think
                                    other suitable supervisory adult in Clubs in libraries)             there’s something about failure that is really
                                    who, though possibly lacking programming skills, has                important. Children aren’t taught that failure is okay,
                                    the experience of educating and controlling pupils that             that failure is the key to success. They’re taught that
                                    would be an intimidating barrier to many volunteers.                you have to pass exams; you have to pass. And it’s my


  Next, the World!
  “We were becoming overwhelmed with              safe environment. Some things do change
  emails from people in other countries,          by country – in Canada there is no model
  saying: ‘Can I set this up in my own            of after-school clubs; pupils go home and
  country?’” Sam Milsom told us. Code Club        eat dinner, then return to school for Code
  World has now become a full-time concern        Club. Language is a barrier to growth outside
  for Code Club founder, Clare Sutcliffe, who     the Anglosphere, but already Code Club’s
  told Linux Voice that CCW would: “create        teaching materials have been translated into
  a framework to allow other countries to         eight different languages, and there are six
  support local volunteers.”                      more well on the way on GitHub.
     Currently, frameworks of support for            Code Club World defines an active country
  volunteers exist in some countries, such as     as one with a team supporting 30 or more
  Brazil and Ukraine. In others, such as India,   volunteers, and there are currently six at
  there are several individual Code Clubs,        this level: Australia, Brazil, Hong Kong, New
  but no national support mechanism. The          Zealand, Norway and Ukraine. The ambitious
  model is the same everywhere: volunteer         target, Sutcliffe tells us, is to get 100 countries   World domination? This time it’s a benign empire of
  programmers, CC-licensed projects, and a        with active communities by the end of 2018.           educational volunteers spreading across the globe.



32                                                                      www.linuxvoice.com
                                                                                                                  CODE CLUB FEATURE


  Volunteering
  Before becoming Code Club’s General Manager, Sam
  Milsom was its Volunteer Support Officer. He tells us:
  “We’ve got such an amazing volunteer community, we use
  Google Group forums, and have meet-ups, and some of the
  projects that the volunteers come up with off their own bat
  are incredible.”
      Go to CodeClub.org.uk and click on “Start a Club” and
  then the “Volunteers start here” button, and you’ll find all
  the information you need, as well as hearing about the
  experiences of other volunteers. To work with children in
  the United Kingdom, you need an Enhanced DBS (formerly
  known as a CRB) check, and you’ll need insurance to go
  in to schools. Code Club makes it easy to get these for
  free by linking up with STEMNET’s STEM Ambassadors
  Programme, and encouraging you to sign up through
  your local STEMNET office. STEM Ambassadors is a
  volunteering programme for STEM (science, technology,
  engineering and maths) professionals and enthusiasts.
  After registering, you get a two-hour induction session on
  working effectively and safely with young people. After a
  few weeks your DBS check should be complete, and while
                                                                                                                             If coding is the new Latin,
  you’re waiting, as well as taking the time to read through         Many of the core concepts are already being taught,
  Code Club’s teaching materials, you can look on the Code
                                                                                                                             then no wonder London
                                                                  adds Deen: “Algorithms – instructions – are taught in      Mayor Boris Johnson is
  Club website for a local school wishing to start a Code Club.
                                                                  English. Sequencing, basic logic and reasoning are         getting behind it.
                                                                  taught already.” Code Club Pro’s materials are about:
                                                                  “Really trying to demystify the language and context
experience of seeing Code Clubs in action, that it                of the new curriculum.” Teachers are non-specialists,
teaches them that it’s okay [to fail].”                           but good at teaching, and coding is no more difficult
  The latest offshoot of Code Club is Code Club Pro,              than music, which non-specialist primary school
sending trained volunteers to teach groups of                     teachers regularly tackle.
teachers how to deliver the new curriculum. As we                    Code Club Pro’s materials aim to “demystify
near September’s arrival of the new IT curriculum into            language and core concepts,” showing that the
schools, demand for CPD (Continual Professional                   computer language gives expression to ideas. “We
Development training) in schools is likely to be                  want to help inspire the ideas,” and to get teachers
immense. We asked Code Club Pro’s Sophie Deen                     enthusiastic about the changes to curriculum. The
about this: “We’re just scratching the surface of                 materials should be online by the time you read this; if
understanding that demand,” Deen told us. “We’re                  you’d like to volunteer to train the teachers, the
present in schools and hear back directly from                    process is a little more involved than volunteering to
teachers [who don’t] understand coding or knowing                 run a Code Club, as outlined in the box above. There’s
how to get there.                                                 an online test, a Skype
  Deen wants to show teachers that it’s not just about
code, but that computational thinking “can be used to
                                                                  interview, then a day’s
                                                                  training. “We have        “Code Club’s teaching materials
enrich the way children think and learn in a cross-               amazing trainers,” says   have been translated into eight
curricular way, covering core skills.” In the first two
months of Code Club Pro’s existence, with no publicity,
                                                                  Deen: “Clever, good
                                                                  communicators and         languages, and there are six
850 schools signed up. “We know from teachers that                well-motivated.”          more on the way on GitHub.”
when it [officially] launches there’ll be a huge demand.”
                                                                  Your turn
                                                                  Have you always wanted to do your bit with passing
                                                                  on your enthusiasm for coding to the next generation,
                                                                  but been perhaps a little scared of facing a
                                                                  classrooom of demanding and unruly children? Code
                                                                  Club’s structure, with a teacher present at all times to
                                                                  work with the children, takes away this fear and gives
                                                                  you, dear reader, the perfect chance to spread some
                                                                  programming joy. The great materials mean that even
                                                                  if you are more of a system administrator than a
                                                                  coder, you can still teach – just read one lesson
                                                                  ahead, and you’ll be fine.
Code Club’s quirky robotic graphics are an external                  You are wanted. You are needed. Step up to the
reflection of a friendly, easy-to-access service.                 task and you’ll be appreciated, too.



                                                                    www.linuxvoice.com                                                                 33
     FEATURE STEAMOS




                                                    AND THE
          DEMOCRATISATION
          OF GAMING  Discover how Valve singlehandedly changed the future
                                  history of games on Linux.


         V
                   alve is a video games company with some          One to become its proxy for home entertainment, and
                   serious history. It created genre-defining       its changing attitudes to core technologies such as
                   games with its Half-Life series. It built a      DirectX and .Net have left many developers looking to
         cutting-edge games engine used by its own titles, and      broaden their asset pools and experience.
         then went on to dominate digital games distribution           And then there’s the emergence of independent
         with Steam, long before Apple thought about walled         development studios, many of which are now
         gardens and app stores.                                    accustomed to developing for consoles, tablets,
           But none of this history has been played out on          smartphones and PCs using cross-platforms tools
         Linux: until relatively recently, Valve was entirely       and APIs. For them, Windows is just another platform.
         wedded to Microsoft Windows, the master system of
         PC gaming. This was due to several factors; Windows        Next-gen gaming
         had been able to maintain a position it held since         The next generation of gaming consoles have also
         the end of the DOS gaming era, thanks to its DirectX       helped shift priorities. The PlayStation 3, for example,
         games API. Almost                                                                          was notorious for its use
         two decades of intense
         competition between
                                     “Valve’s future, and potentially                               of proprietary
                                                                                                    technology, forcing
         the accelerated graphics    the future of PC gaming itself,                                developers to learn
         hardware manufacturers
         had dropped prices and
                                     is now dependent on Linux.”                                    techniques specific to a
                                                                                                    single (complex)
         boosted performance,                                                                       platform, rather than the
         and the Windows drivers for them worked well.              cross-platform approach taken by most studios. Now
         Windows was actually a pretty good gaming platform.        that both the Xbox One and the PlayStation 4 are
           But all that has changed with Windows 8, at least        based on what are essentially standard PC
         for Valve. Gabe Newell, Valve’s co-founder and             components, the only differentiators are their
         managing director, has said that Windows 8 is a            operating system and development environments
         “catastrophe”, which is somewhat ironic considering        (and performance, of course). On the one hand you
         that he worked for Microsoft for 13 years before Valve,    have the PlayStation 4 running an operating system
         and was, according to one interview, “the producer on      based on FreeBSD and using all kinds of open source
         the first three releases of Windows.” But users are also   tools, and on the other you’ve got Microsoft with its
         reconsidering their commitment to Microsoft’s              latest incarnation of DirectX. The result is that it
         operating system in the face of both user-interface        makes sense for most games development, for most
         and community challenges. Microsoft wants the Xbox         games studios, to be cross-platform, enabling studios



34                                                     www.linuxvoice.com
                                                                                                                    STEAMOS FEATURE


  Valve and open source
  Valve isn’t a natural Linux company. It rarely responds
  to emails, and its approach to the Linux community is
  somewhat detached compared with that of some other
  companies or distributions. However, it has given the
  complete library of all Valve-produced games to both
  Ubuntu and Debian developers in recognition of the work
  they’ve done to build the basis of SteamOS, and Valve’s
  own team are beginning to have an effect on the open
  source tools that they themselves are modifying.
     Its biggest contribution is the DirectX To OpenGL
  translation layer, which it uploaded to GitHub under the MIT
  licence (https://github.com/ValveSoftware). This neat bit
  of software helps developers migrate from Windows-only
  games, and could even help games for Microsoft’s Xbox
  360 console be ported to SteamOS/Linux.
     Valve has also sponsored work on the Mesa project,                                                                    The latest update to the
                                                                 competitive third-party publishing on Windows and
  the open source libraries that implement OpenGL with                                                                     Steam client includes game
  hardware acceleration, to help improve shader compilation
                                                                 OS X and forced Valve to come up with a dramatic          streaming for everyone and
  time. The improvement should help the launch time of           change in direction. Until then, Linux hadn’t been part   less OpenGL lag.
  games using those shaders, and patches have already            of its history. But Valve’s future, and potentially the
  shaved 20 seconds off the launch time of Dota 2. Valve has     future of PC gaming itself, is now dependent on what
  also been helping make improvements to the XPad kernel         was an outsider and an underdog: Linux.
  driver. This is the driver used by many Xbox and Xbox-alike
  controllers, which have become close to being a standard
  on Linux and whose button mappings are the default             Steam client
  in Steam. Valve’s own Steam Controller uses the same           The first whiff of Valve’s changing direction came in
  driver, and the patches so-far submitted help with dynamic     early 2012. Some users reported that their Windows
  wireless device creation and LED feedback. Finally, despite    and OS X Steam clients included references to a
  their not being open source, Valve has been working with
  Nvidia to improve its proprietary drivers.
                                                                 non-existent Linux port, along with a few vague
                                                                 configuration files for the game Left 4 Dead 2. Most
                                                                 people cast these Linux appearances aside, as the
to release games for many platforms without the                  rumours used to surface every few years regardless
corresponding ramp in resources.                                 of fact. And until that point, the popular consensus
   Valve has watched this shift in development                   had been that without obvious desktop growth, there
priorities, and also watched Microsoft become more               was little advantage in a Linux port and only potential
single-minded and controlling. It must have also seen            pain for Valve when it attempted to troubleshoot 200
the launch of Apple’s app store and games portals,               different Linux distributions.
both on iOS and OS X, and noted that it will never be               But those original rumours were confirmed on
able to compete on a level playing field while in                16 July 2012, when Valve wrote a blog post called
someone else’s walled garden. The same could also                ‘Steam’d Penguins’. It was used to straighten out the
be true, to a lesser extent, of Microsoft, and it seems          rumours, announce an 11-strong Linux Team (initially
likely that for both operating system vendors, the ideal         formed in 2011), and to finally confirm that they were
situation would be one where their users could only              working on both a Steam client and a port of Valve’s
install software (including games) through their own             Source games engine. Left 4 Dead 2 would be the first
authenticated systems. And when your own app                     game. The blog also explained that Gabe had been
ecosystem is dependent on someone else’s operating               interested in a creating Linux versions for some time
system, what can you do?                                         and that after conversations in the hallway sometime
   The perfect storm of a new generation of games                in 2011 those conversations led to the creation of a
consoles and the dawn of more restrictive and less               new team.
                                                                    Valve has a rather unusual employee hierarchy
                                                                 because there isn’t one. It describes this arrangement
                                                                 as a ‘flat organisation’ where employees don’t report
                                                                 to anyone and are free to choose to work on whatever
                                                                 projects they think are interesting. In answer to the
                                                                 question “Why do I need to pick my own projects?” in
                                                                 the infamously leaked 2012 ‘Handbook for New
                                                                 Employees’, the answer simply states “We’ve heard
                                                                 that other companies have people allocate a
                                                                 percentage of their time to self-directed projects. At
SteamOS isn’t about improved performance, as there’s very        Valve, that percentage is 100.” Even Gabe Newell is
little difference. It’s about controlling the ecosystem and      himself described as follows in the handbook’s
competing with Sony, Microsoft and Apple.                        glossary, “Of all the people at this company who aren’t



                                                                   www.linuxvoice.com                                                             35
     FEATURE STEAMOS

                                                                                          mainstream alternative to the proprietary alternatives
                                                                                          of OS X and Windows. That blog post also outlined
                                                                                          that initial support was going to be for Ubuntu only;
                                                                                          which we all understood, because you don’t want to
                                                                                          deflect valuable resources from making a port to
                                                                                          working out whether broken audio on Arch is down to
                                                                                          ALSA, PulseAudio or OSS.

                                                                                          All hail the new gaming overlords
                                                                                          By December 2012, there was an open beta version of
                                                                                          the Linux client, and while there were very few games
                                                                                          – around 30 initially and growing to 50 by the time of
                                                                                          the first official release in February 2013, Valve was
                                                                                          having an effect on independent games developers.
                                                                                          Many had started to consider creating a Linux port, as
                                                                                          long as their cross-platform tools were able. But over
                                                                                          the following summer, there was something more
                                                                                          significant brewing. In the shadow of new console
                                                                                          announcements from Sony and Microsoft, it seemed
                                                                                          likely to most of us that Valve would attempt to enter
Steam and Linux are
                                your boss, Gabe is the MOST not your boss, if you get     the console market, and that perhaps its recent Linux
spreading the excellent
Sir You Are Being Hunted        what we’re saying.”                                       manoeuvring would form part of a bigger plan.
across the world.                 We’d imagine there was a constant background               The news eventually came in two slices at the
Good show!                      noise of Linux chatter at Valve. They already used it     end of September. The first was the announcement
                                for their servers, and Gabe was probably vocal about      of SteamOS – a Debian-based cut-down Linux
                                where he wanted the company to go. At some point,         distribution that boots directly into a new Steam
                                the chatter resulted in a critical mass of opinion, and   interface, and the second was an open hardware
                                employees started pushing their desks together to         specification that it called the Steam Machine, along
                                create a new product, which became the Linux version      with a revolutionary controller. Unlike games consoles,
                                of the Steam client. This ad-hoc formation eventually     there are going to be several different tiers for Steam
                                led to more resources and to the the 1,700 responses      Machines, and different manufacturers – some of
                                that appeared in the comments thread to the original      which have already built and sold gaming PCs under
                                blog post.                                                the brand name. This means people can choose a
                                  The Linux community were understandably very            specification according to their budget and gaming
                                receptive to the idea that their operating system         requirements, and even upgrade their own hardware.
                                would finally be receiving a little premiere league          Valve followed the hardware announcements with a
                                gaming love. Many of us thought that the prospect of      lottery to send optimised prototypes of their own
                                Steam finally coming to Linux was the last key in the     specification to 300 lucky Steam users. This was
                                puzzle and one of the last stumbling blocks for any       undoubtedly used by Valve to test their burgeoning
                                operating system that wanted to consider itself as a      Linux operating system, its Steam front-end and its
                                                                                          hardware, drivers and update mechanism, a process
                                                                                          that’s still very much on-going. The launch of
                                                                                          SteamOS and the promise of a new hardware
                                                                                          platform was all that was needed for many major
                                                                                          companies to start including Linux in their tier 1
                                                                                          gaming plans. Both Unreal Engine 4 and Unity 4
                                                                                          delivered Linux support, something which looked
                                                                                          unlikely before Steam on Linux, and they’re both
                                                                                          making cross platform development much more
                                                                                          viable for many developers. And with the prospects of
                                                                                          Valve’s Half Life Episode 3, a massively anticipated
                                                                                          gaming title, coming to Linux on day-one, so too are
                                                                                          other major studios considering Linux. There are now
                                                                                          more than 431 Linux titles on Steam with more
Steam Linux usage is still
                                                                                          announcements than we can keep up with. More than
hovering around 1%, but
                                                                                          the hardware and the software, this is what Valve has
there are many major titles
in the pipeline and we’ve yet                                                             brought to Linux - a very real opportunity to create the
to see cheap Steam Boxes                                                                  best possible PC-based open gaming platform, which
to compete with the PS4                                                                   to many of us who love gaming, seems like a dream
and Xbox One.                                                                             come true.



36                                                             www.linuxvoice.com
                                                                                                                      STEAMOS FEATURE


Installing SteamOS
It might be a moving target, but if you’ve got the luxury of a dedicated games
machine, it’s worth installing SteamOS onto a spare partition.
We’d recommend grabbing the ISO version of                      partitions. Change ‘Use As’ to ‘Ext4’, the ‘Mount point’
SteamOS. This is a 4GB file that can be downloaded              to ‘/’ and enable the boot flag for your root partition.
from http://repo.steampowered.com/download/                     Click on ‘Done Setting Up The Partition’ to go back
SteamOSDVD.iso. You then have the choice of either              to the list and make sure only those partitions you’re
burning the ISO to a DVD, if your Steam PC is capable           going to use are marked with a ‘K’ and an ‘f’ or ‘F’. This
of booting from one, or transferring the contents               is important, because the installer could change a
of the ISO to a suitably large USB stick. The latter            drive you want to keep. When you’re happy, click on
doesn’t require any ISO conversion, such as with the            ‘Finish Partitioning And Write Changes To Disk’.
UNetbootin tool, and the data can be written directly              The base system will now be installed according
to the USB stick. The simplest method is sudo dd                to your wishes, and you’ll get the chance to install
bs=1M if=/path/to/dvd.iso of=/dev/sdX, but you                  the Debian desktop environment and the standard
need to make sure that /dev/sdX is definitely your              system utilities before the installer finishes, which
USB stick, as if you get this wrong, all your data will         we’d recommend for greater post-install flexibility.
be overwritten. We’d suggest checking your system               After one more
logs after inserting the device to make sure you get
the correct device name. Before rebooting, we’d also
                                                                question your system
                                                                will be rebooted, and
                                                                                               “You’ll get the chance to install
recommend creating the SteamOS partition on your                with a bit if luck, you’ll     the Debian desktop environment
drives with a tool like GParted, as it’s easier than doing
the same thing through the SteamOS installer.
                                                                soon be presented with
                                                                the SteamOS Grub
                                                                                               and standard system utilities.”
   After rebooting, press the hotkey to open your               bootloader menu, from
system boot menu (usually F12). If you want                     which you’ll be able to select SteamOS.
SteamOS to be bootable from UEFI, make sure you                    SteamOS should launch automatically, and on your
boot into UEFI for your chosen boot method. If you              first boot you’ll first need to choose a language, agree
want old-school BIOS booting, don’t select a UEFI boot          to a EULA, change the screen configuration and your
mode. Either way, the same SteamOS boot menu will               time zone. You can now use your Steam account
then appear. Choose Expert Install from this menu,              details to log in and as with any other Steam client,
unless you want to give SteamOS complete control                you’ll have to enter an activation code sent do your
over your system. Then select a language, a location            email address first. After the activation, you’ll find
and a keymap. A few moment later, you’ll see the                yourself in SteamOS proper, complete with New Age
‘Partition Disks’ window. On our system, SteamOS had            background music and motes of OpenGL particles.
arbitrarily selected and suggested repartitioning our           While waiting for the official Steam controller, we’d
first drive, which is bad. Click on ‘Go Back’ and select        recommend using Microsoft’s Xbox 360 controller or
the Partitioner again to remove any default choices.            Logitech’s F310, as these work without any need to
You’ll then be able to double-click on your preferred           reconfigure the buttons.



Install SteamOS from ISO




 1 Boot it up                                         2 Partitioning                                       3 Sign in
      Burn the ISO to a DVD or copy it across to a          SteamOS recognises if a drive is empty and          When it’s up and running, validate your
8GB USB stick. Boot from either UEFI or BIOS mode    makes best use of it. Otherwise, be careful with    account and start downloading your games library.
- SteamOS will now work with both. Choose Expert     its default configuration and make sure it doesn’t   All Steam games are available to all clients, plus you
mode from the boot menu.                             overwrite your data.                                can stream and share with family members.



                                                                   www.linuxvoice.com                                                                         37
     FAQ LLVM/CLANG




LLVM/CLANG
Watch out GCC – there’s a new compiler suite in town, and it wants your crown.

                                                    Great! So GCC rules – shall we                You keep talking about LLVM/
MIKE SAUNDERS                                       just go to the pub now?                       Clang – what’s with the funny
                                                   Hang on a second. GCC is highly        name? Is it like GNU/Linux?
       Uh-oh – compilers. There’ll be               regarded, but it has flaws. The               No; it refers to two technologies
       a lot of acronyms and                 codebase is very complicated, and                    that are parts of the compiler. In
initialisms in this article, then…           some developers claim it’s so messy          the olden days, compilers would simply
       Actually, no. The technology          that very few people can add new             read source code and generate
       behind LLVM and Clang is              features to it, hindering progress. In       equivalent CPU instructions on the fly,
tremendously complex, but here we’re         addition, it’s hard to split up individual   perhaps performing a bit of
more interested in its practical             parts of the compiler, making it hard to     optimisation along the way. As time
applications – how it’s going to make        integrate with modern IDEs (integrated       went on, it made more sense to split the
life easier for developers, and make our     development environments). Finally, the      part of the compiler that parses the
applications faster and more reliable.       licence is an issue for some developers,     source code away from the part that
                                             who’d rather avoid the GPL and use           generates the CPU instructions. This
       So what’s going on with this          something more BSD-like.                     makes a lot of sense, as it becomes
       strangely named software?                                                          easier to support more programming
       Right now, GCC (the GNU                      So this LLVM/Clang thing              languages and CPU types. For instance,
       Compiler Collection) is                      solves all these problems?            someone could add Fortran processing
responsible for compiling virtually all of          Well, it’s a start. LLVM has been     capability to the compiler without
the code in a typical GNU/Linux                     around since 2000, and Clang          having to know about ARM and x86
distribution. That is, it takes the          since 2007. Developing a new compiler        CPU instructions. Or someone heavily
human-readable source code for               is a gargantuan task, especially given all   versed in those CPU instructions can
programs and turns it into executable        the languages, language features and         make optimisations without having to
files that the CPU can understand. GCC        CPU architectures in use today.              think about the high-level languages.
is arguably the biggest success story of        While GCC is still the de facto              In order to separate these parts of
the GNU project – it’s used everywhere,      standard compiler in the FOSS world,         the compiler and add a level of
from supercomputers to embedded              LLVM/Clang is nipping at its heels,          abstraction between them, you need an
devices, and it can generate code for a      thanks to support from notable               intermediate language. And that’s
huge range of CPU types.                     companies such as Apple. One                 exactly what makes LLVM/Clang work.
                                             testament to the maturity of LLVM/           Essentially, Clang is a front-end for
                                             Clang is that it’s the default compiler in   C-like languages (C, C++, Objective C),
“Some developers claim that                  FreeBSD 10, replacing GCC. FreeBSD is
                                             well regarded as a conservative and
                                                                                          so it parses C code, includes header
                                                                                          files, handles macros and so forth, and
the politics of the GPL scare                highly reliable open source Unix flavour,    then generates some intermediate
away potential contributors.”                so its adoption of LLVM/Clang was a
                                             major event in the compiler’s history.
                                                                                          code. This code looks a bit like a
                                                                                          mixture between assembly language



38                                             www.linuxvoice.com
                                                                                                   LLVM/CLANG FAQ

and a high-level language:
%result = mul i32 %X, 8
Here, the 32-bit integer variable %X is
multiplied by 8, and the result is stored
in the %result variable. This is not
specific to any kind of CPU type, but is
sufficiently low-level for LLVM to
process. (That’s where the name
comes from – Low Level Virtual
Machine.) So Clang knows C, and LLVM
knows this intermediate language.
LLVM then performs optimisations and
tricks with the intermediate code,
before generating CPU instructions for
the chip of your choice.

       Wow! That sounds rather                                                                              Every good FOSS project
       clever… But are other                                                                                    needs a mascot, and
programming languages supported?                                                                               LLVM’s robot is rather
                                                                                                             darn cool, we must say.
       Yes – quite a few. You can chuck
       out Clang and replace it with
another language front-end that              companies to add patches. It’s a                    Can LLVM/Clang compile
generates the intermediate language.         massive debate with a million points to             everything that GCC can?
LLVM doesn’t care. Right now there are       be made, and GPL vs BSD arguments                  Not quite. GCC provides various
front-ends for Ada, D, Fortran and other     will rage for decades to come.                      extensions for C and C++, and
languages, and many of these front-                                                       because it has been the de facto
ends were taken from the GCC                        Hokey dokey. Anyway, earlier          standard compiler for free Unix
codebase. And because LLVM is                       you talked about LLVM/Clang           systems for decades, many developers
released under a BSD-like licence (so        making our applications faster and           use these extensions. Clang’s support
you can do what you want with it,            more reliable. How does that work?           is constantly expanding, though. In
providing you give credit to the original           One of the goals of Clang is to       addition, there are efforts underway to
developers), it’s making its way into               produce more informative error        make the Linux kernel compilable by
various other compiler suites, IDEs and      messages than those spat out by GCC,         LLVM/Clang, (see http://llvm.
projects: www.llvm.org/                      making it easier for developers to spot      linuxfoundation.org). Right now it’s
ProjectsWithLLVM.                            and fix bugs. Ideally, this should result     possible to compile the kernel, but
                                             in better code with fewer bugs.              some external patches are required.
         Hrm, I’m not sure I like the        http://clang.llvm.org/diagnostics.html
         BSD-style licence, whereby          shows what the Clang team is doing in                OK, so how do I get it installed
anyone can make closed source                this direction. It should be noted that              and test my code?
programs with LLVM inside.                   GCC is making progress in this area too,             Few distributions include LLVM/
Wouldn’t the GPL be better?                  with colorised output in GCC 4.9 as an               Clang by default, although almost
         We’re big GPL fans at Linux Voice   example. Competition is good!                all of the big-name distros have the
         HQ, so we know what you’re             Right now, LLVM and GCC are pretty        compiler in their package repositories
saying. And Richard Stallman isn’t           much neck-and-neck when it comes to          – look for llvm and clang. Interestingly,
especially happy about LLVM either:          the speed of their produced code. GCC        some Debian developers are trying to
   “The existence of LLVM is a terrible      has a tiny edge in some benchmarks,          build a version of the distro entirely with
setback for our community precisely          but given that LLVM is a much younger        LLVM/Clang; of the 40,000+ packages
because it is not copylefted and can be      project, it’s impressive that it has         that Debian includes, only 11.6% of
used as the basis for nonfree compilers      reached the same level so quickly.           them can’t be compiled right now. As
– so that all contribution to LLVM              Because LLVM’s codebase is simpler        LLVM/Clang improves and becomes
directly helps proprietary software as       and easier to navigate than GCC’s, the       more compatible with GCC, this number
much as it helps us.” (Full message at       hope is that it’ll be easier for new         will go down, and in a few years we
http://gcc.gnu.org/ml/gcc/2014-01/           developers to add optimisations, and         might see mainstream distros compiled
msg00247.html)                               the more people that can get involved        entirely with the newer compiler.
   Still, there are other sides to the       with the compiler’s internals, the better.      GCC is still an awesome compiler,
argument. Some developers claim that         So while LLVM doesn’t magically make         and LLVM/Clang’s presence has
the GPL scares away potential                applications faster now, if its              rejuvenated its development. With both
contributors due to all the politics         development continues more rapidly           teams scrambling to make faster, more
involved, whereas a BSD-licensed             than GCC’s, it might outperform the          informative and more reliable compilers,
compiler makes it simpler for                GNU compiler substantially over time.        the future looks very rosy indeed.



                                                              www.linuxvoice.com                                                 39
     INTERVIEW PIMORONI


PIRATE
MONKEY
ROBOT
NINJA:
PIMORONI
Fancy launching your own maker revolution?
You could could do worse than follow the
example of one of its most successful offspring.


P
        erhaps William Blake was              based Pimoroni epitomises this new
        right. There may yet be a New         community and maker attitude. Paul is
        Jerusalem built in the shadow         the designer who won the competition
of his Dark Satanic Mills.                    to create the (now famous) Raspberry
  In the north of England, the cities of      Pi logo, and he made the original laser
Sheffield, Manchester and Liverpool
are hosts to a new kind of industrial
                                              cuttings for the 100,000-selling Pibow
                                              case at his local hackspace. Jonathan
                                                                                               “The ancient Greeks had
revolution, and it’s one where any            is a software engineer and startup               absolutely no concept of
one of us can create anything. It’s a
revolution for makers and tinkerers
                                              veteran. He’s unfazed by PCB design,
                                              wave soldering machines and arrays
                                                                                               graphic design. When they
and it’s built on the success of              of laser cutters.                                were making their alphabet
the Arduino micro-controller, the                We met them to discuss their
                                                                                               they just didn’t think about
                                                                                               branding at all.”
Raspberry Pi, and of course, Linux.           beginnings, their remarkable growth
  Co-founded by Paul Beech and                and what’s next for the company in the
Jonathan Williamson, Sheffield-                 heart of the Maker Belt.



       Did you guys know each other           came out. It was part of their...                  But they knew about Bucky
       before you got together to                                                                balls [the shape of the C60
create Pimoroni? Had you discussed                   Their competition!                    Buckminsterfullerene molecule]…
doing something like this before?                    PB: Exactly. I saw the BBC article    PB: Absolutely. Aristotle probably
Paul Beech: We’d done some startup            and I was following the project after that   worked it out and then thought ‘Nah, no
stuff before, but we’ve kind of levelled up   because I thought, ‘Yeah, this is gonna      practical application’. So, that was
to one another haven’t we?                    to change everything’. And then they         around August or September the year
Jonathan Williamson: Yeah, we’d               had the logo competition and it was one      before it came out.
known each other for about eight years        of those things where I was so inspired,
probably.                                     I said ‘This is going to be so huge, it             There were a load of delays
PB: I think we got to know each other         needs a kick-ass logo’. It took me about            and it came out about nine
when we were doing startupy things            an afternoon.                                months after we all expected it to.
and doing our first freelance things,                                                      PB: Yep, there was all the getting it to
starting our own first business together,            An afternoon!                         manufacture, which they blogged
all that kind of thing. We’ve crossed                PB: Yeah, well, it was an             brilliantly, and people were frustrated
paths many times and got on together          inspiration, because I believed in it, so    about it, but actually getting that level of
when working and hanging out.                 the berry popped out of something I          detail from the process was really great
                                              thought was good. The most important         as well. That’s another thing that made
      Did the Pibow and the design            thing was dropping the Pi concept. The       us think ‘Yeah, great project’. They
      for the Raspberry Pi logo come          ancient Greeks had absolutely no             would tell you exactly where things
about at around the same time?                concept of graphic design. When they         went wrong and why, which is very cool.
PB: No, the Raspberry Pi logo was             were making their alphabet, they just        But, anyway, it got released and people
created a few months before the Pi            didn’t think about branding at all.          started getting it in their hands. There



40                                                              www.linuxvoice.com
                                                                                                           PIMORONI INTERVIEW




        was conjecture when the cases were                 problem is that the perspex has terrible      in Sheffield have got a laser cutter, and I
        coming out, they were functional, pretty           tolerances, so if you’re relying on those     knew them a little bit, so I kind of walked
        boring. And there was one case that I              kind of jointed connections, they’re          through the door and went ‘Hey, can I
        think Adafruit made, which slotted                 either going to be too tight or too loose     use your laser cutter?’
        together, but I got one and bits of it             and you’ll very rarely get something
        broke off and it wasn’t quite there. I             bang on.                                            Do you get people coming
        mean, there were good reasons for it               JW: And the perspex is quite brittle in             around to you now saying ‘Hey,
        but it just like ‘Oh, this isn’t right’. So then   single sheets.                                can I use your laser cutter?’?
        I said, ‘OK, I’m gonna make a case’.               PB: So for laser cutting, I went to Fab       JW: Yeah, a fair bit! And we try to let
           The Adafruit case was nice because it           Lab in Manchester [this place looks           them if we can.
        wasn’t injection molded, so it’s                   brilliant – www.fablabmanchester.org]
        something you can make yourself on a               and kind of bounced off there with                   We probably shouldn’t put that
        laser cutter. And Adafruit is very open            trying to get in and use the laser cutter.           in the interview!
        with its designs. They’ll let you                  It’s a very good place and they have          PB: It’s something we’d like to do more
        download that kind of thing and let you            various kinds of open policies on what        of but it’s trying to make it so that it’s
        do it yourself if you want. The main               you can come and do, and how you use          easy for them and easy for us.
                                                            the laser cutters. And if you use them       JW: Like scheduling it and having a
                                                            on Fridays and Saturdays, they’ll offer      window where we say just come in and
“Getting that level of detail                               you feedback on your design. They
                                                            make it open for people to learn. It was
                                                                                                         use the laser cutter. Generally it’s fine,
                                                                                                         but sometimes we’re in a massive
from the Raspberry Pi launch                                trying to get onto the laser cutter and      crunch and we just can’t deal with
process was really great.”                                  get a bit of help getting started that was
                                                            hard. At the same time, Access Space
                                                                                                         anything else at that moment.
                                                                                                         PB: We do want to have a bit more of a



                                                             www.linuxvoice.com                                                                  41
     INTERVIEW PIMORONI

hackspace vibe, but we’ll just see how it           Were you always going to use                    So you were still serious with
pans out with the new place. So I                   bolts to hold the case together?                one another at that early stage.
ordered a stack of swatches of perspex       PB: I don’t think we were going to do          That’s good! I think that’s very telling.
and it came in a portfolio of all the        anything to be honest. We were just            JW: Yeah, we were both quite serious
different colours, and I didn’t think        buying small things and putting them           and nerdy about stuff.
anything of it. Then John was around         together and saying ‘Yeah, that looks          PB: We used to read everything on the
the flat one day, saw it, and he knew all    better than it did last time’. It made         internet twice a day, all of it, and we’d
the colours from the top to the bottom       sense with the layers. Because they’re         know what we like, we know what
and said ‘Ah, that one’s quite nice’.        not at right angles to each other, you’re      works and what doesn’t, and try to
JW: That was my entire contribution.         not going to dovetail them or join them,       match it as much as possible.
PB: Then it was about 10 hours over a        and that was the problem with the              JW: We both have quite well-formed
couple of weeks, Access Space                other cases. It wasn’t the first thing to      opinions on what we like and don’t like.
                                                                be layered, but it was      PB: Which sometimes means we don’t

“Open Source allows us to                                       tricky getting them to
                                                                go around the ports,
                                                                                            agree on something, so we just don’t do
                                                                                            it because neither of us can get it to
look at all sorts of stuff and                                  because the ports on        that point where we both like it, even

learn from it, which is great.”
                                                                the Pi are pretty crazy.    though one of us feels it would improve
                                                                JW: So solving that,        the end result.
                                                                you’ve got to have          JW: It’s difficult, especially working with
[http://access-space.org] being very         splits on the edges where the port             materials where a small change can
helpful, and we had a prototype!             connectors come out. And, if you just          make a massive difference to the end
JW: The first prototypes were hilarious      cut rings and holes, you’d just have a         result. And you don’t know it until you
though, because they were would be           stack of useless pieces basically. So          try it, which is why having the
ones all in black or whatever because it     you’ve got to structure it internally to       equipment around is nice for
was just a single sheet, but there would     make sure it bolts together.                   prototyping stuff.
only be half a lid because the sheet had     PB: This is where I think we worked
run out. Because from an A4 sheet, you       together really well. There’s one phrase I             So where does the circuit
would get about eight or nine slices on      like which is if that two people always                design come from then?
it and half of the lid.                      agree, one of them is useless. If two          JW: Well, I used to do a bit of
PB: You had to use your imagination.         people always disagree, both of them           electronics when I was 15, but then I
JW: Just to fit around the Pi, yes, the      are useless. And me and John are kind          didn’t touch it again. That was mostly
dimensions are pretty good. It’s 99mm        of a perfect middle ground. So I’d bring       from playing with the Adafruit stuff
by 66mm by up to 33mm, so it’s               the case to John and say ‘Look, look,          really, wasn’t it. You were into it (Paul),
complete 2001: A Space Odyssey 3-2-1,        you see this John, I think it’s alright,       so I got into it.
except it’s a bit thinner so it looks kind   there’s this, this and this’, and he’d say     PB: We both did electronics at school
of nice. Probably a designer’s trick.        ‘And that, that and that doesn’t work,         and when we were young, but that’s a
PB: One of the other things were the         and that’s a bit crap, and it’s leaning like   reasonably long time ago for us.
bolts, because originally they were          this’ and I was kind of ‘Yeah, I was kind      JW: We discovered electronics through
metal and the nylon just felt a lot more     of ignoring that’, but it was good that he     Adafruit Industries, SparkFun and
playful.                                     pointed it out.                                companies like that.
                                                                                            PB: The thing is, electronics is much
                                                                                            more fun than it used to be. Because it
                                                        Laser cutters cutting plywod
                                                                                            used to be just analogue electronics,
                                                               smell like burnt toast.
                                                       Significantly nicer than PCBs.       which is all about knowing the
                                                                                            equations and doing the maths. You
                                                                                            could do interesting stuff, but it took a
                                                                                            lot of groundwork.
                                                                                               Whereas these days, you can grab
                                                                                            amazing sensors, hook them up and,
                                                                                            although there’s proper ways of doing
                                                                                            things too, but you can get things to
                                                                                            work without very much effort. And we
                                                                                            learnt a lot more about the crap way of
                                                                                            doing things, which is kind of where it
                                                                                            gets a bit boring again, but actually you
                                                                                            can start getting results through very
                                                                                            quickly and easily.
                                                                                               You can spend about $30 and have
                                                                                            an accelerometer and a colour sensor
                                                                                            and a temperature sensor, and direct it



42                                                             www.linuxvoice.com
                                                                                                            PIMORONI INTERVIEW

                                                           PB: But someone can do better than us          that you can slot together into the
                                                           probably. So we learned from open              model automatically. You have to do a
                                                           source stuff, seeing how it was done.          bit of finickying, but it’s there.
                                                           John has spent probably the last eight
                                                           months to a year just basically hacking               So, as you’ve spent the last
                                                           away, making mistakes and then                        eight months or so learning the
                                                           making it better, and then improving it        machines and the electronics, does
                                                           and working out the other really               that mean we’re about to get a great
                                                           esoteric things that made it better.           new product?
                                                                                                          JW: There might be some things in the
                                                                But the scale that you’re working         works! We’re working on the final retail
                                                                 at now, seems a world away from          version of Picade at the moment.
                                                           messing with a stack of coloured               Basically, the main reason we’re doing
                                                           perspex. How do you go from Arduino            that is because we’re doing a mini and a
                                                           and temperature sensors to selling             maxi double product.
                                                           100,000 units?                                 PB: We’re delivering the last 50 odd
                                                           PB: You’ve just got to learn quickly.          units now, waiting on the last batch of
                                                           JW: We’re lucky the Pibow gave us the          LCD monitors. They go out the door,
                                                           money to buy equipment.                        then we’ve got some software stuff to
                                                                                                          do. Just support our users how we said
                                                                    But how do you go from Arduino        we would. Obviously getting the
                                                                    and temperature sensors to the        hardware out there and then updating
                                                           scale your operating at at the                 the software is kind of accepted now.
 Jonathan: “When I was a kid I used to get
                                                           moment?                                        So, yeah, we’ve just been heads-down
 told off for staying on the computer until
 2AM writing Assembler on our 386.”                        JW: Laser cutters are just a really good       getting the hardware fixed.
                                                           introduction. They’re a relatively safe
                                                           industrial machine that’s not very                     You were the first Kickstarter
              to an Arduino or a Pi and start playing      expensive either. So learning on lasers                project in the UK [with the
              around with that in software, and it’s       was great. Once we’d done that, then           Picade – a desktop Raspberry Pi
              amazing. It makes it a lot more like         things like the wave solder seemed a lot       arcade machine], so it must have
              software than traditional analogue           less scary. You know, it’s just a series of    been quite a new concept for most
              electronics. So we got into it from the      robots, or it’s just a big heater and a        people – buy now, take delivery
              easy angle, and then we’ve spent the         load of molten metal. That’s not too bad       when it’s ready. How have your
              last nine months to a year really            now. We know what to do when things            backers been?
              learning it properly.                        set on fire. We’ve got fire extinguishers.     PB: They’ve been really really
                                                           That’s all fine. So taking the first step      exceptionally patient. Because we were

“We know what to do when                                   meant that the next step seemed a lot
                                                           less scary.
                                                                                                          looking at grumblings and that’s when
                                                                                                          we failed to update them and keep them
things set on fire. We’ve got                                 We forget how daunting it was. That         in the loop. So that was totally our fault.

fire extinguishers…”                                       first time, two years ago, when I walked
                                                           into Fab Lab and I’d just seem people
                                                                                                          JW: There were literally times when,
                                                                                                          and it’s not an excuse, but we’d be sat in
                                                           doing smoke and stuff, I thought that          that workshop at the darkest times of
                 Open Source allows us to look at all      was pretty scary stuff, I need someone         that Kickstarter, both sat staring at the
              sorts of stuff and learn from it, which is   to hold my hand a bit. And Access              Kickstarter page, at the update form
              great. We released the Pibow a under         Space was the place that did that, and         and think we have nothing to say. You
              Creative Commons non-commercial              got over these first few humps. After the      know, I know what’s going on, but none
              licence for the same reason. We don’t        first hour, my complete mindset had            of it’s of help to anybody.
              want people cloning us just so they can      changed from ‘Whoa, scary fire’ to ‘Ooo,       PB: We want to please people. We don’t
              write a book, because the people who         fire!’ I can make anything now, as long        want to say ‘Yeah, this has been a
              do that aren’t people who contribute         as it’s kind of flat.                          delayed, we haven’t quite sorted this
              back to the community. But we do want                                                       out, we’ve got nothing useful to say on
              people to, if they want to use a laser             And made out of slices, which I          this and we’ve got no idea how to do it’.
              cutter they’ve got access to, make their           guess is anything pretty much.           We didn’t want to do those updates.
              own crazy extensions, make up their          JW: Yeah. Paul had Autodesk 123D,              JW: The best thing is if we’d have done
              own colours, or do whatever they want.       and they have a tool now and you can           the updates, it would have been better.
              Or if they’re using it in school, we want    do 3D stuff in there, and it will cut in       PB: But everyone’s been super
              them to be able to do that.                  slices for you. And it will cut in so you’re   supportive, and the few that have
              JW: Children at school cutting their         kind of tessellating slices. So if you’ve      grumbled have been much happier
              own cases, that’s what it was all about      got a model of a dinosaur, it’ll cut it so     when we’ve responded, and just told
              really; that was the whole point.            you can laser cut corrugated cardboard         them what’s happening.



                                                             www.linuxvoice.com                                                                  43
Email andrew@linuxvoice.com to advertise here
                                                                                                                           INTRO REVIEWS




                                              REVIEWS
                                              The latest software and hardware for your Linux box, reviewed
                                              and rated by the most experienced writers in the business


                                               On test this issue...
                                                  46                                                       48



Andrew Gregory
Has been given a box running Ye Olde Vista
from 2006. Elementary OS, we need you now.




T
           here’s an uneasy meeting of
           cultures when Free Software         Acer C720 Chromebook                                     Ubuntu 14.04
           and money intersect. At Linux       Google, thanks very much for this smart,                 ‘Pretty’ used to be Ubutu’s killer feature.
Voice, we plan to give some of out             light laptop. But please, can you stop                   Now it’s a smooth interface, a reliable
profits back to deserving projects.            following me now?                                        core, heaps of software and a silly name.
Personally, I’d like it if one of those was
the Electronic Frontier Foundation, as I
think that’s a body that really                   49                                                       50
understands the issues presented by
the changing tech landscape.
    Then there are companies like
Canonical. The work of organisations
such as Debian is there for all to take
and build on, and thats exactly what
Ubutu does. If it makes some money
out of doing this, great.
    Ubuntu/Debian is the best analogue
to Kano/Raspberry Pi that Ican come
                                               TBS Matrix                                               BitScope BS10
up with. To some, Kano is piggybacking         On the plus side, this ARM box makes a                   Generate waveforms, monitor the data
on the work of a charitable foundation,        great platform for a DIY smart TV. On the                coming out of your devices and intensify
packaging it nicely and selling itself as      downside, you need Windows to use it…                    the hardware hacking fun.
somethign that’s going to revolutionise
computing (forgetting the fact that the
revolution is happenning already, with         BOOKS AND GROUP TEST
or without tasteful orange websites).
                                               The deeper you get into Linux, the more time you’ll
    But it’s more helpful to see Kano as a
                                               find yourself at a terminal emulator. If you’re just
partner. Just as some grumbled when            using your PC for Facebook and Twitter, you won’t
Ubuntu made Debian easy to install             care, but for everyone else, a good terminal is
(how dare they!) and put a nice Gnome          essential, so we’ve tested a handful of the best
interface on it (the temerity!), the Kano      and found something there for everyone. What
                                               caught our eye in this issue’s book reviews was The
project is packaging the Raspberry Pi.
                                               Snowden Files. Snowden, by his illegal/patriotic/
It’s taking Linux out there into the wider     heroic/treasonous actions, has given us all cause to
world, and as such is helping to spread        think about our security. For that, he deserves a slap
the message. Greed is good.                    on the back; or maybe something more vigorous…
andrew@linuxvoice.com



                                                                 www.linuxvoice.com                                                                   45
     REVIEWS ACER CHROMEBOOK C720



Acer Chromebook C720
There’s never enough Google in your life. Says Google. So it’s a good job that you
(and Graham Morrison) can install something else on this great little Chromebook.

                                 N
                                            ot many of us would have thought that a
  DATA                                      laptop with little more than a web browser
  Web
                                            would be useful. How can you build things?
  http://www.acer.co.uk          Or edit anything other than text? Or put together a
  Developer                      magazine, or play games?
  Acer                             However, portable computing has become more
  Price                          divergent than we could ever have imagined when
  £199
                                 we wanted our netbooks to do everything. We’re now
                                 productive with smartphones and tablets, despite
                                 neither being capable of running a virtual machine
  SUNSPIDER 1.0.2                nor a compiler, and the typical Chromebook is an
  BENCHMARKS                     extension of that idea. It’s a low-powered laptop that
                                 boots quickly into Google’s Chrome OS, a Linux-based
  C720 with Chrome OS:           operating system that’s basically nothing more than
  411.4ms                        the Chrome browser running in fullscreen mode.
  Firefox/Ubuntu LTS:            There’s no support for applications other than the
  315ms
  Intel 2.4GHz i5 (4258U):
                                 web-based ones you can download through Chrome.
  168.2ms                        There’s no command line, and there’s very little scope
                                 for customisation.                                          There’s a USB 2 port and a USB 3 port, plus an SDCARD
                                   What you do get is online and offline access              reader – but there’s only 10GB of usable local storage.
                                 to Google’s carefully crafted suite of productivity
                                 applications; word processing, spreadsheets and             scenarios. There is a small task manager bar at the
                                 presentation creation alongside YouTube, Maps, Keep         bottom of the screen, and a launch menu on the right
                                 and anything else you install through Google’s web          for the Google apps and other apps you may install.
                                 store. It all works extremely well, and the lack of the     Configuration is through Chrome’s settings panel,
                                 usual clutter that comes with an operating system           which is augmented for Chrome OS with options to
                                 helps to keep you focused – that is, until you install      change the background image, network management,
                                 Command & Conquer. There’s very little to be said           and touchpad control – both for sensitivity and for
                                 about Chrome OS, which is a good thing for certain          reverse (labelled ‘Australian!’) scroll settings, which is a
                                                                                             mode we’re ashamed to admit we now prefer.

                                                                                             Chronos
                                                                                             Acer’s C720 is better than the average Chromebook. It
                                                                                             has a 1.4GHz Intel Celeron CPU descended from the
                                                                                             current Haswell range, which is a massive step up
                                                                                             from the ARM CPUs used by many chromebooks. It’s
                                                                                             a processor that has far more in common with the
                                                                                             CPUs found on more general-use laptops and
                                                                                             desktops, even if you can’t take advantage of its
                                                                                             particulars from Chrome OS. It does, however, help
                                                                                             Chrome OS feel extremely slick. Wireless internet
                                                                                             resumes within seconds of lifting the lid, and it deals
                                                                                             with complex websites, WebGL, HD Adobe Flash and
                                                                                             HTML playback with ease.
                                                                                                There’s very little local storage – around 9GB to
                                                                                             play with, but Google obviously wants you to use its
                                                                                             own cloud product and Chrome OS plugs directly
                                                                                             into your Drive account, as well as offering a deal
                                                                                             on 100GB cloud storage for 2 years. Google’s video
                                                                                             conferencing app, Hangouts, is a good example of
                                                                                             whatever hardware acceleration Chrome OS must
Acer’s Chromebook is surprisingly light, yet despite that it feels like it could withstand   be leveraging, as we had our best experience on the
the bumps and knocks of travelling to a thousand geek conferences.                           C720 after trying many devices, from the Nexus 5 and



46                                                                   www.linuxvoice.com
                                                                                                     ACER CHROMEBOOK C720 REVIEWS


  Running Ubuntu

  What many Linux users really want to know is how the laptop         limitation was storage and RAM, but it’s still an impressive
  performs if you install a different flavour of Linux into it. We     feat and genuinely useful for running small or server-oriented
  installed Ubuntu 14.04 with relative ease, but this was mainly      distributions. Battery performance under Ubuntu was about
  thanks to ChrUbuntu, a series of scripts that automatically         the same as Chrome OS, but there were a few hiccups that
  handle the re-partitioning and downloading of the required          would probably flummox a lot of users. The touchpad stopped
  packages. All you need to do is go through the slightly             working with a kernel upgrade, for example, and we couldn’t
  convoluted procedure of entering developer mode and making          get Wi-Fi to resume from suspend or the USB 3 port to work
  sure that every command you type looks sensible.                    without a little script tinkering.
     The main problem with running Ubuntu rather than Chrome
  OS is that a default installation requires around 4.5GB of
  space, leaving you with only a few precious GB for your own
  data if you keep Chrome OS installed alongside – which
  we’d recommend. Ubuntu ran brilliantly on the C720, and
  running a full-fat Linux distribution on the Chromebook felt
  very liberating. Overall performance, for a 1.4GHz CPU, was
  fantastic. We even installed Steam to play a few games, and
  the 3D acceleration in the CPU was more than adequate
  for many of the less demanding games in our collection.
  Unfortunately, it’s the 2GB of RAM that’s the biggest limitation.
  There’s theoretically a 4GB version of the same laptop, but
  we’ve not been able to find UK stock, but that would make life
  a lot easier for other distributions.
     Thanks to a VT-x enabled CPU, we even had VirtualBox up          Ubuntu runs brilliantly on the Chromebook – it was
  and running with a couple of Linux distributions. The biggest       possible to run OpenGL Steam games and VirtualBox.



Nexus 10 to quad-core 16GB desktops and laptops.                      larger unit, even if it does invoke the use of a small
We also had almost two weeks standby time and a                       plastic wedge. We did like the keyboard, however, and
typical battery life of 7–8 hours, depending again on                 the Chrome OS specific keys – backwards, forwards,
whether we launched Command & Conquer.                                task switching, and refresh – made us miss their
   We were disappointed by the screen, as this hasn’t                 inclusion on many post-Windows 98 keyboards.
moved with the times. It could be argued that a                          You can work and
1366x768 resolution on a 11.6” screen is acceptable                   type very effectively
when all you’re doing is running a full-screen browser,
but we’re growing increasingly used to the high DPIs
                                                                      from the Acer and
                                                                      we were able to write
                                                                                                   “The C720 Chromebook makes
found in phones and tablets. It also lacks punch                      many words for this          an extremely good low-cost
when compared with IPS displays and has a woeful
range of viewing angles. The screen, along with the
                                                                      very issue from its
                                                                      keyboard. It’s also
                                                                                                   travelling companion.”
gun-grey plastic case design helps to make the C720                   light enough (1.3kg)
feel rather more utilitarian than it should. We also wish             and small enough (19mm thick) to throw into almost
there were more options for storage. We understand                    any bag, and as long as you can offer some kind of
that the tiny SSD is there to keep costs down and                     networking connectivity, it’s the perfect travelling
perhaps to limit its use outside of Chrome OS, but                    companion for people who need to do some work.
we’d like the option of adding more. Watching a film or                  We like the C720 a lot, mainly because of its price,
managing anything more than a few albums is going                     portability and relative power. At just less than £200 in
to be impossible without a great data connection.                     the UK, it could be the perfect laptop to give to family
Fortunately, while we’ve not tried it ourselves, it looks             or friends who aren’t too confident with computers,
relatively straightforward to replace the SSD with a                  where you know the limited options of Chrome OS
                                                                      are going to be all they’ll ever need. But it also makes
                                                                      an extremely good low-cost travelling companion,
                                                                      especially if you put another Linux distro onto it. If you
                                                                      can find a compatible SSD, it makes a great machine
                                                                      for hacking about on and for throwing into a rucksack
                                                                      for LUG meetings or hacker sessions.

                                                                        LINUX VOICE VERDICT
                                                                        Excellent value for money and perfect
                                                                        for non-technical relatives, corporate
Many games are playable though the Chrome web store,                    deployment and expert Linux tinkerers.
and it’s surprising just how powerful the average web
browser has become.



                                                                        www.linuxvoice.com                                             47
     REVIEWS UBUNTU 14.04



Ubuntu 14.04
Unity and kernel tweaks make up for what is otherwise a fairly
low-key release, says Mike Saunders.

                                C
                                         anonical has its fingers in many pies at the
  DATA                                   moment. Go over to www.ubuntu.com, for
  Web
                                         instance, and the first thing you’re greeted with
  www.ubuntu.com                is a big “the cloud platform of choice” message,
  Developer                     accompanied by some blurb about OpenStack. Hover
  Canonical Ltd                 over the Download link and the first options are Cloud
  Price                         and Server – almost as if the desktop is an
  Free to download
                                afterthought. On the other hand, Canonical is still
                                pushing Unity, its mega-convergence interface that
                                will (eventually) run on your desktop, phone and TV.
                                   Ubuntu 14.04 is an LTS (Long Term Support)
                                release, which means it will receive five years of
                                updates and is designed for use in large enterprises
                                where even the smallest changes can cause massive             LibreOffice 4.2 sports a new start screen that’s more
                                disruption. So don’t expect world-shaking new                 attractive and useful than in previous releases.
                                features here: there’s no Mir or Unity 7, and by and
                                large the distro is a bunch of small (but useful)             speaking of menus: if you utterly hated the global
                                updates rather than anything revolutionary.                   menu bar, whereby all windows showed their menu
                                   For starters, it’s built on kernel 3.13 with support for   entries in the top-left of the screen, Mac OS style, you
                                TRIM. This boosts performance on machines with                can now disable this and revert to a traditional format
                                solid state drives, and given that these are becoming         via Appearance > Behaviour > Show The Menus.
                                more common, it’s a welcome improvement. If your                  It’s still a bit unusual: menus are displayed in the
                                machine has Nvidia Optimus graphics, you can now              program’s titlebar, and you have to hover over the
                                switch between the high-power Nvidia chip and Intel’s         titlebar before you can see them. You can still click
                                battery friendly alternative – although you’ll need to        and drag anywhere on the titlebar (even when the
                                restart X for the changes to take effect.                     menu is displayed) to move a window. When you
                                                                                              resize a window in Ubuntu 14.04, its contents are
                                GUI fiddlings                                                 updated automatically – there’s no yellow box like in
                                Interface-wise, much work has been done on Unity to           previous releases.
Global menu haters rejoice:
it’s now possible to have       make it more usable with HiDPI displays, such as                  Unity has taken a lot of flack over the years, but
menus back in individual        those on the Retina MacBook Pro and Chromebook                Canonical has persisted with tweaks and fixes in
applications (albeit in their   Pixel. Menus and launchers now scale better without           every release, and it’s now at the point where we’re
title bars).                    looking teensy-tiny on super high-res displays. And           pretty happy using it. Software-wise, Ubuntu 14.04
                                                                                              ships with LibreOffice 4.2.3, Firefox 29 and
                                                                                              Thunderbird 24. Rhythmbox remains the default
                                                                                              music player, while Totem is used to play videos. If
                                                                                              you’re looking at this LTS release on a server, you’ll find
                                                                                              Apache 2.4.7, MySQL/MariaDB 5.5.37, PostgreSQL
                                                                                              9.3.4 and PHP 5.5.9. And for programmers there’s
                                                                                              GCC 4.8.2, Clang 3.4, Python 3.4 and Perl 5.18.2.
                                                                                                  There’s nothing that screams “install me” in Ubuntu
                                                                                              14.04, but it’s worthy of an LTS release, and Canonical
                                                                                              hasn’t tried to rush ahead with anything that isn’t
                                                                                              ready. It’s easy to ask for more in a new distro version,
                                                                                              but when a company has to support it for five years, it
                                                                                              makes sense to take a more conservative approach.

                                                                                                LINUX VOICE VERDICT
                                                                                                Performance boosts, Unity tweaks and
                                                                                                software updates make this a solid, if
                                                                                                not hugely exciting, release.




48                                                               www.linuxvoice.com
                                                                                                                 TBS MATRIX REVIEWS



TBS Matrix
A little Linux machine for building smart TVs – Ben Everard unglues himself from
The Jeremy Kyle show long enough to take a look .

T
        he Matrix is designed as a little ARM computer
        to run Tvheadend, the TV streaming server for
        Linux. It comes with a minimalist version of
Linux, pre-loaded with the drivers for several of TBS’s
DVB receivers, as well as the software to use them
(Tvheadend and XBMC). In theory, this means it
should be really easy to create your own Linux-
powered smart TV, and record all the shows you want.
   The Matrix is well designed for this purpose. The
quad-core Freescale i.MX6 processor with 2GB of
RAM provides enough horsepower to decode the
video streams in Tvheadend and display them in
XBMC. There’s 16GB of internal storage so there’s
space to record a limited amount of TV even without
external storage, but if you want to expand it, there are
plenty of options including a SATA port and a mini
PCIe. To get the video out, there’s an HDMI port, and
for audio there are 3.5mm jack and optical ports.

More than a box
The hardware looks good, feels solidly made and              The clear plastic box feels solid to us, and provides good protection for the Matrix, while
works well. However, this alone isn’t enough to make a       showing off the circuitry to glorious effect.
Linux-powered smart TV: there’s also the software
side of things to consider. Tvheadend is a challenging       available to download. Unfortunately though, you’ll
beast at the best of times (and using it with the Matrix     need a Windows machine in order to push them onto                   DATA
and a TBS USB DVB tuner is the best of times). It            the internal eMMC storage. The reliance on Windows                  Web
takes a little prodding to get everything set up, and        will put some people off, and it’s a bit of a shame that            www.tbscards.co.uk
there’s not much documentation from TBS to help              only Ubuntu 11.10 is available as we much prefer the                Developer
you with that. The Tvheadend wiki is a good place to         12.04 LTS version.                                                  TBS Technologies
                                                                                                                                 Price
start (https://tvheadend.org/projects/tvheadend/               The Matrix is capable of running either of these
                                                                                                                                 £159.99
wiki). As long as you’re using a supported DVB               OSes without any real sluggishness. Android comes
receiver, all the necessary software will be installed. It   with the full Play store, so you’ve got access to all the
shouldn’t be beyond a reasonably technical person,           usual games. It would be nice to have the ability to
but it can take a few hours, especially if you haven’t       dual boot, because we’d really like the option of
done it before. Once it is set up, Tvheadend integrates      switching between Android for games and MatrixTV
really well with XBMC either running on the Matrix           (TBS’s custom Linux distro) for TV, but this isn’t
itself, or on a separate computer.                           possible at the moment.
   In addition to the Matrix’s own minimalist distro,          The 16GB of storage means you can run it without
there versions of Android (4.2) and Ubuntu (11.10)           any expansion should you wish, which is a big
                                                             advantage over some ARM boards. We would also
                                                             expect this storage to be a bit more durable as we’ve
                                                             had some issue with SD cards on other ARM boards.
                                                               Over all, we’d say that the TBS Matrix is good
                                                             hardware that’s let down by the software. It’s a good
                                                             option for building a PVR, but don’t expect it to be
                                                             completely straightforward.

                                                               LINUX VOICE VERDICT
                                                               A handy little ARM PC that’s most
                                                               at home as streaming and recording
                                                               broadcast video.
XBMC performance is fantastic and could make the Matrix
one of the best frontends you could buy.


                                                               www.linuxvoice.com                                                                          49
     REVIEWS BITSCOPE 10



BitScope 10
It’s an oscilloscope & analyser in a tiny case with Linux and Raspberry Pi
support, and it’s completely taken over Graham Morrison’s life.

                              W
                                           hat’s an oscilloscope? It’s a way of
  DATA                                     measuring small variations in voltage.
  Web
                                           You’ve probably seen them in their CRT lab
  bitscope.com                coat incarnations, plotting sine waves or the
  Developer                   harmonics in the words from an alien overlord. They’re
  BitScope Designs            almost essential for anything other than the most
  Price                       basic of electronic tinkering, because they enable you
  £160 (approx.)
                              to monitor changes over time, unlike a voltmeter for
                              example, which simply shows the voltage.
                                 What’s an Analyser? It’s similar to a scope, but it’s
                              designed for capturing multiple digital signals at once
                              so that you can see the relationship between them.
                              They’re useful for reverse-engineering the output
                              from old chips or decoding digital protocols from the
                              signals themselves.
                                 If you’re any kind of electronics tinkerer or hobbyist,
                              connecting chips to an Arduino or playing with I2C
                              on a Raspberry Pi, oscilloscopes and analysers are
                              essential for troubleshooting. But more importantly,
                              they’re a lot of fun.                                        It’s a little fiddly to use if you’ve got large hands, but you
                                                                                           can also attach standard probes or a differential add-on
                              Lights, action…                                              for a more professional solution.
                              BitScope’s BS10 is both an oscilloscope and an
                              analyser. It’s relatively cheap, and that’s because          the right of these are digital input pins for the logic
                              instead of the screen and controls of standalone units,      analyser, and to the right of these the waveform
                              you get a block of exposed copper pins held within a         generator output. There are lots of separate ground
                              tough extruded aluminium case and software for the           pins for each input, plus 3V and 5V outputs and
                              functionality. The BS10 is tiny – 67x64x17 mm –              general-purpose pins.
                              fitting neatly within its own handy carrying case that          A USB port on the rear powers the device when
                              also contains the small clipped wires you use to             connected to your Linux box. No drivers are required,
                              connect the pins to the things you want to measure.          as the device is driven by the FTDI support built into
The Bitscope feels
                                 The 26 pins provide a huge range of facilities, with      almost any Linux kernel, but you’ll need to install one
like a large toolbox of
functionality. Here it’s      their assignments helpfully labelled on the underside        of the applications from the comprehensive software
probing the inner poetry      of the unit. There are two inputs for the dual-channel       suite to be able to start using the unit.
of the output from an 8-bit   digital oscilloscope, labelled A and B and marked               It’s the job of the software to handle the functionality
SID chip.                     by removable green and yellow plastic jumpers. To            that you’d expect from the controls and screen of a
                                                                                           more expensive unit, and the principal application is
                                                                                           called ‘DSO’. We installed the Deb package on Mint
                                                                                           with a single click, but there are no real dependencies,
                                                                                           so you should have no issues with a different distro.
                                                                                           RPM and (32-bit binary) downloads are available, and
                                                                                           we also tried the Raspberry Pi ARM package, which
                                                                                           worked flawlessly. BitScope has blogged about the
                                                                                           amount of effort it’s put into optimising the Raspberry
                                                                                           Pi version, and it’s easy to see why. Connecting the
                                                                                           BS10 to a Raspberry Pi makes for a convenient
                                                                                           package that will work exceptionally well in an
                                                                                           educational setting, especially if you’re programming
                                                                                           the Pi to send signals being monitored by the
                                                                                           BitScope. You could even add a low-cost touchscreen
                                                                                           to create a DIY hardware oscilloscope.
                                                                                              DSO is an overwhelming application, not helped by
                                                                                           a lack of hardware-specific documentation. It’s the



50                                                            www.linuxvoice.com
                                                                                                                       BITSCOPE 10 REVIEWS


  An oscilloscope for the Raspberry Pi
  BitScope recently launched a new model, sometimes         One consequence of this, apart from the tinkering
  called the Micro and sometimes called the BS5. It’s    opportunities of programming your Raspberry Pi
  tiny a piece of hardware based on the BS10 we’ve       while you monitor the output, is that it makes a
  reviewed here, only squeezed onto a long thing PCB     cheap network-attached monitoring station. One of
  that’s covered in a resin to make it waterproof. On    the tools in the software suite is ‘BitScope Server’,
  one end is the USB connector and on the other end      which after being installed, is simply executed on
  is a 10-pin subset of what you find on the model 10,   the command line. The device needs to be plugged
  making this device cheaper (£120). The remainder       into the USB port of the server and the server tool
  of the specification seems identical, including the    running. Anyone else on the network can then run
  number of analogue and digital channels and all        DSO to connect. It works exactly as it would were
  of the functionality that’s unlocked through the       the hardware connected directly, and what surprised
  software. It’s a perfect partner for the Raspberry     us most was that you could connect to the same
  Pi and helps to explain why BitScope has spent so      device from multiple instances of DSO on different
  much time making sure its USB products work well       machines. This could be useful for lab or teaching      The RPi drivers have been enhanced to make
  with a device known to have a USB bottleneck.          scenarios, as well as remote monitoring.                best use of its limited USB bandwidth.


software that’s used for all of BitsScope’s hardware,              area, but the eight input channels were more than
and it suffers a little from trying to do too much. It can         adequate at showing what was happening across
display a single-scope channel, dual channels, the                 many pins at once, and with these inputs reportedly
logic input and a mixed combination of all of them,                working at 40 million samples per second, they should
alongside a waveform generator and a spectrum/                     be able to decode even complex protocols, especially
phase plot of the analogue inputs.                                 on older or off-the-shelf components. You can cross-
   The challenge is to enable and manage these                     trigger the digital inputs from the analogue input
features, and it all starts in the top-left. Without a             (and vice versa) and use a trigger mask to look for a
trigger, the hardware doesn’t generate data. A trigger             specific state or digital value, all of which helps make
is what captures and recognises a cycle or a frame                 best use of the limited buffer space within the DC10.
from an input waveform, enabling you to monitor                       From an educational perspective, there’s a lot
the input in real time (if you’ve got repeat enabled), or          more to the analyser
saved as a single cycle on the display. From there you
can accurately measure the inputs, either manually
                                                                   mode, as it enables
                                                                   you to see what your
                                                                                                “The BS10 packs so many
with the cursor or automatically, and adjust the                   software is actually         features into its small case, it’s
timeframes/voltages for capture and scaling. If you’ve
used an oscilloscope before, this will all be familiar
                                                                   physically doing
                                                                   and how devices
                                                                                                difficult to know where to begin.”
territory, as too will be the units and terms used                 communicate. This
throughout. But for a beginner, using DSO for the first            isn’t easy to accomplish with other methods, and
time will leave you feeling a little like how you must             can also lead into all kinds of engineering and design
feel having read through this paragraph.                           territory not easily covered by software alone. And
                                                                   while there are many, many other features we haven’t
Sine your name                                                     mentioned, perhaps the API is the most significant, as
We can only hope you’ll persevere, because there’s an              it enables you to access many of the same functions
incredible amount of power here. Far more than even                within DSO only through your own Python/C/C++
on a cheap hardware oscilloscope. The 100MHz                       code, which could have all kinds of uses for your own
bandwidth of the BS10 is enough to for real-time                   projects, tutorials and even installations.
repetitive capture, and you can adjust scales                         Oscilloscopes and logic analysers have always
separately for both channels, as well as trigger inputs            been expensive and are usually considered luxury
from the other channel. You can adjust code and                    items by most hackers. But they make the impossible
parameters as you’re monitoring the signal, and we                 possible, and they’re a lot of fun. The BS10 packs so
were able to play with all kinds of cross-modulated                many features into its small case, it’s difficult to know
audio signals and voltages in ways you just can’t                  where to begin. It has great Linux support, works well
without dedicated hardware. We did have some                       on a Raspberry Pi, and can take you from Arduino
difficulty mastering the triggers, but the waveform                tinkerer to an electronics and engineering wizard. Just
output – which includes sine, square and triangle                  don’t rely on the (non-existent) BS10 manual.
waveforms – is a good way of testing your setup
against differences in external hardware.                             LINUX VOICE VERDICT
   The other major mode in DSO is the logic analyser,
                                                                      Fantastic value for such a powerful
used for displaying binary data captured on the digital               and versatile device, suitable for so
inputs. We attached ours to a PCB connected to a                      many different users.
SID chip and used DSO to monitor the various bits of
control data going into the chips. This is a complex



                                                                     www.linuxvoice.com                                                                       51
     REVIEWS BOOKS



Raspberry Pi Assembly Language
– Raspbian Beginners
Mike Saunders don’t need no silly high level languages, fool.

G
         iven how much people love poking           The code samples are well commented,
         around with the Raspberry Pi            and there are appendices for the ASCII
         hardware, it’s surprising that there    character set and Linux kernel system calls.
aren’t more books on low-level programming       In all it’s a solid read, tackling a notoriously
for the dinky device. Indeed, books on           difficult subject with confidence and making
assembly language for any platform are hard      the reader feel like he/she is making good
to come by. This 260 page tome is available      progress through each chapter. We’d just
as both a paperback and a Kindle edition,        like to see more practical code samples,
the latter of which can be read via a web        especially early on when tricky concepts are
browser at http://read.amazon.com.               being introduced.
   Raspberry Pi Assembly Language…
introduces ARM assembly language pretty
well, although it dives straight into the
details fairly quickly: you learn about binary     LINUX VOICE VERDICT
arithmetic before you’ve even printed a line       Author Bruce Smith
of text on the screen. We tend to prefer a         Publisher BSB
                                                   ISBN 978-1492135289
more hands-on approach where you learn
                                                   Price £14.99 (print), £5.97 (Kindle)
things by doing, and not just reading. Still,
                                                   Great value, and thorny topics are explained
the chapters are well written and dense, and       well. Could do with more code snippets though.
cover using libc, disassembling C programs,                                                         Mike’s head explodes with potential when
and working with the GPIO pins.                                                                     there’s more than 640k of base memory.




Understanding Computation
Graham Morrison found this book ideal for understanding his own code.


T
         his book isn’t ideal for morning        and computers, by example. It really does
         reading before you’ve had a coffee      make you think about how you approach
         or two. Nor is it perfect for a mid-    your own projects – what statements and
afternoon browse, when your lunch is having      expressions are really doing. There’s a lot
maximum effect on your glucose levels. It’s a    about finite states and Turing machines, at
book to be read while you’re wide awake and      one point building compute units out of
engaged, because it doesn’t hold back.           Conway’s Game of Life. But this is all theory.
   Within the first 20 pages, you’re dealing     There’s nothing you’ll immediately be able to
with the semantics of expressions and            take away and use, and if you want to apply
trying to get your head around the Ruby          what you’ve learnt to your own projects,
code used to illustrate most of the ideas,       you’ll find their foundations broken, forcing
and that’s after you’ve read a page about the    yourself to start from scratch.
meaning of ‘meaning’.

Automata for the people                            LINUX VOICE VERDICT
Despite this being a book aimed at                 Author Tom Stuart
programmers “with little or no formal              Publisher O’Reilly
                                                   ISBN 978-1-449-32927-3
training in computer science,” the last time
                                                   Price £26.99
we read a book like this was while studying
                                                   An intense and complex book about the theory
computer science. This isn’t a cookbook of         many of us take completely for granted.          Almost five pages consist entirely of the
programming recipes. It’s a comprehensive                                                           characters -, >, {, [ x, y, l, m n, o, p, ], and }. If that
overview of the theories behind computing                                                           sounds like fun, you’ll love this book.



52                                                             www.linuxvoice.com
                                                                                                                         REVIEWS BOOKS


The signal and the noise                                                                              ALSO RELEASED…
Ben Everard never trusted the TV weatherman. Now he knows why.



N
           ate Silver earned his reputation
           as a forecaster by correctly
           predicting the results of the
2012 US presidential election for every
state in the US. In this book, he looks
at how people make predictions and                                                                                                     Other books
forecasts. It’s a guide to help regular                                                                                                about using
                                                                               Get it, read it,
people understand the perils and pitfalls of                                                                                           the Raspberry
                                                                               then laugh at the
trusting the forecasters.                                                                                                              Pi are also
                                                                               certainty of so-
   The reader learns why some TV                                                                                                       available.
                                                                               called experts in
weather forecasts are less accurate than                                       the news.              Raspberry Pi – A Quick Start Guide
the raw forecast data the TV stations                                                                 This is the second edition, and as things have
base their forecasts on, and how to tell if       to predict the future, and investigates             changed so much, and the Pi has become so
an economic forecast is accurate.                 whether those forecasts have been                   successful, we’d imaging there are plenty of
                                                                                                      new things to write about. This is still a book
   In an age where everyone seems to be           successful, and why.
                                                                                                      aimed at the complete beginner, however, so
trying to collect big data, and analyses it for                                                       we’ll let you know whether it succeeds.
traits about us, the world and everything           LINUX VOICE VERDICT
else, understanding the difference between          Author Nate Silver
signal and noise, and how they affect our           PublisherPenguin
ability to correctly understand the world           ISBN 978-0-141-97565-8
                                                    Price £8.99
(and therefore predict what will happen),
                                                    Esential reading for anyone who has ever
is now more important than ever. This               wondered about why we trust experts.
book is important because it coolly looks                                                                                              The only
at a number of areas where data is used                                                                                                things we’ve
                                                                                                                                       ever disliked
                                                                                                                                       about this
                                                                                                                                       series are the

The Snowden Files                                                                                                                      big heads on
                                                                                                                                       the cover.

Ben Everard wonders if James Garner will star in the TV series.                                       Head First JavaScript Programming
                                                                                                      There have been a few misses, but mostly,



F
                                                                                                      O’Reilly’s Head First books are brilliant. They
          ew people actually know that much                                                           make technical subjects fun and immediate in
          about him. When he appeared in                                                              a visual web 2.0 way that may be getting a
          the news most frequently, he had                                                            little tiresome, but not quite yet. JavaScript is
risen to fame so quickly that reporters                                                               the perfect subject matter for this style too.
struggled to find details of who he was or
what he did. At the same time, information
about his whereabouts and travels was
often kept guarded.                                                           Edward Snowden
   Luke Harding obviously has access                                          still faces a life of
to some of the people involved in the                                         uncertainty.
reporting of the case, and The Snowden
Files details exactly what happened as            written and engaging. In many places it                                              Java – who’d
Edward Snowden went from high-school              reads like a spy story, which in a slightly                                          have thought
dropout to NSA contractor to the biggest          unusual way, it is.                                                                  it would still
whistleblower in history to man-on-the-run.                                                                                            be kicking
                                                                                                                                       around ?
   It is, perhaps, a bit mis-named because          LINUX VOICE VERDICT
the main focus of the book is not the files         Author Luke Harding                               Java 8 Pocket Guide
he acquired from the NSA, but the man               Publisher Faber & Faber                           If our Android coding tutorial has got you
himself.                                            ISBN 978-1-78335-035-3                            wondering about Java again, then this small
                                                    Price £12.99                                      reference book contains quick access to
   The book paints a picture of Snowden
that’s broadly in line with how Snowden             We found the book mesmerising, and we’re          details like naming conventions, types,
                                                    sure most people interested in the events         statement and blocks. It’s perfect if you’ve
has been portrayed in most unbiased                 will do too.                                      used Java in the past, or use another OOP
media, so don’t expect to find any                                                                    language and need a quick reference.
shocking details, but the story is well



                                                                 www.linuxvoice.com                                                                       53
     GROUP TEST TERMINAL EMULATORS




      TERMINAL
     EMULATORS
                 GROUP TEST
                 Marco Fioretti opened more shells than you want to know
                 to help you discover what terminal emulator is right for you.



 On Test                                             Terminal emulators
                                                     Relics of a long-gone era, or effective tools?
 Eterm

                                                     T
                       URL www.eterm.org                       erminal emulators are              because they are like baby
                       Version 0.9.6                           rectangles on a screen that        gestures: whatever you want, be it a
                       Licence BSD                             let users communicate with         document on your drive or a movie
                       The original emulator of      the local computer, or a remote one,         from the internet, you point your
                       the Enlightenment window      much like in a generic chat session:         finger at it, just like you did to get
                       manager: is it still up to    you type some commands as text,              toys when you were a toddler.
                       the task?                                                                     The obvious problem is that
                                                     and the computer answers by

 Guake                                               displaying other text, or launching
                                                     another program. All GNU/Linux
                                                                                                  gesture-based interaction is the
                                                                                                  most effective way to go in many
                       URL www.guake.org             distributions include, or let you            cases (think drawing software) but
                       Version 0.4.4
                                                     install very easily, a range of              not in all ones. The reason is that
                       Licence GPLv2+
                       An “on-demand”                terminal emulators.                          you can only “work” with what was
                       emulator that hides in           Such interfaces can, however,             already visible on screen. Learning
                       your system dock and          look boring or intimidating,                 to talk is a daunting, apparently
                       only opens when called.       especially for people who always             pointless task for babies, but there
                                                     used touchscreen or mouse-based              is a reason why all those who can,
 Konsole                                             computing environments. Do they              eventually do it: it’s the only way to
                       URL                           still make sense in 2014?                    explain exactly what you want, or to
                       http://konsole.kde.org           The answer of this Group Test is          provide a complex description of a
                       Version 4.12.4                a resounding yes. It does make               problem. Terminal emulators
                       Licence GPLv2 and GFDL        sense to know terminal emulators,            provide access to the same
                       The official terminal         and the available choices in this            communication system used
                       emulator for the KDE          field, for a very simple reason:             among grownup humans: speech.
                       desktop environment.                                                       That’s why we’re delighted to
                                                     mouse or touchscreen interfaces
                                                     are gratifying and easy to learn             present you with five great choices.
 Terminator
                       URL http://
                       gnometerminator.              “Graphical interfaces are easy to learn
                                                     because they are like baby gestures.”
                       blogspot.com/p/
                       introduction.html
                       Version 0.97
                       Licence GPLv2
                       Ascetic power.                  THE CRUCIAL CRITERIA
                                                       We wanted to show you how many                 This, and the fact that we only have
 Terminology                                           different choices of terminal emulators    space for five products, are the only
                       URL                             you have under Linux, including some you   reasons why we left a good emulator
                                                       may have never discovered otherwise. We    like Gnome-terminal out. It’s included
                       www.enlightenment.org
                                                       also wanted to give you choices as easy    in the basic versions of (at least)
                       Version 0.4.0
                                                       as possible to install and try.            Debian, Ubuntu, Fedora and all their
                       Licence BSD                        Therefore, we looked for emulators      cousins. Besides, it has all the main
                       Made for Enlightenment,         that are rich in features and easy to      features discussed in these pages, and
                       it conceals a hidden            install, normally available as binary      is somewhat hidden in one of them. In
                       trove of features.              packages, but that are not the default     other words, you really have no excuses
                                                       ones in the most popular Linux distros.    to not try it at least once.




54                                               www.linuxvoice.com
                                                                                         TERMINAL EMULATORS GROUP TEST



Multitasking                                                                                        Installation and
Is it easy to manage many terminals simultaneously?                                                 configuration
                                                                                                    Is it complicated to get these
                                                                                                    emulators up and running?


                                                                                                    D
                                                                                                              ue to the criteria with which they were
                                                                                                              chosen, none of the emulators
                                                                                                              considered for this Group Test should
                                                                                                    give you any trouble. Unless you use some
                                                                                                    little-known distribution, you should easily find
                                                                                                    binary packages with the software manager of
                                                                                                    your GNU/Linux system. In any case, here are
                                                                                                    a pair of issues that are worth mentioning.
                                                                                                        The first is that, while emulators are small
                                                                                                    programs, they may consume much more
                                                                                                    disk space than you expected, especially if you
                                                                                                    install them as packages. Konsole, for
                                                                                                    example, will bring with itself most of KDE,
                                                                                                    even if you had no plan to ever use any other
                                                                                                    part of that desktop. Guake and Terminator
                                                                                                    may do the same with parts of Gnome.
                                                                                                        Eterm and Terminology are both products of
Konsole, Terminator and Terminology can shuffle terminals in more ways than you’ll ever need.       the Enlightenment window manager
                                                                                                    community. They have the same “problem” as



B
        y now, you know that terminal             right-click in any sub-window and select          the other three – their dependency on
        emulators enable interaction with         “New”, to open a new terminal exactly over        Enlightenment libraries and other
        computers more or less like               the already existing one. Moving from one         components. However, they will generally
written speech. As it happens in other            terminal of the same sub-window to                consume less memory, and much less space,
realms of life, it is often necessary to carry    another is easy to do but hard to spot.           than their competitors.
on, or at least keep open, several                When you create more terminals in one                 A final word of advice: depending on your
conversations in parallel. Four of our            sub-window, the emulator activates a very         disto, you may find that some minor feature of
emulators make it very easy to do so. The         small terminal switcher in its upper-right        an emulator doesn’t work as documented
exception is Eterm, at least in the version       corner: the default colour scheme of              (sound effects, background configuration and
tested on Fedora 20. Guake has tabs, like         Terminator makes it hard to see, but you          similar) if you run it under a different window
Konsole, but with fewer settings.                 can just click there to move from terminal        manager or desktop environment than that for
   The tabs in Konsole work very much like        to terminal.                                      which it was primarily designed.
those of Firefox and other web browsers.             Terminator is so flexible from this point
You can right-click on the name of each           of view that if you find yourself using all its
tab to close it, rename it or move it to a        functions together… it probably means
separate window. We also like the                 you’re working too much. First, there are
possibility to automatically assign a             both tabs and multiple levels of vertical or
different colour to each new tab.                 horizontal window splitting. Second, there
   A dedicated panel in the Konsole               is another feature that is even cooler, even
configuration interface (Settings >               if many people will find no use for it. The
Configure > TabBar) lets you hide the Tab         coloured rectangle in the left-hand corner
Bar, put it on top or bottom of the window        of the Terminator status bar opens a
and place in it dedicated buttons to add or       menu in which you can define groups of            The software managers of all the main Linux
close tabs. Our preferred function of that        terminals, so that everything you type in         distros include all the terminal tested here.
panel, however, is the one that sets where        one of them is broadcast to all the others.
all new tabs should appear, that is, at the                                                          VERDICT
end of the bar, or next to the currently           VERDICT                                           Eterm
                                                                                                     Guake
active tab.                                        Eterm                                             Konsole
                                                   Guake                                             Terminator
   Terminology can split its own window            Konsole                                           Terminology
                                                   Terminator
and each sub-window both vertically and            Terminology
horizontally. In addition to that, you can



                                                                 www.linuxvoice.com                                                                 55
     GROUP TEST TERMINAL EMULATORS



Customisation                                         General behaviour
What makes a good terminal?                           Can you live with them day-to-day?


                                                      A
                                                                large part of what we think of as    settings of your distribution, as well as the



F
         or us, a good terminal must have at                    the user interface of a terminal     configuration file of your shell, to make
         least these characteristics:                           emulator is actually the result of   everything look and work just as you like:
         configurable keybindings for all the         its interaction with other, more or less       prompts, history, escape sequences, audio
main operations, ways to define custom                independent programs; specifically the         or visual alarm bells are just the main
commands, and support for automation. The             individual commands that we run inside it.     examples of what we mean. Keep this in
latter feature consists of being able to              No matter how you tweak the emulator           mind, when thinking to how to use each of
memorise and load, automatically or on user           itself, you may have to adjust the locale      these programs.
demand, complex combinations of many
terminals, each with its own settings.
   Konsole and Terminator do practically              Eterm
everything we just mentioned, through                 Eterm was conceived as the “Enlightened        redesigned for 2014, and we mean this as
assorted plugins and support for user-defined         terminal emulator for the X Window             a compliment. You can customise every
profiles. A profile is a set of configuration         System”. It seems well suited both for         detail of how Eterm looks and works, and
parameters for a single terminal, which is            expert users who want a lean and mean          tune its memory consumption with
given a name (eg “root profile” or “web server        terminal, and for beginners looking for        command line switches. If you have the
profile”) so that it can be loaded automatically,     something fast, but with an unusual (shall     patience, that is: we hope we’re wrong, but
when the emulator is launched, or on demand.          we say “vintage”?) look and feel. Working      the default looks and strain on the eyes of
   The point of profiles is to make your              in Eterm feels like running an Xterm (the      Eterm doesn’t seem to encourage
terminal emulator do as much housekeeping             main Unix terminal emulator of the 80s)        newbies, which is a shame.
as possible for you, by running predefined
commands every time you load them. Let’s
assume that you always need to have three
terminals open at all times: one for checking
email, one for working remotely on your web
server and one to execute all other commands
and generic scripts at the prompt. You can
                                                                                                                        Eterm has a pleasant
define an email profile that, all by itself, before                                                                     vintage look, and enough
you even see the window, starts the Mutt                                                                                visual parameters to set
email client; a web one, which automatically                                                                            that it takes time to find
connects via SSH to your server; and a generic                                                                          the best combination.
profile for everything else. Each profile may
also load a completely different configuration.
   Konsole and Terminator can also split their        Guake
window in any combination of sub-windows.             The other emulators of this Group Test all     Guake sits in your system dock and
Terminator makes it quite easy to save these          aim to make long terminal sessions as          appears (or disappears) in a flash
“layouts”, with different profiles for each           efficient and comfortable as possible.         whenever you press the F12 key. By
terminal. All its keybindings can be                  Guake, instead, is “a drop-down terminal       default, due to this design choice, Guake is
reconfigured, or individually disabled.               for Gnome”, designed to be invisible,          configured to “Stay on Top”, but you can
   The other emulators have fewer features,           except when you need a prompt quickly,         disable this behaviour in the General tab of
but still enough that it is impossible to mention     but just for a few minutes. That’s probably    its Properties window. A KDE version of
them all. Eterm has search and run boxes, plus        why you can set the height of the Guake        the same emulator is available at
many scrolling options. Terminology provides          window, but not its width. Once started,       http://yakuake.kde.org.
configurable “helpers” – applications to open
all kinds of files, showing them inline if
possible. Besides tabs, in Guake you can easily
set the default interpreter for your terminals to
bash, nologin and several versions of Python.

 VERDICT
 Eterm
 Guake
 Konsole                                                                                                            Setting an image background
 Terminator
 Terminology                                                                                                        in all the tabs of Guake is a
                                                                                                                    snap. Whether it’s worth it is
                                                                                                                    another question…



56                                                           www.linuxvoice.com
                                                                                      TERMINAL EMULATORS GROUP TEST

Konsole
It’s an obvious thing to say, but we’re going
to say it anyway: Konsole works and feels
just like the rest of KDE. If you have the
                                                   However, even if Konsole were the only
                                                KDE component you’ll ever launch in your
                                                computer, it would still work and present
                                                                                                Flexibility
time and patience to try all its options, and   itself in the most discreet way possible.       Bend them to your will!
configure them to your taste, you will find     Clean menus, bookmarks, readable fonts



                                                                                                T
yourself with a nice, very powerful and still   out of the box… Konsole has many                         erminal emulators can do lots of
unobtrusive tool.                               features you will like.                                  things that you may not expect of
                                                                                                         them, or be used in environments
                                                                                                different from your everyday GNU/Linux
                                                                                                distribution. By definition, this is a sector in
                                                                                                which one is forced to compare apples with
                                                                                                oranges, so please don’t take the
                                                                                                corresponding rating too seriously.
                                                              The default looks, fonts and
                                                              other setting of Konsole may         Eterm is at its best inside the Enlightenment
                                                              seem dull, but they are well      window manager. Its “auto mode”, for example,
                                                              thought-out and don’t get in      gets the images to use for scrollbars directly
                                                              the way.                          from Enlightenment, and lets the Window
                                                                                                manager draw them. At the same time, if you
                                                                                                compile and install Escreen code yourself (see
Terminator                                                                                      the Eterm man page for details), Eterm will get
The Terminator home page greets visitors        arrange terminals inside Terminator are         something that is trickier to achieve in its
with the half pompous, half cryptic slogan      the most flexible of the bunch. And if you      competitors: an interface between the
“The robot future of terminals”. After just a   stop liking a layout, you can just drag and     emulator itself and the screen program, to
few hours of usage, you see why for             drop each sub-window as you please. The         manage multiple (local or remote) terminal
yourself. Technically speaking, this            Group Broadcast feature does look a bit         sessions via Eterm buttons and menus.
program is a tool to host multiple Gnome        like those totally unrealistic Hollywood           Being part of Enlightenment can take Eterm
terminals in one window, as efficiently as      mockups of computer interfaces, but             to places that may be much more difficult to
possible. The ways in which you can             nobody’s forcing you to use it.                 reach for the other emulators. Enlightenment
                                                                                                is much more popular for embedded Linux
                                                                                                applications than the environments for which
                                                                                                the other terminals were designed (with the
                                                                                                possible exception of Konsole, if used inside
                                                                                                Plasma Active systems). Of course, what we
                                                                                                just said for Eterm also applies to Terminology,
                                                              Besides organising terminals
                                                              in tabs and sub-windows,          which besides X11 also works in Wayland and
                                                              Terminator makes it easy to       in the basic Linux framebuffer. Other features
                                                              control whole groups of them,     of Terminology that, in certain scenarios, may
                                                              in broadcast mode.                be useful to both beginners and power users
                                                                                                are its ability to display the content of links
                                                                                                inline and to smoothly reflow text when the
Terminology                                                                                     window is resized.
Terminology can use video clips as              usual ones, but also quite efficient and           Other users prefer the Konsole functions to
background, has a themable visual bell          interesting. Besides looks, you get             print the content of the window as it was
(the window flash when it wants to tell you     splittable tabs and selection of rectangular    before the execution of the last command, or
something), and it can display some             blocks of texts (a godsend for bug              to save it in plain text or HTML format.
graphics formats inline.                        reporting and text processing). Email              Speaking of flexibility, here is one last thing
   Every minute spent using this terminal       addresses, URLs and file paths are              you may like to know: in KDE, and likely in
reminds you that there is a whole desktop       detected automatically, so copying and          other environments as well, you can tell any
environment pretty different from the           pasting them anywhere is a snap.                independent window to become a tab of
                                                                                                another window. This makes it possible to run
                                                                                                all your favourite terminals (each with its own
                                                                                                tabs, sub-windows, etc) in just one window.

                                                                                                 VERDICT
                                                                                                 Eterm
                                                              No menus, no buttons,              Guake
                                                              nothing in sight: Terminology      Konsole
                                                                                                 Terminator
                                                              couldn’t look more spartan,        Terminology
                                                              but its snappy control panel is
                                                              just one click away.



                                                              www.linuxvoice.com                                                              57
     GROUP TEST TERMINAL EMULATORS



Looks
Which of these applications is the tallest man in Liliput?


A
          ll the emulators we tested can    only for your Eterm instances, an image
          have graphic, more or less        as big as your desktop, but different
          transparent backgrounds. Now,     from the wallpaper. The result, as the
if we didn’t think that looks matter, we    Eterm man page puts it, is “especially
wouldn’t have devoted a big box to          keen” if you open several Eterms with
them, so do yourself a favour and don’t     the same viewport.
waste much time with fancy
backgrounds. Back in the 90s, when          Why be boring?
KDE and GNOME were born, such               The Terminology mantra is “Why
backgrounds were cool, maybe even           Should Terminals be boring?” In our
necessary, to prove that Linux was not      opinion, the configuration panels of         Testing fonts, backgrounds and themes in Terminology is
necessarily dull. Today, they just make     Terminology are the best-looking of the      so easy and fun that you may forget to do any work.
text harder to read.                        group. Setting fonts and font sizes, a
   The Eterm defaults are the worst         critical feature, is easy and fun, even if                  Terminator, even the thickness of the
from this point of view. Every new          there are many options. Terminology                         border between terminals in the same
Eterm pops up with a different              also has a cursor that flashes along as                     window is configurable.
background image, which often seems         you type, but it manages to do it                             Guake has all the important visual
chosen just to assault your eyes.           without being irritating.                                   configuration options, and it offers the
Besides, the Eterm menus only give             There is not much to say about the                       ability to make scrolling happen either
three choices of font size (normal,         other competitors, but don’t take that                      when text output has filled the screen,
smaller, bigger) and too many choices       as a critique. The graphical                                or only when you hit some key (which is
for brightness, contrast and gamma.         configuration interfaces of Terminator                      the default).
Luckily, you can force Eterm to always      and Konsole seem to us the best
look exactly as you want with               compromise between ease of use and                            VERDICT
command line switches.                      number of options. Both emulators let                         Eterm
                                                                                                          Guake
   That said, if you do like image          you zoom in or out, that is, set different                    Konsole
                                                                                                          Terminator
backgrounds for text, try the Eterm         font size in each tab or sub-window, by                       Terminology
“viewport” mode: it sets as background,     just pressing Ctrl+ or Ctrl-. In




Documentation
What should I know, and where can I find it?


D
         ocumentation is a tricky issue,    man page. At the opposite end of the
         as far as terminal emulators are   scale we have Konsole: in addition to a
         concerned. That’s why it           handy “What’s this?” function, one click
deserves its own section in these           in its Help menu opens the Konsole
pages. The issue we are talking about is    section of the KDE handbook. There
related to the very nature of terminal      you’ll find almost everything you need       The Konsole handbook, reachable through the help menu,
emulators. The right choice of terminal     to know about this terminal in simple        is clear and complete.
make a big difference in how productive     language, including an introduction to
you can be. However, by definition, any     how to make scripts interact with                           reading, sources of documentation for
program of this kind is just like a         Konsole via Dbus.                                           Eterm are its FAQ and Technical
connector to the tools that hold the real      Terminator only has two man pages:                       Reference at www.eterm.org. The latter
power: shells and other command             one for the configuration options (man                      document is the only one that explains
interpreters. In other words, how much      terminator_config) and one for the                          how to configure settings such as
you can do with an emulator depends         command line switches. The interface,                       escape sequences.
first and foremost from how familiar        however, is simple enough that this is
you are with those other programs.          seldom a problem.                                             VERDICT
   This said, let’s look at what the           A click on the question mark in the                        Eterm
                                                                                                          Guake
programs of this group test offer when      bar of an Eterm window opens the man                          Konsole
                                                                                                          Terminator
it comes to documentation. Guake            page of this terminal, in another Eterm                       Terminology
seems to have nothing but a very terse      window. Other useful, if not mandatory



58                                                           www.linuxvoice.com
                                                                                       TERMINAL EMULATORS GROUP TEST




  OUR VERDICT
Terminator
I
     f you use the command line           old computers, where every CPU
     just to launch an occasional         cycle counts. In all other cases, it      Terminator: easy configuration interface, endless possibilities.
     script a few times a week,           has little that you can’t find in the
practically any terminal emulator
would do. As a matter of fact, you
                                          others, in a more usable package.
                                            Terminology is perfect for people
                                                                                     1st Terminator
                                                                                     Licence GPLv2 Version 0.97
should probably attach that script        who want many terminals but get
to an icon or menu entry of your          bored by always looking at the             http://gnometerminator.blogspot.com/p/introduction.html
desktop, rather than firing up a          same stuff: its configuration panel        Terminator is fast, full of features, has the most flexible layouts
terminal just to type its name.           makes experimenting with colours,          and is easy to configure. It also looks good without any fiddling.
   In all other cases, which on Linux     fonts and graphic styles so easy
means “basically always, if you           that it may kill your productivity.        2nd Konsole
want to fully exploit the power of          Konsole (as you’d expect from a          Licence GPLv2 and GFDL Version 4.12.4
this operating system” things are         KDE application) demands some
much different.                           work to make it behave just as             http://konsole.kde.org/
   Having several terminals               you’d like, but it is powerful and well    The official KDE terminal, perfectly integrated with that desktop,
                                                                                     but great even on its own. Not flashy, but solid and complete.

“Terminator is not a fashion icon, but is                                            3rd Terminology
good looking, fast, and above all flexible.”                                         Licence BSD Version 0.4.0

regularly open, each for one              pre-configured enough that most            www.enlightenment.org
                                                                                     If you need power, but can’t do without an original look and feel,
different task (eg system                 people will be happy with it by just
                                                                                     Terminology makes it easy to get just what you want.
monitoring, file searches, web            opening more tabs.
server administration) is not                Terminator is not a fashion icon,
something that only top-notch IT          but is good looking, at least as fast      4th Eterm
professionals must do – it’s for          as the others (on medium-powered           Licence BSD Version 0.9.6
everyone. That’s where a terminal         computers, at least) and, above all,
                                                                                     www.eterm.org
emulator that can bundle,                 flexible! If the terminal emulator of
                                                                                     Not needed in Enlightenment, now that we have Terminology,
preconfigure and run all those            your dreams, the one that would            but it’s still powerful and fast.
shells, makes a big difference.           make you work happy, looks like a
   If you are in the “occasional          patchwork quilt, be assured that
script” category, go for Guake:           Terminator can look like that, with
                                                                                     5th Guake
besides being made to order for           relatively little effort. This, plus       Licence GPLv2+ Version 0.4.4
that use case, it looks good and still    custom commands and other                  www.guake.org
has tabs and other useful features.       things we already mentioned, make          Guake came last simply because it is more specialised than the
   Eterm may be the best option           of Terminator the winner of this           others, but is a great tool all the same.
when you need lots of terminals on        Group Test




  YOU MAY ALSO WISH TO TRY…
  The terminals presented here are, in our             There are many more projects that, while        Google Chrome. Finally, we’re keeeping an
  opinion, among the most interesting ones          not really ready for prime time yet, may make      eye on Final Term. This aims to redefine the
  that are available today on Linux. This doesn’t   things much more interesting in a few              nature and task of a terminal emulator, with
  mean you should ignore the others, of course.     months. Some are terminals that run inside         features like smart command completion,
  Use this Group Test as a guide to how to          any browser, like Anyterm, AjaxTerm or Shell       and above all semantic text menus, which
  evaluate them, instead. Among traditional         In A Box. Then there is TermKit, which is a        recognise what the piece of terminal output
  terminals, for example, you may try               desktop application, but running inside the        you have selected is, and only display actions
  lightweight apps like lxterminal or wterm.        same WebKit rendering engine used by               compatible with it. Stay tuned!




                                                                www.linuxvoice.com                                                                         59
     SUBSCRIBE




SUBSCRIBE              shop.linuxvoice.com
                                                                        Introducing Linux Voice,
                                                                        the magazine that:
                                                                          Gives 50% of its profits
                                                                        back to Free Software
                                                                          Licenses its content
                                                                        CC-BY-SA within 9 months

                                                                        12-month subs prices
                                                                        UK – £55
                                                                        Europe – £85
                                                                        US/Canada – £95
                                                                        ROW – £99

                                                                        7-month subs prices                               DIGITAL
                                                                        UK – £38                                          SUBSCRIPTION
                                                                        Europe – £53
                                                                        US/Canada – £57
                                                                                                                          ONLY £38
                                                                        ROW – £60


         Get 114 pages                                     Access our                                         Save money on
          of tutorials,                                  rapidly growing                                       the shop price
      features, interviews                            back-issues archive                                    and get each issue
          and reviews                                 – all DRM-free and                                        delivered to
          every month                                  ready to download                                         your door

               Payment is in Pounds Sterling. 12-month subscribers will receive 12 issues of Linux Voice a year. 7-month
            subscribers will receive 7 issue of Linux Voice. If you are dissatisfied in any way you can write to us to cancel your
                      subscription at subscriptions@linuxvoice.com and we will refund you for all unmailed issues.



64                                                         www.linuxvoice.com
                                                                                                                                          NEXT MONTH



                                 NEXT MONTH IN



                                                                                          EVEN MORE AWESOME!
ON SALE
THURSDAY                                                                                                                                     Old Code
26 JUNE                                                                                                                                      In the olden days the
                                                                                                                                             computer was used




             HACK
                                                                                                                                             only by science and
                                                                                                                                             match students –
                                                                                                                                             but then along came
                                                                                                                                             John Kemeny and
                                                                                                                                             Thomas Kurtz’s




            THE WEB
                                                                                                                                             masterpiece: BASIC.

                                                                                                                                             Pibrella
                                                                                                                                             Program a simple
                                                                                                                                             flashing board to
                                                                                                                                             obey your command,
                                                                                                                                             then use your skills
                                                                                                                                             to flash up rude
                                                                                                                                             messages on
                                                                                                                                             Blackpool’s famed
                                                                                                                                             Illuminations.

                                                                                                                                             Nethack

HACK CRACK THE WEB                                                                                                                           Once you’ve
                                                                                                                                             discovered this
                                                                                                                                             cultish, addictive
Feel the sick glow of the CRT screen on your                                                                                                 way of life and never
face. Slurp your Diet Coke. Text scrolls by:                                                                                                 look at an
                                                                                                                                             ampersand in the
“ACCESS GRANTED”. You have hacked into                                                                                                       same way again.
the Pentagon, and Guantánamo awaits…


       LINUX VOICE IS BROUGHT TO YOU BY
Editor Graham Morrison           Editorial consultant Nick Veitch                through the use of advice in this magazine.   Copyright Linux is a trademark of Linus
graham@linuxvoice.com            nick@linuxvoice.com                             Experiment with Linux at your own risk!       Torvalds, and is used with permission.
Deputy editor Andrew Gregory                                                     Distributed by Marketforce (UK) Ltd, Blue     Anything in this magazine may not be
andrew@linuxvoice.com            All code printed in this magazine is licensed   Fin Building, 110 Southwark Street, London,   reproduced without permission of the
Technical editor Ben Everard     under the GNU GPLv3                             SE1 0SU                                       editor, until February 2015 when all content
ben@linuxvoice.com                                                               Tel: +44 (0) 20 3148 3300                     (including images) is re-licensed CC-BY-SA.
Editor at large Mike Saunders    Printed in the UK by                                                                          ©Linux Voice Ltd 2014
mike@linuxvoice.com              Acorn Web Offset Ltd                            Circulation Marketing by Intermedia Brand     ISSN 2054-3778
Creative director Stacey Black                                                   Marketing Ltd, registered office North Quay
stacey@linuxvoice.com            Disclaimer We accept no liability for any       House, Sutton Harbour, Plymouth PL4 0RA       Subscribe: shop.linuxvoice.com
                                 loss of data or damage to your hardware         Tel: 01737 852166                             subscriptions@linuxvoice.com

                                                                    www.linuxvoice.com
     CLOUDADMIN




CLOUDADMIN
System administration technologies brought to you from the coalface of Linux.

                          Jonathan Roberts
                          dropped out of an MA
                                                   Logs
                          in Theology to work
                          with Linux. A Fedora
                                                   Get started with your distro’s built-in log management tools.
                          advocate and systems



                                                   A
                          administrator, we hear
                                                            fter three months looking at exciting          The request itself.
                          his calming tones
                          whenever we’re stuck              new technologies, this issue I want            The status code (the result of the request).
                          with something hard.              to step back and look at something             How many bytes were returned to the
                                                   far less glamorous: logging. Often an                   clients.
 I’ve said it before and I’ll say it again: as a   afterthought to developers and system                   It only takes a little bit of imagination to
 system administrator, all I want is a quiet       administrators alike, collecting, monitoring         see how storing all this information can be
 life. I want to be able to walk out of work,
                                                   and using logs is one of the best things you         useful. You can map IP addresses to
 on call, and know that I’m not going to be
                                                   can do for your infrastructure. Let’s start          geographic location, letting you know where
 woken in the night. Unfortunately, that’s
 just not going to happen. Accidents               with the basics – what are logs and why              in the world your site’s visitors are coming
 happen and hardware fails. It’s a fact of         should you care?                                     from; you can see which web pages are
 life, and a perfectly quiet life is not              Logs are how non-interactive components           most popular; you can even see if any pages
 realistic. If not a quiet life, then, we ought    of your system communicate with you, the             experience more errors than others and at
 at least to aim for an anxiety free life.         user. Each time an action takes place a note         what times those errors occur.
    Although it passed me by at the time, I        will get written to a file (the ‘log’) somewhere         Other logs on your system can help you
 now see that 31 March was World Backup            on your hard drive. Most logs contain one            keep things secure, too. For instance, on
 Day – a friendly reminder that we should          entry per line in the file. In the case of a web      Red Hat-based systems, you can look in the
 all be backing up our stuff. As a system          server, for example, an entry will probably be       /var/log/secure file and see a record of who
 administrator, just knowing that you’re
                                                   in the Common Log Format:                            logged in and when. You will also be able to
 backing up all your important data,
                                                   192.168.79.2 - - [27/Apr/2014:13:55:36 +0000] “GET   see failed login attempts, commands
 checking that the backups are actually
 running and that you can restore them in          /lv.html HTTP/1.1” 200 2326                          executed with sudo and more besides. In the
 case of disaster, will go a long way to             Here, you see:                                     event of a security incident, your logs can be
 reducing your anxiety. In an age of                 The IP address of the user who visited the         an invaluable source of information to help
 configuration management, Amazon Web                 website.                                           you understand how it happened, what
 Services and the like, you should go one            (Two empty fields not logged in this                damage was done, and how to stop it
 step further: you ought to know that you            example, represented by dashes).                   happening again in the future.
 can quickly, accurately and automatically           The date time and timezone when the                   Now you know what logs are and why you
 rebuild every single one of your systems.           server finished dealing with the request.           should care about them, let’s look at how you

 Destroy to rebuild
 Ideally, this means taking advantage of all
 that redundancy you’ve built in to your
 platform. Running a web farm behind a
 load balancer? When you release new
 software, don’t just push it out to the
 existing servers; build new servers and
 destroy the old ones. Running a database
 cluster and doing an OS upgrade? Don’t
 just do a yum update and reboot; rebuild
 the server, restore your data and destroy
 the old one.
    Having done this a thousand times,
 knowing that you can rebuild your systems
 and restore critical data to them will cut
 out so much anxiety from your life as a
 system administrator.
                                                   RSyslog comes with a comprehensive set of documentation if you install the rsyslog-doc package.
                                                   You’ll find it installed in /usr/share/doc/rsyslog-docs/.


62                                                              www.linuxvoice.com
                                                                                                                              CLOUDADMIN


manage them. While not quite universal,
you’ll find many of your system’s logs (on
Red Hat based systems, at least) are
managed by a program called RSyslog – the
‘rocket-fast system for log processing’. It
implements the syslog standard, enabling
you to store logs locally or ship them
remotely and store them in different formats.

RSyslog
In syslog-based systems, each message
gets categorised with a facility and a priority.
The facility describes which subsystem
generated the messages, and can be one of
auth, authpriv, cron, daemon, kern, lpr, mail,
news, syslog, user, uucp, and local0 through       /var/log/messages is overwhelming at first, but it contains a treasure trove of information. Next
local7. The local0–7 facilities are used for       time you’re trying to figure out why something doesn’t work, make /var/log your first stop.
custom applications and reserved for the
user to specify.                                   written (backup scripts etc), then you can           $ModLoad imudp
   The priority describes whether the              use the logger command. Use is simple:               $UDPServerRun 514
message is just informational or whether it        logger -p local2.info “Database backup started.”     ...
relates to one of various error states.              This will send your defined message to              $template web,”/var/log/remote/%fromhost%/%year
Available priorities are debug, info, notice,      syslog with the facility local2 and priority         %/%month%/%day%/error.log”
warning, err, crit, alert, and emerg.              info. You can then configure where such               ...
   The syslog daemon your computer is              messages end up by adding a new entry to             local7.error          ?web
running will be configured to store                 the /etc/rsyslog.conf file.                              This snippet instructs RSyslog to load the
messages of different facility and priority          What’s great about using logger is that            imudp module, which lets it receive logs via
combinations in different locations. On a          you don’t have to worry about formatting             the UDP protocol, and instructs it to listen on
Red Hat-based system, you can see what             your message: logger will automatically              port 514. Below that, we define a template
the default configuration is like by looking in     append date, host and user information to            for the output file name. In this example,
/etc/rsyslog.conf. For now, just skip to the       your messages.                                       we’ve included a number of properties that
#### RULES #### section.                             Try playing with this to see if you can            will get expanded by RSyslog on receipt of
   Here, you can see lines defining where           generate a message in /var/log/messages              messages to create the full path to the log
different messages go. To explain the              – on most systems, if you run logger                 file. Finally, we filter all local7 facility error
syntax, look at this example:                      without the -p option, you’ll find your               messages to go to this template (the ?
*.info                         /var/log/messages   message in /var/log/messages due to a line           indicates that a template is being used in
  On the left is a filter to match log              similar to the following in /etc/rsyslog.conf:       the action).
messages: in this example, messages of             *.info;mail.none;authpriv.none;cron.none                Remotely storing logs like this isn’t just
any facility with the priority info will be        /var/log/messages                                    convenient, it can help improve security, too.
matched. On the right is the action – that is,                                                          In the event of a breach, you have a second
what should happen to the message. In this         Logrotate                                            set of logs kept elsewhere. If the attacker
example, the matched messages will be              As great as syslog is, if you ever find yourself      wants to cover their tracks, they now have to
sent to the file /var/log/messages (note that       managing a cluster of more than two                  break into a further server if they’re to get at
most log messages will be stored in the            servers, you’ll quickly find yourself getting         all copies of the logs.
/var/log directory by default – it’s always a      annoyed with logging in to many different
good place to start when looking for a log).       servers just to get a picture of what’s              What next?
  If you want to, you can use this file to          happening across your entire cluster.                That was a brief introduction to logging in
redirect certain log messages to different           Thankfully, RSyslog provides the means             Linux and rsyslog in particular. There’s much
files. Be sure to restart the rsyslog daemon        by which you can centralise your logs. For           more you can do with logs, however, and
after you make changes. Remember that              example:                                             next month’s issue we’ll introduce you to
many application might define their own             *.*                               @192.168.79.10     Logstash. This open source tool can be
logging arrangements, so you could find, for          Putting this line in your RSyslog                  taught how to parse your logs, after which it
example, that your web server has its own          configuration file will instruct RSyslog to            will index them, make it easy for you to
log configuration in /etc/httpd/conf/httpd.         forward messages of all facilities and               generate pretty graphs and extract useful
conf or in individual virtual host definitions.     priorities to the machine at 192.168.79.10.          information from all those text files – all
Keep this in mind if you can’t find the log file     Pretty simple, and you can filter messages in         without having to touch grep and with
you’re looking for.                                exactly the same way as shown for local              lightning speed.
  If you want to interact with the syslog          logging, too. Setting up the receiving server           Until then, run back to your desk and sort
implementation from shell scripts you’ve           isn’t much more difficult:                            out your logging – you’ll thank us!



                                                                www.linuxvoice.com                                                                    63
      CORETECHNOLOGY




                                  CORE
A veteran Unix and Linux
enthusiast, Chris Brown has
written and delivered open
source training from New Delhi
to San Francisco, though not on
                                  TECHNOLOGY
the same day.                     Dive under the skin of your Linux system to find out what really makes it tick.

Processes
All the world’s a Unix filesystem/and all the processes merely players…


Y
        ou’re undoubtedly aware that            information it carries. Take a look at the       is only one way to actually do it, and that’s
        Linux, like most modern operating       table, below.                                    for a process to create a copy of itself. This
        systems, can run many applications                                                       operation is called forking. The new process
at the same time, through a feature called      Everything you know is wrong                     is called the child and the original process
multi-processing, or multi-tasking. I can       Even if you’re not a programmer, you’ll be       is called the parent. The child shares the
easily count the number of processes that       used to some of these concepts. Take the         code segment with the parent… that is, it is
my machine is running with a command            notion of a current directory for instance (as   executing the same program. It receives a
such as:                                        reported by the pwd command). You think of       copy of the data segment, the stack, and
ps -e | wc -l                                   yourself as being “in” a particular directory.   the heap. (The reality is actually a bit more
   The answer turns out to be 175, which        But really, it’s the process that’s running      complicated. These memory regions are not
seems quite a lot for a humble laptop that’s    your shell that holds the concept of current     copied piecemeal, but the “copy-on-write”
basically just editing a text file.             directory. You’re probably also aware that       operation of the virtual memory system
   So how do all these processes come into      you’re running as a specific user, as reported   makes things behave as if they were.) The
being? Well, some of them are started at        by the id command. But again, it’s really        child also inherits many other things – user
boot time. These are the system services        the process that’s running your shell that       ID, current directory and so on – from
(usually referred to as “daemons”), and many    maintains the notion of user identity. This is   the parent. In fact, the child begins life
of them may continue to run indefinitely,       the identity that’s used when access control     essentially as an exact clone of the parent
until the system is shut down. Some             checks are made – am I allowed to write to       except for one small thing – it has a different
services (such as the Apache web server)        such-and-such a file, for example.               process ID. Returning to our actor/script
maintain a pool of processes to enable them        Although there are many circumstances         analogy, forking is roughly analogous to
to promptly service multiple concurrent         under which a new process is started, there      our original (parent) actor calling out to the
clients. Quite a lot of processes come into
existence when the desktop is started. Of         Information carried by a process
the 175 processes I counted earlier, rather
more than 60 are there to give life to my         Item                Description
desktop or to run the applications that are       Process ID (PID)   Unique integer identifying the process
active there. Finally, some processes are         Code segment       Memory region that holds the program’s executable instructions
started by my own actions when I launch an        Data segment       Memory region that holds statically defined data
application from a menu or dahsboard, or I        Stack              Expandable memory region used to store ‘local’ function variables
type a command at a shell prompt.                 Heap               Expandable memory region used to store dynamically allocated objects
   A process is sometimes defined as              Priority           Determines how favoured the process will be by the scheduler.
“an instance of a program in execution”.                             Derived from the ‘nice value
The analogy of an actor reading from the          Signal disposition The way that the process responds to the receipts of signals
script of a play may be useful – the script                          – are they caught, ignored, etc.
represents the program: the passive list          Environment        A list of environment variables of the form NAME=VALUE
of instructions of what’s to be done. The         File descriptors   ‘Handles’ on streams that are available for reading or writing
actor represents the process, the active                             (includes stdin, stdout and stderr)
entity responsible for carrying out those         UID                Read user identity
instructions. But perhaps the best way            EUID               Effective user identity
to get a handle on what a process is is to        CWD                Current working directory
delve more deeply into the resources and



64                                                          www.linuxvoice.com
                                                                                                                                  CORETECHNOLOGY


  Try It Out
  Compile C code                                           } else {
  To compile the C examples in this tutorial you’ll           for (i=0; i<10000; i++)
  need to install the C compiler (GCC). On a Debian-            printf(“ **CHILD %d\n”, i);
  style system use this command:                           }
  # apt-get install gcc                                }
  and on a Red Hat-style system:                          To compile the program, run the command:
  # yum install gcc                                    $ gcc -o forkdemo forkdemo.c
     Now create a file called forkdemo.c with          and assuming you don’t get any compilation
  content as follows:                                  errors, run it like this...
  #include <stdio.h>                                   $ ./forkdemo
  void main()                                             The thing to notice here is that the output
  {                                                    from the parent and the child is interleaved in a
    int i;                                             non-deterministic way, as the scheduler switches
    if (fork()) {                                      back and forth between the processes. It’s also
       for (i=0; i<10000; i++)                         possible (rather likely in fact) that some of the
          printf(“** PARENT %d\n”, i);                 CHILD messages will appear AFTER the shell’s              The classic fork/exec/exit/wait model. This is
                                                       next prompt.
                                                                                                                 what happens every time you run a command.


wings for a new actor, who trots out onto              exec() is akin to the actor discarding his                last command through the variable $?. For
the stage and stands by the side of the first          current script, picking up a copy of Macbeth,             example,
actor, sharing a copy of the script.                   and starting at the beginning. He remains                 $ grep root /etc/passwd
                                                       the same actor, but he’s performing a                     root:x:0:0:root:/root:/bin/bash
Scary C code                                           different play. There are, in fact, six versions          $ echo $?
To see how this really works I’m going to              of the exec call, but I will not burden you with          0
inflict a few lines of C code on you. The              the minutiae of their differences. The call is            $ grep xyzzy /etc/passwd
action here centres around the fork()                  unusual in that it doesn’t return except in the           $ echo $?
system call. It’s a simple enough call -- it           case that it fails (usually because it can’t find         1
takes no arguments and returns just an                 the executable).                                          $ grep root /etc/xyzzy
integer result – but of all the system calls in           Two other system calls are important                   grep: /etc/xyzzy: No such file or directory
Linux it’s perhaps the one that is hardest to          for management of processes – exit() and                  $ echo $?
get to grips with, because although only one           wait(). The exit() call is simple enough – it             2
process makes the call, two processes                  terminates the process. You can pass an                   Here we see that grep returns an exit status
return from it – the original parent and the           integer argument to exit(), which is passed               of 1 if it doesn’t find the pattern and 2 if it
new child. They figure out which is which by           back to the parent process and is known                   can’t find the input file.
examining the return value from the call. In           as the “exit status”. The convention is that                The wait() call is used by a parent process
the parent, fork() returns the PID of the              an exit status of zero indicates a normal,                to wait until its child process (or one of its
newly-created child. In the child, it returns          successful termination, and non-zero values               children) terminates. This call can also be
zero. So you invariably see the fork() call            indicate failure of some sort.                            used to retrieve the exit status of the child.
wrapped inside an if test. Keeping in mind                For programs started from a shell                      Using fork(), exec(), exit() and wait() we can write a
that in C any non-zero integer value counts            prompt, you can find the exit status of the               minimal shell:
as “true”, and zero counts as “false”, the code
might look something like the boxout above.
   Sometimes, parent and child continue to
                                                           Try It Out
execute the same program. This happens,                    Write a shell                                                 }
for example, when Apache spawns its pool                   Create a file called tinyshell.c with this content:           else wait(0); /* Parent */
of “spare” server processes. More often,                   #include <stdio.h>                                        }
though, the child will start to execute a                  #include <unistd.h>                                   }
different program. This is what happens, for               #include <stdlib.h>                                      Now compile and run it something like this:
example, when I type a command into the                    /* A minimal shell */                                 $ gcc -o tinyshell tinyshell.c
                                                           main()                                                $ ./tinyshell
shell. (I’m talking about running a command
                                                           {                                                     > date
that lives in an external executable file, not a
                                                              char line[100];                                    Wed Mar 19 15:25:35 GMT 2014
built-in shell command such as echo or cd.)                   /* Main command loop */                            > hostname
A process runs a new program by executing                     while (printf(“> “), gets(line) != NULL) {         ubuntu1204
an exec() system call. In doing this, the code,                  if (fork() == 0) { /* Child */                  > who
date, stack and heap of the old program are                         execlp(line, line, (char *)0);               chris tty7       2014-03-19 13:52
discarded; however, the process retains its                         /* Don’t come here unless execlp fails */    chris pts/0       2014-03-19 14:05 (:0)
process ID, its current directory, its open file                    printf(“%s: not found\n”, line);             > ls -l
descriptors, and (usually) its environment.                         exit(1);                                     ls -l: not found
To return to our actor/script analogy, an



                                                                       www.linuxvoice.com                                                                            65
     CORETECHNOLOGY

                                                                                                                subdirectories you’ll see a standard set of
  Try It Out                                                                                                    ‘files’ that expose per-process information.
                                                                                                                Let’s change to the directory corresponding
  Braaaaaains!                                           5983 pts/0 00:00:00 makezombies <defunct>
                                                                                                                to the process running my rsyslog daemon:
  It’s rather easy to make zombies. Create a file        5984 pts/0 00:00:00 makezombies <defunct>
  called makezombies.c with content as follows:                                                                 $ pgrep rsyslogd
                                                         5985 pts/0 00:00:00 makezombies <defunct>
  #include <stdio.h>                                     5986 pts/0 00:00:00 makezombies <defunct>              527
  #include <stdlib.h>                                    5987 pts/0 00:00:00 makezombies <defunct>              $ cd /proc/527
  void main()                                            5988 pts/0 00:00:00 ps                                   Much of this information you’ll find here is
  {                                                     32052 pts/0 00:00:00 bash                               very low-level. Try this:
    int i;                                                 The point of this example is that the parent         $ cat status
    for (i=0; i<5; i++)                                 creates five children that immediately exit.            You’ll see lots of memory usage information
      if (fork() == 0)                                  Rather than waiting for them, the parent enters a
                                                                                                                and stuff about signal dispositions that is
        exit(0); /* Child */                            1000-second sleep. You cannot kill the zombies in
                                                        the usual way. For example, the command                 downright inscrutable. Usually, the output
    sleep(1000);
                                                        $ kill 5987                                             from programs such as ps and lsof will be
  }
  Then compile it and run it in the background:         has no effect.                                          easier to scrute (is that a word?). Let’s delve
                                                           The trick to getting rid of zombies is to track      a little deeper though. The subdirectory “fd”
  $ gcc -o makezombies makezombies.c
                                                        down and kill the parent, which is easy to find in
  $ ./makezombies &                                                                                             contains symbolic links that are named after
                                                        this case:
       Now if you run ps you’ll see a parent and five                                                           the process’s open file descriptors:
                                                        $ kill 5982
  zombie children:                                                                                              $ sudo ls -l fd
                                                           When the parent dies, the zombie children are
  $ ps
                                                        inherited by init (PID=1) which will collect the exit   total 0
    PID TTY          TIME CMD                           status from each of them, allowing them to be           lrwx------ 1 root root 64 Mar 21 14:40 0 ->
   5982 pts/0 00:00:00 makezombies                      finally laid to rest.                                   socket:[7307]
                                                                                                                l-wx------ 1 root root 64 Mar 21 14:40 1 -> /var/log/
                                                                                                                syslog
   You’ll notice that the last example                  program, or have a specified owner or a                 l-wx------ 1 root root 64 Mar 21 14:40 2 -> /var/log/
fails – the shell doesn’t understand about              specified parent, and so on.                            mail.log
command options and tries to find a file                                                                        lrwx------ 1 root root 64 Mar 21 14:40 3 ->
called ls -l. Well, honestly, what do you               A figment of the kernel’s imagination                   socket:[7309]
expect from 12 lines of code? But despite               Commands such as ps garner most of their                lr-x------ 1 root root 64 Mar 21 14:40 4 -> /proc/
its simplicity, this little program illustrates         information from the proc filesystem, which             kmsg
the essence of what happens when I run a                is usually mounted on the /proc directory.              l-wx------ 1 root root 64 Mar 21 14:40 5 -> /var/log/
command in the shell.                                   Through this filesystem the kernel exposes a            auth.log
   With this model in mind, it’s easy to see            large amount of process information in the              l-wx------ 1 root root 64 Mar 21 14:40 6 -> /var/log/
how the shell implements background jobs                form of what it calls ‘files’. They are not files       kern.log
(when the command line ends with &). The                as we normally think of them; they are an               We see here that file descriptor 1 (for
shell simply doesn’t do the wait() before it            illusion provided by the kernel to give us a            example) is connected to /var/log/syslog.
prompts for the next command.                           file-like view of some of its internal data
   Occasionally, things go wrong with this              structures. You can tell there’s something              The environment
model. If a process exits, and its parent is            funny going on because the command                      One important piece of baggage that a
not waiting for it, the child enters a “defunct”        $ ls -l /proc                                           process carries around with it is the
state (also known as a “zombie”). The child             shows most of the ‘files’ as having zero                environment, which is basically just a list of
cannot be completely laid to rest because it            length, but if you read from them there is              strings, each of the form NAME=VALUE. A
needs a waiting parent to pass its exit status          content. Try this:                                      child process inherits its environment from
back to. Here’s an analogy. Little Jimmy,               $ cat /proc/partitions                                  its parent after a fork() and the environment
who’s only six, is usually met by his mother            for example. A directory listing of /proc will          usually remains intact across an exec(), too,
after school. She waits for him by the school           reveal a number of subdirectories named                 depending on which version of the exec()
gate and Jimmy is always excited to see her.            directly after the process IDs. In these                call is used. From your command prompt
One day, mum gets held up in traffic and isn’t
there when Johnny comes out of school. He
                                                          Threads
has no-one to report his exit status to, and
enters a zombie state. (Of course, analogies              Linux allows multiple concurrent paths of             being the passive holder of context, and the thread
should not be pushed too far!)                            execution within the address space of a single        as being the active entity that gets stuff done.
                                                          process. Some people refer to threads as                 Here’s an analogy. Sue (the process) takes
   Let’s move away from C code and take
                                                          “lightweight processes” because they carry a          her three children (the threads) on a picnic. She
a look at processes from the command                      lot less context around with them than regular        struggles up the hill to a nice spot overlooking the
line. The classic command for viewing                     processes, and are much cheaper to create.            river carrying a blanket, a food hamper, and some
processes is ps. Other commands you                       Threads exist within a process; they rely on the      folding chairs. She sets them all out on the ground.
might find helpful are pstree, which shows                process to carry around most of the execution         The kids, meanwhile, just have a good time running
                                                          context. By default a process has only one            around. They are not laden with hampers or
the process ancestry using simple ASCII art,
                                                          execution thread. In a more thread-oriented view      blankets – they carry with them almost no context
and pgrep, which reports the process ID(s)                of the world, you could consider the process as       of their own.
of the processes that are running a specified



66                                                                      www.linuxvoice.com
                                                                                                                    CORETECHNOLOGY

you can examine the environment of your          like crontab and the command line mail             make it easy to run multiple applications on
shell’s process with the env command:            program which editor to use) DISPLAY               a single host, all the while ensuring each
$ env                                            (which tells graphical programs where their        remains separate.”
SSH_AGENT_PID=31487                              X server is) and CLASSPATH, which tells              But you can do that with processes too! In
TERM=xterm                                       Java apps where to look for their class files.     fact we can see threads and processes as
SHELL=/bin/bash                                  Environment variables are commonly set in          one end of a spectrum of containment
USER=chris                                       shell startup files such as /etc/profile.          technologies, with chroot jails, containers
LANG=en_GB.UTF-8                                                                                    and full-blown virtualisation at the other end.
HOME=/home/chris                                 As a final thought                                 As we move across the spectrum, less is
   The list I’ve shown here is vastly stripped   There’s quite a bit of interest at the moment      shared and more is separate. For example,
down. As they are inherited, environment         in Linux Containers, which is finally reaching     processes all share the same TCP/IP port
variables can be used to pass configuration      some level of maturity. In his excellent           space – I can’t have two processes binding
information to applications. Examples            feature about them in LV002, Jonathan              to port 22. Each container, on the other
include EDITOR, (which tells commands            Roberts wrote: “The idea of containers is to       hand, provides a separate port space.




Command of the month: ps
ps is the classic command for listing the
processes running on the machine. Used
without options, it gives you a minimum of
information about the processes associated
with your terminal:
$ ps
 PID TTY             TIME CMD
 352 pts/0           00:00:00 ps
32052 pts/0          00:00:00 bash
    Typically, this output will show only the
ps command itself, and its parent shell
(bash). How come the PID for the ps
command (352) is less than the PID of its
parent (32052)? That’s because after PIDs
have reached a specified limit (by default
it’s 32768) the numbers wrap around and
the PIDs get recycled. I didn’t deliberately
engineer that result, it just happened to
come out that way.
    ps has a large and very confusing set        The ps command sure generates a lot of output. But what does it all mean?
of options, partly because it’s trying to
remain backwards compatible with both            F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY        shows the process ID, group ID, and
of its progenitors (the BSD and System V         TIME CMD                                           command line:
versions) and partly because, well, it’s just    0 R 1000 4771 32052 0 80 0 - 3475 - pts/0          $ ps -o pid,gid,cmd
got a lot of options. Some of them control       00:00:00 ps
which processes are listed; some control         0 S 1000 32052 32042 0 80 0 - 6937 wait pts/0       PID GID CMD
how much detail is shown. I suspect that         00:00:00 bash                                      6260 1000 ps -o pid,gid,cmd
most people just remember two or three             The divided heritage of ps causes                32052 1000 bash
combinations of options that they find           confusion. For example the two commands              There are LOTS of output columns
useful, and stick with those.                    $ ps -elf                                          you can select here; see the STANDARD
                                                 $ ps aux                                           FORMAT SPECIFIERS section of the man
ps in depth                                      produce approximately the same output.             page for the details.
The -f option gives a full listing:              The first uses System V syntax, the second           The -e option lists every process, but
$ ps -f                                          uses BSD syntax (note the absence of a             you can also get finer control over which
UID     PID PPID C STIME TTY    TIME CMD         hyphen). They do not, however, show exactly        processes are listed. For example,
chris 4770 32052 0 12:33 pts/0 00:00:00 ps -f    the same output fields. I suspect that most        $ ps --ppid 1
chris 32052 32042 0 Mar19 pts/0 00:00:00 bash    administrators memorise two or three               shows those processes whose parent is PID
                                                 useful combinations of options and stick           1 (note the use of the GNU-style command
…and the -l option gives even more (rather       with those. That’s what I do!                      option with the double hyphen!), or to show
like the -l option of ls):                         If you want detailed control over the            just the processes running as chris:
$ ps -l                                          output fields use the -o option. This example      $ ps -u chris



                                                             www.linuxvoice.com                                                                 67
     FOSSPICKS




FOSSpicks                                                                                         Sparkling gems and new
                                                                                                  releases from the world of
                                                                                                  Free and Open Source Software

              Mike Saunders has spent a decade mining the internet for free
              software treasures. Here’s the result of his latest haul…
CD/DVD image editor


ISO Master 1.3.11
I
     f you’ve ever taken a peek at the    distros). Extract the .tar.bz2 file,
     genisoimage or mkisofs               change into the resulting directory
     manual pages, you’d be forgiven      with cd and run make followed by
if you come away shuddering. The          sudo make install. Then start the
former is a whopping 1,596 lines          program with isomaster.
long – and that’s not a bad thing,
because its level of detail is superb.    Functional minimalism
But the number of options included        Many disc authoring tools clog up
in these command line CD/DVD              the screen with toolbars, panels
creating tools is overwhelming,           and directory trees all over the
especially if you’re not au fait with     place, but ISO Master has just two
making disc images and you just           panels: the top one browses your
want to knock together a quick            filesystem, and the bottom one
backup DVD.                               browses the contents of the disc.
   ISO Master aims to be a simpler        You can open an existing ISO image
and friendlier graphical alternative.     by double-clicking on one in the top
But it’s not just limited to basic data   panel, or create a new image via the   Rock Ridge and Joliet filesystem extensions for CDs/DVDs provide
discs; it has options for making          File > New menu. Click a file or       better integration with Unix and Windows systems respectively.
bootable discs with multiple              directory in the top panel, then Add
filesystem formats as well. GTK 2 is                                                                        to add it to the DVD, or Extract to
used to provide the interface, so to
compile ISO Master from source,
                                          “ISO Master aims to be a simpler                                  remove a file from an ISO.
                                                                                                               To change filesystem options, go
you’ll need the development               and friendlier graphical alternative                              to File > Properties; there you can
packages installed (try libgtk2.0-
dev under Debian/Ubuntu-based
                                          to genisoimage and mkisofs.”                                      choose whether Rock Ridge and
                                                                                                            Joliet extensions should be enabled
                                                                                                            (a good idea, as these let discs use
                                                                                                            longer filenames), and you can also
                                                                                                            enter text for the volume name and
                                                                                                            publisher. Use the Tools > Boot
                                                                                                            Record menu to add a boot image
                                                                                                            to a disc, eg if you’re making a
                                                                                                            bootable Linux distro.
                                                                                                               When you’re finished creating the
                                                                                                            disc, click File > Save As and
                                                                                                            provide a filename. ISO Master will
                                                                                                            generate <filename>.iso, ready to
                                                                                                            be burned to a CD/DVD-R or booted
                                                                                                            in a virtual machine such as
                                                                                                            VirtualBox. It’s simple, fast and
                                                                                                            trouble-free – great work, team!
                                                                                 ISO Master shows the
                                                                                 estimated size of the
                                                                                 resulting ISO on the
                                                                                                              PROJECT WEBSITE
                                                                                 right-hand size, between     www.littlesvr.ca/isomaster
                                                                                 the two panes.


68                                                             www.linuxvoice.com
                                                                                                                                                FOSSPICKS


Social networking client



Dianara 1.2.0
T
          he big social networking                Pump.io account. And if you don’t
          sites, such as Facebook,                have one of those yet, you can get
          Google+ and Twitter, have               one from many different sites – we
two major problems: they’re all                   used https://pumpit.info.
massively centralised, and they                   Reassuringly, the Pump.io service
retain scary amounts of personal                  doesn’t just let random applications
data about us. It’s not all bad                   connect to your account and post
though. Pump.io is an example of a                things (a sure source of spam), so
social networking service that is                 Dianara needs a validation key and
both open source and decentralised                confirmation from the web
– that is, anyone can run a server                interface that you want to link the
that becomes part of the network.                 program to your account.
So no single company owns or
controls the service, and if one                  Pump.io up the volume
machine goes down, users                          Pump.io is a relatively simple
registered on another machine                     service compared with the                    Dianara crams plenty of information and widgets into its window,
won’t be affected. Anyone can set                                                              making better use of space than the web interface.
                                                  heavyweights of Facebook and
up their own Pump.io node (even                   Google+, and this is reflected in the
on low-spec kit such as a                         application. You can post                                                  packs in a good amount of
Raspberry Pi), so if anyone is                    messages to your timeline (plain                                           functionality. It’s also decently
interested in a tutorial, let us know.            text, or with media attachments),                                          configurable, with options for
   Anyway, Dianara is a graphical                 follow people to see what they’re up                                       changing how notifications work
application for accessing your                    to, and click stars on posts to add                                        and how often the timeline should
Pump.io account without having to                 them to your Favourites list. You                                          be updated. There’s not much in the
go through a web browser. Its                     can also add comments to posts,                                            way of online help, although the tips
interface is built using Qt, and to               share them with other people, and                                          are useful.
install it you’ll need the qjson-devel,           set up lists (to separate friends                                              The biggest problem for Pump.io
qoauth-devel and libmagic-devel                   from colleagues, for instance).                                            is its relatively small userbase. But
packages. Extract the dianara-                       In all it’s an attractive and                                           it’s a great system, so if we all get
v1.2.0.tar.gz archive and see the                 newbie-friendly program that still                                         on Pump.io, maybe we can finally
INSTALL file inside for detailed                                                                                             show that info-hoarding Zuckerberg
installation instructions, including a
helpful list of dependencies for
                                                  “Maybe we can finally show that                                            fella who’s boss…

many popular distros.                             info-hoarding Zuckerberg fella                                              PROJECT WEBSITE
   When you first start Dianara,
you’ll be prompted to link it to your
                                                  who’s boss?”                                                                http://jancoding.wordpress.com/
                                                                                                                              dianara




How it works: Get posting on Pump.io




  1 Sign up                                                 2 Add contacts                                          3 Post a message
       Create an account at https://pumpit.info, then             Click the Contacts tab and add people you              Click the Timeline tab and click in the text field
start Dianara and link it to your account. (You will be    know. If you don’t know anyone yet, try adding evan@   at the top. Give your post a title, add some text or an
asked to get a verification key from the site.)            e14n.com, aka Evan Prodromou, Pump.io’s creator.       image, and click Post to share with your followers.



                                                                        www.linuxvoice.com                                                                               69
      FOSSPICKS


Process sandboxing tool



Firejail 0.9
C
         ontainers, virtual machines,   something strange? Yes, there are
         chroot jails… There are many   only two processes listed – and PID
         ways to run programs in        1 (which is normally /sbin/init) is
restricted sandboxes, where they        the current Bash process. Firejail
can’t interfere with the rest of the    has created its own process
system. This is great idea if you’re    namespace for this Bash session,
ramping up security measures, or        so it can’t poke around and discover
you’re running a program from an        anything else that’s running.
unknown source and want to make         Another useful option is:
sure it doesn’t hose your distro.       firejail --overlay bash
Setting up these sandboxes can be           If you have OverlayFS enabled in
                                                                                 With the --overlay
tricky, though – so Firejail provides   your kernel, this will overlay a                                     providing them with their own TCP/
                                                                                 option, file changes
an easier alternative.                  temporary filesystem onto the            inside a Firejail session   IP stacks, and it includes a simple
    Both RPM and Deb binary             current one. So you can create and       are forgotten when the      monitoring tool (firemon, which
packages are available to download      modify files inside the jailed           session ends.               shows activity in Firejail sessions).
from the program’s website, or you      environment, but when you access                                     In all it’s a simple and user-friendly
can compile it from its source code     it, all of the changes are forgotten.                                way to run applications in restricted
(it has no unusual dependencies         This is great when you have                                          environments, so if you’ve been
and should install on any recent        programs that need to write files,                                   bamboozled with VMs, containers
distro). Once you have it installed,    but you want to revert to the original                               and chroot commands, give it a go.
run it along with a program like so:    state of the filesystem when you
firejail bash                           close them.                                                           PROJECT WEBSITE
  Now, inside the new Bash shell            Firejail includes various other                                   http://l3net.wordpress.com/projects/
                                                                                                              firejail
session, enter ps ax. Notice            ways to sandbox programs, like


Internet radio browser



Streamtuner2 2.1.0
F
        or various reasons, mostly to   player such as Audacious to hear
        do with mountains and           the streams. When you start
        wheat beer, this author         Streamtuner2 for the first time, it
started learning German four years      asks you which player you want to
ago. It has been a tough ride, but      use. Then it presents you with
one of the things that helped is the    several internet radio station
abundance of German radio               directories, some of which didn’t
stations on the internet.               work in our testing, which was
   There are thousands of radio         slightly annoying. We had the most
stations being broadcast via the        luck with the SHOUTcast and Music
internet, and while you can access      Goal services.
                                                                                 Fancy some Top Albania
them via your browser, it’s easier         With thousands of stations to                                     choose bookmark. You’ll then find
                                                                                 Radio? Or perhaps some
and faster to search via a dedicated    browse, across all manner of             Bluegrass Jamboree?         that station under the Bookmarks
program. Streamtuner2 is one such       genres and languages, it can be          Streamtuner2 has it all.    tab, on the far left of the tab bar.
app: it’s written in Python with GTK    difficult to remember your                                             Streamtuner2 has some rough
as its front-end, so you’ll need the    favourites. So Streamtuner2                                          edges in the layout and wording
pygtk package installed to run it.      includes a handy bookmarking                                         used in the interface, but it’s still a
Generic Deb and RPM packages            system: right-click on a station and                                 good way to explore the vast world
are available on the project’s                                                                               of internet radio.
website, and we had no problem
installing the Deb on Ubuntu 13.10.
                                        “Streamtuner2 includes a handy                                        PROJECT WEBSITE
   Streamtuner2 doesn’t play audio      bookmarking system.”                                                  http://milki.include-once.org/
                                                                                                              streamtuner2
itself – you’ll need a standalone



70                                                                www.linuxvoice.com
                                                                                                                              FOSSPICKS


Compression utility



PeaZip 5.3
P
         eaZip is a graphical              tiring work, so kudos to the devs for
         application for creating and      putting a lot of effort in.
         extracting compressed                 PeaZip’s interface is attractive,
archives, and as of the latest             clean and largely self-explanatory,
release, it supports over 150 archive      so we won’t dwell on it here, but
formats. (Yes, 150 – that’s not a          instead focus on the new features.
typo!) Along with the usual                The biggest addition in 5.3 is the
suspects such as Zip and .tar.gz,          Compression Profiles. Go to File >
the program can work with                  Create Archive, and in the dialog
relatively obscure formats such as         that appears, click on the down
.arc and .arj. If you created some         arrow to the left of the OK button.
                                                                                   Compression Profiles
archives with a random piece of            This provides some pre-created          make it a one-click job        Also in 5.3 are improvements to
shareware on your Amiga back in            settings for compression, such as       to choose formats and      the file manager (such as a better
the early 90s, chances are that            “7zip with password” or “Keep           options.                   treeview sidebar), while bookmarks
PeaZip can still open them.                output under 10MB for email                                        can be sorted. The inclusion filters
   PeaZip can use GTK or Qt for its        attachments”. These shortcuts are                                  that you can use when choosing
interface, and along with Deb and          very handy when you don’t have                                     which files should go in an archive
RPM packages, there are “portable”         time to poke around inside                                         are more flexible too. PeaZip just
versions that can be run without           individual settings boxes.                                         keeps getting better and better –
installation. Just extract the .tar.gz                                                                        it’s an outstanding piece of work.
file, jump into the resulting directory,
and run peazip inside. Packaging           “PeaZip’s interface is attractive,
up software to run across the
myriad Linux distros out there is
                                           clean and self-explanatory.”                                        PROJECT WEBSITE
                                                                                                               http://peazip.sourceforge.net




Password manager



gpgpwd 0.4
I
     n the wake of the Heartbleed             If you’ve used the GPG encryption
     OpenSSL vulnerability most            tools before, you’re ready to go –
     major sites and services have         but if not, enter gpg --gen-key to
recommended that users change              create a new encryption key. You’ll
their passwords – and, of course,          be prompted for a password, and
it’s a bad idea to use the same            this will become the master
password across multiple sites.            password you’ll use to access other
So we’ve all ended up with another         passwords via gpgpwd. To create a
bunch of passwords to remember,            new entry in gpgpwd’s database:
and for those of us without                gpgpwd set somesite.com
                                                                                   gpgpwd is low on
incredible memories, a password              Here, gpgpwd will ask you for a                                  password – that is, the GPG
                                                                                   dependencies, uses
manager comes in mightily useful.          password for somesite.com, or           existing tools (GPG) for   password you used during the
    gpgpwd is a great little manager       offer to create a new one. A few        security, and works        --gen-key command earlier.
written in Perl and requiring the          commands are available for              without any faffing        Passwords are stored in the
JSON and Try-Tiny modules, which           generating passwords:                   around.                    encrypted .gpgpwddb database file
are available as libjson-perl and          /alphanumeric 20, for instance, will                               in your home directory, and to
libtry-tiny-perl in Debian/Ubuntu-         generate a random 20-letter/                                       remove them from the database,
based distros. Extract the program,        number password. Hit Enter, and                                    use gpgpwd remove followed by
switch into the resulting directory        the password will be stored. To                                    the site name.
and install as follows:                    retrieve it in future:
tar xfv gpgpwd-0.4.tar.bz2                 gpgpwd get somesite.com
                                                                                                               PROJECT WEBSITE
cd gpgpwd-0.4                                When you do this, you’ll be
                                                                                                               http://random.zerodogg.org/gpgpwd
sudo make install                          prompted for your master



                                                                www.linuxvoice.com                                                                 71
     FOSSPICKS


File integrity checker



Checkit 0.2.0
I
     f you’ve ever downloaded a           (as root) procedure. Go into a
     large file such as a distro CD/      directory containing files that you
     DVD ISO image, you’ll probably       want to check, and run this:
have seen a file called MD5SUM (or        checkit -s -o *
SHA256SUM) to go alongside it.               This stores and overwrites the
This contains a checksum – a              checksum for all the files in the
sequence of characters that can be        current directory, storing the
used to check the integrity of the        checksums in the file’s extended
download. This is all good, but if        attributes (ie the bit of the
you need to watch the integrity of        filesystem that contains metadata
many files on your filesystem, it         about a file, such as its creation
                                                                                  After we’ve modified
becomes a bit fiddly to have foo.         date). Your filesystem needs to                                    checksums, and shows you which
                                                                                  test.txt, Checkit
md5sum and bar.md5sum files all           have extended attribute support for     gives us a red “failed”    files have changed.
over the place. And then you have         this to work, but if you’re using       message to show that          Checkit isn’t a replacement for a
to run the md5sum tool each time…         ext3/4, XFS, JFS or BTRFS you’ll be     the file has changed.      full-on intrusion detection system,
Checkit makes the whole process a         fine. Now modify one of the files,                                 and it’s limited to certain formats
lot easier by embedding a                 and then run:                                                      and filesystems (many archive
checksum into a file’s extended           checkit -c *                                                       formats don’t save extended
attributes (so you don’t need             This checks all files against their                                attributes, for instance). But for
separate files) and letting you do                                                                           simple jobs it works just fine.
batch checks on multiple files.
   Its only dependency is libattr1-       “Chechit embeds a checksum into                                     PROJECT WEBSITE
dev, and you install it with the usual
./configure, make and make install
                                          a file’s extended attributes.”                                      http://dennisk.customer.netspace.net.
                                                                                                              au/checkit.html




Text editor



LE 1.15
I
     n last issue’s cover feature we      between formats. We used:
     gave mad props to Vim, but we        alien --to-deb le-1.15.0-1.x86_64.rpm
     appreciate that not everyone           Along the bottom you’ll see a
likes its mode-based operation and        status line containing information
(initially) confusing keybindings.        about the current file, while hitting
Emacs is a hugely powerful                F10 (or Ctrl+B) opens the menu at
alternative, but it can still be tricky   the top. Use the arrow keys to
to learn all the Ctrl/Meta+key            navigate through the menus, and
commands. If you’ve come from an          enter to open them. You’ll also see
MS-DOS background, you might              keyboard shortcuts in the menu –
want a more accessible editor that        eg F2 to save, or Ctrl+F to search.
                                                                                  LE is reasonably
presents its options in familiar                                                                             you convert between Unix and
                                                                                  configurable, and if you
menus – and LE could be exactly           Back to the old house                   don’t like the default     DOS-style text files (they have
what you need.                            LE includes all the common              colour scheme, others      different line ending characters).
   Despite having decent knowledge        features you’d expect in a decent       are available.                While it’s not the ultimate kitchen
of C, we couldn’t get past the fiddly     editor: syntax highlighting, search                                sink editor like Emacs, it does 95%
errors that cropped up when we            and replace with regular                                           of what most people need, and the
tried to compile LE from source, so       expressions, line and column                                       menu-based interface makes it
we converted the RPM package              selections (with many available                                    easy to pick up.
from http://lav.yar.ru/download/le/       operations to perform on them),
binaries/ to a Deb for our Ubuntu         UTF-* support, custom colours and
                                                                                                              PROJECT WEBSITE
system using alien. This is a very        more. It can be used as a hex editor
                                                                                                              https://github.com/lavv17/le
handy tool for converting packages        (see the -h option), and even lets



72                                                               www.linuxvoice.com
                                                                                                                              FOSSPICKS


  FOSSPICKS Brain Relaxers
https://launchpad.net/pybik/
 Board game compilation



 Holtz 1.4.0
 H
           oltz isn’t a single game       games. The first, Zertz, is designed
           as such – it’s an engine       for two players, but if you’re on your
           for four board games.          own, you can set up the computer
 And these aren’t your common-            as an AI player. It combines
 or-garden board games either, but        elements of draughts and solitaire,
 abstract strategy games that take        and every time you lay a piece, you
 a while to get your head around.         remove a space on the board, so
 Sadly, the README file is blank          the playing area gradually gets
 and the INSTALL file contains            smaller. (The rules are complicated,
 generic GNU build instructions           so click Help > Contents in the
 from 2002, so here’s how to              menu to get the full description.)
                                                                                   This is Relax, where
 compile it: install the wxWidgets                                                                            involves racing from the corners
                                                                                   your goal is to place
 development packages from your           Game of four halves                      pieces so that the         to grab as much space on the
 distro’s package manager (eg             Dvonn, meanwhile, is another two-        coloured lines extend      board as possible.
 libwxgtk2.8-dev and                      player game, which involves              for as long as possible.     Holtz is a brilliant little package,
 wx2.8-headers) along with Boost          stacking pieces on top of one                                       and some of the games will keep
 (libboost-dev). Then run                 another to control areas of the                                     you busy for hours, even if they
 ./configure, make and sudo               board, while Relax is a good                                        seem rather odd at first.
 make install, followed by holtzt to      single-player game where you have
 start the game.                          to score points by placing colour-
    Click File > New in the menu to       aligned pieces. The final game,                                      PROJECT WEBSITE
                                                                                                               http://holtz.sourceforge.net
 choose one of the four included          Bloks, is for two or four players and




 Tetris variant bundle



 Galois 0.3
 T
           etris has pretty much          regular Tetris game will kick off. By
           been done to death at this     default, Galois’s Tetrisy games run
           point, although we still see   at a fair pace, but you can change
 new versions on Freecode.com             that by going to Game > Stop and
 every week. So at first we almost        then Game > Preferences (see
 skipped over Galois, but then we         “Initial speed level”). This is also
 saw the screenshots, and just            where you’ll choose a different
 had to try it. Galois is a Tetris        format, such as hexagonal or
 engine that includes the classic         triangular bricks.
 game, but also some variants
 with different shapes. To compile        I’ll have a T please, Bob
                                                                                   What’s this – Tetris? Or
 it, you’ll need GTK 2.4 and              We love the hexagonal version: it’s                                    There’s only one flaw: pressing
                                                                                   Blockbusters? Or some
 LibXML++ 2.6; in Debian and              similar enough to Tetris that it         ker-azy mutant hybrid      Esc to pause leaves the screen
 Ubuntu-based distros, these are          doesn’t take long to pick up, and        of both?                   intact, so you can plan your next
 provided in the libgtkmm-2.4-dev         many of the tactics you use in the                                  move (the screen goes blank in
 and libxml++2.6-dev packages.            classic game still apply. The                                       most Tetris variants). We’ll submit
     When you start Galois, you’re        controls are as usual for Tetris, but                               a bug report…
 presented with a grand total of          the unusual shapes make the game
 nothing. Just a grey screen. Click       different enough to exercise other
                                                                                                               PROJECT WEBSITE
 Game > New in the menu,                  neurons in your noggin, and                                          www.nongnu.org/galois
 however, and a version of the            especially difficult at times too.




                                                               www.linuxvoice.com                                                                  73
     LISTEN TO THE PODCAST



     WWW.LINUXVOICE.COM




72
                                                                                                                             TUTORIALS INTRO




                                                   TUTORIALS
                                                   Dip your toe into a pool full of Linux knowledge with nine
                                                   tutorials lovingly crafted to expand your Linux consciousness.


                                                    In this issue…
                                                       76                                    78                                 84




Ben Everard
Is off to investigate Linux usage on the Mull of
Kintyre. Next issue: the frog chorus.

                                                    Create a font                        Build a robot                        Stalk wildlife

M
                                                    Fonts are the handwriting             Transform an ice cream tub,         If you want to take pictures
             oney has always been a
                                                    of computers. Create                  a Raspberry Pi, a mobile            of badgers but you’re afraid
             thorny subject in the Free
                                                    your very own personal                phone and two motors into           of catching bovine TB,
             Software world. There’s
                                                    typography, with Mike                 a robot in just six pages full      follow Jon Archer’s example
no doubt that some companies are
                                                    Saunders and BirdFont.                of Ben Everard’s words.             and build a remote camera.
making huge amounts of profit on the
back of open source software. In fact,
we can’t think of any major technology                 86                                  90                                  94
companies that don’t. However, many
of the projects that support these
companies are chronically short of
money. OpenSSL is a famous example
of this, but there are many more.
   Fortunately, it seems to be sinking in
that essential infrastructure needs to
be funded properly. Pitivi, The Blender
                                                     Harden a server                     Move from XP                        von Neumann
Foundation and MediaGoblin have all                  Linux can be secure, but it         It’s the OS that we love to         Juliette Kemp moves on to
raised significant amounts of money                  isn’t always. Here’s what           hate, and it’s embedded it-         John von Neumann, the
in crowdfunding. Elementary OS is                    you can do to prevent nasty         self so deeply that it’s hard       architect of the modern
working with BountySource.com to                     hackers and botnets from            to get rid of. Mark Crutch          computer, inventer of
provide cash incentives to people fixing             getting into your servers –         keeps XP alive (undead?) in         cellular automata and
bugs. Hopefully, 2014 will be a turning              by Mike Saunders.                   VirtualBox.                         developer of the first virus.
point in the funding of Free Software.
   Much as we may like the thought of
developers working on open source                   PROGRAMMING
projects for nothing, the truth is that
complex software requires time and                  FPGAs                                Error detection                     Android Studio
even the most altruistic people have                 98 Design your own                  102 Data errors are an              104     Google has just released
bills to pay. In the past, most paid                       microchips. Really! With an          unfortunate fact of life.           a new development
                                                    FPGA board you can load new          However, that doesn’t mean we       environment: Android Studio. It’s
open source developers were paid by
                                                    designs onto Field Programmable      should just sit back and meekly     based on IntelliJ IDEA, and it looks
corporations and followed their agenda.             Gate Arrays and implement your       accept our fate. With a bit of      great. We take a look around the
By funding development directly, you get            own integrated circuits. We start    clever maths, we can fight back     preview version and show you how
a say in what direction the project takes,          simple and investigate some          against flipped bits and ensure     to create a simple smartphone
and you can help struggling projects                chips using the ZPU processor,       that the data that arrives is the   app to help you digest all the
                                                    then build a few circuits that       same data that we send, because     latest news from the Linux Voice
keep developing great software.
                                                    use them.                            no-one likes nasty surprises.       RSS feed.
ben@linuxvoice.com



                                                                     www.linuxvoice.com                                                                             75
     TUTORIAL DIY TYPEFACES



                               MAKE YOUR OWN FONTS
          TUTORIAL
                               WITH BIRDFONT
                               You don’t need to be a design whizz to create your own custom
MIKE SAUNDERS
                               fonts – BirdFont makes it easy as a particularly good-looking pie.


                               I
                                   f you were using Linux in the late 90s (or you’ve
 WHY DO THIS?                      seen screenshots of the desktop environments
 • Create funky typefaces          back then), you’ll know that it was pretty ugly.
   from scratch or based
   on existing designs         Fonts, in particular, were a bit of a disaster area. Today
 • Give your printed           we have gorgeous desktops and window managers,               The street sign we’ll be using to create the lowercase “a”
   documents or website a      and distros ship with oodles of top-quality, free-as-in-     character in our custom font.
   unique feel                 freedom fonts. But have you ever considered making
 • Export to TTF, EOT and      your own font? You can create one from scratch if            from the project’s website, extract it, and follow the
   SVG formats
                               you’re full of ideas, or base one on an existing design      instructions in the README. Once you have it
                               – eg an old document or a logo. It’s much simpler            installed, just enter birdfont in a terminal to start it.
                               than it sounds, so we’ll explain how.                           In this tutorial we’ll use an existing design as the
                                  To make our custom font we’ll be using BirdFont           basis for a font. We’ll take a street sign and create a
                               (www.birdfont.org), an excellent font editor that runs       glyph (font character) of the letter “a” from it. Of
                               on Linux, Mac OS X and Windows. Packages are                 course, if you want to make a complete font then
                               available for many distros, but if you can’t find it in      you’ll need an image that contains all letters
                               your distro’s repositories, grab birdfont-0.37.tar.gz        (uppercase and lowercase) along with numbers.


                                   Step by step: create a font
                               1
                                   Align image                                              2
                                                                                                Create the outline
                               Start BirdFont and click on File > New to create a new       Now click the icon (add new points) in the top-left
                               font. A list of glyphs will appear – scroll down and         of the toolbox, and click several times around the
                               double-click on “a”. In the right-hand toolbox, click the    outside edge of the character to create an outline,
                                  button (it’s shows an uppercase B) towards the            eventually clicking on the first point to complete it.
                               bottom to insert a new background image (all of the          This outline can be pretty rough – you don’t need to
                               buttons have tooltips, so hover over them with the           add points for every tiny detail. Use Shift+Ctrl+=
                               mouse to find out what they do).                             (equals key) to zoom in.
                                  Click on the + button to add an image, and then
                               double-click its thumbnail. Move the image using
                               the target ( ) tool until the image’s “a” character is
                               inside or over the box. Right-click the button to
                               open a scale value bar, and scale the “a” until its height
                               matches the box. Finally, grab the right-hand guide
                               line using its small arrow at the bottom to match the
                               “a” character’s width.




We’ve moved and resized
the image so that the “a” is
inside the box, and pulled                                                                  Figure 2: The outline for our glyph. It’s looking rather
the right-hand guide in.                                                                    angular at this stage, but we’ll fix that in a moment...



76                                                              www.linuxvoice.com
                                                                                                                    DIY TYPEFACES TUTORIAL

3
    Smoothen the edges                                                 4
                                                                           Align the paths
Back in the bottom-right of the toolbox, click the                     Click the (show/hide background) button again.
icon (show/hide background image). Then click the                      Chances are that the current paths won’t be 100%
button at the top. Now hold down Shift, and click on all               perfectly in sync with the original image, so click and
of the blue points on the outline, going round the                     drag the blue points to line them up (they’re Bézier
whole glyph clockwise. When they’re all selected, click                curves, so you can also alter them with the green
the (tie curve handles) button in the tool pane and                    points). If you have an area that needs removing, like
the edges will be rounded out.                                         the hole in the bottom of the “a” character, for instance,
                                                                       draw a new path as per the previous instructions, and
                                                                       when it’s complete click on Create Counter From
                                                                       Outline). Then smooth out the points as in step 3, to
                                                                       get the result shown below.




That looks a lot better! With the edges rounded it’s                   Here we’ve added the inside part of the character as a
starting to look like a proper character.                              counter path. We won’t be giving up the day job.

5
    Preview it
When you’re happy with everything, go to File >
Preview (you’ll be asked to enter a name for the font).
Then a Preview tab will appear, showing your glyph
being used in some example sentences.
   If you’re happy with the results, congratulations –
you can now go on to do all the other letters! (It might
be a long job.) If you need to fine-tune the character
more, click its tab again, choose the arrow (Move
Points) button in the tool pane, and fine-tune it. And
if you need any help, pop by our wonderful forums at                   Our new “a” character in BirdFont’s Preview. Sure, it looks
http://forums.linuxvoice.com.                                          rather out of place, but when we’ve done the others…



    Exporting your design
    When you’ve finished designing your font, click File > Export
    in the menu and provide a name for it. BirdFont will save your
    work as <name>.bf in your home directory (eg /home/mike/
    myfont.bf). It will also create various font files that you can
    install into your Linux distribution (or indeed other operating
    systems): Typeface.ttf (TrueType, the most common format),
    Typeface.eot and Typeface.svg.
        It’s also possible to include your font in your website,
    giving it a more personal feel than those sites that use regular
    Helvetica or Times fonts. During the Export process, BirdFont
    also generates a Typeface.html file. Have a look inside it,
    especially the @font-face parts of the CSS towards the top, to
    see how to use custom fonts in a page.




                                                                           www.linuxvoice.com                                                77
     TUTORIAL BUILD A MARS ROVER



                               RASPBERRY PI:
          TUTORIAL
                               BUILD A MARS ROVER
                               Polish your CV and call NASA: you’re about to become
   BEN EVERARD
                               a professional-grade robot builder.


                               “R
                                              obotics is a complex area that requires a   phones should work, though you’ll need the
 WHY DO THIS?                                 combination of electronics understanding    appropriate development environment).
 • Get started with robotics                  and the ability to use specilised             If you haven’t worked with robotics before, the final
 • Learn more about the        machinery”. That last sentence is a common                 four might sound a little complex, but don’t worry, they
   Raspberry Pi
                               sentiment, but it’s utter balderdash. Modern               needn’t be. While you could use almost any motors
 • Build a robot army and
   take over the world         development boards like the Raspberry Pi (and the          you can get your hands on, there are some easy,
                               host of expansions that do with them) combined with        reasonably priced ones that are particularly easy to
                               the flexibility of Linux makes robotics incredibly easy.   use from PiBorg (http://piborg.org/accessories/
                                  To prove this, we’re going to build a Mars rover-type   dc-motor-gearbox-wheel) and other suppliers. You
                               buggy based on a Raspberry Pi. You’ll be able to           only need two of these to drive the robot, and the only
                               control it remotely, and it’ll stream video back to the    assembly is pushing the wheel onto the axle.
                               controller. To make control really easy, we’ll build a
                               smartphone app to use the phone’s accelerometer, so        Reliant Mars Robin
                               you can drive the buggy by turning the phone (much         For the final wheel (ours has three, but yours could
                               like the controls in many smartphone video games).         have four), we used a ball caster (like this one: http://
                                  There are quite a few parts to this, and we’ll be       shop.pimoroni.com/products/pololu-ball-caster-
                               using a few different technologies to control different    with-3-4-metal-ball). This allowed the back of the
                               parts, but thanks to the wide range of development         buggy to move freely and follow the front two wheels.
                               tools on Linux, it’s not as difficult as it sounds.           The Raspberry Pi does have General Purpose Input
                               For the hardware you’ll need:                              and Output (GPIO) pins that can be used to switch
                                  Raspberry Pi and SD card (it is possible with a         low-power components like LEDs on and off. However,
                                  model A, but a model B will be easier to develop on).   motors draw a much higher current than the GPIO
                                  Raspberry Pi camera module (the NoIR module will        pins can provide. Therefore you need some way of
                                  be able to see in the dark).                            taking a signal from the Pi and converting it into an
                                  Raspberry Pi-compatible Wi-Fi dongle                    electrical current powerful enough to drive a motor.
                                  (see http://elinux.org/RPi_USB_Wi-Fi_Adapters).         For the purposes of this project, we can classify these
                                  Power supply for Raspberry Pi.                          into two types: on/off controllers and variable speed
                                  Power supply for motors.                                controllers. The first (such as the PicoBorg or the
                                  Two motors and drive train.                             relays on a PiFace) will work, but the controls won’t be
                                  One or two more wheels.                                 as finely-grained as they could be. We used a
                                  Motor controller.                                       PicoBorg Reverse (http://piborg.org/picoborgrev),
                                  Chassis.                                                which enables us to vary the speed of each motor
                                  You’ll also need a Linux machine to do some             (other controllers are available with the same features).
                               development on, and an Android phone (other smart          The most important thing is that the board you use as
                                                                                          the brains of the robot should be controllable from
                                                                                          Python (almost all are). There should be sample code
                                                                                          on the board’s website to show you how to do this.

                                                                                          The build
                                                                                          The chassis can be as simple or as complex as you
                                                                                          like. Specialised robot chassis are available that are
                                                                                          robust and capable of carrying lots of sensors. We
                                                                                          don’t need this much for a simple buggy though. You
                                                                                          can use anything provided you can mount the wheels
                                                                                          on it and it will support the electronics.
An ice cream tub makes                                                                       Finally, we used a USB power pack and a 9V battery
a simple and cheap robot                                                                  to power the Pi and the motors respectively. This is
chassis – just make sure                                                                  quite a lot of hardware, but all of it could be used on
you wash it out first.                                                                    other projects.



78                                                            www.linuxvoice.com
                                                                                                         BUILD A MARS ROVER TUTORIAL

   Obviously the build will vary depending on exactly                                                                           A bit of glue will hold the
what parts you’ve chosen. For us, it involved                                                                                   motors in place, but be
connecting the PicoBorg Reverse according to the                                                                                careful not to get any on
instructions on the website (http://piborg.org/                                                                                 moving parts.
picoborgrev/install).
   To set up the buggy, we glued the motors to either
side of one end of the ice cream tub, and bolted the
caster to the other end. This created a three-wheeled
buggy driven by the two motors at the front. We set
the Wi-Fi to automatically connect to our network
using the WiFi Config tool on the Raspbian desktop.
   All motor controllers should come with some test
code so that you can make sure everything is working.
The software that installs the PicoBorg Reverse
drivers will also put an app on the desktop. If you
haven’t already, you should run that now. Now is also
a good time to make sure that both motors are wired
the correct way round. With both motors on forward,
the buggy should obviously move forward. With motor
1 on and motor 2 off it should turn left, and with motor             content/uploads/2014/04/turtle.png you are
2 on and motor 1 off, it should turn right. If this is               requesting the file /wp-content/uploads/2014/04/
different on your buggy, you just need to switch the                 turtle.png from the server www.linuxvoice.com. The
wires around until it works correctly.                               server will respond to this request by sending
                                                                     an image from the Python drawing tutorial from
Fire up Python                                                       Linux Voice issue 2.
The PicoBorg Reverse software includes a Python                         Requests don’t have to be for files though. The web
module to control the motors, but it doesn’t install it to           server can deal with requests however it wants. You
the global Python directory, so it’s not available to                can also send bits of data in the URL. These
scripts that are run from other locations. In order to               arguments in the URL string come after a question
make this module available, you’ll have to copy it                   mark and are separated by ampersands. For example,
across yourself with the following code (you may                     in the URL www.google.co.uk/search?q=linuxvoice,
need to adjust the path depending on where you                       the argument q is set to the string “linuxvoice”.
unzipped the install files):                                            We’re going to use the Python Tornado web server
sudo cp /home/pi/picoborgrev/PicoBorgRev.py /usr/lib/cd              to use these requests to control the motors on the Pi.
pymodules/python2.7/                                                 You’ll need to install this on the Pi with:
  We’ll use a simple web server to control the buggy.                sudo apt-get install python-tornado
Web servers work by waiting for requests, and then                     The code to control the motors using the PicoBorg
serving web pages based on the request they get.                     Reverse is:
Normally, the request is given in the URL that the                   import PicoBorgRev
website visitor’s browser sends to the web server. For               import subprocess
instance, if you visit www.linuxvoice.com/wp-                        import tornado.ioloop
                                                                     import tornado.web

  Alternatives to the Pi
                                                                     maxspeed = 0.3
                                                                                                                                     PRO TIP
  The Raspberry Pi is particularly well suited to this project       PBR = PicoBorgRev.PicoBorgRev()
  because the camera is well supported and there are plenty                                                                      Robots are like Lego:
                                                                     PBR.Init()                                                  once it’s built, play with it
  of motor control add-ons to provide all the functionality          PBR.ResetEpo()                                              for while, then take it to
  you need. However, it’s not the only option. It should be                                                                      bits and build a new one.
  possible to do more or less the same thing on a BeagleBone
  Black, although you’ll have to do a little bit more work to get    class TurnHandler(tornado.web.RequestHandler):
  streaming video set up (there’s a guide here: http://shrkey.                  def get(self):
  com/installing-mjpg-streamer-on-beaglebone-black).                                        PBR.SetMotor1(min([float(self.
  Larger boards such as the Odroid or Udoo should work as            get_argument(“motor1”))/100, maxspeed]))
  well, though they’ll drain the batteries faster, and their extra
                                                                                            PBR.SetMotor2(min([float(self.
  processing power isn’t really useful for this project.
     It should be possible to use a microcontroller such as          get_argument(“motor2”))/100, maxspeed]))
  an Arduino to handle the motor control (though it would                                   self.write(“Updated”)
  be better to use Bluetooth than Wi-Fi in this case). Getting       class HaltHandler(tornado.web.RequestHandler):
  streaming video working with a microcontroller would be                       def get(self):
  challenging, though probably not impossible if you are
                                                                                            subprocess.call([“sudo”, “halt”])
  determined enough. However, you could do this separately
  using a wireless webcam.
                                                                     if __name__ == “__main__”:



                                                                       www.linuxvoice.com                                                                        79
     TUTORIAL BUILD A MARS ROVER

                                                                                               arguments against a threshold, and if it is, turn the
                                                                                               motor on. For example:
                                                                                               if float(self.get_argument(“motor1”)) > 30.0:
                                                                                                             #code to turn motor one on
                                                                                               else:
                                                                                                             #code to turn motor one off
                                                                                                 HaltHandler is used to turn the Pi off, since there’s
                                                                                               no other way to shut it down cleanly when there’s not
                                                                                               a screen unless you SSH in, which is a little excessive
                                                                                               for a simple robot.
                                                                                                 We called the file server.py, and you can start it
                                                                                               running from the LXTerminal command line with:
                                                                                               python server.py
                                                                                               We’ll get it running automatically a bit later on.
                                                                                                  You can now control the robot from the Raspberry
The PiBorg Reverse GUI
                                      application = tornado.web.Application([                  Pi by opening the web browser and going to http://
controller is useful for
making sure everything’s                          (r”/turn/”, TurnHandler),                    localhost:8000/turn/?motor1=20&motor2=20 (be
connected correctly.                              (r”/halt/”, HaltHandler)])                   careful not to accidentally drive your robot off your
                                      application.listen(8000)                                 desk when testing this). You can then stop the motors
                                      tornado.ioloop.IOLoop.instance().start()                 by going to http://localhost:8000/
                              The final block of this code (which starts with if __            turn/?motor1=0&motor2=0.
                           name__) sets up the web server running on port 8000
                           (we’ll use port 80 – the usual web server port – a bit              Control from other machines
                           later). It uses the class TurnHandler to handle                     You can also access this from other computers on the
                           requests to /turn/, and the class HaltHandler to deal               same network by using the IP address of the Pi. To
                           with calls to /halt/. Both of these classes extend                  find out the IP address of the Pi, open LXTerminal and
                           tornado.web.RequestHandler, which sets them up                      type ifconfig. This will output a block of information
                           with almost everything they need. The only thing this               for each of the network interfaces. The one you need
                           code does is add the get method that is called                      is labelled wlan0, and you’re looking for the inet addr.
                           whenever a HTTP GET request is sent to the                          In the following, the IP address is 192.168.0.33:
                           appropriate URL.                                                    wlan0     Link encap:Ethernet HWaddr bc:ee:7b:87:7b:38
                              You can access the arguments passed in the URL                             inet addr:192.168.0.33 Bcast:192.168.0.255
                           using the self.get_argument() method. The two calls                 Mask:255.255.255.0
                           in TurnHandler are to get the arguments called                                inet6 addr: fe80::beee:7bff:fe87:7b38/64 Scope:Link
                           motor1 and motor2. We then use these values (which                            UP BROADCAST RUNNING MULTICAST MTU:1500
                                                                 we’ll set between             Metric:1

“You could add an output device                                  -100 and 100) to set
                                                                 the speed of the              frame:0
                                                                                                         RX packets:88425 errors:0 dropped:0 overruns:0

to the Pi such as a little LCD                                   motor (which is                         TX packets:81516 errors:0 dropped:0 overruns:0

screen to display the IP address.”                               between -1 and 1).
                                                                 We’ve limited the
                                                                                               carrier:0
                                                                                                         collisions:0 txqueuelen:1000
                                                                 motor speed using                       RX bytes:76786575 (76.7 MB) TX bytes:14405224
                           the global variable maxspeed to stop the motors                     (14.4 MB)
                           burning out.                                                           Unfortunately, this isn’t fixed and may change from
                              The code here works for a PicoBorg Reverse, but it               time to time if you reboot the Pi, and it won’t be easy
                           should be fairly trivial to adapt it to other motor                 to run ifconfig if the Pi is mounted inside a robot.
                           boards. If your motor controller only supports on and               There are a few ways around this. Many Wi-Fi routers
                           off, you’ll have to include an if statement to test the             enable you to assign a static IP address to a device,


                             Web sockets
                             The method we’ve used for controlling the motors is, well,           A better method would be to create a communications
                             a little hacky. It works, but it doesn’t work well. The main      channel through which you can continuously send data. There
                             problem is that there’s a large overhead each time you change     are a couple of options for this: TCP sockets or Web sockets.
                             the motor speed. The phone app has to negotiate a new TCP         Both are supported by Python, and both have plugins for the
                             connection and send the data, then the Tornado server re-         Cordova framework that we’re using for the Android app.
                             initialises the module to send data to the server. This means     Neither should be excessively complex to set up, though they
                             there’s a noticeable lag between turning the controls and the     will require some knowledge of both Python and JavaScript.
                             buggy responding. Part of this is also due to the interval that   Using one of these methods, you should be able to reduce the
                             the app checks the accelerometer, but this has been adjusted      latency of the control and increase the frequency with that the
                             to work well with the speed of the server.                        app updates the accelerometer readings.




80                                                               www.linuxvoice.com
                                                                                                  BUILD A MARS ROVER TUTORIAL

which will enable you to set it so the same IP address
will always be assigned to the Pi. You could add some
output device such as a little LCD screen to the Pi to
display the IP address. The simplest method is to use
another Linux computer to scan the address range
and find the IP address for the Pi. You can do this
using Nmap.
  First you’ll need to install Nmap from your distro’s
repositories (on Debian-based systems, this is done
with sudo apt-get install nmap). Since the above
server runs on port 8000, we can use this to detect
the Pi. The following command will check all
computers in the IP range 192.168.0.0 to
192.168.0.20 to see if that port is open.                                                                                       The finished app
nmap -sT 192.168.0.0-20 -p 8000                                another computer connected to the same network                   controlling the buggy. It’s
  The Pi will respond with something like this:                and see the video stream. You don’t need to modify it            not much to look at, but
Nmap scan report for 192.168.0.33                              at all, but it’ll fit into the smart phone app we’ll create      the controls are intuitive
Host is up (0.039s latency).                                   in the next step a bit better if you get rid of the title and    and fun.
PORT STATE SERVICE                                             resize the image.
8000/tcp open http-alt                                            To do this, open up the /var/www/index.html file on
Usually, the Pi will be the only IP address that returns a     the Pi using a text editor running as sudo. For
state of OPEN for this port.                                   example, to do this in Leafpad, run
  Currently, you also need to start server.py manually.        sudo leafpad /var/www/index.html
We’ll set it to start automatically at the end once              To get rid of the title, delete the line:
everything else is set up.                                     <h1>RPi Cam Control</h1>
                                                                 The size you want the image to be will depend on
Getting visuals                                                the resolution of your phone screen. We went with a
Installing the Raspberry Pi camera module is simply a          width of 400 pixels, though you can adjust this at the
case of slotting it into the correct port (the one             end to make it fit properly on your phone. To do this,
between the Ethernet and HDMI ports) with the silver           change the line:
coloured bare metal facing towards the HDMI port,              <div><img id=”mjpeg_dest”></div>
then enabling it. Enter sudo raspi-config in                   to:
LXTerminal, then select Enable Camera, then Yes.               <div><img id=”mjpeg_dest” width=400px height=auto></div>
You’ll need to reboot the Pi for the changes to take              The only thing left to do set the Python script that
effect. There’s a video guide at www.raspberrypi.org/          runs the motor control server to start automatically
help/camera-module-setup if you have any problems.             (we didn’t do this earlier because the setup for the
   If you don’t have a camera mount to attach to the           webcam overwrites the file it’s done in). Just add the
chassis, a blob of Blu-tack also works.                        following line (you may have to modify it depending
   That’s the hardware completely set up. There’s still        on where you saved server.py):
a little bit of software to set up on the Pi, but it doesn’t   python /home/pi/picoborgrev/server.py
involve any more coding. As the saying goes, “good             to the file /etc/rc.local directly before the final line (exit
programmers borrow, great programmers steal”, and              0). Again, you’ll need to use a text editor running as
that’s exactly what we’re going to do. Streaming video         superuser, so open Leafpad with sudo as you did with
from a Raspberry Pi to a website isn’t new, and there’s        index.html. That’s all the setup for the Pi – now to
no reason to do it yourself.                                   create the phone app that will control it.
   The easiest setup we’ve found is at https://github.
com/silvanmelchior/RPi_Cam_Web_Interface. Just                 Hands on
download the ZIP file and install it with:                     The easiest way to create smartphone apps is with
unzip Rpi_Cam_Web_Interface-master.zip                         Apache Cordova (as seen in Linux Voice issue 2). The
cd Rpi_Cam_Web_Interface-master                                idea is that it enables you to use web technologies
chmod a+x RPi_Cam_Web_Interface_Installer.sh                   (mainly HTML and JavaScript) to create apps that can
./RPi_Cam_Web_Interface_Installer.sh install                   access phone functions that regular web pages
Reboot the Pi so it picks up all the new settings. It’ll       cannot. In this case, we’ll access the accelerometer.
automatically create a web server (on port 80) that              Accelerometers measure what’s known as proper
starts when you turn on the Pi, and hosts a website            acceleration. This is a little different from what most
with the streaming video as well as some settings so           people know of as acceleration, because it’s the
you can control the video stream (and record pictures          acceleration experienced by an object. This means
and video from your buggy).                                    that an accelerometer resting on a surface will
  Once it’s up and running, you should be able to open         experience an acceleration of 9.8 m/s because it’s
http://<ip-address-of-pi> in a web browser on                  experiencing that acceleration from gravity. On the



                                                                 www.linuxvoice.com                                                                       81
     TUTORIAL BUILD A MARS ROVER

                               other hand, if you drop the accelerometer, it will read 0      export PATH=${PATH}:/home/ben/adt-bundle-
                               because it’s in free fall and not experiencing any             linux-x86-20140321/sdk/platform-tools:/home/ben/adt-bundle-
                               acceleration. (Actually, it will read a little higher than 0   linux-x86-20140321/sdk/tools
                               because of air resistance.)                                      You’ll need to amend the paths to point to the
                                  As long as you hold the device still, the                   Android SDK you downloaded and extracted. You can
                               accelerometer measures gravity. It measures it in              run these commands in the terminal, but it won’t
                               three dimensions (x, y and z), which means that you            remember the settings, so you’ll have to re-enter them
                               can use it to measure the orientation of the device in         each time you reboot. In order to add these
                               three dimensions. In other words, it tells you which           permanently, add the two lines to the .bashrc file in
                               way up the device is.                                          your home directory.
                                                                    First, though, you’ll       To create a Cordova project for the buggy run:

“Cordova’s Accelerometer                                          need to set up a
                                                                  Cordova environment
                                                                                              cordova create buggy
                                                                                              cd buggy
plugin should work on just                                        on your development         cordova platform add android

about every smartphone.”                                          machine. According to
                                                                  the Cordova
                                                                                              cordova plugin add org.apache.cordova.device-motion
                                                                                                We based our code on the watchAcceleration Full
                                                                  documentation, the          Example from http://cordova.apache.org/docs/
                               Accelerometer plugin should work on every phone                en/3.3.0/cordova_accelerometer_accelerometer.
                               that supports Cordova, which is just about every               md.html#Accelerometer. This provides everything to
                               smartphone (Amazon Fire OS, Android, Blackberry 10,            read the acceleration periodically, and the function
                               FirefoxOS, iOS, Ubuntu Touch, Windows phone 7 & 8,             onSuccess() is called when it’s successfully read.
                               Windows 8 and Tizen). We’ll look at Android here, and            Before getting into what we do with the
                               there are details of how to get started in the different       acceleration, let’s look at how we’ll lay out the screen.
                               environments on the Cordova website                            This is the code between <body> and </body>:
                               (http://cordova.apache.org/docs/en/3.4.0/guide_                IP address of Pi <input type=”text” name=”ip” id=”ippi”>
                               platforms_index.md.html#Platform%20Guides).                    <button onclick=”startMoving()”>Start moving</button>
                                  Cordova runs on node.js, so you’ll need to install          <button onclick=”stopMoving()”>STOP</button>
                               npm (the node package manager) from your distro’s              <button onclick=”getCamera()”>Get camera</button>
                               repositories. People using Ubuntu-based systems will           <div id=”sendingstring”>waiting to start</div>
                               need to add a PPA to get the most up-to-date version           <iframe id=”cam” width=100% height=600px></iframe>
                               of node for this.                                              <iframe id=”turnIframe” width=1px height=1px></iframe>
                                sudo add-apt-repository -y ppa:chris-lea/node.js                As you can see, there will be a text field to enter the
                               sudo apt-get update                                            IP address of the Raspberry Pi, and three buttons to
                               sudo apt-get install npm openjdk-6-jdk                         start controlling the motors, stop controlling the
                               sudo npm install -g cordova                                    motors, and start the camera feed. <div
                                 As well as Cordova, you’ll also need the Android             id=”sendingString”></div> will hold the URL that’s
                               Software Development Kit (SDK) from Google                     being sent to control the motors. This isn’t necessary,
                               (download this from http://developer.android.com/              but it’s useful to see what’s going on.
                               sdk/index.html). Once you’ve downloaded and
                               installed this, you’ll need to set up some environmental       Embed video
                               variables so that Cordova knows where to find                  Iframes enable you to embed web pages inside of
                               export PATH=${PATH}:/home/ben/adt-bundle-                      web pages. The first one (with the id ‘cam’) holds the
                               linux-x86-20140321/sdk/platform-tools:/home/ben/adt-bundle-    streaming video from the Raspberry Pi camera. The
                               linux-x86-20140321/sdk/tools                                   second one (with the id ‘turnIframe’) doesn’t actually
                                                                                              hold anything useful, but by changing its URL, we can
                                                                                              use it to create GET requests that control the motors.
                                                                                                 To make this work, you need three new JavaScript
                                                                                              functions that will run when the buttons are pressed:
                                                                                              function getCamera() {
                                                                                                document.getElementById(‘cam’).src = “http://” + document.
                                                                                              getElementById(‘ippi’).value;
                                                                                              }
                                                                                              function startMoving() {
                                                                                                window.piMoving=true;
                                                                                              }
That’s all it takes to build
                                                                                              function stopMoving() {
a simple robot: Linux on
the Raspberry Pi to power                                                                       window.piMoving=false;
the motors, and Linux on a                                                                    }
smart phone to handle the                                                                        The first of these just sets the URL of the cam
controls.                                                                                     iframe to the address of the streaming webcam



82                                                                 www.linuxvoice.com
                                                                                                      BUILD A MARS ROVER TUTORIAL

running on the Pi. Remember that we’ve removed the
title and resized the image to make it fit in here. The
rest of the controls are still there, so you can tune the
streaming image by scrolling down the iframe.
startMoving() and stopMoving()
set the variable window.piMoving to true or false.
This is just a global variable that we’ll use to control
whether the motor settings are sent to the Pi or not.
  You also need to update the onSuccess() function
(which runs every time it reads the acceleration) to:
  function onSuccess(acceleration) {
    var element2 = document.getElementById(‘sendingstring’);


   if (window.piMoving) {
       var motor1Prop = (acceleration.y + 10)/20;
       var motor2Prop = 1 - motor1Prop;
                                                                                                                                   We’ve used Cordova to
       var totalSpeed = acceleration.z * 10;                           The acceleration in each axis is returned as a
                                                                                                                                   create a phone app, but
       var motor1Speed = motor1Prop * totalSpeed;                   number between -10 and 10. The formula                         you could easily modify
       var motor2Speed = motor2Prop * totalSpeed;                   (acceleration.y+10)/20 returns a number between 0              the code to create a web
       sendString = “http://” + document.getElementById(‘ippi’).    and 1 depending on how far the phone is rotated. This          interface using sliders
value + “:8000/turn/?motor1=” + motor1Speed + “&motor2=” +          is then used as a multiplier for the speed of one motor.       or buttons to control the
 motor2Speed;                                                       The multiplier for the speed of the other motor is this        buggy.
       element2.innerHTML = sendString;                             value taken away from 1.
       document.getElementById(‘turnIframe’).src = sendString;         The overall speed is the acceleration in the z axis
   }                                                                multiplied by 10. This gives it the range -100 to +100
  }                                                                 (with negative values being backwards). This is the
  Although it’s not completely necessary, you can                   same range that the motors have. To get the final
increase the frequency with which the app updates                   speed for each motor, we just multiply that motor’s
the buggy’s speed by altering the frequency setting in              proportion by the total speed. This is quite a simplistic
the startWatch function. In the following example, it               method of calculating the speed, and the turn
updates it once a second, but you could set this to be              directions will go back to front if the phone’s held the
higher or lower.                                                    wrong way up. However, it works, and it’s easy to
  function startWatch() {                                           understand, so it’s good enough for our buggy.
    var options = { frequency: 1000 };                                 With the code ready, you just need to get it on to
    watchID = navigator.accelerometer.                              a phone in order to run it. Unfortunately, this can
watchAcceleration(onSuccess, onError, options);                     require a little fiddling with the Udev rules. There’s
  }                                                                 full information on the Android developer site here:
   The full code is on the Linux Voice website.                     http://developer.android.com/tools/device.html. You
   This calculates the speed for the two motors.                    can skip step 1 because Cordova will handle it for you.
acceleration.y is used to change the direction and                     Once this is set up, and the phone is plugged into
acceleration.z is used to change the speed. This                    your computer, you can compile and transfer it to the
works for holding the phone in landscape. With the                  phone. Enter the following in a terminal in the root
screen at right angles to the ground, the buggy will                directory of the app:
stop, and as you tilt the screen forward (so the screen             cordova build android
starts to face upwards), it will start to move. If you tilt         cordova run android
the screen back, the buggy will move backwards.                        As you can see, this isn’t a particularly elegant
Tilting the screen from side to side (as though it were             solution. Running two web servers is a little over the
a car steering wheel) will turn the buggy.                          top. It could have been re-written to do everything in
                                                                    one either by serving the video up from Python or by
                                                                    controlling the motors from PHP. The phone app
  Security
                                                                    could be more integrated rather than just serving up
  This robot is controlled via Wi-Fi with absolutely no security    an iframe of the webcam controller. However, this
  whatsoever. Anyone else on the network could quite easily         project isn’t about technical perfection, it’s about
  take over control. Normally this isn’t a problem on a local
                                                                    demonstrating how you can quickly and easily link
  area network, but there may be occasions where you want
  a bit more privacy. Tornado does handle security quite well,      things together to easily create complex robots by
  though it’s beyond the scope of this tutorial to go into it in    using the tools that are available on Linux.
  detail. Take a look at the documentation on the project’s
  website for guidance on this (www.tornadoweb.org/en/               Ben Everard is the co-author of the best-selling book on
  stable). Securing the video stream may be a little trickier, as    learning Python with the Raspberry Pi, Learning Python with
  it’s not really designed for it.                                   Raspberry Pi. He wrestles lions for fun.




                                                                      www.linuxvoice.com                                                                       83
     TUTORIAL BADGERCAM



                               RASPBERRY PI: MONITOR
          TUTORIAL
                               WOODLAND CREATURES
                               Set up a sturdy camera out in the woods and use Linux to take
     JON ARCHER
                               pictures of lions, tigers and bears.


                               A
                                        trail camera will capture images of wildlife that
 PARTS REQUIRED                         frequent a certain area, such as woodland.
 • Raspberry Pi                         These images, still or moving, can be captured
 • SD Card (bigger the         without the need of the photographer to be present.
   better)                     The camera either constantly records video or uses
 • Pi Camera                   motion detection technologies to trigger an image
 • Waterproof case with        capture. Off-the-shelf versions of these are expensive,
   see through area
                               don’t offer any option for customisation, and contain
 • USB Wi-Fi dongle
                               proprietary hardware and software.
 • USB rechargeable
   portable battery pack         A Raspberry Pi, with its fantastic range of hardware
                               and software options, is an ideal platform to create a
                               similar device with the potential to create your very
                               own wildlife videos and photographs. Although this           Components cost money, but the beauty of the Pi is that
                               project is geared towards building a Pi-based trail          everything can be re-used for your next project.
                               camera, there are many other situations where this
                               could potentially be deployed; it would also make a          date (sudo apt-get update; sudo apt-get upgrade).
                               simple security camera, for example.                         One more update we need to pull in is the latest
                                                                                            firmware for the Raspberry Pi. This includes the latest
                               Installation                                                 camera firmware, which is required by the
                               First, ensure your camera is connected to the Pi and         RaspiMJPEG camera control software. This can be
                               that you have a network connection for installation.         done by running sudo rpi-update.
                               Now we can install the OS and the required software.            It should be part of the Raspian install, but we also
                                  The central part of this project is a piece of software   need to ensure that Git isinstalled. This will be used to
                               called RaspiMJPEG (which is based on the MMAL                retrieve the software and scripts needed to complete
                               library) to control the Pi camera.                           this installation. Let’s confirm it is installed by running
                                  From the starting point of a base Raspbian install,       the command sudo apt-get install git. We can now
                               we can start up the Pi and use the configuration tool        start to install the components required to provide the
                               to increase the free space, ensure that SSH starts on        web interface, motion detection and live feed.
The box we used had an         boot and set the password for the Pi user. One other         Fortunately for us the majority of this is captured
IP rating of 65, which         vital step is to enable the Pi camera.                       inside a script created by Silvan Melchior, who also
essentially means it is nice      Once we have finished with the configuration tool         created RaspiMJPEG. Run the command:
and waterproof.                the next thing is to ensure that the system is up to         Git clone https://github.com/silvanmelchior/RPi_Cam_Web_
                                                                                            Interface.git
                                                                                              This will download the initial scripts for the install
                                                                                            along with some configuration files and pre-compiled
                                                                                            binaries (don’t worry – these are open source, just
                                                                                            pre-compiled to save time).


                                                                                              Using a cat5 for power and connection.
                                                                                              If cat5 were an option, then powering the Pi could be
                                                                                              achieved by using a power over Ethernet injection kit.
                                                                                              Also, if the cable is run over a considerable distance then
                                                                                              voltage drop must be taken into consideration. Therefore a
                                                                                              higher voltage power supply should be used and a voltage
                                                                                              regulator at the Pi side to ensure that it receives the
                                                                                              necessary 5V.
                                                                                                  The PVC box is one option for housing the project, but
                                                                                              the recently crowdfunded kickstarter campaign PiCE should
                                                                                              also do the job quite nicely.




84                                                             www.linuxvoice.com
                                                                                                                  BADGERCAM TUTORIAL


  Software used in this tutorial:
     Apache httpd with PHP for the web interface
     http://httpd.apache.org & www.php.net
     Motion, used for the motion detection
     www.lavrsen.dk/foswiki/bin/view/Motion/WebHome
     Raspimjpeg – to interface with the camera and output as
     image/video/stream
     www.raspberrypi.org/forums/viewtopic.php?t=61771


  You should see an output similar to:
Initialized empty Git repository in /home/pi/RPi_Cam_Web_
Interface/.git/
remote: Reusing existing pack: 161, done.
remote: Total 161 (delta 0), reused 0 (delta 0)
                                                                                                                               We were hoping to find
Receiving objects: 100% (161/161), 104.62 KiB, done.             This box was all good and safe, but there was no
                                                                                                                               badgers, but just got these
Resolving deltas: 100% (70/70), done.                            opening for cables or view area for the camera to see         deer. D’oh, a deer!
  A new directory will be created called Rpi_Cam_                out of. This is where a 45mm camera skylight lens
Web_Interface. In this directory resides a script that           and a hot glue gun came in handy.
will complete the rest of the installation. Use cd to               If your Pi is already in a plastic case then simply
move into the directory, and launch the script with              glue this to the deeper side of the PVC junction box,
./RPi_Cam_Web_Interface_Installer.sh install                     otherwise some M3 size nylon stand-off spacers
  This script will go away and install all the required          should be used to attach the board inside the box.
packages, of which Apache HTTPD, PHP and Motion                  You’ll need to drill a hole into the junction box where
are the most important.                                          the lens will be situated – ensure that when you
  Afterwards we have a couple of choices as to how               attach the lens a liberal amount of glue and or sealant
the software will start, if at all, on boot. For this tutorial   is used to ensure the box stays waterproof. Using one
we will have it automatically start with motion                  of the many available plastic camera mounts also
detection. For this we need to edit the file /etc/               helps with securing it inside the case with glue.
raspimjpeg, the last line of which contains the line                How you decide to power the device is all
motion_detection false                                           dependant upon the location you choose and the
Use your favourite text editor to change this value to           facilities available in that location. If your camera is to
true, then re-run the install script with the option             be situated in your garden or surrounding then laying
autostart_yes instead of install to set the software up          a cat5 cable inconspicuously may be an option with
to start on boot. That’s all there is to the install. There      some kind of power over Ethernet solution. Otherwise
is much that could be configured both within /etc/               the Pi can be powered using a battery pack such as
raspimjpeg or Motion, but for now we have a working              those used for emergency mobile phone charging,
system. Let’s reboot!                                            just make sure there is a reasonable capacity in the
   Launch your favourite web browser from another                batteries such as 10,000mAh. If a battery pack is
PC and you should be presented with a live image                 used then this must also be taken into consideration
from your camera with a series of buttons and a table            when deciding on an enclosure as extra room may be
of options underneath. If this is the case then our              required. The downside to running on batteries would
installation was a success.                                      be that a live view would only be available if the box
   Most of the buttons you see should be greyed out,             were be situated within the signal range of a wireless
with only the Motion Detection Stop button available.            router. Using wireless would also have a bearing on
At this point you can test the motion detection by               the battery drainage and time available.
waving an object in front of the camera; subsequently               For simplicity we will power the Pi using a battery
clicking on the Download Videos And Images link you              pack that will fit nicely inside the PVC box.
will see a video file listed.                                       We won’t go into the configuration of wireless
   Back on the RPi Cam control main page, the table              dongles as this varies slightly for each device and is
of options presents a multitude of configuration; from           well documented, but once you have this configured
here you can set image resolution, image quality,                and the battery pack fully charged, plug it into the Pi,
various levels of brightness, ISO, contrast etc.                 secure your box and place it where you expect to see
Experiment with these to find the best setup for you.            your target subject, then head back to your PC and
                                                                 watch the live feed through your browser. And don’t
Enclosure and powering the device                                forget to check the battery level regularly!
As the Raspberry Pi and its camera will be outdoors,
choosing a suitable enclosure is vital to ensure your Pi
                                                                  Jon Archer is a Free Software evangelist, Red Had
stays nice and dry. In our project we used a PVC
                                                                  ambassador and the founder member of RossLUG.
outdoor electrical junction box (150x110x70 mm).



                                                                   www.linuxvoice.com                                                                   85
     TUTORIAL SERVER HARDENING



                              SSH, APACHE & TIGER: MAKE
          TUTORIAL
                              YOUR SERVERS SUPER SECURE
                              Lock down your Linux installations for maximum security
MIKE SAUNDERS
                              and keep one step ahead of crackers.


                              B
                                      ruce Schneier, the well regarded American              Anyway, while most server-oriented Linux distros
 WHY DO THIS?                         expert on cryptography and computer                 are pretty secure out of the box, they still make
 • Stop bots and crackers             security, once said these wise words: “security     certain sacrifices for user-friendliness. In this tutorial
   getting easy access to
   your systems               is a process, not a product.” Keeping your servers safe     we’ll show you how to tighten key components in
 • Understand the             from malicious types isn’t just achieved by chucking        a server system, including OpenSSH and Apache,
   trade-offs between         on a few extra pieces of software, but by having            and demonstrate how you can mitigate potential
   security and               proper plans and procedures to deal with issues that        problems in the future with scanning tools and an
   convenience
                              come up. And security is a moving target – you might        intrusion detection system.
 • Re-use the skills you
   learn here when you        have your systems locked down and fully patched                In this case we’ll be using a vanilla installation of
   install distros in the     right now, but you never know what holes are going          Debian 7, as it’s arguably the most popular GNU/Linux
   future                     to be discovered in the future. Look at the OpenSSL         distribution used on servers, but the guides here will
                              Heartbleed mess, as an example…                             be applicable to other distros as well.


                                1   HARDENING OPENSSH
                              It’s absolutely imperative that we start with OpenSSH.         OpenSSH’s daemon (server) configuration file is
                              Why that’s? Well, it’s almost certainly the way you’ll be   stored in /etc/ssh/sshd_config, so you’ll need to edit
                              interacting with your server, unless you have the           that (as root) to make changes to the setup. The first
                              luxury of logging into it directly via a physically         thing to do is find this line:
                              connected keyboard and monitor. For headless                PermitRootLogin yes
                              servers, a good SSH setup is critical, because once            Change yes to no here to disable direct root logins
                              you have that out of the way, you can focus on the          via SSH. This immediately adds an extra layer of
                              other running programs.                                     security, as crackers will have to log in with a regular




A good Vim setup (see
last month’s cover feature)
provides syntax
highlighting for sshd_
config, making it easier to
read and edit.



86                                                            www.linuxvoice.com
                                                                                                    SERVER HARDENING TUTORIAL

user account and password first, and then know the
root password as well. (Warning: make sure you have
a regular user account on the system first, because
if you only have a root account, you can lock yourself
out by changing this!)
   Next, add a line like this to the configuration file:
AllowUsers mike graham ben
This restricts which users can log in via SSH; if you
have many accounts on the machine but only one or
two will log in, this is worth doing.
  Next, change this line:
Port 22
   22 is the standard SSH port, so it’s a good idea to
change this to something else (and make sure that
your router or firewall is also aware of the change
if you’ll be logging in from outside your network). A
random number like 1234 is fine here – it adds a bit of
“security through obscurity”. When you log in with the
ssh command now, you’ll need to add -p 1234 to the
end of the command.
                                                                 Here’s /var/log/auth.log (again with lovely Vim syntax highlighting) on a sample server,
                                                                 with the red lines showing root login attempts by bots.
Triple lock
Now, these three changes are useful enough on their
own, but together they add a major layer of protection              One enormously useful add-on for OpenSSH
against automated cracking scripts and bots. These               is Fail2ban. This is a program that monitors
are programs that attempt to break into your machine             unsuccessful login attempts; if a certain IP address
by repeatedly trying username and password                       fails to log in too many times, that IP is automatically
combinations, many times a second, until they get                blacklisted. This again adds more work for crackers
access. (If you have a net-facing machine with                   and bots, as they can’t keep trying to log in from
OpenSSH that has been online for a while, look in                the same IP address
/var/log/auth.log and you’ll probably see many login
attempts from IP addresses around the world.)
                                                                 and need to switch
                                                                 periodically.
                                                                                             “The default OpenSSH
   The default OpenSSH configuration means that                     On Debian it’s a         configuration means that bots
these bots don’t have to do much work: they know
that the root account is available, and they know to
                                                                 simple apt-get install
                                                                 fail2ban away, and it
                                                                                             don’t have to do much work.”
try on port 22. By disabling root access and switching           starts up automatically.
to a different port, the bots have to do a lot more              By default it automatically blocks IPs (using the
guesswork, trying random ports and usernames.                    system’s iptables command) for 600 seconds if they
If you have a strong password, this makes it very                have six failed login attempts. You may want to raise
difficult for a bot to gain access.                              the duration to something much longer, and also
   Once you’ve made your changes to /etc/ssh/sshd_               allow IPs a few more attempts – you don’t want to
config, you’ll need to restart the OpenSSH daemon:               make a few typos when entering your password and
service ssh restart                                              accidentally ban yourself!
                                                                    Fail2ban’s main configuration file is /etc/fail2ban/
                                                                 jail.conf. However, it’s a bad idea to edit that directly
  Passwordless authentication
                                                                 (as your changes could be overwritten by system
  While good passwords are hard to crack, you can make it        updates), so copy it to /etc/fail2ban/jail.local and edit
  almost impossible for nasty types to log in by disabling       that file instead. The bantime and maxretry options
  password authentication, and using public/private key          towards the top control the default settings we
  pairs instead. On the machine(s) you use to log in, enter      mentioned before, and you can also exempt certain
  ssh-keygen to generate the keys, then accept the defaults
  for the file locations and the blank password. (If you
                                                                 IPs from being banned in the ignoreip line.
  suspect someone else might get access to the machine              But hang on – maxretry here at the top has a value
  you’re using, you can set a password for the key.)             of three, yet we mentioned earlier that there must be
      Now enter ssh-copy-id followed by the hostname or IP       six failed login attempts for Fail2ban to take effect!
  address of the server; your public key will be transferred     This is because there’s a special “[ssh]” section further
  over to that server. Try logging in and you should see
  that you don’t need to specify a password any more.
                                                                 down that overrides the default settings. You’ll see
  If it all works, edit /etc/ssh/sshd_config, change the         that Fail2ban can be used with other services than
  PasswordAuthentication line to no, and restart OpenSSH.        SSH too. Once you’ve made you changes, restart the
  (And never give away your private key – it’s ~/.ssh/id_rsa!)   program like so:
                                                                 service fail2ban restart



                                                                   www.linuxvoice.com                                                                       87
     TUTORIAL SERVER HARDENING


                               2    HARDENING APACHE
                             The standard Apache web server configuration in
                             Debian is fairly secure and usable out of the box, but
                             can be made even tighter by disabling a few features.
                             For instance, try to access a non-existing URL in your
                             Apache installation, and at the bottom of the “404 not
                             found” screen that appears you’ll see a line like this:
                             Apache 2.2.22 (Debian) Server...
                                It’s best not to tell the world the exact version of
                             Apache you’re using. Vulnerabilities that affect
                             specific versions occasionally appear, so it’s best to
                             leave crackers in the dark about your exact setup.
                             Similarly, Apache includes version information in its
                             HTTP headers: try telnet <hostname> 80 and then
                             HEAD / HTTP/1.0 (hit Enter twice). You’ll see various
                             bits of information, as in the screenshot.                     Apache is telling the world its exact version details, both
                                To disable these features, edit the Apache                  in 404 pages and HTTP headers – but we can fix that.
                             configuration file; in many distros this is /etc/
                             apache2/apache2.conf, but in the case of Debian, its              This is an exceptionally powerful module that can
                             security-related settings are stored in /etc/apache2/          protect against SQL injection attacks, cross-site
                             conf.d/security, so edit that instead. Find the                scripting, session hijacking, trojans and other risks.
                             ServerSignature line and change On to Off, and then            After installation a configuration file is placed in /etc/
                             find the ServerTokens line and make sure it’s just             modsecurity/modsecurity.conf-recommended;
                             followed by Prod (ie the server will just say that it’s the    rename this and remove the -recommended part to
                             Apache “product”, and not give out specific version            activate it. The rules for detecting attacks are provided
                             information). After you’ve made the changes, restart           in /usr/share/modsecurity-crs/ – go there and have a
                             Apache with:                                                   look inside the base_rules, optional_rules and
                             service apache2 restart                                        experimental_rules directory. Each .conf file inside
                                Apache also tries to be helpful by providing directory      has some comment text explaining what it does, so if
                             listings for directories that don’t contain an index.html      you find something useful, copy (or symlink) it into the
                             file. This feature, provided by the Apache module              /usr/share/modsecurity-crs/activated_rules folder.
                             autoindex, could be abused by hackers to poke around              Next, you’ll need to tell ModSecurity to use these
                             in your system, so you can disable it with:                    rules. Edit /etc/apache2/mods-enabled/mod-
     PRO TIP                 a2dismod autoindex                                             security.conf and beneath the Include “/etc/
 ModSecurity is loaded
                                                                                            modsecurity/*.conf”” line, add these lines:
 with advanced features,     Status report                                                  Include “/usr/share/modsecurity-crs/*.conf”
 so visit www.modsecurity.   Another initially helpful (but risky on production             Include “/usr/share/modsecurity-crs/activated_rules/*.conf”
 org/documentation for
 all the details.
                             machines) module is status: this lets you go to                  Now restart Apache to activate the configuration.
                             http://<hostname>/server-status and get a bunch of             By default, ModSecurity only detects problems and
                             information about the configuration and performance.           doesn’t act on them, logging its work to /var/log/
                             In Debian it’s only possible to access this page from          apache2/modsec_audit.log. This gives you time to
                             the same machine on which Apache is running, but               see how the rules will affect your site (and if they
                             this may vary in other distros, so it’s wise to turn. it off   could break anything). When you’re confident with
                             unless you really need it using a2dismod status.               everything, make ModSecurity actively prevent
                                There’s a very useful module called ModSecurity,            exploits by opening /etc/modsecurity/modsecurity.
                             which you can grab with a quick:                               conf and changing the SecRuleEngine option from
                             apt-get install libapache2-modsecurity                         DetectionOnly to On. Finally, restart Apache.


                               3    HARDENING YOUR SYSTEM
                             So that’s two of the most commonly used server                 – an Intrusion Detection System, which keeps an eye
                             programs hardened: OpenSSH and Apache. What you                on critical system files and alerts you if they change.
                             do from here depends on your particular setup, eg              This is a good way to see if someone has gained
                             whether your server will primarily be used for email or        remote access to one of your machines and is
                             databases. Still, there are many other things you can          tampering with configuration files.
                             do to enhance the general security of your Linux                 Another useful program is an auditing tool. There’s
                             installation. It’s a good idea to use an IDS, for instance     a good one in Debian’s package repositories, called



88                                                              www.linuxvoice.com
                                                                                                       SERVER HARDENING TUTORIAL

Tiger, and although it hasn’t been updated for a while,
it’s still useful for finding holes in your setup. Run:
apt-get install tiger
  Doing this will also install Tripwire, the IDS we’ll be
using. Once the packages have been downloaded
                                                                                                                             Tiger gives a good
you’ll be prompted for two passwords; these are                                                                              overview of potential
used to protect two keys that will be used to protect                                                                        security flaws in your
configuration files (after all, auditing and file checking                                                                   setup, and the tigexp tool
tools aren’t much use if they can also be easily                                                                             provides more detailed
exploited). Enter something memorable, and once the                                                                          descriptions.
configuration has finished, enter:
tiger -H                                                        when you installed Tiger earlier.) To see that the
   This will start an extensive security scan of the            database works, edit a file in /etc – you could add a
system, and might take a few minutes depending on               comment to /etc/rc.local for instance. Then run:
the speed of your machine. (Don’t be alarmed if your            tripwire --check > report.txt
hard drive thrashes a lot during this procedure!) At              Now look in report.txt and do a search for “rc.local”
the end, Tiger will generate a HTML file and show you           (or the file you changed). You’ll see something like this:
exactly where it is stored in /var/log/tiger/. Open it up       Modified:
(you could use the brilliant text-mode Elinks browser           “/etc/rc.local”
if you’re logged in via SSH) to get a comprehensive                Nice and simple – it tells you exactly which files
report that lists potential risks in your system.               have changed. At the start of the report you’ll see a
   These include: file permission problems; processes           useful summary as well. There’s one problem in the
listening on network sockets; poor configuration file           default setup, though: Tripwire monitors /proc, and
settings; accounts without valid shells; and more.              as that’s constantly changing (because it contains
Tiger uses checksums to see if system files have                information about running processes), it clogs up
changed after their initial installation, so if an intruder     the report with unimportant text. To fix this, we need
puts a trojan in a binary in /sbin, for instance, Tiger         to change the Tripwire policy that defines which
will tell you in the report that it differs from the original   directories it should monitor. Edit /etc/tripwire/twpol.
packaged version.                                               txt and find this line:
   Every warning is accompanied by a code such as               /proc -> $(Device) ;
acc022w. To get a detailed description of the warning,            Delete this line and enter the following to update the
enter this as root:                                             policy database:
tigexp acc022w                                                  twadmin --create-polfile /etc/tripwire/twpol.txt
  It’s very helpful, as it often suggests fixes as well.           Now we need to rebuild the filesystem database,
See the manual page for Tiger (man tiger) for other             so go into the /var/lib/tripwire directory and remove
report formats and extra options.                               the .twd file contained therein. Run tripwire --init and
                                                                generate a report, and you’ll see that /proc is no longer
Advanced file checking                                          included in the report.
While Tiger is useful for checking executables against             Have a more detailed look inside /etc/tripwire/
their original packaged versions, Tripwire goes a lot           twpol.txt to see what Tripwire can do, including
further and lets you spot changes all over the                  different types of warnings for different directories. If
filesystem. To set it up, enter:                                you make a change to a system file and don’t want
tripwire --init                                                 Tripwire complaining in every report, you’ll need to
  This creates a database of file information that              update the database. In /var/lib/tripwire/report, find
will be used when you perform a check. (You may                 the most recent report (eg with ls -l). Then run:                 PRO TIP
be prompted for one of the passwords you specified              tripwire --update --twrfile <report>                          If you’d like us to run
                                                                  Replace <report> here with the most recent version.         a separate tutorial on
                                                                                                                              hardening another piece
                                                                The report will open in a text editor, and as you scroll      of server software, drop
                                                                down, you’ll see changed files listed like so:                us a line at
                                                                [x] “/etc/rc.local”                                           letters@linuxvoice.com.
                                                                   This means that the file is selected for updating in
                                                                the database, so you won’t be warned about it next
                                                                time. (If you still want to be warned about that file,
                                                                remove the x.) Save the file and exit the editor, and
                                                                after the next --check command you’ll see that the
                                                                complaint is gone.

                                                                 Mike Saunders is the author of The Haynes Linux Manual,
                                                                 writer of the MikeOS assembly language operating system
Tripwire can monitor any directory on your system, and give
                                                                 and has been messing with Linux since 1998.
you an instant report listing any files that have changed.



                                                                  www.linuxvoice.com                                                                     89
     TUTORIAL VIRTUALBOX



                              VIRTUALBOX: CONVERT AN XP
          TUTORIAL
                              BOX INTO A VIRTUAL MACHINE
                              Ease the move to Linux by bringing your old Windows
  MARK CRUTCH
                              XP machine with you.


                              O
                                       n 8 April this year Microsoft issued its last     destination machine is a Linux box, you can use this
 WHY DO THIS?                          update for Windows XP, leaving it vulnerable      same method to migrate your old system to a virtual
 • Keep hold of your old XP            to future security exploits. Despite months of    machine running on a MacOS host, or even another
   installation
                              advance warning there are still millions of machines       version of Windows if you really want to.
 • Save £5.5m in support
   costs                      running this now obsolete operating system. Although
 • Move to Linux without      this may seem like a perfect opportunity to migrate to     Gather your hardware
   the risk of losing XP      Linux, many users are still reticent to give up on their   Before starting our migration, it’s worth noting a few
   functionality              old machines. One way to overcome this inertia is to       hardware requirements. Virtual machines can quickly
                              convert the old Windows box into a virtual machine         eat into available memory, drive space and processing
                              (VM) that will run inside the new Linux system,            power, so a capable host machine is a must. Take a
                              providing the reluctant user with a digital security       look at the old XP machine to determine how much
                              blanket to cling to.                                       memory it has, and how much of the hard drive is in
                                 The real aim is to reduce the number of XP systems      use, then ensure that the host has sufficient spare
                              that are connected to the internet: every machine          capacity to cover both the virtual machine and its own
                              taken offline is one less that can host malware or         day to day usage. A large USB hard drive will also
                              participate in a denial of service attack. With that       make things a bit easier, although it’s not essential as
                              in mind we’ll not only convert the physical box to         long as you can move large files around using a
                              a virtual one, but also include a few tips to ease         network connection.
                              the move to Linux and reduce the need to boot the             The Windows licence is probably tied to the old
                              Windows VM or put it online.                               physical machine, so strictly speaking you should
                                 We’ll be migrating a Windows XP machine, but the        keep the hardware for as long as you have the
                              same approach also works with Vista and Windows            virtual machine. You’ll probably need the Windows
Disk2vhd was written to
create disk images for        7. Due to hardware differences, licensing rules and        Product Key from the sticker on the old box, but if
Microsoft’s own VirtualPC     various OEM flavours of Windows, not every machine         that’s too faded to read there are programs available
program, but it works just    will migrate using this approach – but we’ve had           that can extract the product key from a running
as well with VirtualBox.      far more successes than failures. Although our             Windows system. Although Microsoft’s anti-piracy
                                                                                         restrictions can sometimes cause problems, most
                                                                                         XP machines migrate relatively smoothly. There are
                                                                                         no guarantees, though, especially with XP Home and
                                                                                         OEM installations, so don’t go spending lots of money
                                                                                         on extra RAM and a bigger hard drive until you’re sure
                                                                                         the migration will be a success.

                                                                                         Clone your hard drive
                                                                                         We’ll start the migration by creating a disk image that
                                                                                         we can use directly in VirtualBox. There are a variety of
                                                                                         ways to do this, but for this tutorial we’ll be using
                                                                                         Disk2vhd on the Windows box. This can be
                                                                                         downloaded free of charge (http://bit.ly/18b9O1i),
                                                                                         but remember that we’re trying to keep the XP
                                                                                         machine off the internet, so it’s probably best to
                                                                                         download the file using another machine and then
                                                                                         copy it to the XP box via a USB drive. Unzip the file,
                                                                                         enter the directory, and double-click on the EXE file to
                                                                                         run it.
                                                                                           Once you’ve accepted the EULA you’ll be presented
                                                                                         with the Disk2vhd dialog. The controls always seem
                                                                                         to be in the wrong order, in our opinion, and we usually
                                                                                         approach them from bottom to top. First, therefore,



90                                                           www.linuxvoice.com
                                                                                                             VIRTUALBOX TUTORIAL

is the Volumes To Include panel, which lists all the
drive partitions that XP knows about. Ensure that
the partitions on the internal drive are checked, and
that any partitions on the USB drive are unchecked. If
you have multiple physical drives in the machine it’s
probably best to export each of them separately – all
the partitions for the first drive into one file in the first
pass, then run the program again to export all the
partitions for the second drive into another.
   Moving up the dialog we get to the VHD Filename.
Use the button on the right to browse to your USB
disk. If necessary you can use the internal drive for the
file destination, but performance will suffer, and you’ll
need at lot of free space. Finally, confirm the state of
the two checkboxes at the top of the dialog: we want
to create a plain VHD file, so uncheck the Use Vhdx
option; we do, however, want to check the Use Volume
Shadow Copy option, which utilises a feature built into
XP and later versions of Windows to snapshot the
hard drive for imaging. This is especially vital if you’re
creating the file on the source drive.
   With all the options set, it’s time to click on the
Create button and leave it working for a while. How
                                                                                                                           While you’re at the
long will depend on the amount of data and the speed            www.virtualbox.org/wiki/VirtualBox_PUEL) if you’re
                                                                                                                           VirtualBox website, make
of the machine and the drives, but it typically takes           using it for anything other than inarguably personal or    sure you also download the
hours rather than minutes.                                      academic reasons.                                          extensive user manual.
                                                                   The extension pack adds various features to the
Prepare VirtualBox                                              base VirtualBox system, the most notable being USB
While the XP box is being imaged, we can take the               2.0 support. If you’re migrating XP to support a printer
time to install and configure VirtualBox on the host.           or other USB hardware that has poor Linux drivers
Most distros’ repositories tend to lag some way                 this might be an important consideration – although
behind the official release, so we’ll download it directly      VirtualBox’s USB support isn’t perfect, especially when
from the VirtualBox website (https://www.virtualbox.            dealing with esoteric drivers, so make sure you test           PRO TIP
org/wiki/Linux_Downloads). The top of the                       the final system thoroughly.                                To prevent XP connecting
downloads page has links to DEB and RPM files, but if              Installing the extension pack is as simple as            to the internet, uncheck
                                                                downloading it from the link on the VirtualBox              the Cable Connected
you scroll down a little you’ll find instructions for
                                                                                                                            option in the VirtualBox
installing from the VirtualBox repositories.                    download page (https://www.virtualbox.org/                  network settings so that
   The core of VirtualBox is licensed under the GPL,            wiki/Downloads), then opening it with the main              Windows simply thinks
                                                                VirtualBox application. If your desktop has a suitable      the Ethernet lead has
but there’s an additional commercial extension
                                                                                                                            become unplugged. That
that you’ll probably want to use. This is licensed              file association set up you’ll probably be offered the      way, should you find you
under Oracle’s own “PUEL” licence, which allows                 option to open with VirtualBox when you download            have to connect to the
for personal, academic and evaluation use at no                 the file; otherwise you can manually add it via the         network in future, you can
                                                                                                                            just re-check that option
charge. Note that “personal use” includes using it in           File > Preferences > Extensions panel in the main           to reconnect the virtual
a commercial setting if you’ve installed it yourself,           VirtualBox manager.                                         cable.
but do check the wording of the licence (https://                  With VirtualBox installed we’re going to create a
                                                                new VM. At this time it won’t have a hard drive – that’s
                                                                probably still being imaged – but we can get the
                                                                rest of the machine in place. Start by launching the
                                                                VirtualBox manager and clicking the New button to
                                                                bring up a wizard.
                                                                   Give your VM a name: this will also be used as
                                                                a directory name for holding your machine’s files.
                                                                Ensure that you pick the values for Type and Version
                                                                that correspond to the machine you’re migrating. In
                                                                our case that’s Microsoft Windows and Windows
                                                                XP, respectively, but if your source machine is one of
                                                                those rare beasts that’s running the 64-bit version of
                                                                XP you’ll need to pick that specifically.
Either your desktop is using a theme with black text on a          On the next page of the wizard you’ll need to set
black background, or you’ve got the wrong HAL.                  the size of the virtual machine’s memory. If you can



                                                                  www.linuxvoice.com                                                                     91
     TUTORIAL VIRTUALBOX


  Accessing your Windows files
  If you want to copy files from your Windows             of the virtual machine – or use the lower-level         command as root (or prefix with sudo if your
  machine to the Linux host, the simplest approach is    Samba tools if your desktop environment doesn’t         distribution needs it), replacing the VDI file and the
  probably to just attach a USB drive to Windows via     understand the SMB:// URL syntax.                       ~/Windows mount point as appropriate:
  the VirtualBox Devices menu, copy the files, detach         One problem with all of these file transfer          guestmount -a Windows_XP.vdi -i --ro -o allow_other ~/
  it from VirtualBox to make it available to Linux and   methods is that they require the Windows machine        Windows
  then copy the files back off it into the host.          to be running. If all you want to do is get some           To unmount the disk image when you’re finished
      That’s fine for a one-off transfer, but for more    files out of the Windows drive, there are various        with it, use:
  frequent use you can set up a file share within XP      ways to mount the VM’s disk image directly as a         fusermount -u ~/Windows
  using Windows’ own SMB protocol, which can then        block device in the Linux filesystem. We’ve had             Although these are run as root, the -o allow_other
  be mounted on your Linux host. VirtualBox also         most success with the guestmount command line           FUSE option lets any user access the files, so you
  has a Shared Folders pane in the VM’s settings         tool, which mounts the drive using FUSE and is          can copy files out of the Windows drive and into the
  dialog that will let you share host folders with the   available in the repositories of most mainstream        Linux environment as a regular user. Despite both
  Windows machine in a similar way, enabling you to      distributions. A word of warning: on our Linux Mint     the VDI file and the mount point being owned by our
  “push” files to the Linux box from within XP. In our    system we also had to install libguestfs-tools to get   normal user account, we have to use sudo on our
  experience it’s usually easier to share a Windows      it working, which in turn pulls down a lot of files.     Mint box for this approach to work. If anyone has
  folder, then connect using Nautilus, Dolphin or            Using guestmount you can mount your Windows         any tips on getting guestmount to work as a regular
  Caja with the SMB protocol and the IP address          drive in read-only mode with the following              user, please post them to the Linux Voice forums.



                                   spare it, allocate the same amount as is present in the              to add a hard disk (check the tooltips to distinguish
                                   physical source machine. The third page is where we’ll               between the two small icons, if it’s not clear which
                                   tell VirtualBox that we don’t want a hard drive, and                 one represents a hard disk). In the resultant dialog you
                                   then finally create our new machine – but not until                  should select Choose Existing Disk, then pick your
     PRO TIP                       VirtualBox has offered a final warning about our lack                VHD file from the VM’s directory.
 Once the main migration           of a disk.                                                              We’re close to starting our virtual machine, but it’s
 is working you may wish              Congratulations: you now have a half-imaged                       worth taking a couple of minutes to step through the
 to clone your VHD file
 into VirtualBox’s native          physical machine and a disk-deprived virtual machine.                other settings pages. If you’ve installed the VirtualBox
 VDI format, as it’s likely        Take a well-earned break while the imaging chugs its                 extension pack then it’s worth checking that USB 2.0
 that the code for its own         way to completion.                                                   is enabled. We also like to enable the Remote Display
 format is better tested
 and more robust. Select                                                                                option, which lets you access the screen of your
 the File > Virtual Media          Add the virtual hard drive.                                          running VM from another machine using a remote
 Manager menu in the               With the imaging process over, you should now find a                 desktop client such as Reminna or Rdesktop. On the
 VirtualBox Manager, then
 release your VHD file              large VHD file on the USB drive. Copy any other files                Advanced tab of the General Settings panel it’s usually
 from the VM. Copy it to a         that you want off the XP box, then finally shut down                 worth enabling the Shared clipboard feature. Set it to
 dynamically allocated VDI         the physical machine forever (hopefully). Mount the                  bidirectional to let you copy and paste text between
 file, then attach it to the
 Windows machine via the           USB drive on the host machine, and copy the VHD file                 the Linux host and the virtual machine. We tend to use
 Settings dialog. Check            into your new virtual machine’s directory. Unless you                the Description tab in the same panel to hold a copy
 that it works, then delete        specifically chose otherwise it’s probably in a folder               of the Windows Product Key, to save me rummaging
 the VHD file.
                                   called VirtualBox VMs in your home directory.                        around the loft for the physical box if I need to enter it
                                      Return to the VirtualBox manager and select your                  in future.
                                   XP VM in the list on the left. Click the heading of the                 One final thing to set up is networking. We don’t
                                   Storage section in the right-hand panel to open the                  really want this machine on the internet, but you’ll
                                   VM’s settings dialog with the storage page showing.                  probably want it connected during its first boot to
                                   Select the IDE controller and click on the small icon                deal with Windows’ activation requirements. On the
                                                                                                        Network panel, enable the first adaptor, and choose
                                                                                                        NAT from the first pop-up menu. Ensure the Cable
                                                                                                        Connected setting is checked.
                                                                                                           With all that done it’s time for the big moment.
                                                                                                        Close the settings dialog, ensure the XP VM is
                                                                                                        selected on the left, click the Start button in the
                                                                                                        VirtualBox toolbar, and watch your new virtual
                                                                                                        machine boot…

                                                                                                        I’m sorry, Dave. I’m afraid I can’t do that.
                                                                                                        If you’re very lucky you’re now sitting in front of a
You’ve changed your
                                                                                                        VirtualBox window showing the XP login screen, or a
hardware. Pirates
sometimes change their                                                                                  Windows activation screen. More probably you’re
hardware. Ergo, you are                                                                                 looking at a black window, with the icons in the
a pirate until you prove                                                                                VirtualBox status bar showing no disk or network
otherwise                                                                                               activity. You’ve just been halted by HAL.



92                                                                    www.linuxvoice.com
                                                                                                              VIRTUALBOX TUTORIAL

    HAL is the Hardware Abstraction Layer, a system
component in Windows that exists as a number of
different variants. The exact version that is on a given
machine depends on the hardware that was present
when Windows was installed. A mismatch between
the installed HAL and the fake hardware presented by
VirtualBox is the most common reason for a failure
to boot at this time, and manifests itself as the VM
hanging on a black screen during the boot process.
    The solution to this predicament is to fix the
mismatch between the HAL and the hardware, either
by changing the HAL or by changing the emulated
components of the machine. Most instances of this
problem can be solved by shutting down the VM,
opening the System panel of the settings dialog, and
setting the Enable IO APIC option. Start the VM once
more, and usually the machine will boot as expected.
    If you’re one of the unlucky few for whom this little
checkbox doesn’t fix the boot problem, you’ll have
                                                                                                                           Now that XP is virtualised
little choice but to change the HAL. That process           mouse to the VirtualBox menu and choose Devices >
                                                                                                                           it can be easily moved to
falls outside the scope of this tutorial, but there’s       Install Guest Additions. If you can’t get the mouse to         new hardware in future.
lots of information online about the process. Most          leave the Windows environment, tap the VirtualBox              This ageing OS is now
techniques involve replacing the HAL on your running        host key. Guest Additions is a collection of drivers that      more immortal than ever!
Windows installation, so you’ll probably find that you      enable your virtual machine to work more efficiently
have to make the change on the physical XP box              with the VirtualBox host. It appears as a CD-ROM
and then re-image the hard drive to create a fresh          in the Windows environment, so if it doesn’t auto-
VHD file. Bear in mind that changing the HAL can            run, launch the installer manually by running the
result in an un-bootable system, so you might want          VBoxWindowsAdditions.exe from the CD drive.
to consider making a full disk image of the machine            During the Guest Additions installation it’s likely
using something like dd or Clonezilla before you start      that the Windows screen will go black a couple of                   PRO TIP
messing around with Windows’ system files.                  times, and you’ll be warned about the drivers not               If you need to use
                                                            having passed through Windows Logo certification.               a file share or other
Final steps                                                 Just select the option to continue. Finally you’ll be           network server on your
                                                                                                                            XP machine, consider
Once you’re able to boot the Windows VM, you’ll             prompted to reboot, and once you’ve done that you’ll            the Host Only network
probably get to a familiar looking login screen. Avoid      have a far wider choice of resolutions available to you.        mode in VirtualBox, to
the temptation to press Ctrl+Alt+Del, even if Windows       You can decide whether to run your XP system in                 only allow a connection
                                                                                                                            between the VM and the
claims you need to. Doing that will send the keystrokes     full-screen mode (Host key+F), or leave it in a window.         host. You need to add
to the Linux host first, possibly shutting it down.         If you opt for the latter, resizing the window will cause       a network in the main
Instead you need to send the keys to the XP box inside      the Guest Additions to automatically resize XP’s                VirtualBox Preferences
                                                                                                                            dialog, then you’ll be able
the VM, either by choosing the option from VirtualBox’s     virtual monitor to suit.                                        to set Host Only mode in
Machine menu, or by pressing the VirtualBox “host”             You should now have a working, virtualised copy              the Network pane of the
key (usually the Right Ctrl key) plus Delete.               of your old Windows XP machine. Most applications               VM’s settings.
   Given that we’ve essentially replaced the machine’s      won’t notice the difference, although some versions
motherboard, Windows is almost certain to throw             of Microsoft Office will also prompt you to reactivate
up a prompt telling you that you need to activate the       them, though quite why a userland program should
machine. The easiest way to do this is online, and          care that you’ve replaced your motherboard is another
this is the one part of this tutorial where I’m going to    matter entirely. 3D games or anything that expects to
recommend actually putting your XP box back onto            talk directly to hardware may have issues, so make
the internet. Choose to activate over the internet and      sure you test the machine thoroughly, but for a lot of
be ready with your Product Key in case it’s requested.      users this solution will be good enough to help them
If you have problems activating over the internet there     move to a different OS while still being able to fall back
is also an option to telephone customer services.           to their old Windows system when they absolutely
We’ve never had to take this approach, but if you do        have to. Just remember that virtualising an old box
end up talking to a real person it’s probably best to       may make it more convenient to access, but doesn’t
avoid mentioning virtual machines and instead just          make it any safer: it’s still an obsolete system and you
tell them that you’ve replaced your motherboard.            still need to keep it off the internet.
   You should now be at a small Windows desktop,
probably being pestered with the Found New                   Mark Crutch has been a Linux user for 20 years, and has
Hardware wizard. Cancel each wizard that pops up             written occasional articles about electronics and computing
                                                             in a variety of magazines for almost as long.
until you’re back to just the desktop, then move your



                                                              www.linuxvoice.com                                                                          93
     TUTORIAL VON NEUMANN, EDVAC, AND THE IAS MACHINE



                           JOHN VON NEUMANN,
         TUTORIAL
                           EDVAC, AND THE IAS MACHINE
                           The Linux Voice time machine takes us back to one of computing’s
     JULIET KEMP
                           eureka moments: the von Neumann architecture.


                           J
                                   ohn von Neumann was born in Hungary in              Von Neumann consulted on both the ENIAC and
                                   1903. He was a prodigy, publishing two major     EDVAC projects. The initial design of the ENIAC, the
                                   mathematical papers by the age of 19. After      first programmable general-purpose computer, did not
                           teaching at the University of Berlin, in 1930 he was     include the ability to store programs, and while it was
                           invited to Princeton University in the US, and later     programmable and Turing-complete, the
                           joined the Institute for Advanced Study there. During    programming was done by manipulating switches and
                           this time he contributed to several branches of maths,   cables. (Colossus was programmed similarly, but was
                           including set theory, game theory, quantum               not general-purpose, being dedicated to cryptanalysis.)
                           mechanics and logic and mathematical economics.          ENIAC used an immense number of vacuum tubes to
                              During the late 1930s, he worked on modelling         both store numbers and calculate, and punch cards
                           explosions, which led to his involvement in the          for input and output. It was developed to run artillery
                           Manhatten Project. He is also credited with developing   calculations, but due to the involvement of von
                           the strategy of “mutually assured destruction” which     Neumann and Los Alamos, in the end the first
                           drove the Cold War. (In game theory, mutually assured    calculation it ran was computations for the hydrogen
                           destruction is an equilibrium, in which neither player   bomb, using around a million punch cards.
                           has the incentive either to act or to disarm.)
                              Von Neumann was also heavily involved in early        EDVAC and the First Draft of a Report
                           computing, partly because the work he was doing on       The EDVAC was proposed by the inventors of ENIAC,
                           the hydrogen bomb required vast and complex              Mauchly and Eckert, in late 1944 – before the ENIAC
                           calculations. These were done initially by human         was fully operational, but using improvements
                           computers – women using desk calculators to run          thought of while building it. EDVAC, like ENIAC, was
                           the calculations required, on a production-line basis.   built for the US Army’s Ballistics Research Laboratory
                           During 1943 they began to use IBM punched-card           (at the Aberdeen Proving Ground). Although it hadn’t
                           machines, which worked at roughly the same speed         yet been built, von Neumann’s famous First Draft of a
                           but didn’t need sleep. (A single calculation problem     Report on the EDVAC was written (by hand while
To run the emulator on
Linux and study von        took three months, which Richard Feynmann reduced        commuting to Los Alamos by train) in June 1945.
Neumann’s programming      to three weeks by running cards in parallel on the          The Draft Report contains the first published
methods, you will need     machines.) These machines, however, weren’t              description of the logical design of a stored-program
Java version 5 or later.   programmable computers; they were just calculators.      computer, specifically the design that is often now
                                                                                    known as the Von Neumann architecture and which is
                                                                                    still widely used today. However, there is controversy
                                                                                    over the extent to which this was solely von
                                                                                    Neumann’s work.
                                                                                       Some of the EDVAC team maintained that the
                                                                                    concepts arose from discussions and work at the
                                                                                    Moore School (where EDVAC was designed) before
                                                                                    von Neumann began consulting there. Other
                                                                                    documents suggest that Eckert and Mauchly had
                                                                                    already thought of the idea of a ‘stored program’, but
                                                                                    they hadn’t fully outlined a design.
                                                                                       The First Draft of a Report on the EDVAC was,
                                                                                    indeed, a first draft. It was intended as a summary
                                                                                    and analysis of the logical design of the proposed
                                                                                    EDVAC, with further extensions and suggestions from
                                                                                    von Neumann. In it, von Neumann recommended that
                                                                                    the computer have a central control unit to control all
                                                                                    operations, a central processing unit to carry out
                                                                                    operations, and a memory that could store programs
                                                                                    and data and retrieve them from any point (ie random



94                                                       www.linuxvoice.com
                                                    VON NEUMANN, EDVAC, AND THE IAS MACHINE TUTORIAL

access, not sequential access). He also                                                                             Von Neumann invented
recommended that EDVAC have a serial, rather than a                                                                 cellular automata.
parallel, processor, as he was concerned that a parallel                                                            Turing invented parts
processor would be too hard to build.                                                                               of mathematical
                                                                                                                    biology. These days,
   Unfortunately (and apparently without von
                                                                                                                    cellular automata are
Neumann’s knowledge), Goldstine distributed the First
                                                                                                                    at the forefront of our
Draft with just his and von Neumann’s names on it,                                                                  investigations into
and without any credit given to Eckert and Mauchly.                                                                 mathematical biology –
(From the gaps in the report, it is likely that von                                                                 and those investigations
Neumann intended to insert further credits before                                                                   rely on the computers that
‘proper’ publication.) Goldstine likely only meant to                                                               Turing and von Neumann
share the ideas as quickly as possible, but it had the                                                              put so much work into.
unfortunate effect of linking this architecture with von
Neumann alone, rather than with the whole group of
people who had been working on it.
   When EDVAC was in due course built, it had a
computational unit that operated on two numbers at
a time then returned the results to memory, a
dispatcher unit which connected this to the memory,
three temporary operational tanks, nearly 6,000
vacuum tubes, and a mercury delay line memory of
1,000 words (later 1,024 words). It read in magnetic        depending on whether there was a ‘dot’ or a ‘dash’
tape. It finally began operation in 1951, by which time     stored there. A metal pickup plate over the tube
von Neumann had moved back to IAS; not only that,           detects the voltage pulse and passes the data out to
but the Manchester Mark I team in the UK (who were          the next part of the memory system and ultimately to
later joined by Turing) had beaten them to the post of      the control unit. The act of reading the memory also
developing the first stored-program computer, running       wipes it, so it must immediately be rewritten; and as
their machine for the first time in June 1948.              the charge well fades quickly, the whole thing must
                                                            also be frequently rewritten. The advantage, though,
The IAS Machine                                             over mercury delay lines was that as the beam could
Meanwhile, in 1946, von Neumann wrote another               point at any location immediately, memory was
paper, “Preliminary Discussion of the Logical Design of     entirely random-access. With mercury lines, you had
an Electronic Computing Instrument”, which further          to wait until your data word came around to the
developed his ideas. The IAS machine was the                output of the line before you could read it.
embodiment of those ideas.
   One of the big differences between the IAS machine       Von Neumann architecture
and EDVAC was that the IAS machine had a parallel           The crucial point about the ‘von Neumann’
processor. Words were processed in series, but the          architecture was that it combined both instructions
bits in each word were stored and operated on in            and data in a single memory. This meant that you
parallel. This shows how fast the technology was            could, for example, implement a loop by modifying
moving -- in the report on EDVAC in 1945, von               stored instructions. Unfortunately this also has the
Neumann thought that a parallel processor would be          effect that all operations are using the same memory,
too difficult to build, so recommended a serial             so the machine cannot fetch an instruction and act on
processor. By the time IAS machine project started in       data at the same time. This came to be known as the
May 1946 (or possibly soon after, while they were           von Neumann Bottleneck. The alternative, the Harvard
working on the design), von Neumann had become              Architecture (originating with the Harvard Mark I),
convinced that parallel processing could work.              separates data and instruction storage. Most modern
   The IAS machine itself used a 40-bit word (with two      computers use von Neumann architecture for main
20-bit instructions per word), with a 1024-word             memory, but a modified Harvard architecture is used
memory and two general-purpose registers. Unlike            for some caches and in some other situations.
many other early computers, it was asynchronous,               The IAS had five main parts: Central Arithmetic
with no clock regulating instruction timing. Instructions   (which performed arithmetic operations), Central
were executed one after the other. It used vacuum           Control (which passed information between CA and
tubes for its logic, and Williams tubes (cathode ray        memory), Memory, Output, Input, and the recording
tubes) for its memory, known as the Selectron.              medium (magnetic tape, initially). It had seven
   Cathode ray memory relies on the fact that when a        registers, three in the CA and four in CC:
dot is drawn on a cathode ray tube, the dot becomes         Central Arithmetic
positively charged and the area around it negatively          AC Accumulator.
charged. When the beam is next pointed at that                MQ/AR Multiplier/Quotient register (aka Arithmetic
location, a voltage pulse is generated, which will differ     Register).



                                                              www.linuxvoice.com                                                            95
     TUTORIAL VON NEUMANN, EDVAC, AND THE IAS MACHINE

                                                                                  coding for yourself. Download the Zip file, unpack it,
                                                                                  and cd into the folder. This command will launch the
                                                                                  emulator in its own window:
                                                                                  java -cp IASSim2.0.4.jar:jhall.jar:IASSimHelp2.0.jar iassim.Main
                                                                                  -m
                                                                                  IAS.cpu
                                                                                     You can load in an assembly language text file from
                                                                                  the File menu, and there is a tutorial and online help
                                                                                  available from the Help menu.
                                                                                     The folk who wrote the emulator have also written a
                                                                                  basic assembler for it, to make life a little easier. For
                                                                                  this first example I’ll use the assembler as little as
                                                                                  possible, to give you the best flavour of the IAS
                                                                                  machine’s language. Open up a new text file in the
                                                                                  emulator and enter this (without the line numbers):
                                                                                  0. S(x)->R 10 ;       load working number into AR
                                                                                    S(x)*R->A 10 ;      multiply working number by AR
                                                                                  1. R->A      ;        move AR into AC
                                                                                    At->S(x) 12 ;       save AC in location 12
                                                                                  2. S(x)->Ac+ 10 ;     load working number into AC
Using a little more
                         MDR Memory Data Register.                                  S(x)->Ah+ 11 ;      add one to working number
assembly language
makes coding loops    Central Control                                             3. At->S(x) 10 ;      store incremented working number
straightforward.         IBR Instruction Buffer Register.                           S(x)->R 10 ;        and start again!
                         IR Instruction Register.                                 4. S(x)*R->A 10
                         PC Program Counter.                                        R->A
                         MAR Memory Address Register.                             5. At->S(x) 13 ;      but save in location 13 this time
                         The IAS instructions took the form of “8-bit               S(x)->Ac+ 10
                      operation code” + “12-bit memory address” (the              6. S(x)->Ah+ 11
                      memory address was ignored if the instruction did not         At->S(x) 10
                      need it). So the instruction S(x)->R 010 meant “load        7. .empty
                      the number at Selectron location x into the Arithmetic        .empty
                      Register; location x is 010”. The available instruction     8. .empty
                      set had 21 operations (plus Halt making 22), which            .empty
                      copied numbers into and out of the AC and AR,               9. .empty
                      subtracted, added, multiplied, or divided them, and           .empty
                      controlled execution. The execution control enabled         10. .data 4
                      the programmer to jump to a particular memory               11. .data 1
                      address, or to check whether a given value was                 Let’s take a look at that. First of all, each ‘line’ (which
                      greater than or equal to 0, or to rewrite a given           is in fact the register address where the instruction is
                      instruction; it was these abilities that enabled loops.     stored) has two instructions, since the IAS machine
                         The IAS architecture and plans were implemented          had two instructions per ‘word’ on its tapes.
                      in several machines across the world, as the plans          Line 0: The first half of our first pair of instructions
                      were freely distributed. However, all of these              loads the number in location 10 into AR, the
                      machines, although IAS derivatives, were slightly           Arithmetic Register. S(x) refers to Selectron (memory)
                      different; you couldn’t just run software written for one   location x, and 10 is given for x at the end of the line.
                      machine on another machine without rewriting it for         The second half, S(x)*R->A 10 multiplies S(10) by R,
                      the quirks of that individual machine. Some of the          and stores the result in A. Multiplication on the IAS
                      famous IAS machines include MANIAC (at the Los              gave rise to a result stored in two halves: the left half
                      Alamos National Laboratory; von Neumann was                 of the number in AC and the right half in AR. Since we
                      involved with this one too and was responsible for the      are only multiplying small numbers, only the right half
                      name), the IBM 701 (IBM’s first commercial scientific       is useful.
                      computer, with 17 installations), and ORACLE (in Oak        Line 1: The next instruction, R->A, therefore moves
                      Ridge National Laboratory). Other IAS machines              the right half of the result from AR into AC. We can
                      existed in Copenhagen, Moscow, Stockholm, and               then save it to location 12 with At->S(x) 12. That gives
                      Sydney, among others.                                       us the first answer, the square of the working number,
                                                                                  stored in location 12.
                      IAS emulator                                                Line 2: Load the working number itself into AC, then
                      There’s a Java-based emulator, IASSim, available for        add the contents of location 11 to it (S(x)->Ah+ 11).
                      the Princeton IAS machine, from www.cs.colby.edu/           As you’ll see in a moment, location 11 contains 1, so
                      djskrien/IASSim/ -- so you can try out IAS machine          this just increments our working number by 1.



96                                                    www.linuxvoice.com
                                                    VON NEUMANN, EDVAC, AND THE IAS MACHINE TUTORIAL

Line 3: We store the incremented working number             you prefer – feel free to try it out!). We start off with n
back in location 10, and start the process again.           (see the data labels at the bottom), load it into the AC,
Lines 4–6: As above, but this time around our new           and check that it is still non-negative. If so, we jump to
result is stored in location 13. We increment the           the sq subroutine.
working number one more time before stopping.                  The first four lines of sq are familiar – load up n,
Lines 7–9: These are empty just for ease of setup.          square it, and store the square in the out location.
The empty lines mean that we can store our working          Next is the interesting part.
number in location 10 and leave a bit of room to add           S(x)->Ac+ 3 loads the instruction at location 3 into
more instructions if desired. (If you remember coding       the AC register. Location 3, if you count lines
in BASIC with line numbers, you may recall numbering        (remember that the locations start at 0) contains the
in tens to give yourself wiggle room; same thing!).         instruction R->A on its left side and At->S(x) out on its
Lines 10-11: The assembler instruction .data is used        right side. So we now have a number representing
to put the numbers 4 (our working number) and 1 (for        those instructions in the AC.
use when incrementing) into locations 10 and 11. The           The next instruction, S(x)->Ah+ adds one to that.
original programmers would have just been able to           This effectively alters At->S(x) out to At->S(x) out+1.
write numbers (whether all zeros for an empty line, or         We then write this altered instruction back to
data numbers) straight to tape.                             location 3, with
   To run this, go to the Execute menu and choose
Clear, Assemble, Load, and Run. Check out the RAM
                                                            Ap’->S(x) 3
                                                            (specifically, Ap’ alters     “Von Neumann designed a
Selectrons window to see the contents of the                the right-hand side of        self-replicating computer
registers -- you should see 16 in location C
(hexadecimal) and 25 in location D. (You might need
                                                            the instruction at
                                                            location 3, and Ap            program, which is considered
to change the Data view to Decimal.) You can also           alters the left-hand          to be the first computer virus.”
step through the program one instruction at a time          side). So the next time
using Debug mode, and watch the registers change in         we loop around this
the Registers window, if you prefer.                        code, instead of writing the output to the location
   In fact, if you change the Data view of the RAM          labelled out, we’ll write it to the next location along.
Selectrons window to Hexadecimal, you can code              To watch this happen, you can use Debug mode, step
your instructions directly into the Selectron locations.    through the code, and keep a close eye on the
Each location has two sets of one 2-place and one           Registers window.
3-place hex number, corresponding to an                        The next three lines load n up again, decrease it by
instruction+location, twice. So, for example, the hex       one, ad save it. We then jump back to loop with the Cu
representation of S(x)-R is 09, and the first instruction   instruction, and go round the loop again.
of our first line is 09 00A (A being 10 in hex).               If you load and run this, you’ll see that you get the
   Here’s a loop version of our squares code using          squares from 100–0 output in locations 10–20. This
assembly language (with thanks to the writers of the        is the behaviour that the von Neumann architecture
IAS Sim software for the loop control code):                makes possible: altering the program’s stored
loop: S(x)->Ac+ n ; load n into AC                          instructions as you go along.
    Cc->S(x) sq ; if n >= 0, go to sq
    halt                                                    Final years
    .empty                                                  Von Neumann carried on working on computing,
                                                            alongside his other areas of interest, for the rest of his
sq:     S(x)->R n                                           life. In 1949, he designed a self-reproducing computer
      S(x)*R->A n                                           program, which is considered to be the first ever
      R->A                                                  computer virus, and he worked on cellular automata
      At->S(x) out                                          and other aspects of self-replicating machines. He
      S(x)->Ac+ 3                                           also introduced the idea of tochastic computing
      S(x)->Ah+ one                                         (which, broadly, uses probability rather than
      Ap’->S(x) 3                                           arithmetic) in a 1953 paper, although the computers
      S(x)->Ac+ n                                           of the time weren’t able to implement the theory.
      S(x)->Ah- one                                             Sadly, he died in 1955 from bone or pancreatic
      At->S(x) n                                            cancer. (A biographer has speculated that this might
      Cu->S(x) loop                                         have been due to his presence at the Bikini Atoll
      .empty                                                nuclear tests in 1946.) His contribution across his
                                                            fields of interest was truly immense and he might well
n: .data 10                                                 have contributed still further had he lived longer.
one: .data 1
out: .data 0
                                                             Juliet Kemp is a scary polymath, and is the author of
  The labels here are part of the assembly language,
                                                             O’Reilly’s Linux System Administration Recipes.
to make looping easier (but it could be done by hand if



                                                              www.linuxvoice.com                                             97
      CODING FPGAS



                               FPGAs: BUILD YOUR OWN
CODING TUTORIAL
                               CUSTOM SOUND CHIP
                               Mine Bitcoins or make silly noises: anything’s possible
    BEN EVERARD
                               when you have the power to design your own chips.


                               F
                                       ield Programmable Gate Arrays (FPGAs) are         USB device. In this tutorial, we’re going to use a Papilio
  WHY DO THIS?                         chips that can be programmed to perform           One 500K, which we bought from the Gadget Factory.
  • Make funky noises                  different actions. However, they’re               In many ways, you can think of this as the Arduino of
  • Create hardware            programmable in a different way to CPUs and               FPGAs. It’s not the most powerful chip available, but
    customised for your
    exact needs                microcontrollers. An FPGA contains a series of logic      it’s enough to get started, and there are some
  • Peek into the innards of   circuits that can be programmed to connect to each        easy-to-use tools to help beginners get started on it.
    chips and learn about IC   other in different ways, so when programming an           The Gadget Factory also sells the Papilio Pro, which is
    design                     FPGA, you don’t describe a series of steps like you       more powerful than the model we’re using (in FPGA
                               would in Python or C but the circuit that you want to     terms, a device is more powerful if it has more
                               implement. In many ways, you can think of an FPGA         components inside it, thereby enabling you to create
                               as being a bit like a breadboard for prototyping a your   larger and more complex circuits).
                               own chips. Because of this, you can program FPGAs             Gadget Factory also produces a range of wings,
                               to perform some tasks much quicker than they could        which are add-on hardware to enable things like audio
                               be done on a CPU (such as mine bitcoins).                 and VGA output. Since the FPGA can be programmed
                                  One common use of FPGAs is to re-implement             to include the driver circuits for these, they’re far
                               processors and other chips from old computers such        simpler than they would be for microcontroller boards.
                               as games consoles. It’s important to remember that
                                                               the FPGA doesn’t          The language of hardware
 “One common use of FPGAs                                      emulate the design of a
                                                               chip like a games
                                                                                         The two common languages used to program FPGAs
                                                                                         are Verilog and VHDL, but diving straight into the code
 is to re-implement processors                                 console emulator may      isn’t the easiest way to get started with the Papilio.

 from old computers.”                                          when running on a
                                                               normal CPU: it actually
                                                                                         Instead, you can start with circuits that other people
                                                                                         have built. There aren’t huge numbers of these, but
                                                               implements it in          there are a few. One of the most useful for Papilio
                               hardware. This has a massive effect on the speed at       users is the Zylin CPU (ZPU).
                               which it performs, because all the parts of the circuit      This core is also openly licensed (under a BSD-style
                               are running in parallel not being simulated one at a      licence). So, while running open source code on a
                               time like they would be on a CPU.                         ZPU, you’re using fully open software on a fully open
                                  There are a few FPGAs available, and a number of       processing unit on a fully open board. There’s enough
                               different prototyping boards for working them into        freedom there to keep anyone’s inner Stallman happy.
                               your projects. Some need specialist equipment to             ZPUs aren’t powerful enough to run a regular
                               program, while others can simply be plugged into a        computer, but in microcontroller terms, the ZPU
                                                                                         performs quite well. It’s a 32-bit processor that runs at
                                                                                         96MHz. That makes it quite a bit faster than most
                                                                                         Arduinos (about the same processing power as the
                                                                                         Arduino Due). This means it’s useful for embedded
                                                                                         applications where you don’t need a full OS stack, just
                                                                                         a bit of processing power to control inputs and
                                                                                         outputs. One of the most popular uses of the ZPU on
                                                                                         the Papilio has been in making music synthesisers.
                                                                                         The ZPU can control what’s going on, while additional
                                                                                         peripherals can generate the noises. That’s what we’re
                                                                                         going to look at here.
                                                                                            GadgetFactory has modified the Arduino IDE to
                                                                                         work with the ZPU and the Papilio One FPGA. We’ll
                                                                                         use that for our projects in this tutorial, so you’ll need
 The Papilio FPGA board is                                                               to get it from http://forum.gadgetfactory.net/index.
 one of the easiest ways to                                                              php?/files/file/8-zap-zpuino-arduino-papilio-ide.
 get started with FPGAs.                                                                 Installing this is simply a case of unzipping it. Inside



 98                                                           www.linuxvoice.com
                                                                                                                               FPGAS CODING

there’s an executable called zap, which will start the
IDE. If you’ve used the Arduino IDE before, you can use
Zap in exactly the same way, but it does have a few
features that are specially for the Papilio FPGA. You
may have noticed that there’s an extra menu called
Papilio, and it’s here that we’ll get started.
  Create a new project (known as a sketch in the
Arduino terminology). Go to Papilio > New Papilio
Project, and give it a name.
  The programming language used is a dialect of
C++. The two main functions are setup() and loop().
The setup() function is run when the Papilio first
starts, then loop() runs continuously. In the new
project you’ve just created, these will contain the code
to simply turn pin 0 off and on a few times. Actually,
the default code contains a typo: it uses a variable
                                                                                                                                All of the Papilio example
that’s not declared. To correct it, change the loop                 at the bottom of the ZAP window:                            sketches come with
function to:                                                        DONE      =0                                                schematics showing the
void loop() {                                                          Once this is finished, you can upload your code to       chip design inside the BIT
  digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage    the processor by clicking on the arrow icon in the          file, so you can see what’s
level)                                                              top-left corner of the window.                              connected to which pins.
  delay(1000);         // wait for a second                            There won’t be any instant sign that it’s worked, so
  digitalWrite(0, LOW); // turn the LED off by making the voltage   you need to connect an LED to the appropriate pin
LOW                                                                 along with a resistor to stop it drawing too much
  delay(1000);         // wait for a second                         current. Any colour LED will do, but it needs to be
}                                                                   connected the right way around (one of the legs will
    Here, in the two places where the led variable was              be a little shorter and there will be a flat side on the
used, we’ve just put in the value 0 instead. This simple            base. This is the negative leg). To stop it drawing too
function sets pin 0 to high, then waits a second (the               much current, you’ll also need a resistor (any value
delay function takes the number of milliseconds as                  between 220 and 1,000 ohms will be fine).
it’s argument), then puts the pin low, waits another                   First, unplug the Papilio. You need to connect the
second and repeats.                                                 positive leg of the LED to pin AL_0 on the Papilio One.
    This code isn’t for the FPGA, remember, but for the             If you look at the board with the USB port on the top
ZPU processor. So, before you can use this code, you                side, this is the pin in the middle of the three in the
have to load a BIT file containing the processor onto               bottom-right corner. The negative leg of the LED
the board. To do this, click on the following link, which           should connect to the resistor, and then the resistor
should be in the comments at the top of the page:                   should connect to the ground. You’ll need a
sketchdir://500K/papilio_one_500k.bit                               breadboard or some other circuit-building hardware to
    This will write a ZPU processor to the FPGA. Once               link everything together.
it’s finished, it’ll display the following line in the console         Once all this is connected, plug the Papilio back in
                                                                    and the LED should start to blink on and off.
  Expanding the Papilio
                                                                    Chip tunes
  There are three official ‘MegaWings’ made by the Gadget           The ZPU in an FPGA is a way to get a slightly more
  Factory to add features to the Papilio (all are compatible
                                                                    powerful Arduino, but the Papilio can be far more than
  with all versions of the board.
     The LogicStart MegaWing adds a four-character                  just a souped-up microcontroller. The ZPU doesn’t
     seven-segment display, a VGA port, audio jack, 12-bit          take up all of the space in the Papilio One 500K. You
     eight-channel SPI ADC, five direction micro joystick,          can use the remaining space to implement additional
     eight LEDs and eight slide switches.                           features that you might find useful.
     The Arcade MegaWing adds a VGA port, a sound jack,
                                                                      Go to Papilio > Papilio Examples > Audio YM2149
     PS/2 ports and two DB 9 joystick ports (for Commodore
     and Atari joysticks).                                          Simple in the Zap menu. This will open a new sketch
     The RetroCade MegaWing adds two stereo audio jacks,            that includes an implementation of a YM2149 audio
     MIDI in, out and through, microSD card, micro joystick,        chip. The music geeks among you will know this as
     2x16 character LCD display, 16 analogue inputs and 16          the audio chip from the Atari ST (and several other
     digital inputs.
                                                                    games systems). This example can be used to play
     The first of these is designed for people who want to
  explore the general possibilities of the Papilio while the        music files from these old systems to generate some
  second and third provide functions for Arcade machines            retro sounds.
  and music synths respectively. There are also a wide range          To see the schematic for the FPGA used in this
  of single-function wings available. Head to                       sketch, click on sketchdir://schematic_papilio_
  www.gadgetfactory.net/papilio to see all the options.
                                                                    one_500k.pdf. You’ll see that this contains three



                                                                      www.linuxvoice.com                                                                  99
      CODING FPGAS


Figure 1. These pulldown                                                                      most of the wings are simple connectors to the
resistors ensure that the                                                                     hardware (sometimes with a high- or low-pass filter).
                                                            To positive voltage               This sketch is designed to work with an audio wing
pin reads low when the
button isn’t pressed.                                                                         that includes a low-pass filter and an audio jack.
                                                                                              However, this isn’t essential. It is possible to connect a
                                                                                              speaker directly between the output pins and the
                                                       R1                                     ground (though it’s best to add a 220Ω resistor to
                                                       6.8kΩ                                  prevent too much current being drawn).
                                                       ±5%
                                                                                                  The speaker should be connected to pin 8 on the
                                To ground                                                     side with the single strip of connectors (CL 0).
                                                                                                  With this in place, upload everything to the Papilio
                                                                             R2               as you did before. First, click on the appropriate BIT
                                                                             220Ω
                                                                             ±5%              file link, and once this has finished, click on the icon to
                                                                                              upload the sketch. You should hear the music playing.
                                                                                              If it’s a bit quiet, you can increase the volume by
                                                                To input pin                  changing 11 to 15 in the following lines:
                                                                                              ym2149.V1.setVolume(15);
                                                                                              ym2149.V2.setVolume(15);
                                                                                              ym2149.V3.setVolume(15);
                            things in addition to the ZPU and the output pins: a                You’ll need to reupload the sketch for this change to
                            YM2149, a sigma-delta DAC and an Audio splitter. The              take effect.
                            first takes the data file and converts it into audio data,
                            the second takes the audio data and creates the                   You can’t arrest me, I’m a rock star
                            signal, and the final one takes a mono audio signal               You may have noticed that there are also examples to
                            and splits it so that it works with stereo headphones.            play Atari MOD files and Commodore SID files.
                               The ZPU has 10 empty wishbone slots. These are                 However, these are too big to fit on the Papilio One. If
                            the places that additional peripherals can connect to             you want to use an FPGA to emulate audio chips, the
                            the wishbone bus of the processor. In this example,               Papilio Pro is a better choice because it has more
                            the YM2149 is connected to wishbone slot 5. This is               space for these more complex designs.
                            set up in the code with:                                             In the next example, we’ll keep going with music,
                            ymplayer.setup(&ym2149,5);                                        but steer away from these more complex designs.
                               The program then reads data from the SmallFS                   Instead, let’s get back to basics with a sine wave
                            filesystem. This is included as part of the sketch that’s         generator. The one included with ZAP is designed for
                            uploaded, and it contains the files in the smallfs folder         testing circuits, but it also works for generating tones.
                            in the sketch folder (these are saved in sketchbook in               In ZAP, go to Papilio > Papilio Examples > Bency_
                            your home directory). If you have other YMD music                 Waveform_Generator to open the sample project, then
                            files, you can put these in there, and play them, though          go to File > Save As to create a copy.
                            there’s not much space. ZAP does come with one                       The software is set up to generate a sine wave at
                            that’s loaded by default called                                   2.4 MHz, which is a far higher frequency than humans
                            music.ymd.                                                        can hear, so before uploading it, you’ll need to change
                               Add-on bits of Papilio hardware are known as                   this to something a little more audible. Let’s go for
                            wings, and these slot directly into the headers on the            middle C (or 261.6Hz). Change the line in setup() to:
                            board. There are a few available; because the FPGA                 setFreq(0.0002616);
                            can be reconfigured to include any driver hardware,                  Burn the bit file to the FPGA, then upload the sketch.
                                                                                              You should have a nice clean tone that gets a
                                                                                              annoying after a while. To make the tone a little more
                              Designing chips
                                                                                              interesting, we can add a slight vibrato effect by
                              In this tutorial we’ve only looked at using designs that        changing the sketch to the following:
                              have already been made and compiled for the Papilio. It is      #define MYBASE IO_SLOT(5)
                              possible to create your own and upload these. If you want
                                                                                              #define MYREG(x) REGISTER(MYBASE,x)
                              to understand what’s going on at a deep level, there’s a free
                              book on the Spartan E3 (the FPGA in the Papilio) and VHDL
                              (a hardware definition language) on GitHub at                   float frequency= 0.0002616;
                              https://github.com/hamsternz/IntroToSpartanFPGABook.            float frequencyStep = 0.0000002;
                                 Alternatively, The Gadget Factory has produced a             int numberOfWarbles = 10;
                              schematics library. This enables you to work at a much
                              higher level and link together components such as the sine
                              wave generator. It is still quite technical, but easier than    void setup() {
                              working with raw VHDL. There are some video tutorials on          setFreq(frequency);
                              their website to help you get started: www.gadgetfactory.       }
                              net/learn.
                                                                                              void setFreq(float freq)



100                                                               www.linuxvoice.com
                                                                                                                            FPGAS CODING

{
    unsigned long long phase = freq * 44507433.119;
    MYREG(0) = phase;
}


void loop() {
 for(int i=1;i<numberOfWarbles;i++){
   setFreq(frequency + frequencyStep*i);
   delay(10);
 }


}
   Most of this is taken from the example sketch, with
just a little added to take some values out to variables
(to make them easier to change), and a for loop that
changes the frequency slightly. This will vary the
frequency by gradually increasing it, then dropping it
back down. A more sophisticated version would also
drop the frequency back down gradually, but we’ll
leave that up to you to implement.
   This produces a slightly more interesting tone, but it
still just keeps playing it on and on.
                                                                                                                             Our little synth will
   The ZPU has plenty of input/output pins that we           unsigned long long phase = freq * 44507433.119;
                                                                                                                             probably never produce
can use, and the ZAP environment gives us a way of           MYREG(0) = phase;                                               any top 10 hits, but it has a
controlling the sine wave generator based on these          }                                                                sound unique to us.
inputs. We’re going to use this to create a simple          void loop() {
keyboard. To save space, we’ll only use five keys (four       // put your main code here, to run repeatedly:
to play notes and one to control the vibrato), but you        for(int i=1;i<numberOfWarbles;i++){
can use the same techniques to build up to a more               setFreq(frequency + frequencyStep*i);
complex instrument. The banks of IO pins are handily            delay(10);
arranged in blocks of eight, and five of them are             }
completely free (three of the sixth are used up by the        frequency = 0.0;
wave form generator, but the remaining ones could be          if(digitalRead(0)==HIGH){ frequency = freqC; }
used for control).                                            if(digitalRead(1)==HIGH){ frequency = freqD; }
   The code is similar to the example above, with some        if(digitalRead(2)==HIGH){ frequency = freqE; }
input pins set up, and some if statement to control the       if(digitalRead(3)==HIGH){ frequency = freqF; }
variables depending on which ones are pressed.                frequencyStep = 0.0000002;
#define MYBASE IO_SLOT(5)                                     if(digitalRead(4)==HIGH){ frequencyStep = 0.000002;}
#define MYREG(x) REGISTER(MYBASE,x)                         }
                                                              The buttons can’t be directly connected to the pins,
float frequency = 0.0;                                      as they need a pair of resistors in order to correctly
float freqC = 0.0002616;                                    control the voltages. See figure 1 for details of how
float freqD = 0.0002936;                                    these should be connected. The five input pins on the
float freqE = 0.0003296;                                    Papilio are in the middle row at the bottom of the pin
float freqF = 0.0003492;                                    bank on the right-hand side if you hold the Papilio
float frequencyStep = 0.0000002;                            with the USB port facing upwards.
int numberOfWarbles = 10;                                     We haven’t even scratched the surface of what’s
                                                            possible with the Papilio and other FPGAs. The ability
void setup() {                                              to create custom hardware in chips enables you to
  // put your setup code here, to run once:                 easily create things that are quite difficult with
  pinMode(0, INPUT);                                        microcontollers, and this is only one use for them. At
  pinMode(1, INPUT);                                        the moment the library of components to go into your
  pinMode(2, INPUT);                                        designs is still quite small, but it’s already exciting. As
  pinMode(3, INPUT);                                        they become more popular with the hobbyist
  pinMode(4, INPUT);                                        community, you can expect to see a growing range of
  setFreq(frequency); //Sets in Mhz                         easy-to-use schematics.
}
                                                             Just in case you missed it, harware wrangler Ben has written
void setFreq(float freq) //sets in Mhz                       a book about Learning Python with the Raspberry Pi. It’s
                                                             called Learning Python With Raspberry Pi.
{



                                                              www.linuxvoice.com                                                                      101
       CODING NINJA



                      ERROR DETECTION WITH
CODING TUTORIAL
                      HAMMING CODES AND CRCs
                      Data errors are a fact of life, but with a little clever code,
   BEN EVERARD
                      you can catch them out before they trip you up.


                      W
                                   hen sending data across a network or                  p1 is calculated based on even parity with data bits
                                   storing it on disk drives, there’s a chance           d1, d2 and d4.
                                   that the data will become corrupted. Good             p2 is calculated based on even parity with data bits
                      hardware design can help minimise this, but it can                 d1, d3 and d4.
                      never eliminate it completely, so it’s important to be             p3 is calculated based on even parity with data bits
                      able to detect when these errors happen so that the                d2, d3 and d4.
                      data can be re-sent.                                               The data is sent in the order p1,p2,d1,p3,d2,d3,d4.
                          The easiest way to check for errors is to add a parity         By interlacing the parity bits in this way, you can
                      bit. This is an extra bit of data added after each small        not only tell that an error occurred, but which bit it
                      block that’s used to detect errors. There are two types         occurred in. For example, if p1 and p2 are incorrect,
                      of parity: odd and even. In odd parity, the bit is used to      but p2 is correct, then you know that the error must
                      make it so there is an odd number of 1’s in the data,           be in d2 (or there is more than one error). This
                      while even parity makes it an even number of 1’s.               means that if you are reasonably confident that the
                      When checking the data, the computer just counts the            communications channel won’t flip more than one
                      number of 1’s and sees if it matches with the type of           bit out of every 7, you can correct any single-bit error.
                      parity being used.                                              On the other hand, if it’s a noisy channel, you can
                          For example, the letters LV are 01001100                    detect any two-bit errors (these would be corrected
                      01010110 in ASCII. With an even parity bit added to             incorrectly if you dealt with them as single-bit errors).
                      each letter, they become 010011001 010101100.
                      This adds one bit for every eight bytes of data, so             Stop: Hamming time
                      there is more to send; however, in many cases it’ll be          This is known as a 7,4 Hamming code, because the
                      a good trade off because there’ll be fewer errors. This         method was developed by Richard Hamming, and for
                      extra data is known as redundancy because it doesn’t            every 7 bits set, 4 are data.
                      add any information (we still only have the letters LV,           The reason we know how many bits can be
                                                            but we’ve sent 18         corrected or detected by a particular code is because
                                                            bits rather than 16).     of the Hamming distance. This is the number of bits
 “A parity bit is an extra bit of data                         A parity bit won’t     that have to flip to get from one valid sequence to
 added after each small block,                              detect every error.
                                                            If any single bit
                                                                                      another. For example, using the 7,4 hamming code,
                                                                                      1111 and 0111 are encoded as:
 which is used to detect errors.”                           gets flipped then         1,1,1,1,1,1,1
                                                            it will flag it up, but   0,0,0,1,1,1,1
                      if two bits get flipped, it won’t detect the error. It will        You can see that at least three bits have to flip
                      detect an odd number of errors in the data, but not an          to get from one to the other. If you calculate 7,4
                      even number of errors. You could increase the error             Hamming codes for all possible values of d1,d2,d3
                      detection by using a parity bit on a smaller piece of           and d4, you’ll find that this is the minimum number
                      data. For example, you could split the above data into          of bits different between any two, so we can say
                      four-bit chunks and add a parity bit on these. This             that it has a minimum Hamming distance of three.
                      will improve the error detection, but at the expense            Whenever there is a single-bit error, it will be closer to
                      of extra redundancy. The best trade off between the             one code than the other. However, if there are two-bit
                      these two opposing forces will depend on how error-             errors, then it will be closer to the wrong code.
                      prone the communications channel is.                               If you want to detect or correct more errors, then
                                                                                      you need to increase the Hamming distance. Again,
                      Error correction                                                this means increasing the redundancy. It turns out
                      There are other ways than just splitting the data up            that this is easily done by adding a parity bit that
                      into ever smaller chunks. One common way is to add              covers every bit (p1–p3 and d1–d4). The result is
                      three parity bits for every four bits on data. In this          a code that has four bits of data for every eight bits
                      case, the parity bits (p1, p2 and p3) are interspersed          sent and a minimum Hamming distance of four (this
                      so that they only cover some of the four data bits (d1,         is an 8,4 Hamming code). This can still only correct
                      d2, d3 and d4).                                                 a single-bit error, but it can detect three bit errors in a



 102                                                    www.linuxvoice.com
                                                                                                                                         NINJA CODING




                                                                                  d1
                                                  p2
                                                                                                           p1


                                                                                  d4

                                                                 d3                              d2




                                                                         p3
                                                                                                                                A Venn diagram like this one can be
                                                                                                                               used to work out which bit is in error
                                                                                                                                  in a 7,4 Hamming code. The three
                                                                                                                                circles represent the parity bits, and
                                                                                                                                the error is the data bit that’s within
                                                                                                                                    all of the circles of the parity bits
                                                                                                                                   showing errors, but not inside the
                                                                                                                                  circle of the parity bit not showing
                                                                                                                                                errors (if there is one).


single block. A 9,4 Hamming code would be needed to                      To reverse the CRC, the full data is run through the
correct two-bit errors. It is possible to go on building              same process, except that the CRC value takes the
codes with more and more redundancy that can                          place of the trailing zeros. At the end, if the remainder
detect and correct more and more errors. However,                     is 0 then the CRC data is correct; otherwise there is an
the more bits you add, the more you have to send, and                 error in the data (we’ll leave it up to you to perform this
so the less data you can get through the channel.                     and check that the above value is correct).
                                                                         CRCs don’t help you fix the error in the same way
Cyclic codes                                                          that Hamming codes do, they just try to spot them.
Hamming codes are good for detecting errors in very                   CRCs can also be designed to be longer or shorter,
noisy channels, but other times we want a solution                    and the length will make them better or worse at
that’s very quick to calculate and that doesn’t have too              finding errors.
much redundancy. In this case, we may use Cyclic                         The reason this is very efficient to implement in
Redundancy Checks (CRCs). The mathematics of                          hardware is that it can be done with little more than
why these work is a little complex, but in practice, they             a shift register and a few logic gates. This is far less
are a little like long division using XOR, and the                    than what is needed for Hamming codes. Because
remainder is the redundancy used to check that the                    of this simplified requirement, it can run in real time
received value is correct. Let’s look at an example                   even on very fast data transfer, and you’ll find CRCs
using the coefficient 1011 on the data 01001100 (the                  in everything from CDs and DVDs to Ethernet and 3G
letter L in ASCII) and a three-bit CRC.                               mobile networks.
01001100 000     data (trailing 0s are the 3 bits for the CRC)           The outside world is a scary place for data. There is
 1011            divisor aligned with the first 1                     all manner of electromagnetic interference and other
00010100 000     result of XOR                                        problems just waiting to flip 0s into 1s. With a little
 1011            divisor aligned with the first 1                     careful planning, though, we can protect our precious
00000010 000     result of XOR                                        digits and make sure they don’t come to any harm.
      10 11      divisor aligned with the first 1
00000000 110     result of XOR
The CRC finishes because the result is all zeros except                Ben Everard is the best-selling co-author of the best-selling
                                                                       Learning Python With Raspberry Pi.
for the three bits that form the CRC value (110).



                                                                        www.linuxvoice.com                                                                            103
         CODING ANDROID



                                 DEVELOP YOUR FIRST
 CODING TUTORIAL
                                 ANDROID APPLICATION
                                 Google’s Android Studio has made Android development more
GRAHAM MORRISON
                                 straightforward than ever. As we prove. Kind of…


                                 A
                                           ndroid’s success is colossal. It’s the most        requirements for running your own applications,
    WHY DO THIS?                           widely distributed version of a Linux-based        development isn’t even that difficult – especially if you
    • Develop for a hugely                 operating system, used on everything from          just want to hack your own solutions into the chaos.
      successful platform
                                 smartphones and tablets to cars, fridges and air             Which is exactly what we’re going to do here, in what
    • Get into the Android app
      store and make £$€         conditioning units. It’s only a matter of time before it     will be the first part of a series on creating a Linux
    • Never miss another         reaches your toaster. And while it may have started          Voice application for Android.
      Linux Voice podcast        life outside of Google as an advanced operating                 We’re going to start modestly. We’ll build a very
                                 system for digital cameras, Google’s purchase of             simple RSS reader app that will parse the latest posts
                                 Android, Inc. in 2005 slotted Android into Google’s          from LinuxVoice.com and enable you to select a story
                                 plans for mobile world domination, inadvertently             to open in a browser. As a starting point, we may then
                                 making it the operating system for the touchscreen           expand upon this simple application to create a much
                                 generation – the opposite of Apple’s iOS, with all its       more functional application. But it’s also a perfect
                                 walled garden and hardware consistency. Android is           way to acclimatise yourself to Android development,
                                 wild, chaotic, uncountable and outgrowing itself. But        and from there, put your own ideas into code. And
                                 it’s also open source and still relatively open. You don’t   because we’re embracing all things cutting-edge and
                                 need to pay Google to write software for it, and you         chaotic in this tutorial, we’re going to use this as an
                                 don’t need to root your device to run your applications.     excuse to try Google’s own Android development
                                 Despite an unwieldy API and a huge boilerplate of            environment – Android Studio.


                                   1    INSTALLATION
                                 Android Studio exists solely for Android applications.
                                 It ties itself seamlessly with the Android SDK and the
                                 emulator tools used to test your code, and also offers
                                 cutting-edge shortcuts for writing. There’s WYSIWYG
                                 realtime app rendering, a UI designer, Android
                                 templates and an editor that spots mistakes as they
                                 happen. But its cutting edge nature also means it’s
                                 unstable, and Google doesn’t yet recommend it for
                                 use in mission-critical development. That’s not going
                                 to affect us as we take our preliminary steps in
                                 Android development, but it’s something to consider          It’s worth updating Android Studio frequently, as each
                                 when your app development ambitions take you                 update makes the environment more stable.
                                 further than a simple RSS reader.
                                     Android Studio is based upon another IDE, IntelliJ       However, we find installation on Mint an easier
                                 IDEA, and as you might have inferred by the mention          proposition as it automatically deals with
                                 of Eclipse and IntelliJ IDEA – two IDEs written in Java,     dependencies and the environmental variables
                                 Android is all about the Java. Java is something of a        required by Android Studio to find the SDK (which also
                                 contentious language even now, but there’s no                needs to be installed manually). To install from
                                 denying its ubiquity. More importantly, as long as           Ubuntu or Mint, just type the following:
                                 you’ve some previous experience in an object-oriented        sudo apt-add-repository ppa:paolorotolo/android-studio
                                 environment, Java is legible and easy to understand          sudo apt-get update
                                 and get along with. It’s a good choice for a hacker-         sudo apt-get install android-studio
                                 friendly tutorial.                                             This should grab over 650MB of data, as the
                                     We installed Android Studio on both Arch Linux and       download includes the SDK alongside the
                                 Linux Mint/Ubuntu. Arch packages are held in the user        development environment and any dependencies
                                 repository, while manual installation is also relatively     you’ve yet to install. But it will leave you with a full
                                 straightforward: just download and execute a binary.         development environment capable of building



   104                                                            www.linuxvoice.com
                                                                                                                  ANDROID CODING

projects that can run on your desktop through an            border. After checking against the server, the
emulator and deployed to your own Android devices.          application will almost certainly announce that there’s
Android Studio can be started by typing android-            an update that can be installed, and unlike other
studio on the command line, or through an icon              applications installed through a distribution, in-place
embedded within your desktop’s launch menu, and             updates to Android Studio work. Just let the
the first thing we’d recommend you do after the             application run and update itself. Android Studio is in a
splash screen has gone is to ignore the ‘Welcome to         rapid state of development, so it’s a good idea to keep
Android Studio’ window, and instead open the small          on top of updates. There are usually one or two per
‘Check For Updates’ link in the windows bottom              month, and recent updates have been very stable.


  2    DEVICE CONSIDERATIONS
From the ‘Welcome to Android Studio’ window, click
on ‘New Project’ to start our adventure. We’ve now got
to change a few values in the next window that
appears. The app needs a name, and we called ours
simply ‘Linux Voice’. We’ll also need a package name,
which needs to adhere to Java’s package naming
convention. Recent versions of Android Studio will
automatically create this from your application name,
but if you need to change this to something that
closer matches your own configuration, make sure it
uses the reverse hierarchical naming pattern, normally
(but not always) linked to the top level domain of your
organisation plus the name of your app.
   The next three fields ask you which version of the
                                                                                                                        The Android Studio New
SDK you want to build your application against.             using a 4.x version of Android, there’s still almost a
                                                                                                                        Project wizard creates
Android has changed a lot over the years, and many          fifth of all Android devices running Gingerbread. We        sensible defaults for nearly
of its more advanced features are only available in the     decided with setting a minimum required SDK of 14           all values.
4.x SDK. But while choosing the latest SDK is the           (Ice Cream Sandwich), while setting the target and
easiest option, the best answer is going to depend on       compile SDK at the very latest version, 19 (Kit Kat).
what capabilities you want your application to have            You can leave the other options at their default
and where you want it to be used. Unlike iOS, many          values – just make sure that ‘Create Activity’ is
Android users can’t simply update their devices to the      enabled, as this adds the next page to the New Project
latest releases. Many manufacturers don’t even              wizard, which enables you to select which kind of
provide updates, and even when they do offer                template to use for your project. These are worth
updates, they’ve usually made so many modifications         exploring, as each example will include the best
to Android themselves that it takes many months for         practice for different elements of a typical Android app,
an update to be distributed. The result is that there are   and each new version of Android Studio includes
many different versions of Android in active use.           more. But for our first application, we’re going to keep
                                                            things simple and go with the ‘Blank Activity’. This lets
Choose your platform                                        us build things up from scratch but also avoids too
Google uses statistics gathered from its Google Play        many complex concepts that come with more
app to report on the devices accessing the store over       complex templates. After selecting the blank template,
the previous seven days, so that developers can make        the final page is where we give our activity a name.
their own judgment on which platforms to target.               An activity is what Android calls the application             PRO TIP
We’ve printed the table from early April, and you can       component that expects something of the user. For            When using ‘try’ and
see that while a significant percentage of devices are      nearly every instance, that means putting something          ‘catch’, debugging is much
                                                            on the screen you can interact with. Android likes to        easier if you isolate each
                                                                                                                         exception rather than
  Current Android versions                                  break down the functional components within an               grouping them together
                                                            application, and an activity is one such component,          (as we have).
  Version        Codename           API    Distribution     usually with one purpose. It could be a web browser, or
  2.2            Froyo                8        1.1%
                                                            a music player, but equally, it could be a stream of RSS
  2.3.3 -2.3.7   Gingerbread         10       17.8%
  3.2            Honeycomb           13        0.1%         stories, which is the only activity our application is
  4.0.3 -4.0.4   Ice Cream Sandwich 15        14.3%         going to provide. An application is then a combination
  4.1.x          Jelly Bean          16       34.4%         of multiple activities tied together to create a fully
  4.2.x                              17       18.1%         functional tool. Having said that, you can leave the
  4.3                                18        8.9%
                                                            Activity and Layout names at their default values, as
  4.4            KitKat              19        5.3%
                                                            they make only a cosmetic difference.



                                                              www.linuxvoice.com                                                                105
      CODING ANDROID


                               3   ANDROID EMULATION
                             This is where we hit some cutting-edge turbulence.
                             With Android Studio 0.5.7, the template generated an
                             error before we’d even got to the code. The error
                             console complains that the Android Support
                             Repository isn’t installed. And while this was indeed
                             installed, any update required another update to push
                             the Support Repository version up from 4 to 5. To fix
                             this, we needed to open one of several support tools
                             used to augment the Android development
                             environment – the Android SDK Manager. This can be
                             opened from the Tools > Android menu, and when
                             opened it lists the various SDKs and tools installed
                             alongside Android Studio. We needed to allow this to
                             update two packages, which it did automatically after      You can run almost any real and functional Android
                             accepting a couple of licences from Google. Hopefully,     device from the Android Virtual Device manager.
                             you won’t have to go through a similar process when
                             you first start Android Studio.                            selected and click on the ‘Expand’ button to the right
                                 Before we spend a little time going through Studio’s   of the drop-down list. This will open AVD – the Android
                             GUI components, first click on the Play button in the      Virtual Device manager.
                             toolbar at the top of the window. This will build and         This is the tool that manages your real and fictitious
                             attempt to launch the template, which is itself a fully    virtual Android devices, and to get started you need
                             executable application. Most of the few seconds            to click on the ‘Device Definitions’ tab. This page
                             it takes is spent launching the Android Debug              lists common definitions for a device, and clicking
                             Bridge, ADB, which is a tool that grabs runtime and        on ‘AVD’ will create an instance for you to run. If you
                             debugging information from a runtime instance of           want to edit any of these settings, you’ll need to clone
                             your application, whether it’s running on an emulator      a definition first. This will allow you to adjust things
                             or on a real device.                                       such as the native resolution of a device, or whether
      PRO TIP                                                                           both portrait and landscape modes are available.
 Android Studio’s editor     Android emulator                                           After you’ve added a device to create an AVD, you can
 will grey-out lines, such   The next window that appears lets you select which         edit runtime options such as the amount of internal
 as imports, if they’re      device you want to run your application on. The            story available to the emulation, whether an instance
 redundant, and even make
 suggestions for spelling    Android Emulator is one of the most useful tools           is persistent (storing the data between sessions), or
 corrections.                for both Eclipse and Android Studio development,           whether graphics calls use your real machine’s GPU,
                             as it enables you to run your code on a fully fledged      as well as the target level of the SDK.
                             Android device, albeit one being emulated in software.        If you’ve got the correct packages installed, you
                             This does affect performance, but it also means            can also switch between the much slower ARM CPU
                             you can spin up any kind of device you want, from          emulation to the x86 instruction set of your native
                             old models using an ancient version of the SDK, to         system. This gives a big performance boost and
                             models with resolutions and hardware combinations          won’t cause any compatibility issues unless you’re
                             that don’t get exist, and you don’t have to spend any      performing more complex or low-level operations.
                             money getting the latest devices. From the ‘Choose         We opted for a clone of the Nexus 4 profile with no
                             Device’ window, make sure ‘Launch Emulator’ is             other modifications.


                               4   TESTING YOUR ENVIRONMENT
                             With a device added to the device list, you just need to   Android tools have been added to your path, it can be
                             click on Launch to run the instance. However… stop!        run with the emulator command; if not, you’ll need to
                             On most displays, a running Android instance takes         find it yourself. Arch installs the SDK into the /opt
                             up nearly all your screen space, because of the            folder, while the PPA packages for Ubuntu and Mint
                             high-DPI values on most Android devices. A Nexus 5,        install themselves into /usr/share/android-studio/
                             for example, has a screen resolution of 1920x1080          data/sdk/. And because your own copies of the AVD
                             pixels, which is more pixels that many screens are         profiles are copied to your home folder, you can
                             capable of displaying. We’ve not found a way of            reference them directly from the emulator command.
                             scaling the emulator from the launcher, but you can        To run the emulator at 50% resolution, which we’ve
                             scale the emulator from the command line. For that         found perfectly acceptable, type the following,
                             reason, we’d recommend running it from there. If the       replacing the name of the virtual device with the AVD



106                                                          www.linuxvoice.com
                                                                                                                        ANDROID CODING

name listed in the AVD manager:                             enable the ‘Use Same Device For Future Launches’
emulator -scale 0.5 @AVD_for_Nexus_4                        so that you don’t have to go through this step again -
The emulator window will appear at the proper scale         although this only works for the current session.
and proceed to load Android. This can take a minute            A few moments later, your virtual Android device
or two if you’re emulating an ARM CPU, but speed            should burst into life and your application will run
obviously depends on your system. Before too long,          automatically. This is the default testing environment,
you should have a working Android system that you           and if you take a look back in Android Studio, you
can unlock by sliding the padlock to the right with a       should see that it’s in constant contact with the
click of the mouse.                                         emulator. When you start debugging or monitoring
   You should also be able to go back to the ‘Choose        your application, you’ll be able to break execution and
Device’ window from Android Studio and see the              watch variables across the Android Debug Bridge
running instance listed beneath the ‘Choose A               exactly as you could if the application was running
Running Device’ button, which should be enabled.            natively on your desktop. If everything is working
To run your application, select the running device          correctly, you should see the ubiquitous “Hello world”
from the list and click on OK. We’d also suggest you        staring back at you, and it’s now time to start coding.


  5    LET’S START CODING!
Before we start with the code specifics, we need to
allow our application to access the internet (on the
device you eventually run it on). Think of this being the
Android equivalent to SELinux, and all such control is
governed by a single file found in the root directory of
your project – AndroidManifest.xml. This file controls
access and permissions as well as what can and can’t
be received by the various activities that make up your
application. You can edit it in Android Studio from the
project hierarchy view on the left, by clicking on the
project name, ‘app’ then ‘src’. You need to add the
following before the ‘<application’ tag, as this ensures
accesses to the entire package:
 <uses-permission android:name=”android.permission.         Create a new class within Studio by right-clicking on the
INTERNET” />                                                main activity source file.
   With that line edited, we can now start with our
own code. The first thing we want is a method to            inspiration. This class is going to be very simple, with
grab and parse the RSS provided by our site, and as         no methods to do calculations and only four variables
this is such a common requirement, many people              – three to hold the string parts of the RSS feed we
have already solved this problem in lots of different       want to pass back to MainActivity, and a single integer
ways. The most straightforward we found was written         to keep the list location of the eventual post when
by Tony Owen (http://droidapp.co.uk) and used               it appears in our application. The only peculiarity, if
in several open source projects, including the now          you’re not used to Java, is that our strings are arrays
rather old rpdroid podcasting client. Tony offloads         that we don’t have to give a size to until we initialise
RSS handling into its own Java class, and we’ll do a        them later:
similar thing. To create a new class, follow the path       public class dataRSS {
hierarchy in Android Studio down through src, main,           public static String[] postTitle;
Java and your package name. You should already                public static String[] postURL;
have a single activity called ‘MainActivity’, unless you      public static String[] postContent;
changed this in the startup wizard. MainActivity is           public static int position;
where all the action is happening, and where you can        }
quickly augment the “Hello World” app with your own            We’re going to follow this with the only other class
features.                                                   we’re going to write, a class we’ve called parseRSS,
   To create a new class (which will be contained           which should be created the same way we created
within its own ‘Java’ file), right click on MainActivity    dataRSS. This will contain the method that will
and select ‘New > Java Class’. In the small window          download and parse the bits we want from the RSS
that appears, enter a new class name – we used              file, so it’s going to be slightly more complex. Let’s go
‘dataRSS’, but as long as you’re consistent within          through the code, starting with the first few lines:
the application, it won’t matter which name you             public class parseRSS {
choose. You’ll then see the new class listed beneath          public static void parse() {
MainActivity, with the text editor waiting for your             URL url;



                                                              www.linuxvoice.com                                                         107
      CODING ANDROID

                              try {                                                    net.URL? Alt + Enter’. The editor is saying that Java.
                             All we’re doing is creating the class and adding a        net.URL satisfies the resource and can be imported
                          single method, which is the function we’re going to          by pressing Alt + Enter. If you do this, a popup menu
                          call to process the RSS. You should notice that as you       will open and the first option will allow you to import
                          add ‘URL’, it gets highlighted in red. This is because       the class, and selecting that will add ‘import java.
                          the Java compiler can’t find any other reference. Hold       net.URL;’ to the top of the file and solve the error. For
                          the cursor over the URL characters and the editor            this reason, we haven’t included any of the ‘import’
                          will complain it can’t resolve the symbol. The editor        statements for our code, as you should be able to
                          in Android Studio is smart and can make lots of              add them yourself (and it saves space). If you have
                          intelligent calls when spotting and fixing errors. If you    problems working them out, download the project
                          now click the ‘URL’ text, the tooltop should say ‘Java.      source code from LinuxVoice.com.


                            6     MAKING A CONNECTION
                          The last line in the previous snippet is try, and it’s one    dataRSS.postURL = new String[itemLst.getLength()];
                          of Java’s most useful functions. It’s an exception            dataRSS.postContent = new String[itemLst.getLength()];
                          handler that forces us to deal with the consequences            We’re now going to go through itemLst using a ‘for’
                          of something not happening rather than allowing the          loop and attempt to assign the contents of the
                          app to crash. The situations dealt with by try will be       elements referred to by the tag names ‘title’, ‘link’ and
                          dealt with by a catch instruction later on in the code.      ‘content:encoded’ by passing them to NodeList
                            In the next two lines, we’ll give url the address of our   elements, which is simply a collection of nodes we
                          feed and ask Java to open a connection:                      hope will contain the data we’re after.
                          url = new URL(“http://www.linuxvoice.com/feed”);             for (int i = 0; i < itemLst.getLength(); i++) {
                          HttpURLConnection conn = (HttpURLConnection) url.             Node item = itemLst.item(i);
                          openConnection();                                             if (item.getNodeType() == Node.ELEMENT_NODE) {
                             If the connection can be made successfully, our              Element ielem = (Element) item;
                          application will get past the following ‘if’ statement,         NodeList title = ielem.getElementsByTagName(“title”);
                          taking us into the section of code that deals with the          NodeList link = ielem.getElementsByTagName(“link”);
                          nitty gritty of the XML within the RSS feed. There are          NodeList content = ielem.getElementsByTagName(“content:en
                          many ways to deal with RSS/XML, but we’ve found              coded”);
                          the easiest to be DocumentBuilder, which provides an           Because we can’t be certain that the data we’re
                          API to access the tree layout of an XML file. In the         after will be contained within the title, link and content
                          following code you’ll see that we set up a few               NodeLists we’ve created, we’ll need some exception
                          variables before structures for getting to the data          handling again with try as we attempt to assign the
                          within the data stream before db.parse(url.                  values from the RSS to the string arrays we created:
                          openStream()) passes control of the data to the              try {
                          variable we call doc. We’ll also initialise the arrays we      dataRSS.postTitle[i] = title.item(0).getChildNodes().item(0).
                          created in the dataRSS class using the size of the list      getNodeValue();
                          gleaned from the RSS and now held in itemLst:                  dataRSS.postURL[i] = link.item(0).getChildNodes().item(0).
                          if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {   getNodeValue();
                            DocumentBuilderFactory dbf = DocumentBuilderFactory.         dataRSS.postContent[i] = content.item(0).getChildNodes().
                          newInstance();                                               item(0).getNodeValue();
                            DocumentBuilder db = dbf.newDocumentBuilder();             } catch (NullPointerException e) {
                            Document doc;                                                 e.printStackTrace();
                            doc = db.parse(url.openStream());                          }
                            doc.getDocumentElement().normalize();                         In the previous piece of code, you’ll see that we’ve
                            NodeList itemLst = doc.getElementsByTagName(“item”);       included the catch block for dealing with the
                            dataRSS.postTitle = new String[itemLst.getLength()];       exception. As you might expect, all this does is output
                                                                                       the methods (the stack trace) of the application that
                                                                                       have led to this point, and we’ll finish of the class with
         All our import
                                                                                       closure on the previous try as well as close brackets
         lines were
                                                                                       for all the other blocks. We’ve put these on the same
         automatically
         added via                                                                     lines for brevity, as you should be properly indenting
         Android                                                                       your code or getting Android Studio to do it for you
         Studio’s                                                                      (Code > Reformat Code in the menu):
         auto-complete                                                                 } } }
         features.                                                                     } catch (Exception e) {
                                                                                         e.printStackTrace();
                                                                                       } } }



108                                                        www.linuxvoice.com
                                                                                                                           ANDROID CODING


  7    ADDING THE FUNCTIONALITY
We’re not going to spend much time on the GUI this           list. This is quite straightforward. We use
month. All we’re going to do is replace the TextView         findViewById to link the UI widget we laid out earlier
widget with the ListView widget. ListViews are now           with the ListView widget we create in code, and call
synonymous with smartphones – they’re the bread              this ‘storylist’. We’re then able to add elements via the
and butter widget used to display everything from            setAdapter method. We’re just adding the title at the
email to Tweets. And while Android Studio has a              moment, but we use the URL in the next view lines.
wonderful visual editor for creating your own user           We need to create an even listener to deal with user
interfaces, the best way to accomplish this is to open       input, and we use ListView’s setOnItemClickListener
the GUI resource in your Android project – app/src/          and the AdapterView.OnItemClickListener() to handle
res/activity_main.xml in the project’s hierarchy. When       the callback, which then decodes which item has
you click on this file, Android Studio will switch to the    been pressed via our ‘position’ variable and starts a
visual editor, but you’ll need to switch from the ‘Design’   new activity based on the URL. If we linked to an audio
tab to the ‘Text’ tab to edit the XML file responsible for   file, Android would launch an audio player, but as we’re
the layout directly. This view is still excellent, as it     linking to a web page, it’s going to open the web
updates a virtual Android device of your choice, giving      browser. You’ll always be able to return to our app
you the best of both worlds. To replace the TextView,        using the ‘back’ button.
simply paste over the entire block with the following:       public void populate_list() {
 <ListView                                                    ListView storylist;
    android:layout_width=”wrap_content”                       storylist = (ListView) findViewById(R.id.listView);
    android:layout_height=”wrap_content”                      storylist.setAdapter(new ArrayAdapter<String>(MainActivity.
    android:id=”@+id/listView”                               this, android.R.layout.simple_list_item_1, dataRSS.postTitle));
    android:layout_gravity=”center_vertical”                    storylist.setOnItemClickListener(new AdapterView.
    android:layout_weight=”1” />                             OnItemClickListener() {
   The important thing to note here is that we’re calling       public void onItemClick(AdapterView<?> parent, View v, int
the new widget listView, as referenced by the                position, long id) {
android:id tag. We’ll use this to reference the widget          dataRSS.position = position;
within our MainActivity code, and that’s going to be            Uri uri = Uri.parse(dataRSS.postURL[dataRSS.position]);
our next and final target for this tutorial, so double          Intent intent = new Intent(Intent.ACTION_VIEW, uri);
click on MainActivty.java and let’s make it so!                 startActivity(intent);
   Before we get onto the complete code for the main          } }); }
class, we’ve removed both of the methods that deal              The final chunk of code is the updateRSS method
with the menu, because while they’re an essential part       that we called execute() on earlier. It uses AsyncTask
of the template for adding functionality, they’re only       to show an update dialogue and stop our application
going to add complexity here.                                from locking up whilst we update the RSS feed.
public class MainActivity extends Activity {                 private class updateRSS extends AsyncTask<Void, Void, Void>
parseRSS parserss;                                           implements DialogInterface.OnCancelListener {
@Override                                                      private ProgressDialog dialog;
protected void onCreate(Bundle savedInstanceState) {           protected void onPreExecute() {
 super.onCreate(savedInstanceState);                             dialog = ProgressDialog.show(MainActivity.this, “”, “Updating
 setContentView(R.layout.activity_main);                     RSS. Please wait...”, true); }
 parserss = new parseRSS();                                    protected Void doInBackground(Void... unused) {
 new updateRSS().execute(); }                                    parserss.parse();
   The above section of code is the beginning of our             return null; }
class. We create our own global parserss variable              protected void onPostExecute(Void unused) {
from the parseRSS method we created earlier – this               dialog.dismiss();
should be important automatically because the Java               populate_list(); }
class is in the same file as MainActivity. We then             public void onCancel(DialogInterface dialog) {
change the contents of the onCreate method that                  cancel(true);
Android Studio creates automatically, adding the                 dialog.dismiss();
parserss activation and an execute() method call for a         } } }
background processing class we haven’t created yet.            And that’s it! Run the project and it should download
The @Override annotation is already there, because           our RSS feed. Click on a story and it will open it from
this is a reimplementation of another method and we          your default browser. Let us know how you get on!
want to make sure Java executes our version instead.
   The next stage is to write the method to add items         Graham Morrison is the author of Kalbum, a photo collection
to the ListView widget, and to handle what happens            manager that, in its heyday, was in the Mandriva repositories.
                                                              Nowaday’s he’s best known for synthesizer music.
when one of those items is clicked to add items to the



                                                               www.linuxvoice.com                                                           109
      MASTERCLASS VLC




                             MASTERCLASS
                             Essential Linux tools explained – this month, the VLC media
   BEN EVERARD               player and a trio of command line media tools



VLC MEDIA PLAYER –
THE ONE THAT DOES IT ALL
Play media, transcode files, stream live media and more with this ancient application.


                             T
                                      he VLC Media Player is a free and open-source    on the internet. You can directly access media on your
       JOHN LANE                      multimedia player. There are a number of         local machine, either its hard drive or DVD. If you plug
                                      Linux media players to choose from but this      in a media player that uses the Media Transfer
                             one can play just about anything and will often           Protocol (MTP) you can access its contents directly.
                             succeed where other players fail.                            If you have any DLNA (Digital Living Network
                                But it is much more than just a media player. It was   Alliance – we know, it sounds horrible) devices such
                             originally a pair of applications: the VideoLAN Client    as a PVR machine on your network, then you can also
                             called vlc and the VideoLAN Server called vls. The        access their content through the playlist. DLNA is a
                             client and server functionality are now both contained    media sharing standard offered on some internet-
                             in a single application – the VLC Media Player, which     ready audio-visual devices like televisions and PVRs,
                             everyone now refers to as VLC.                            and it is a simplified subset of something called
                                You can use VLC to encode videos in a similar way      Universal Plug And Play, which VLC also supports.
                             to the command-line tools that we looked at earlier       Opening the playlist (Ctrl+P) and selecting Universal
                             and you can use it as a streaming server. But you’ll      Plug’n’Play will query the devices on the network (this
                             probably want to start by using it as a player.           may take some time) and then offer a list of content.
                                                                                       Click on an item to play it. Other network services can
                             Playlist                                                  be accessed in a similar way – VLC supports SAP, the
                             Central to VLC is its playlist, which is more than your   Session Announcement Protocol, which gives access
                             typical playlist –you can create, load and save your      to published multicast services and Apple’s Bonjour
VLC’s programme guide        own playlists, but what we have here is more of a         protocol.
lets you see what’s on TV.   gateway to content, both on your local network and           You can even directly access Freeview digital
                                                                                       television broadcasts if you have a working TV card
                                                                                       and know your local transmitter’s frequencies. Go to
                                                                                       Media > Open Capture Device and select the TV –
                                                                                       Digital capture mode. Enter the relevant frequency and
                                                                                       press Play. Programme guide information is collected
                                                                                       and you can view this with Tools > Program Guide.

                                                                                       Internet media
                                                                                       Beyond your local network and TV antenna, the
                                                                                       internet is a rich source of media, and VLC gives easy
                                                                                       access to internet radio sources like Icecast and
                                                                                       Jamendo through the Internet choices on the Playlist
                                                                                       screen. You can also add your own media favourites,
                                                                                       such as your favourite Linux podcasts.
                                                                                          To add a podcast, go to View > Playlist, then click
                                                                                       on Podcasts; the Plus sign opens a dialog where
                                                                                       you can enter the URL for the podcast (for example,
                                                                                       www.linuxvoice.com/podcast_opus.rss), giving you



110                                                          www.linuxvoice.com
                                                                                                                        VLC MASTERCLASS

direct access to all episodes of the podcast that the
feed provides.
   The default user interface fits in with your desktop
environment, but VLC is skinnable, meaning that you
can change its visual appearance. Many skins are
offered at the VLC website, www.videolan.org/vlc/
skins.php, and you can even download them all at
once like so:
mkdir -p ~/.local/share/vlc/skins2
curl http://www1.videolan.org/vlc/skins2/vlc-skins.zip | bsdtar
-C ~/.local/share/vlc/skins2 -xvf-
  You need to go to the Preferences page (Control+P)
within VLC and set the Look And Feel to “Use Custom
Skin” and then exit and re-start. You can then choose
a skin by right-clicking Interface > Select Skin.
  You can also choose a skin when starting VLC
                                                                                                                                Change VLC’s look and feel
using the --skins2-last command-line option. You                  preferences, they’re stored in a file:
                                                                                                                                with a custom skin.
need the full path to the skin file:                              ~/.config/vlc/vlcrc
vlc --skins2-last=~/.local/share/vlc/skins2/neon.vlt                  One of the preferences controls the video output.
  Be aware, however, that using skins can hide some               It’s normally set to automatic but, for fun, try setting it
of VLC’s functions.                                               to Color ASCII art video output. You need to re-start
                                                                  VLC after changing preferences but, once you’ve done
Broadcast yourself                                                this, any video played will be rendered using colour
Once you’re happy that you can play pretty much                   ASCII art. This isn’t much use unless you’ve only got a
anything you want, you can move on to streaming,                  text terminal, but it’s fun nonetheless and just goes to
because VLC will stream anything that it can play. You            show that VLC has many tricks up its sleeve.
can select anything from your playlist and stream it                  You can use the command-line version of VLC to
– just use the drop-down menu on the Play button to               view a movie in any terminal window. Now you don’t
change it to Stream.                                              even need a graphical desktop to watch things! (press
   You’ll be walked through a set of screens where you            Alt+F4 to quit.)
specify what and how to stream – the protocol to use              cvlc -V caca my_movie.mp4
and any transcoding to perform. The first screen
defines what will be streamed, and you can fill this in           No GUI needed
yourself, but selecting from the playlist will fill it in for     If you’re using VLC for downloading or streaming or
you. The second screen enables you to define                      you have another reason why you don’t need the full
streaming destinations. These can be a file or one of             GUI experience then
several network profiles including HTTP and RTP (you
can have more than one if you need to). You can also
                                                                  there is a command-line
                                                                  version called CVLC,
                                                                                                “Streaming to a file with VLC
choose whether the streamed content is displayed                  which offers the same         enables you to record a live
locally so you can see what’s being streamed.
   The fourth screen is where you can enable
                                                                  functionality but is driven
                                                                  through command-line
                                                                                                stream to your local machine.”
transcoding, and there are several configurations to              options. This is its server
choose from. If none of those suit, you can create                heritage showing through, and CVLC enables you to
your own. Once the stream starts, you can view it                 use VLC for non-GUI applications such as setting up a         With VLC’s ASCII art, you
from any player that can access it (another copy of               streaming server or as a transcoding tool.                    can watch a movie on a
VLC is an obvious choice here).                                                                                                 terminal.
   Streaming to a file enables you to record a live
stream to your local machine. You can also save
remote content locally, which is a good way to to take
a copy of recordings from your PVR onto your
computer. You can transcode while doing this if you
want the copy in a different format to the original.

Your preference
We already mentioned how you can change the look
and feel with custom skins. You can also change the
behaviour with Preferences (Control+P). There are
many options available here to change VLC’s
behaviour, but it’s unlikely that you will need to change
many of them. If you want to back up your



                                                                    www.linuxvoice.com                                                                 111
      MASTERCLASS COMMAND-LINE VIDEO


FFMPEG AND MENCODER:
COMMAND LINE VIDEO
Use your command-line prowess to make media files for any device.


                   A
                             s with most things Linux, there is a perplexing    The software that performs encoding and decoding is
                             number of media tools available. Many of           commonly referred to as a codec, and is defined by
                             these are merely wrappers around a small           standards that can have multiple implementations.
                   number of utilities that perform the heavy lifting           These implementations all produce acceptable input
                   and the most common ones include Mencoder and                for any decoder, but may differ in the way they do it.
                   FFmpeg, which we’re going to look at here.                      One popular codec these days is called H.264,
                       Mencoder comes from the same stable as the               otherwise known as MPEG-4 Part 10 or AVC, the
                   MPlayer media player, and it enables audio and video         Advanced Video Codec. The usual open-source
                   files to be decoded, filtered and re-encoded. As it’s        implementation is called x264. H.264 is very good
                   built from the same codebase as MPlayer, if MPlayer          at producing high-quality video with small file sizes
                   can play it, Mencoder can decode it.                         and is therefore the current codec of choice for the
                       FFmpeg is a collection of tools and libraries for        internet and mobile devices. Blu-ray discs are also
                   encoding, decoding and streaming audio and video.            encoded using H.264.
                   It includes the libavcodec library, which is widely used        The file itself is a container, and there are various
                   by other packages including Mencoder. FFmpeg                 container formats that you will encounter including
                   claims to be able to work with pretty much any               AVI, MP4, MKV and Ogg. You will usually find H.264
                   multimedia file.                                             within an MP4, MKV or MOV container.
                       In addition to ffmpeg, the command-line tool for            Both Mencoder and FFmpeg use the same
                   converting multimedia formats, the package includes          libraries for the codecs (libavcodec) and containers
                   a streaming server called ffserver and a basic player        (libavformat).
                   called ffplay. Use ffrobe to display media information
                   about a file.                                                Enter the command line
                       Both Mencoder and FFmpeg are complex and you             So, how do we use them? Basic usage requires that
                   will often find that using internet searching will offer     you supply an input file, some options and an output
                   you the command line sequences that you need to              file, like this example:
                   achieve a task and those search results will determine       mencoder input-file -oac mp3lame -ovc lavc -o output-file.avi
                   the tool you use.                                            The mencoder command reads the input-file and
                                                      Both tools are            uses the given audio and video codecs to re-encode

“Ultimately, no GUI app can be                     incredibly versatile. They
                                                   are driven by a large
                                                                                its contents, writing to the specified output-file. An
                                                                                ffmpeg command line sample to achieve a similar
as flexible as a comprehensive                     number of command            thing would be

command line tool.”                                line arguments and this
                                                   complexity can, at first,
                                                                                ffmpeg -i input-file -acodec mp3lame -vcodec lavc -o
                                                                                output-file.avi
                                                   present a barrier to new       The input can be any file. The formats contained
                   users. We’ll introduce some of the more common               within the file are detected automatically. ffmpeg will
                   arguments and refer you to the man pages and web-            display the format information if run without output
                   based documentation where you can learn more.                instructions:
                       The natural complexity of these tools has brought        ffmpeg -i input-file
                   about several GUI-based tools that try to simplify their     Alternatively, the supplied ffprobe command does the
                   use, with varying degrees of success. Ultimately, no         same thing:
                   GUI application can be as flexible as a comprehensive        ffprobe input-file
                   command line, and these tools present a good case              As an example, if you can’t play our free-and-open
                   for taking the time to learn their complexities instead      Ogg Video files on your smart television then don’t fret
                   of masking them with a GUI.                                  – just convert them into a MPEG transport stream
                                                                                that your TV will understand. Either
                   Codec container                                              mencoder fosspicks_cable3.ogv -oac lavc -ovc lavc -lavcopts
                   These tools manipulate multimedia files – containers         vcodec=mpeg2video:acodec=mp2 -of lavf -lavfopts
                   housing one or more streams of encoded data,                 format=mpegts -o fosspicks_cable3.mpg
                   usually audio and video and sometimes data such as           or
                   subtitles. Encoding stores audio or video as a               ffmpeg -i fosspicks_cable3.ogv -vcodec mpeg2video -acodec
                   bitstream that can later be accessed by a decoder.           mp2 -f mpegts fosspicks_cable3.mpg



112                                                 www.linuxvoice.com
                                                                                    COMMAND-LINE VIDEO MASTERCLASS

will give you an MPEG2 Transport Stream container
that should be playable on your TV, because it uses
the same mpeg2video and mp2 audio codecs that
broadcast digital TV uses.

Choose your command
These examples show the style of the command-
line options for each tool and highlights the subtle
differences between them. The main difference
is that Mencoder selects the codec library (-oac
and -ovc) and then passes options in to them
(-lavcopts). Because ffmpeg uses the library directly,
its arguments are more clearly presented as ffmpeg
options (-acodec, -vcodec, -f).
   You can query Mencoder and FFmpeg to see their
supported codecs and container formats:
mencoder -oac help -ovc help -of help
ffmpeg -formats
                                                            ffserver is FFmpeg’s streaming server. You can view its status in a browser.
ffmpeg -codecs
  The command line arguments -oac and -ovc take
parameters that select the audio and video codecs           </Feed>
to use, but here we instead use help to see what’s
available. The third argument, -of, selects the output      <Stream stream.swf>
container format, and the most useful of these is lavf,       Feed feed.ffm
which enables you to use any container format that is         Format swf
supported by FFmpeg’s libavformat library. Normally           VideoCodec flv
the format is inferred from the output filename, but it       VideoBufferSize 80000
can be stated explicitly, as we did in our command line       VideoSize 1024x768
examples above.                                               Noaudio
  FFmpeg can display more detailed information              </Stream>
about a codec, for example
ffmpeg -h encoder=mpeg2video                                <Stream status.html>
lists all the command line options applicable to that         Format status
codec. You will see that there are many options             </Stream>
available.                                                    This minimal example sets up an incoming feed
   You don’t have to use an input file. Using the           and an outgoing Flash video stream. It also sets up
x11grab option enables you to capture a screencast          a status page that you
directly from your desktop:
ffmpeg -f x11grab -r 25 -s 1024x768 -i $DISPLAY -vcodec
                                                            can use to see what the
                                                            server is doing. You run
                                                                                           “MPlayer and FFmpeg are
huffyuv screencast.avi                                      the ffserver as a daemon       complicated, but are well worth
   Here we explicitly set the input format and set the
source to our X display. The huffyuv codec is lossless
                                                            ffserver &
                                                               Now, you use ffmpeg
                                                                                           making the effort to learn.”
and captures the screen exactly as-is. We also set          to provide a feed. We’ll
a frame rate and screen size. To make the resulting         use our screencast example to provide a live
video useful, we should transcode it into a more useful     stream of our desktop (you might instead stream
format such as H.264.                                       from a webcam).
ffmpeg -i screencast.avi -vcodec libx264 screencast.mp4     ffmpeg -f x11grab -r 25 -s 1024x768 -i $DISPLAY http://
  This time, the input format is detected                   localhost/feed.ffm
automatically from the input file. We just need to          You can then point a web browser at http://localhost/
specify the video codec and output container.               stream.swf to see the live streaming video or at
                                                            http://localhost/status.html to view the status of
Live video streaming                                        ffserver.
As well as encoding, FFmpeg can also stream                    With Mencoder and FFmpeg, you can do just about
content. Its ffserver component accepts feeds from          anything you can imagine with multimedia files.They
ffmpeg clients and streams them over HTTP. Setting          are complicated tools, but they’re both well worth
up a server requires a simple configuration file called /   making the effort to learn.
etc/ffserver.conf:
Port 80                                                      John Lane is a technology consultant with a penchant for
<Feed feed.ffm>                                              Linux. He helps new business start-ups make the most of
                                                             open source.
  File /tmp/feed.ffm



                                                              www.linuxvoice.com                                                           113
      /DEV/RANDOM/




Final thoughts, musings and reflections
                           Nick Veitch
                           was the original editor                                              Inspirational
                           of Linux Format, a                                                   painting from
                           role he played until he                                              my son
                           got bored and went
                           to work at Canonical
                           instead. Splitter!


                                                                Dota2 addiction…




A
          short time ago I found myself at the                                                                             Second monitor to
                                                                                                                           keep an eye on IRC
          head of a table one of the many
          restaurants of a large Las Vegas hotel.
To the left of me, some of the very best Go
programmers in the world were conducting a
vociferous and sometimes vicious argument                         Microphone for
                                                                  when I feel brave!
with those situated opposite, a collection of                                                           Obligatory Linux
some of the world’s very finest Python                                                                   Voice DVD shot!
programmers (these are not mutually exclusive
sets, but it paints a nicer picture).
  As I slurped on my noodles, I listened in
wonder and some small degree of awe as the

                                                      My Linux setup Liam Dawe
fundamentals of each language were subject to
the sort of withering critique only possible if the
participants have spent much of their lives
worrying about integer sizes and garbage              Originator of gamingonlinux.com – and our games editor!
collection. There was much to-ing and fro-ing on
DRY principles and boilerplate code.                         What version of Linux are you             purchased for me actually came with it
  Eventually, after slipping a small but exquisite           using at the moment?                      pre-installed and I could never keep myself
rum baba down the hatch, I noticed attention                 Right now I’m using Linux Mint 16         away from Linux since then.
had turned in my direction, as though having                 on the desktop, as I find it comes
exhausted rational argument some sort of              with everything you need. I originally used             What Free Software/open source
consensus could only be agreed by an                  Ubuntu, but I just don’t like their direction           can’t you live without?
independent arbitrator.                               anymore. I also use Android on my Nexus                 It has to be Simple Screen Recorder,
  “You are all wrong” I said, daintily dabbing        4 as there isn’t a Linux distro for phones I            as it’s hands-down the best screen
crumbs from my lower lip, “everything since           am comfortable with putting on it yet.           capture software around. Many people
6502 machine code was a mistake”.                                                                      just use some sort of FFMPEG script that
  I do have a weakness for the elegance of                  And what desktop? Cinnamon                 just crams everything audio/video
some well turned assembly, but it is true that,             or Mate?                                   together without making it sync correctly,
though ruthlessly efficient, it is rather hard to            Cinnamon 2.0. It has the best mix          where as SSR does this for you.
express some of the modern world’s problems                 I’ve found between simplicity and
easily in the language of machines. The               features while not being KDE-flashy and in              What do other people love but
particular problem they were grappling with was       your face.                                              you can’t get on with?
concurrency, and it is indeed something that Go                                                               Gnome Shell & Elementary. Give me
does more convincingly than Python. (Cue flame             What was the first Linux setup                      back my darned minimise buttons!
war.) But maybe that’s just because this is the            you ever used?                              Elementary at least has a normal dock
best book-burning description of concurrency I             My first taste of the Linux brew was         where applications minimise down to,
have ever seen: http://concur.rspace.                      actually Mandrake 9.2 before it             but Gnome Shell is just trying too hard to
googlecode.com/hg/talk/concur.html.                   became Mandriva – the first PC that was           be different.



114                                                           www.linuxvoice.com
                                                                                                                            COMPETITION




   LINUX VOICE ISSUE 2
   COMPETITION RESULTS
   They are the elect to whom beautiful things mean
   only beauty. For the rest of us, beauty is Python




I
     n issue two, we challenged you lot to          Just remember the simple rules: no more
     draw pictures using just 100 lines of          than 100 lines, and only the turtle module
     Python and the turtle module. The              can be used.
results were so fantastic that it was too
difficult to pick just one, so we’ve decided to     The winners!
take the cowards’ way and have a joint first        Steven Minton’s pastoral scene uses the
place. Both entries used clever maths and           relationship between maths and real life to
clever programming, and they used them to           create a country scene that’s far more
create very different pictures.                     detailed that we thought would be possible
   We’ll put all the entries (along with the        in just 100 lines. The second just shows off
source code) online at www.linuxvoice.              the inherent beauty of maths to create a
com/python-gallery, so head down there to           quartet of abstract pieces. Both of them, we
see all the entries and to take a peek behind       feel deserve a place in a gallery, but for now
the scenes. Although the competition is             a page in Linux Voice will have to do.
now closed (and there are no more prizes),             Thanks to everyone who’s helped to make
we’ll keep the website updated with any new         the Linux Voice competitions such a great         This could be yours! The exclusive Linux Voice
pictures that are sent in. To get on the site,      success. Keep an eye out in future issues as      leet T-shirt is only available to the winners of the
send your code to ben@linuxvoice.com.               we have some big plans!                           Linux Voice challenges.




Congratulations to Steven Minton for creating this scene. The clouds and    There’s lots of maths behind this entry. We’d love to tell you how
ferns are drawn using fractals, and loops draw the flowers.                 Jonathan Whitaker created this masterpiece, but we haven’t a clue.



                                                                 www.linuxvoice.com                                                                   115
This is what we’ve done in the last 12 issues.
  Subscribe to the next 12 from just £38.




Every subscription includes access to every PDF, ePub and audio edition we’ve ever published.



              shop.linuxvoice.com