DOKK Library

Linux Voice [Issue 2]

Authors Linux Voice

License CC-BY-SA-3.0

Plaintext
The magazine that gives back to the Free Software community
May 2014
SCARY                          RASPBERRY PI               YE OLDE CODE             114 PAGES
KERNEL                         ARCADE!                    HOPPER                   OF NEURAL
Write your first module         Build an arcade machine    Learn from the creator
                                                                                   ENHANCEMENT!
for the Linux kernel           and live your 80s dreams   of the first compiler


FREE SOFTWARE

NEEDS
YOU
Linux, Android,
JavaScript – jump                                                                       IT’S EASIER TO
into coding now
and make the world                                                                  ASK FORGIVENESS
a better place                                                                       THAN IT IS TO GET
                                                                                          PERMISSION




                                                                             34+ PAGES OF TUTORIALS
UEFI Booting’s Brave New World
                                                                                     May 2014 £5.99 Printed in the UK




TEXT EDITORS The Editor Wars rage on…
SOLYDXK The thinking geek’s rolling release

 ADOPTION                                      DESKTOP

 MUNICH                                        KDE 4
 Inside the biggest Free                       Unleash the power of
 Software migration yet                        the tweaker’s desktop
                                                                                                                           WELCOME



Linux is awesome
The May 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).


                                        T
                                                  here’s a lot of renewed emphasis on learning to code, and
       No later than nine months                  a great deal of noise being made about transforming the
  2
       after first publicaton, we will             way computing is taught. This is unequivocally wonderful
relicense all of our content under      because to many of us, the only way to tackle such subjects is
the Creative Commons CC-BY-SA           through Linux and Free Software. And it’s working. At the recent
licence, so that old content can        OCR Raspberry Jamboree in Manchester, the many educators
still be useful, and can live on even   in attendance were talking in terms we’ve used to describe open
after the magazine has come off         source for years; collaboration, transparency, openness and being
the shelves.                            inclusive. But there was one term they used that I think we as a
                                        community often forget, and it’s a word we try to put at the heart
      We’re a small company, so         of this magazine; put simply, it’s fun. Learning, for me, has
 3
      we don’t have a board of          always been much more effective when I’m enjoying myself.
directors or a bunch of                 It’s the fun element that has kept me sustained, and sees me           SUBSCRIBE
shareholders in the City of London
to keep happy. The only people
                                        through those twilit hours trying to figure out how PulseAudio
                                        works. Linux and Free Software is a serious business, a sober          ON PAGE 34
that matter to us are the readers       and essential cornerstone of computing. But that doesn’t
(you again).                            mean we can’t enjoy every minute of it.

                                        Graham Morrison
                                        Editor, Linux Voice
THE LINUX VOICE TEAM
Editor Graham Morrison
graham@linuxvoice.com
Deputy editor Andrew Gregory
                                        What’s hot in LV#002
andrew@linuxvoice.com
Technical editor Ben Everard
ben@linuxvoice.com
Editor at large Mike Saunders
mike@linuxvoice.com
Creative director Stacey Black
stacey@linuxvoice.com
Malign puppetmaster Nick Veitch
nick@linuxvoice.com
Editorial contributors:
Mark Crutch, Liam Dawe,                 ANDREW GREGORY                      BEN EVERARD                         MIKE SAUNDERS
Juliet Kemp, John Lane,
Vincent Mealing, Simon Phipps,          I’m already working on an easy      KDE has always been a tough         Discovering that Steve Ballmer
Jonathan Roberts,                       solution to this month’s coding     proposition. But our tutorial on    was parachuted into Munich,
Mayank Sharma, Valentine Sinitsyn       challenge: prepare yourselves for   getting the most from the KDE       and his subsequent hilarious
                                        the Gregorian fractal! p96          has made me try it again. p86       encounter with its mayor. p52



                                                          www.linuxvoice.com                                                                     3
           CONTENTS


                                                                                                                                  May LV002
We are all in the gutter, but some of us are looking at the stars
     36
                                                                                                     SUBSCRIBE
                                                                                                     ON PAGE 34


                                                                                       Get coding now!
                                                                                       Android,
                                                                                       JavaScript,
                                                                                       Python – get
                                                                                       stuck into
                                                                                       programming.
     52                                                                                 REGULARS
                                                                                        06    News
                                                                                              Ubuntu for Phones isn’t just
                                                                                              a mirage – it’s coming!
                                                                                        08    Distrohopper
                                                                                              What to put on your
                                                                                              quintuple-booting box.

                                                                                        10    Gaming
                                                                                              Give your brain a treat with
                                                                                              some neural candy.
                                                                                              Speak your brains


      MUNICH
                                                                                        12
                                                                                              These pages are a soapbox
                                                                                              made out of Linux.
                                                                                        16    LV on tour
                                                                                              Manchester: home of the new
                                                                                              Industrial Revolution.
      Find out what’s behind the Bavarians’                                                   Group test
                                                                                        28
      decade-long migration to Free Software                                                  Your machete to cut through
                                                                                              the jungle of text editors.
                                                                                        46    Interview
                                                                                              We track down 3/4 of the
                                                                                              Raspbery Pi education team.

                                                                                        108   Masterclass
                                                                                              Control FTP with FileZilla;
                                                                                              control everything else with SSH.
                                                                                        112   On your DVD
                                                                                              Every single graphical
                                                                                              desktop from Mageia 4.
56
     YOUNG REWIRED STATE   60
                                FAQ Dockers: why           62   SYSADMIN                114   My Linux desktop
     The kids are taking        it’s like VirtualBox,           Jon Roberts presents          At home with Ubuntu
                                                                                              engineering manager Alan Pope.
     over, with code.           but more 1337.                  Linux containers.


4                                                   www.linuxvoice.com
                                                                          REVIEWS
TUTORIALS
  74                                 76




                                                                          20   Dell XPS 13 Looking for a new
                                                                               Linux machine, but don’t want
                                                                               a heap of plastic rubbish? Step
Bug reports: help make             Raspberry Pi & MAME:                        right this way!
free software better               build an arcade machine
If you do it right, getting bugs   Play the games of your youth*
fixed can be an important part of   without squandering all your
free software development.         pocket money. *Graham’s youth

  82                                 86



                                                                          22   Retrode Dust off your collection
                                                                               of games cartridges – the
                                                                               Retrode has arrived to imbue
                                                                               them with new life.
                                                                          23   Krita 2.8 Now Windows types
                                                                               can use KDE’s excellent image
                                                                               editor. That’s great, but is there
Old code: Grace Hopper             KDE: configure the hell                      anything new in 2.8 for us?
and UNIVAC                         out of your desktop                    24   PyBorg Your dream of
                                                                               controlling an underground
How to program on a machine        The defaults in KDE are an                  robot city has just come one
that weighs more than a double-    affront to taste and decency – so           step closer to becoming reality.
decker bus.                        fix it and make your life better.


  92                     96
                                                  Code 101:
                                                 100

                                                Secure key
                                                exchange
                                                Lasers, maths and
                                                cryptography.
                                                                          25   SolydXK Based on Debian?
UEFI: The new          Python: Draw               Linux: Write
                                                 102
                                                                               Yawn. A third way between
world order of         patterns with            your first kernel               timed and rolling releases? Now
                                                                               we’re interested…
booting                recursion                module
Boot Linux without     Write better code        It’s not just for angry
                                                                          26   Books Computing in the UK,
                                                                               then and now, plus a small dose
Grub or a BIOS.        with fractals.           sweary men.                    of Arduino and a huge heap of
                                                                               Raspberry Pi.


                                           www.linuxvoice.com                                                   5
     ANALYSIS




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




Steering where you look
The seductive power of boundary conditions can ruin your business and community.

                           Simon Phipps             and forgotten to keep pace with the             a non-profit or a for-profit organisation; profit
                           is president of the      expectations of their customers.                is an orthogonal concept.
                           Open Source Initiative
                                                       They’ve let the market run away from            The process by which this distraction from
                           and a board member
                           of the Open Rights       them and failed to build new businesses         core values happens is subtle, and undoing
                           Group and of Open        around their fans and friends. Instead,         the error is hard. It probably happens
                           Source for America.      fixating on copyright infringement, they        incrementally as communities pass through
                                                    alienate the very people who should be their    the scales described by Dunbar Numbers
                                                    best bet for the future by treating them as     [the theoretical number of people we are
                                                    criminals. They may not go as far as chasing    capable of forming direct relationships with
                                                    everyone with lawsuits, but the unskippable     without our brains melting, proposed by



W
             hen I learned to drive, my             admonishments on DVDs and their like            Robin Dunbar to be between 100 and 230].
             instructor told me “you steer          shout loud and clear: “We may have some of      They eventually mistake their boundary
             where you look” -- in other words,     your money but we still don’t trust you.”       conditions for their core values.
wherever you focus your attention becomes                                                              At first a community is small enough for
your destination, so keep your eyes on the          Open entrepreneurship                           everyone to have a set of direct trust
road ahead and don’t worry about the stores         Open source projects are another case,          relationships. As the community grows
at the roadside (or even too much about the         perhaps a little more subtle. Entrepreneurs     through the Dunbar limit, it becomes
kerb and the parked vehicles).                      see the word “free” and assume there’s a        necessary to define the norms for the
   The same principle seems applicable in           commons there to exploit for profit. But        community, to make it clear to newcomers
other contexts. We’re moving away from a            open source only has a commons once a           what the values of the community are.
hierarchical, post-industrial society and           community gathers -- it doesn’t magically          As growth continues, those norms
evolving into a meshed society of peers,            arrive the instant you apply an OSI-approved    become rules and the frequency with which
interacting in variable roles on their own          licence. Moreover, the commons exists only      they are enforced increases. Gradually,
terms. That’s challenging established               by the collective agreement of its              communicating the rules to outsiders
institutions, but sadly they have frequently        participants to set aside certain rights so     becomes a common community function
“steered where they looked” and made the            that collaboration becomes possible.            and the ability to do so becomes a
wrong choices.                                      Entrepreneurs tend to be so focussed on         community skill. Over time, application and
   The big media lobby -- especially the            leveraging a free network effect that they      explanation of those rules becomes so
movie and music industries, but also book,          overlook the actual mechanism that makes        important to the community that they
software and games publishers -- is right to        it happen.                                      overshadow the original core values.
be concerned about systematic                          An open source community is an example
infringement of their copyrights by                 of a group of people choosing to                Influence, not control
commercial-scale criminals. But they have           synchronise a fragment of their mutual          There’s no canned solution for this; it takes a
let their eyes wander.                              interests, each at their own expense, for the   brave executive to step away from the
   They have looked so long in anger upon           benefit of all involved including themselves.   weapons and chart a course for influencing
those crooks, invested so much time and             While there may sometimes be a non-profit       the meshed society instead of attempting to
money in frustrating them, that they’ve             organisation for administrative reasons, an     control it. The news that Getty Images is
become fixated on copyright enforcement             open source community is inherently neither     now allowing free embedding of their entire
                                                                                                    catalogue for non-commercial use is just
                                                                                                    such a bold, visionary move. I hope we will
“The media lobby alienate the people who should                                                     see much much more of that and many
be their best bet by treating them as criminals.”                                                   fewer anti-fan lawsuits and copyright-
                                                                                                    assignment-based open source projects.



6                                                              www.linuxvoice.com
                                                                                                                  ANALYSIS




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

          Linux has won. No, really.                  Microsoft to follow                            Mt GOX, the world’s
   1       According to technology             2      strategy espoused by                    3      biggest Bitcoin exchange,
           analysts Gartner, Android                  Linux Voice readers                            has collapsed
has now overtaken iOS as the leading        We’ve only been in print for two issues,       The rabbit hole gets deeper for the most
operating system for tablets. And this is   but already Linux Voice is having an           widely used cryptocurrency.
massively significant – the same date       effect at the top table of tech. We asked
suggests that in around 115m tablets        listeners to the Linux Voice podcast
were sold worldwide in 2012, compared       what advice they would give to the new
with 200m in 2013, so in contrast to PC     CEO, Satya Nadella, and among the
sales, tablets are growing quickly, and     responses was the suggestion that the
Linux is taking the majority of this very   company should give Windows 8 away
large pie. Android is estimated to have     for free, to preserve the market for the
62% of the tablet market, with iOS on       lucrative Microsoft Office package. Lo
36% and Microsoft lagging behind them       and behold, it has come to pass, as the
both with on just 2% market share.          soothsayers of LV foresaw.




          Broadcom releases the                       Google Chromium                                Linux Containers reaches
   4      source code for Raspberry            5      browser ported to run on                6      its 1.0 release
          Pi graphics stack                           Mir graphics server                             Linux Containers have been
Much as we love the Raspberry Pi, it        The great schism at the heart of               bubbling away under the radar for a
isn’t as free as in speech as it could      Linux graphics continues, as Ubuntu            while now – discerning sysadmins can
be, largely because Eben Upton is a         continues to go it alone with its Mir          read our take on them on page 62 –
pragmatist and doesn’t particularly         display server. It has now managed             and now they have reached their first
want to make things easier for the Pi’s     to get Chrome running on the server,           major version number. Linux Containers
profit-driven competitors. However,         which is its intended replacement for X.       can be thought of as being a bit like
we’re glad to see that Broadcom, maker      Meanwhile, most distros have elected to        VirtualBox, except that rather that
of the Pi’s graphics hardware, has          use Wayland as the replacement for X.          being completely virtualised, they use
released the source code for the Pi’s       X is such an old, ingrained standard that      the existing kernel and just create their
graphics chipset under a BSD licence.       it is taking time to replace it, but the day   own userspace, making them handy for
Well done Broadcom!                         will come, and either Wayland or Mir will      anyone who wants to be able to deploy
www.raspberrypi.org/archives/6299           be the new norm.                               lots of Linux instances easily.




          Canonical unveils                                                                          Calligra 2.8 released
   7      manufacturers for                                                                   8       KDE’s office suite, Calligra,
          Ubuntu for Phones                                                                           has reached its latest stable
Like buses, you wait ages for a                                                            release. You can read all about our
phone manufacturer to team up with                                                         impressions of Krita, the suite’s image
Canonical to bring Ubuntu for Phones                                                       editor, on page 23, but there’s much
to market, then two turn up at once.                                                       more to the suite then that. There’s now
Spanish firm BQ (which also operates                                                       support for comments in Author and
in Latin America) and Chinese firm                                                         Words, the ability to open hyperlinks in
Meizu have both signed up to produce                                                       the Kexi database app, and the usual
handsets loaded with Canonical’s                                                           bugfixes. We yield to no-one in our love
swish mobile operating system. We’ve                                                       of LibreOffice, but if you’re running a
always liked Ubuntu for Phones, and                                                        KDE system you might want to give the
we’re delighted that there will soon be                                                    Calligra suite a try as an alternative.
a physical product in the shops.                                                           www.calligra-suite.org




                                                      www.linuxvoice.com                                                               7
    DISTROHOPPER




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

Emmabuntüs
Linux for humanitarians.


D
        ifferent situations need different
        distros. For many users it’s
        important to having a solid base
system that’s around 700MB, making it easy
to download. This is usually backed up by a
great set of repositories that combine to give
you access to almost all the software you
need. Other times, it’s really important to
have everything you need installed from the
start. Perhaps it’s going to be installed
somewhere without a good internet
connection, or perhaps the users won’t want
to install software themselves.
Emmabuntüs fits into this second category.

For recycled hardware
It’s designed for older computers for use by     There’s so much choice in Emmabuntüs, it can take some time just to get to know the applications.
children. It has bucket loads of software in
its 3.3GB download. Much of it will be           Basically, it just has a simplified interface to    software (Flash, etc). If you’re looking at a
familiar to most Linux users, but there’s also   make it a bit more friendly.                        distro for older computers to use in a school
a few unusual choices such as OOo4kids.            Xfce is a good choice for a desktop given         or community group, Emmabuntüs is
This, you probably won’t be surprised to         the intended audience, and we like that it          definitely worth a look. Even if you decide to
learn, is a version of OpenOffice designed for   asks the user if they want a dock at the            go with something else, it’s sure to help you
children (http://wiki.ooo4kids.org).             bottom, and if they want to install non-free        find a useful bit of software or two.




Picore
Possibly the fastest Linux distro on the Raspberry Pi.


T
        inyCore Linux is a technical marvel.     team have now released a build for the Pi
        It’s a full Linux distro, including a    called PiCore.
        graphical desktop, and it’s only about       Compared to any of the other Linuxes for
15MB. However, it’s not the size of your         the Raspberry Pi, PiCore is startlingly quick.
distro that matters, it’s what you do with it.   There’s almost no lag when opening
   The small size of TinyCore allows it to       applications even on a non-overclocked Pi.          There’s not much software included by default
boot in a slightly unusual way. Instead of       It’s a refreshing change from Raspbian,             in Picore, but plenty more can be downloaded
loading files from disk each time something      which can leave the user waiting at times.          from the internet.
is needed, the entire system loads itself into       It’s hard to recommend PiCore to people
RAM when the system boots. This results in       new to Linux because its architecture does          However, experienced Linuxers looking for a
an OS that’s startlingly fast even on modest     add a little complexity, and the RAM storage        little more snap on their (low-powered
hardware. Modest hardware like, for              makes it a little too easy to lose all your files   machine) should seriously consider it. After
example, the Raspberry Pi, and the TinyCore      when you reboot if you’re not careful.              all, it’s only 24MB to download and try.



8                                                            www.linuxvoice.com
                                                                                                                         DISTROHOPPER



Bodhi 3
Seek and ye shall find Enlightenment.


I
     t’s impossible to separate Bodhi and           is the lack of Enlightenment-specific
     Enlightenment (a window manager). In           software. While both GTK and Qt have a
     fact, it’s one of the only popular distros     large stash of programs that will fit in with
that’s set up purely for Enlightenment, and         the look and feel of a desktop, there’s very
so any new user is going to notice this             little built specifically for Enlightenment, so
desktop far more than the underlying distro.        most software looks out of place.                  Beauty is in the eye of the installer, and plenty
    Enlightenment has some real strong                  Underneath this, Bodhi is a solid distro       of people like the eye-candy of Enlightenment.
points. It’s impressively fast for a desktop        based on Ubuntu LTS. Unfortunately, the
with so many graphical effects. We like how         Bodhi team have dropped support for ARM            decision. If you want to run Enlightenment,
it looks, though some people may find the           chips in this release. They found it simply        Bodhi represents the best choice for most
default setup a little gaudy with shimmers          too much work for too little gain, which is a      users. This also means that the Bodhi live
and glows everywhere. The biggest let down          disappointing, though understandable,              CD is the best way to try the desktop.



Linux From Scratch                                                                                       SystemD vs Upstart vs sysV init
Going beyond off-the-shelf Linux distros.                                                                When you turn your computer on, the
                                                                                                         bootloader loads the kernel into memory, then



W
             hen most distros are released,         system. The start of March saw the release           starts the init system. Traditionally, this init
                                                                                                         system has been a series of scripts that start
             you can go to the project’s home       of version 7.5 of this book, which guides the
                                                                                                         everything running, and enables you to stop and
             page and download an ISO.              user through the most recent versions of the         start servers once the system is fully booted up.
Alternatively, you may be able to update a          upstream projects.                                       These scripts (often called systemV init) kept
system that’s already running. Neither of              Different people have different takes on          Unix systems booting long before Linux was
these is possible with Linux From Scratch           LFS, but the two most common opinions are            invented. However, two newer systems have
                                                                                                         been created: systemD and Upstart. These both
(LFS) because, well, it’s a book. You can read      either that it’s the best way to learn about
                                                                                                         offer more advanced features than the older
it online in HTML form, or download a PDF.          the internals of a Linux system, or that it’s        scripts. Loosely speaking, Ubuntu and most
   LFS isn’t really a distro in the usual sense     just a way to waste days compiling                   derivatives use Upstart, while most other distros
of the word. Instead it’s a guide for creating      hundreds of pieces of software. Here at              use systemD and a few still use systemV.
a system that doesn’t need a distro. After all,     Linux Voice, we see the appeal of a system               Debian, a slow mover in the distro world,
                                                                                                         had clung onto systemV up until the start
a distro is really just a collection of software,   such as LFS, and it certainly has its place.
                                                                                                         of 2014. However, the technical committee
and that software is perfectly accessible on        However, most users wanting a distro they            was asked to vote on what direction Debian
the upstream project’s websites. So, instead        have control over will be better served by the       should go. In simple terms, systemD offered
of downloading a single image with all the          likes of Gentoo and Arch. That said, if you          more functionality, while Upstart supports
things you need, you download them                  ever want to know about what goes on                 Debian flavours with other kernels (the distro
                                                                                                         can use the FreeBSD kernel, or GNU’s Hurd).
separately, and this book is a guide for            underneath the various distros, LFS is an
                                                                                                         One sticking point was the fact that Canonical
combining everything into a working                 excellent place to start.                            (which develops Upstart) requires all code
                                                                                                         contributors to sign a Contributor Licence
                                                                                                         Agreement (CLA) giving Canonical control over
                                                                                                         their contribution, including the power to build
                                                                                                         non-free software based on it.
                                                                                                             In the end, systemD won after the committee
                                                                                                         chairman (Bdale Garbee) gave the casting vote.
                                                                                                         Following this, Mark Shuttleworth announced
                                                                                                         that Ubuntu would drop Upstart (in 14.10)
                                                                                                         leaving systemD as the init method on almost
                                                                                                         all distributions of Linux.
                                                                                                             Not everyone is happy about this. Some
                                                                                                         users feel that systemD goes against the Unix
                                                                                                         spirit by being monolithic and logging in non-
                                                                                                         human-readable binary format. Since it doesn’t
                                                                                                         play nicely with other Unix-like systems (such
                                                                                                         as the BSDs), anything that relies on systemD’s
                                                                              It’s the ultimate geek     features also won’t work on these systems.
                                                                              quest, but compiling       There is some truth to these complaints, but
                                                                              a full system takes        unless anything changes, it will soon become
                                                                              time, especially on        hard to find a distro that doesn’t use systemD.
                                                                              older hardware.


                                                                www.linuxvoice.com                                                                            9
     GAMING ON LINUX




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

 VIRTUAL INSANITY
                                               Project Zomboid
                                               Craft your perfect hideout, wait for all this to blow over.


                                               B
                                                         rains braaaains
                                                         braaaiiins! The game           Surviving the zombie
                                                                                        apocalypse has never
                                                         devs at The Indie Stone
                                                                                        been so isometric, grrr
                                               have graced us not only with a
                                                                                        arrrgh!
                                               major patch for the hit Project
                                               Zomboid, but have also
                                               introduced tons of new
 Liam Dawe is the brains behind
 www.gamingonlinux.com, the home               features, including the first
 of Linux gaming on the interweb.              version of their its persistent-
                                               multiplayer. So, now you can go


 V
           irtual Reality is a hot topic in    raiding supermarkets for tins of
           gaming right now, and Linux         food while your friends on
           isn’t being left out in the cold.
                                               another Linux PC stand watch
 A company called Oculus VR has
 created a headset named the Oculus            for zombies outside with a             rough), though it is fairly easy     When complete, Project
 Rift – sounds cool, right? It’s a             baseball bat.                          to get running on a Linux box.     Zomboid will have a sandbox
 strange-looking device that looks like           Anyone is free to run a server        The player models have also      survival mode, a single-player
 it should be in Star Trek.                    for it, as The Indie Stone is          been overhauled, so they have      story, split screen co-op and
     The good thing about the Oculus
                                               giving away the server tools (be       more animations, and the           online multiplayer.
 Rift is that it has Linux drivers ready,
 so it fully supports our platform.            warned though that it’s pretty         game looks fantastic.              http://projectzomboid.com
 Alongside the driver support from
 Oculus VR we also have Valve; the
 company behind Steam. Valve is
 pushing out a Virtual Reality API for
 game developers, which also
 supports Linux.
                                               Strife
     The Oculus Rift is a VR device that       A ‘second generation’ multiplayer online battle arena from S2 Games.
 sits over your eyes strapping you into



                                               S
 your game, and that’s where my                        2 Games shouldn’t be
 problem is. Gaming is supposed to be
                                                       a new name to people
 a social thing, isn’t it? Being strapped
 into some device feels so lonely. Not                 who have been following
 only that, but it’s quite restricting not     Linux gaming for a while – the
 to be able to see anything else.              company has just given out a
     The other problem I have is that a        whopping load of beta invite for
 game is supposed to be a game –
                                               its new multiplayer online battle
 why do people now want to emulate
 real life to the point of strapping           arena (or MOBA for short)
 things over their eyes? This is why I’m       called Strife.                           A pirate is just one of the
 hoping that it’s a fad, like 3D                  I was lucky enough to be              many characters you can
 televisions, 3D movies and the 3D             invited and delighted to report          choose to play as.
 mode on Nintendo’s latest hand-held
                                               that Strife is already fantastic. It
 console, which is more of a pain than
 anything else. Oculus VR will need to         aims to be a more minimalistic
 solve issues like eye-strain and              MOBA when compared to                     Strife plays with the MOBA      can create your own items to
 resolution before it’s taken seriously.       games like Dota2. For example,         experience by introducing a pet    use in-game and gain the
     So, to end on a question again for        a lot of things are hidden from        system. Pets have their own        advantage on your opponents.
 you lot: will Virtual Reality take-over
                                               view to begin with, although           unique abilities, and can be         This really is one to look out
 our gaming lives, or will it fade away
 into oblivion? You decide!                    you can pin different                  levelled up using food that you    for, especially given S2 Games’
 Liam Dawe, gamingonlinux.com                  information to the screen to           acquire after games. There’s       history of great Linux support.
                                               suit your playing style.               also a crafting system, so you     http://strife.com



10                                                                    www.linuxvoice.com
                                                                                                               GAMING ON LINUX


Planetary Annihilation                                                                          ALSO RELEASED…
That’s no moon! No wait, it is a moon – and it’s coming this way!


S
        o, you have looked up at the moon
        and thought to yourself “I wonder
        what it would look like if it smashed
into the earth”? Well you don’t need to
wonder about that anymore.                                                                        The mutant team is
   The developers of Planetary Annihilation                                                       taking a beating!
have now included the ability to build
massive space drives on moons for you to                                                        Mutant Gangland
send them off-orbit and smash into other                                                        Micromanegement got you down? Need some
heavenly bodies.                                                                                flesh pounding against metal? Enter Mutant
   They haven’t stopped there either: they                                                      Gangland, a very simple-looking turn-based
have also only just included their own                                                          strategy game that pits Mutants against
                                                                                                Robots in close-qaurters combat.
version of a Minimap too, which is                                                                 The game includes a level editor for high
essentially the game running again in a                                                         replayability, and also throws in the source
small window on your screen, which uses         Planetary Annihilation was funded on            code for players to create mods with.
up a lot of memory of course, but it does       Kickstarter to the tune of $2,229,344.             The team have recently released the first
look crazy!                                                                                     alpha version and we will be surprised if this
                                                                                                doesn’t pick up some fans.
   This is easily the most intense real-time    recommend checking this one out – just          http://mutantgangland.com
strategy you can find on Linux, taking          don’t blame us= if you get addicted.
inspiration from classics like Total              The game is still a little bit on the pricy
Annihilation and Supreme Commander.             side right now ($29) but they plan to drop
   If you are missing your fix of games like    the price once they hit the ‘stable’ version.
those or even Starcraft, we highly              www.uberent.com/pa

                                                                                                                             Plenty of help to
                                                                                                                              get you started

Starbound                                       The Swapper                                                                 included for free!

Ever seen a tree with big scary eye-balls       You may or may not find talking rocks,
                                                                                                Godot Game Engine
for leaves? No? Play this then.                 it gets a little freaky.                        Are you an aspiring game developer? Been
                                                                                                looking to make a game, but you don’t know
                                                                                                where to begin? Godot has you covered!
                                                                                                   This commercial-grade game-creation kit
                                                                                                has been open-sourced under the MIT licence
                                                                                                to give other engines a run for their money.
                                                                                                It has quite literally everything you need in one
                                                                                                package to begin creating.
                                                                                                www.godotengine.org/wp




So, many, pixels! Starbound is sort of like     Only recently released in the latest
Minecraft only in 2D and with far more to       Humble Indie Bundle 11, The Swapper
do. This game is an absolute gem, not           promises a very atmospheric puzzle-
                                                                                                                                Easily control
only because one of the developers uses         platformer experience.                                                       exactly how your
Linux, but because of just how fun it is.         When we read-up that everything in the                                         videos look!
   You can go from one planet that has big      game was made from real-life materials
scary eyeballs for leaves, to a planet that     we didn’t realise just how good that could
has pools of lava everywhere and pirates        actually look. From an escape-pod that          SimpleScreenRecorder
                                                                                                My absolute favourite screen-recorder
chasing you (no really, that happened to        looks like a can of beans, to freaky talking    software, fully featured and extremely easy to
me once).                                       rocks that look like sponges, the visuals       use. I use this software myself to record games
   Nothing is more satisfying than taking       are completely original.                        as I have found it to be the only software that
down a massive UFO Boss that warps                The game has some very unique                 can perfectly sync audio and video together.
down little penguins (aww) with bazookas        mechanics too: you gain a gun that                If you need more to go on, it’s also open-
                                                                                                source and free, so I want to see more of you
(eek!), though it does seem a little barbaric   creates clones of yourself, which you can       showing us your best play-throughs on the
killing tiny pixellated penguins on a           swap control with to solve puzzles.             Linux Voice forum!
platform that has a penguin as its mascot!      http://store.steampowered.com/                  www.maartenbaert.be/simplescreenrecorder
http://playstarbound.com                        app/231160



                                                               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
  GRACE HOPPER                                                            computing, such as Niklaus
                                                                          Wirth, C.A.R. Hoare, Donald
                                                                                                              how much faster computers had
                                                                                                              become. The picoseconds were
  Congratulations on                   (1981), I learned the basic        Knuth and Grace Hopper.             a packet of ground black pepper
  publishing the first of many         “rules” of programming from        Years later, I worked as a          with the DEC logo and the words
  great Linux Voice editions! I        a phenomenal designer/             civilian contractor at the          “Pico Seconds” printed on it. I
  was excited to see a picture         programmer, Gordon Vikse,          Pentagon. One day while             only wish I could have had her
  of Rear Admiral Grace                who continues to teach             walking one of the literally        sign mine. Her lesson that it is
  Hopper for an upcoming               me things to this day. He          17 miles of hallways, I             easier to ask forgiveness than
  article for next month. In           introduced me to the work          discovered a display on             permission is, in my opinion,
  my first job out of college          of some of the greats in           Grace Hopper, which greatly         embodied in the spirit of FOSS
                                                                          pleased me as it was a richly       computing. I’m glad to see that
                                                                          deserved honor. Shortly             Linux Voice is reminding us of the
                                                                          thereafter, I was even more         greatness that has existed, and
                                                                          pleased to be able to attend        continues to exist, in computing.
                                                                          one of her talks (around            Paul Olson, Oklahoma, USA
                                                                          1990). At the time, she had
                                                                          been forced into retirement         Andrew says: Paul, you’ve made
                                                                          by the U.S. Navy and was            my day. The Grace Hopper tutorial
                                                                          working as a consultant             that we’re running on page 80 isn’t
                                                                          for Digital Equipment               particularly Linuxy, but without Rear
                                                                          Corporation (DEC). During           Admiral Hopper’s work we might
                                                                          the talk, she told the story of     not have Linux at all.The debt that
                                                                          her nanosecond wires, then          we owe the likes of Grace Hopper,
  It’s only fair that we acknowledge, in Paul’s words, “the greatness     handed out picoseconds to           Alan Turing (he’s coming next issue),
  that has existed, and continues to exist” in computer science.          the audience to demonstrate         Donald Knuth et al is enormous.




PAYPONG
I’ve been an enthusiastic reader          is concerned. Is there any way
of your work for many years and           around this obstacle?
have had a subscription to your           Whatever the outcome, good luck
previous magazine, for several            with your new venture.
years, bought for me by a family          Norman Kearey
member; as a pensioner I need all
the help I can get!                       Andrew says: We’ve spoken to our
   In trying to decide what to do         bank about a better online payment
about migrating to your new               system, and they aren’t interested
magazine, I discovered that it            in helping us until we have at least
is impossible to do so without            a year’s accounts under our belt, so,
opening a PayPal account. I               distasteful as it is, we’re stuck with
know that this is not a welcome           PayPal and its exorbitant fees for now.   As much as we dislike it, PayPal is the only way for us to accept
situation, as far as my ‘benefactor’      We’re not happy about it either.          payments for magazine subscriptions at the moment.



12                                                               www.linuxvoice.com
                                                                                                                                       MAIL



PUBLISHING                                                                                                   THE CODE AHEAD
Thoroughly enjoying your first                                                                               Big fan of all your work. I’ve been
issue. What caught my eye at                                                                                 listening to the TuxRadar… I mean
first glance was the news that a                                                                             Linux Voice podcast for a while
new release of Scribus is on the                                                                             and just got the issue 1 PDF. The
way. Great! I have no doubt that                                                                             content is great.
this program will be well able                                                                                   You might already be working on
to compete with the extremely                                                                                these but here’s the two things I’d
expensive equivalents in the                                                                                 love to see:
Windows and the Mac platforms.                                                                                  Have the table of contents and
   But there’s a price to pay for                                                                               cover be made of clickable links
this complexity. In earlier times                                                                               to those stories. That will avoid
Scribus was easy to use and gave                                                                                “this story about bitcoin looks
me all the flexibility I needed. Now,                                                                           interesting, now let me scroll
unfortunately, I can’t perform even                                                                             through 56 pages to get to it”.
the simplest DTP tasks. Everything                                                                              An epub version.
seems to work differently and                                                                                Mark
nothing can be done intuitively.
There’s a complete guide to                                                                                  Graham says: Thanks for the feedback
Scribus in book form but it runs to                                                                          Mark, we appreciate it. We know that
438 pages!                                                                                                   we want to improve the digital offering
   Which brings me to my main                                                                                from PDF-only; at the moment we’re
point: there’s an excellent                                                                                  looking into a HTML 5 container app
                                                                                  Scribus (top) can be
opportunity here for developers         can produce good materials for                                       among other solutions, and epub
                                                                                  overkill for most tasks,
to construct a lower-level DTP          publication without too much              so we’d stick with         might be one of those that we settle
program which is usable by              effort. But many people need              LibreOffice or Inkscape    on. There’s a rift between XML and
ordinary human beings rather            something more versatile.                 for simple jobs.           HTML advocates at Linux Voice
than high-powered professionals.        Maurice George, Ormskirk,                                            Mansions, and this many influence the
Years ago there was ‘Publisher’, an     Lancashire                                                           formats that we choose. However, it’s
elementary Windows DTP program                                                                               one of our principles that we should
which appealed to a different user      Mike says: I quite agree. The power                                  offer the content in whatever medium
than ‘PageMaker’. So I would urge       to change, for example, the spacing                                  the readers want to buy, just as we
open source entrepreneurs to get        between individual letters is awesome                                offer the podcast in MP3, Ogg and
their act together and fill the gap.    when you’re doing high-end design                                    Opus files.
   Or maybe I’m missing a simpler       work, but it’s Scribus and its like are                                  Clickable links in the contents page
alternative in Linux ? Of course        massive overkill for most people.                                    though is something that we should
any word processor can design           Maybe all it would take is a version of                              have got right from day one, and if I
basic documents and Inkscape            Scribus with features taken out?                                     can remember how to do it we’ll have
                                                                                                             it in issue 2.




                                                              www.linuxvoice.com                                                                 13
     MAIL



            HEALTHY COMPETITION
            Congratulations on an amazing
            first issue!
            I could not believe when going
            through LV01, how much it is
            everything I have ever wanted from
            a Linux magazine:
               Amazing features.
               A section dedicated to gaming.        In a happy coincidence there’s another
               Arch.                                 competition for you on p96.
               A challenge after a tutorial.
               My name in it :-).                    Ben says: It’s often easier to learn
               Many more!                            when you have a tangible incentive
               I have a print subscription and       to do so. That’s why we’re offering
            will be with you for the many, many      exclusing Linux Voice T-shirts to the
            years this magazine will no doubt        winners of our coding competitions
            be around for.                           – though of course, if you’re learning
            Craig Waites                             something, you’re already winning.




            REDRUM REDRUM REDRUM REDRUM
            I understand that you must be            net/biamin and browse the code
            really busy these days, but you          directly at https://gitorious.org/
            know what they say: “All work and        back-in-a-minute
            no play makes Jack a dull boy…”             Thanks for providing me with
               So I have made a Bash game            GNU/Linux knowledge and tips for
            called “Back in a minute” that           these last 7-8 years, and keep up
            may offer some escape. It’s a            the good work! Even though my
            simple text-based adventure game         studies and social life permit little
            featuring four playable races, six       time for LUGs and other F/OSS
            enemies, turn-based fighting, eight      related events, listening to your
            hidden items and six different           podcasts makes up for it and also
            scenarios in the 270 sections            keeps me up to date.
            of the world map. You can also           Sigge, Norway
            create your own custom ASCII
            map for use in the game!                 Graham says: Thanks Sigge, we’ll
               I’m currently doing an MA in          show this to Ben as soon as we
            political philosophy, so it is nice to   release him from the coding tower,
            “switch off” every once in a while       where he’s been devising this month’s
            and play around in Bash a little.        competition. And thanks the some
               You can find the “Back in a           light relief; LV Mansions is starting to
            minute” website at http://sigg3.         look like the Overlook Hotel.

            On second
            thoughts, let’s
            not play Back In
            A Minute. ’Tis a
            silly game.




14
                                                                                                                                            MAIL



PIE TIME                                    RANDOM ACTS
First off, congrats on a great              Given the revelations that the
premier issue! Ah, most of the old          NSA tries to subvert the strength
band is back together again                 of encryption by weakening
and sounding fine! Now if you               algorithms and by subtly altering
just had a physicist on board,              the doping of the underlying
and perhaps a female computer               silicon, we should be suspicious
language researcher, and… “Linux            of the integrity of the random
Voice” is perhaps the best start-up         number generators. If the NSA is
investment I have                           doing such things then it is likely
ever made.                                  that the Chinese are doing the
   With all the interest in the             same -- the majority of electronics
Raspberry Pi, here is a suggestion          are now made in China or Taiwan.            outputs when called. This list could     The SID chip, as used
that I have been struggling with:              How do we know that our                  also be sent to the NSA. However,        on the Commodore
setting up a true real-time version         sources of random numbers are               any statistical analysis would show      64, is a part-analogue
of Linux on the Pi. I have looked           truly random? Can Linux Voice               them to be random. Alternatively,        sound chip and also
at Open Embedded, Preempt-RT,               address this question? Is there a           the randomness generator could just      an excellent source
                                                                                                                                 of random numbers
Xenomai and more, and they all              statistical test that can be applied        cycle through non-random numbers
                                                                                                                                 (noise), making it highly
seem promising but I haven’t                to /dev/random and /dev/urandom             under very specific circumstances.
                                                                                                                                 prized by synth geeks
found a good complete setup yet.            to verify that they are continuing              The issue did raise its head last    and encryption experts
I am trying to sample the Pi’s I/O          to provide statistically significant        year when an online petition asked       alike.
pins deterministically at about             sequences of random numbers?                Linus to remove the Intel hardware
10~20 kHz to debounce and filter            Andrew Shead.                               random number generator from /dev/
a 1kHz input, so evenly spaced                                                          random. Essentially, the issue boils
sampling times without latency is           Ben says: You’re right to be concerned      down to the fact that Linux generates
important.                                  about random-number generation. It’s        a random number itself, then XORs
   Congratulations again from the           a mathematical weak point in most           the number with one generated by the
rural parts of New York State (yes,         security systems.                           hardware random number generator.
there is more to NY than NYC, like             One test is to gather output from        This method of combination means
500 km of farmland all the way              the random generator in Linux (/dev/        that the outputted number will be as
to Canada) and I look forward to            random) to a file, then try to zip it. In   random as the most random input.
reading you for years to come!              theory, it’s impossible for any lossless    A compromised hardware generator
Jim Cranston, New York, USA                 compression to shrink random data,          wouldn’t make the system less secure.
                                            so if the zipped file is smaller than the       Of course, there’s also nothing to
Graham says: I love the idea of             uncompressed file, you have a non-          stop a malicious CPU from listening
looking into running real-time stuff        random random number generator.             for software random number
on the Raspberry Pi. From an audio          However, it’s very hard to perform a        generators, and manipulating the
perspective, it’s quite easyto build a      comprehensive statistical check when        output. Ultimately, there’s very
RT kernel for Jack, but I’ll have to look   you don’t know what you’re checking         little defence against a hardware
into whether it works just as well with     for. Imagine, for example, that every       manufacturer that wants to spy on
the Pi’s I/O. Stay tuned!                   CPU is pre-programmed with a list           you, except, perhaps, open hardware
                                            of truly random numbers that it             design like the work of opencores.org.




                                            TASTY PIE                                                                              Graham’s Pi Arcade
                                                                                                                                   tutorial on page 74
                                            Could we see more Raspberry Pi
                                                                                                                                  works on other Linux
                                            stuff in the new magazine please
                                                                                                                                      flavours, not just
                                            – in particular, more projects                                                           the Raspberry Pi.
                                            would be good.
                                            Matt Osman

                                            Mike says: Of course, but we have
                                            to be careful not to alienate non-Pi
                                            users. Luckily most Pi tutorials apply
The Raspberry Pi is like pulling an idea    just as well to generic Linux boxes –
out of your brain and putting it onto a     such as the arcade machine tutorial
USB-powered PCB.                            on page 74. Have fun!



                                                                   www.linuxvoice.com                                                                  15
     LUGS ON TOUR




LUGS ON TOUR
OCR Raspberry Jamboree
Linux Voice heads to the land of dark satanic mills
in search of education, innovation and Pi.


I
     n the computing world, almost       year the two events were run in
     everything has an acronym           different parts of the Manchester
     associated with it, but OCR isn’t   Central Convention Complex, but
one we hear very frequently. It          this year they combined into the
stands for Oxford, Cambridge and         main hall. This was slightly
RSA, though that tells you little. In    disturbing given that the Jamboree
fact, it’s an exam board, and            charged £20 entrance, yet the EICE
responsible for striking fear into the   was free despite giving access to
hearts of 16–18 year-olds across         the same area, and the same
                                                                                    Pi demonstrations were
the UK. That should tell you a           stands.                                                               for teachers, and that is more
                                                                                    provided by Simon
couple of things. Firstly, that the                                                 Walters, Ben Nuttall,      important in this case.
Raspberry Pi has been                    Come together                              Clive Beale and many          That’s not to say that the event
phenomenally successful at               Annoying though the price                  other learned and          wasn’t good for enthusiasts. The
getting into education: the fact that    difference was, it did give the event      knowledgeable folk.        Raspberry Pi foundation were out in
this is the second year that a major     a unified feel. The previous year,                                    force, with Carrie Anne Philbin, Clive
exam board is running the event in       there was a Pi event and an                                           Beale, Alex Bradbury and Ben Nutall
Manchester says a lot about the          education event. This year, it felt like                              wandering the floor and meeting
impact of the Pi in schools.             there was just one. Alongside a                                       people, though the Uptons didn’t
Secondly, it says that the event is      myriad of stands for educational                                      make it as they were in America at
going to have quite an academic          technology, you could see teachers                                    the time. The Linux Voice team
feel to it.                              learning Pi skills, and learning from                                 enjoyed meeting up with fellow
   The event is run in partnership       the experts. While 2013’s event was                                   Raspberry Pi-ers such as RasPi TV,
                                                                                    As well as the stands,
with the Education Innovation            perhaps better for Raspberry Pi                                       Peter Green (of Raspbian fame) and
                                                                                    there was a selection of
Conference and Exhibition. Last          enthusiasts, 2014 seemed better            talks to learn from.       Jack Kelly (organiser of the
                                                                                                               Manchester Raspberry Jam,
                                                                                                               www.mcrraspjam.org.uk), and
                                                                                                               there were plenty more people that
                                                                                                               we missed (such as the excellent
                                                                                                               folks at MagPi) because we
                                                                                                               foolishly went on the Thursday
                                                                                                               rather than the Friday.


                                                                                                                 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,
                                                                                                                 which draws its members to meet
                                                                                                                 and discuss their favourite topic. We
                                                                                                                 want to know more about your LUG
                                                                                                                 or hackspace, so please write to us at
                                                                                                                 lugs@linuxvoice.com and we might
                                                                                                                 send one of our roving reporters to
                                                                                                                 your next LUG meeting




16                                                             www.linuxvoice.com
                                                                                                LUGS NEWS



South Wales LUG
Mark Einon writes from the land of our fathers.


T
                                                                                                Key signing may seem
          he South Wales Linux User      (driver’s licence, passport etc)                       like paranoia to some,
          Group (SWLUG) has been in      for the keysigning, along with                         but it’s only sensible
          existence for more than 15     your key details. The party will                       nowadays.
years, in that time supporting local     mainly follow the course laid out
users of the Linux operating system      in www.cryptnet.net/fdp/crypto/
and other Free Software.                 keysigning_party/en/keysigning_
    In April, SWLUG are adding to        party.html.
their usual long-running tradition          If you can’t make the afternoon
of well-attended monthly meets in        talks in April, stalwart SWLUG
Cardiff and Carmarthen; this time        members will still be partaking
organising a series of talks, starting   in the usual monthly pub-based
on Saturday 26 April, 2.30–5pm at        meetings in both Cardiff (second
FoundersHub (foundershub.co.uk)          Tuesday of the month at The City
in the centre of Cardiff.                Arms, opposite the Millenium
    Expect at least four free and        Stadium) and Carmarthen (third
awesome main talks on diverse            Tuesday of the month, at Yr Hen          you can handle may be found via
Linux topics such as kernel              Dderwen on King Street), from            the website at www.swlug.org.
internals, hardware accelerated          7.30pm or so where we’re always          There you can also find out about
Linux routing, the MIT Athena            happy to welcome anyone to               our mailing list, IRC channel and
project, and Linux security              join whatever their interest or          Google+ community where you can
monitoring. There’s also time to         experience level.                        get involved at any time. Look out
fit in a few lightning talks and            Lots more details, further            for the Eventbrite link to register for
a keysigning party – so don’t            updates and ways to join in all the      talk attendance and we hope to see
forget some sort of official ID          South Wales-based Linuxy action          you there!




QCon London
Spend a beautiful spring day in London with some of the world’s smartest coder geeks.


T
        his was our first time at
        QCon London, and we                                                                      QCon costs a chunky
        can’t believe we’ve missed                                                               £2,295 to attend the
an event like this for so long. But                                                             conference plus three
                                                                                                    days of tutorials.
before you get too excited. It is
expensive to attend. This is one of
those professional events where
you need to surreptitiously place a
cost/benefit analysis chart where
your boss can see it.
  The benefits are obvious. Some
of the best developers in the
world, working on some of the
most cutting edge-projects, such
as Spotify and Netflix, all in the
same place and talking about the
challenges they’re facing and how        from Game of Life into a talk about
they’re solving them. Each talk we       how programming languages are
saw was inventive and engaging.          structured, how insane they can be,
But our highlight was Wednesday’s        and how he’s invented a own 24th
keynote, presented by Perl maestro       century programming language
Damian Conway. Somehow,                  based on Klingon, complete
he was able to shoehorn John             with throat-mangling Klingon
Conway’s (no relation) automata          pronunciation.



                                                             www.linuxvoice.com                                       17
     LISTEN TO THE PODCAST



     WWW.LINUXVOICE.COM




72
                                                                                                                      REVIEWS INTRO




                                    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...
                                                 20                                                    22




Andrew Gregory
Is at long last planing an expedition to
                                              Dell XPS 13                                            Retrode
Bletchley Park to visit the old computers.    Wireless problems fixed, this Ubuntu-                  Unlock the fun that’s currently
                                              powered laptop is bringing Linux (and                  imprisoned in your old games cartridges.
                                              6-hour battery life) to the High Street.               Emulation has never been so much fun.


D
         on’t it always seem to go, you
         don’t know what you’ve got ’til
         it’s gone. Yes, it does.                23                                    24                             25
   The thing that I had, which I don’t
have any more, is freedom over my
computing environment. Through
necessity I’m spending more and more
time on my new Mac, and the limits are
chafing like a tight sock.
   There’s little to no customisation         Krita 2.8                            PiBorg                           SolydXK
over the GUI, for instance. Then there’s
                                              Finger painting goes digital:        Get into robotics with this      Thesis: regular updates.
the lack of a software centre – if you’re
                                              KDE’s image editor gets              cheap and cheerful kit           Antithesis: rolling releases.
used to installing whatever you want
                                              touchscreen support.                 powered by the RPi.              Synthesis: turn to p25…
through Synaptic or with a simple
apt-get, other operating systems seem
extremely restrictive in comparison.
And the worst thing is that before it lets    BOOKS AND GROUP TEST
me update, Apple wants to know my
                                              Trees are good. They provide shelter, for woodland
shoe size, inside leg measurement and
                                              animals, many of which taste good when casseroled.
mother’s maiden name. Not cool at all.        They can also be mashed up into paper, which makes
   Apple does make fantastic hardware,        excellent medium for the written word. This month
and until recently it’s been impossible to    we’re mostly reading about the Raspberry Pi, but Ben
find similar quality in a standard laptop.    also got his hands on A Computer Called Leo, which
                                              recounts the early adoption of computers by Lyons’
Praise be then, for the Dell XPS 13 – it’s
                                              Tea shops way back in the 1950s, and tells how the
built with Linux in mind in conjunction       Brits lost the post-war computing initiative to our
with Ubuntu, and has raised the bar for       American colonists despite being jolly good chaps.
your next Linux box.                          And in the Group Test, it’s text editors.
andrew@linuxvoice.com



                                                              www.linuxvoice.com                                                                19
     REVIEWS DELL XPS 13 I7-4650



Dell XPS 13 i7-4650
Graham Morrison is happy to discover the wireless problems
that blighted last year’s model have gone.


                          T
                                   here’s a lot to like about the XPS 13. Thanks to   capable of some serious processing and great
  DATA                             machined aluminium and carbon fibre, it’s a        graphics performance, and we’d highly recommend
  Web
                                   tough, small, powerful, rigid and stylish device   going with the latter model for the £100 extra it costs.
  www.apt-net.co.uk       that’s proved itself in combat. Both last year’s model         It’s still significant that this is a Dell machine that
  Developer               and the new one beneath our collective fingertips           comes with Ubuntu 12.04 (LTS) installed, thanks to
  Dell                    feature Intel’s powerful Core i7 architecture, with an      what Dell calls Project Sputnik. This noble endeavour
  Price                   incredible 1920x1080 13-inch screen, bright backlit         attempts to offer more from Dell than simply buying a
  £999 + VAT
                          keyboard (something essential for nocturnal rambling)       laptop with a specification suitable for compiling
                          and a backpack-friendly form factor.                        things. The idea started with Stephen O’Grady of
                             This XPS13 is just 316mm wide, 205mm deep and            RedMonk, who suggested there may be a market for
                          6–18mm high (it’s a wedge), and weighs 1.4kg It’s           developers in the emerging cloud markets. The end
                          slightly lighter than the new 13-inch Apple Macbook         result was some custom-developed drivers, mostly for
                          Pro but the 2cm less depth makes a considerable             the Cypress touchpad, and bespoke cloud
                          difference visually, with no less control from the (still   management software, profile management and
                          larger than average) trackpad.                              storage that comes with the Developer Edition. These
                                                                                      are great features, but we’re more interested in a
                          Nice specs                                                  major manufacturer offering a Linux laptop along with
                          The new model has had a specification update,               its great recovery tools and support, things which
                          primarily to accommodate Intel’s new Haswell CPUs           don’t usually apply to hardware you buy and then
                          as well as the inclusion of a touchscreen. With the         install Linux on top of. Still, it’s a pity the project hasn’t
                          CPU architecture update comes Intel’s widely                bumped the officially supported version of Ubuntu yet,
                          respected Intel HD GPU power. There are two variants        but that’s probably a business/support issue rather
                          of the XPS 13, the first with Intel HD Graphics 4400        than anything to do with the way the XPS works with
                          and an i7 4500U CPU running at 3GHz, and the                other version of Ubuntu or any other Linux distro.
                          second with Intel HD Graphics 5000, i7 4650U at                The big problem for us with the previous model was
                          3.3GHz and a 256GB mSATA SSD, which is the model            wireless: it didn’t work. For some reason, the version
                          we’re looking at here. This is a powerful netbook,          we’d been sent didn’t maintain a connection with any




At low-CPU, low screen
brightness and low
keyboard LED settings,
whilst web browsing
and typing, the new XPS
13’s battery lasted an
exceptional six hours.



20                                                        www.linuxvoice.com
                                                                                                    DELL XPS 13 I7-4650 REVIEWS



                                                               Touchscreen

                                                               The most intriguing addition for this model is    framework as Android or Ubuntu Mobile,
                                                               the inclusion of a touch screen. This is likely   swiping down from the screen edges, for
                                                               to be because many Windows 8-based                example, or touch gestures to rotate and
                                                               laptops are now featuring touch capabilities      zoom, or the on-screen contention for the
                                                               to make some sense of Microsoft’s latest          mouse pointer which either represents the
                                                               user interface, but it’s a welcome addition for   location of the mouse or your touch, the
                                                               a Linux laptop, especially when so many           touchscreen is an added bonus, rather than a
                                                               desktops seem to want to be prodded.              reason to buy this laptop in itself.
There are two charge friendly USB 3 ports, a combination          Having used a Nexus 10 with a keyboard
mic/headphone jack and a mini-display port. An SD card         for some time, we can see the advantages of
slot would have been handy.                                    having both a laptop and touch screen, but
                                                               we’re not sure this yet translates into extra
access point for more than a couple of minutes. This           usability on the XPS 13. Firstly, the laptop
                                                               itself is too light to be prodded much. The
wasn’t an isolated incident either, as there were many
                                                               whole unit moves when you touch the
threads and comments online with Ubuntu XPS 13                 screen, although thankfully there’s too much
users experiencing the same problems. The problem              friction on the screen’s hinge for the angle to
was with the Centrino Advanced-N 6235 wireless                 change. In Ubuntu 12.04, touching the
chipset and the iwlwifi driver it was using. Despite the       screen does help when it comes to moving
Linux emphasis, it seemed a wireless hardware                  windows out of the way, or selecting text.
                                                               We’d say it’s slightly more efficient than with
revision had slipped under the testing dragnet. Dell           the touchpad or mouse for specific small          Ubuntu 12.04 includes drivers to make
sent out a Killer Wireless-N 1202 as a replacement.            jobs. But without the same gesture                the touchscreen work out of the box.
But we’re pleased so say the new version doesn’t
suffer connectivity problem at all. Wireless is now
provided by Intel’s 7260 chipset, giving strong, reliable    ultra-high resolutions and Linux is that there’s no
’N’ compatible connectivity. Lifting the lid to resume       decent system for scaling whilst keeping the fonts at
brought us wireless connectivity in around eight             a reasonable size (in the same way Apple does with
seconds, which is only a few moments after you’ve            its Retina displays), so until this problem can be
entered your password to unlock the screen.                  solved, 1980x1080 is the ideal number of pixels for us.
   Our system was supplied by Apt-net Ltd, a                 The only slight hitch was some backlight bleed in the
company that’s going to provide the XPS 13 in the UK         lower left of the display. More annoyingly, our model
at no extra charge, free delivery and with a choice of       also suffered from a whining sound, emitted most
distributions. To that end, ours came with Fedora 20,        loudly when the keyboard backlight was low. The pitch
Ubuntu 13.10, Ubuntu 12.04, OpenSuse and                     changed depending on the keyboard brightness,
LinuxMint 16 helpfully installed on a 32GB USB stick.        hinting at some
Every distribution worked well – much better than
before some of the patches had made it to the kernel.
                                                             regulation interference.
                                                             Dell’s support thread          “Lifting the lid to resume
We’re sure with a little tweaking your favourite distro      has lots of people with        brought us wireless connectivity
                                                                                            in around eight seconds.”
could feel as well integrated with the hardware as           the same issue,
Ubuntu 12.04 does with its custom driver pack.               regardless of operating
                                                             system, and Dell is
Key                                                          reportedly still looking into the issue. It’s worth
We really like the keyboard. We’ve typed tens of             checking whether the problem has been resolved
thousands of words on it. Compared to our                    before you make an order.
benchmark (which is a modern Macbook Pro, sorry!),              Overall, this is a fantastic piece of hardware. It’s
it’s got a softer, more cushioned final third of travel,     expensive, yes, but it’s designed for people who travel,
which we’d imagine is easier on RSI-battered wrists.         want to use Linux and still be as productive as they
The horizontal layout is a little wider than normal, but     are with a desktop. It’s also cheaper than the
we soon got used to it, and the LEDs behind the keys         equivalent Apple units with a similar form factor –
have variable levels of brightness. The font used on the     many of which are used by Free Software geeks at
keys is a little too Sci-Fi for our tastes, but the dimmer   conferences. The new XPS 13 is a solid upgrade to a
settings make the keys perfectly legible even in             powerful machine with excellent Linux credentials.
complete darkness. The granularity of control of the
screen brightness was perfect, and brightness settings         LINUX VOICE VERDICT
were great in a dark room, and sharp in sunlight.
                                                               About the most powerful netbook you
    The screen itself is gorgeous. As per the original         can buy. Light, bright, packed full of
model, we feel that the full HD resolution is a good           features and it comes with Linux.
compromise between the amount you can get on the
screen and the clarity of the text. The problem with



                                                               www.linuxvoice.com                                                                           21
     REVIEWS VINTAGE GAME ADAPTER



Retrode
Emulation-nut Mike Saunders is in heaven. And for once,
it has nothing to do with Weißbier…

                   W
                               hat a fantastic idea this is. We love
 DATA                          emulators, and spend way too much time
 Web
                               playing classic games from the 80s and
 www.retrode.org   90s. But there’s always one problem: the legality of
 Developer         ROM files (the file that contains the data from a
 Matthias Hullin   read-only memory chip – more or less a clone of a
 Price             game cartridge). Some people argue that if you
 €64.90
                   already own the physical version of a game, there’s
                   nothing wrong with playing a ROM file in an emulator
                   – but then, where do you get the ROM file from?
                   Chances are it has come off a website somewhere,
                   and generated by someone else, so the legal
                   questions remain.
                      The Retrode avoids all of these complications by        Plug in your game cart and its contents appear as a ROM
                   enabling you to play your original Super NES and Sega      image on a removable drive – simple as that.
                   Mega Drive (aka Genesis) cartridges in an emulator on
                   your PC. And the way it does that it is beautifully        emulator such as ZSNES. You’re no longer playing a
                   simple. It doesn’t require special data transmission       random ROM file from an unknown source, but the
                   software or custom emulators or anything like that         exact code in the physical cartridge that you own.
                   – it just works out of the box.
                      On the top of the Retrode are two cartridge slots for   Rainbow Road revisited
                   the aforementioned consoles. Plug in a cartridge,          One of the most common annoyances that people
                   connect the Retrode to your PC via the included USB        have with emulators is having to use different
                   cable, and you’ll see a new removable USB drive            controllers to the original machines. You can get
                   appear. Open this drive and voilà: the contents of the     adapters to connect original Super NES and Mega
                   cartridge are available as a ROM file (eg for SNES          Drive joypads to USB ports, but the Retrode is ahead
                   games they appear as .sfc files), ready to play in an       of the game here and includes four joypad ports: two
                                                                              Super NES and two Mega Drive. These appear to the

“It doesn’t require special data transmission
                                                                              system as standard USB game controllers, so they
                                                                              will work with any emulator.
software or custom emulators – it just works.”                                  And it gets better: if the game has battery-backup
                                                                              save states, in many cases you can access them too.
                                                                              We plugged in our copy of Super Mario Kart that we
                                                                              bought in 1992, and a .srm file containing our lap time
                                                                              records appeared on the drive, which loaded
                                 Shiny and black, the Retrode                 seamlessly into ZSNES. If you have some saved
                                 reminds us very much of the
                                                                              games that mean the world to you, and you’re worried
                                 Sega Master System II.
                                                                              about the in-cart batteries dying, you need this. Now.
                                                                                The Retrode worked with all the Mega Drive (5) and
                                                                              SNES (8) cartridges we tested, although there are
                                                                              compatibility notes on the website, so it’s worth
                                                                              checking those before buying the device. You can
                                                                              even get adapters to play Nintendo 64, Game Boy and
                                                                              Master System games. We’re beaming with delight at
                                                                              the prospect of getting our old Wave Race 64 records
                                                                              off the cartridge…

                                                                                LINUX VOICE VERDICT
                                                                                A brilliant idea, executed well. Not
                                                                                cheap for casual gamers, but for
                                                                                hard-core emulation fans it’s bliss.




22                                                www.linuxvoice.com
                                                                                                                            KRITA REVIEWS



Krita 2.8
Ben Everard decamps to the South of France, pours himself a coffee,
cuts off his ear and searches for his artistic side.


I
    mage editing software comes in many different
    forms. The majority we come across, are for
    touching up photographs. Krita, though, is
different. It’s designed for digital drawing, and creating
new images rather than touching up existing ones.
Think of it as digital painting software and you’ll be
pretty close. It does have some filters that could be
used to touch up photos, but you’d almost always be
better off with other software for this.
   Digital drawing covers quite a wide range of tasks,
and Krita is surprisingly capable of meeting most
challenges. It’s simple and intuitive enough for most
beginners to get started with quickly. The range of
brush presets has been improved in 2.8, and using
just these and a bit of clicking, most people can start
to create something loosely resembling art. If you
possess some basic artistic talents, you should be             It’s a sunset over an ocean, in case you were wondering.
able to make something looking good quite quickly.
   Yet despite how easy it is to get started, Krita is still   Intel, presumably as a way to show off laptops that
complex and powerful enough to suit the needs of               can convert into tablets (see the demo video at www.           DATA
many professional digital artists. The dockers                 youtube.com/watch?v=qiSGuCzRZFk). This looks                   Web
interfaces make it easy to show or hide functionality          pretty, but it’s almost useless unless you own a very          www.krita.org
so you have access to the tools you need, but don’t            specific type of device, especially as there’s no              Developer
overcrowd the window. For serious users, various               Android support.                                               Krita Foundation
                                                                                                                              Price
levels of commercial support are available through                 There is some good news for Linux users. The
                                                                                                                              Free under GPL or from
www.kritastudio.com.                                           wrap-around mode makes it much easier to create                €225 per person per year
                                                               tiling images, which is great if you’re working on game
Free software on Windows                                       art. OpenGL support has also been improved, so
2.8 is an important release for the project and will           some of the rendering can now be offloaded to free up
probably see a large uptake in users for two reasons:          the CPU. The developers claim that support for
it’s the first stable version for Windows, and it’s            graphics tablets has been improved, though we don’t
been greenlit by the community to come to Steam                have a device to test this on. Along with the usual
(www.steamcommunity.com/sharedfiles/                           bugfixes, this adds up to a useful, though not overly
filedetails/?id=225403385). While this is exciting             exciting release.
news for the project, neither of these things really               We can forgive Krita 2.8
affects how the software performs for us Linux users.
But still, welcome to the party, everyone else!
                                                               for being focused on
                                                               Windows. After all, it’s the
                                                                                              “Krita is powerful enough
    Krita now comes with Krita sketch. This is the a           first stable Windows           to suit the needs of many
new user interface that’s been designed for
touchscreens. It was developed in partnership with
                                                               version. If this makes it
                                                               easier for KO GmbH (the
                                                                                              professional digital artists.”
                                                               company that supports
                                                               development of Krita) to fund development, then we
                                                               all win. There’s nothing wrong with version 2.8, but,
                                                               unless you need wrap-around mode, or happen to
                                                               own a laptop that transforms into a tablet, there’s little
                                                               reason to rush out to download the latest version.

                                                                 LINUX VOICE VERDICT
                                                                 A solid release for Linux users,
                                                                 and an exciting release for
                                                                 Windows users.
Krita Sketch is useful for posing with transformable
touchscreen laptops, but not much else.


                                                                 www.linuxvoice.com                                                                  23
     REVIEWS ROBOTICS KIT



PiBorg PiCy
Ben Everard loses hours of his life to this little kit that
sets your Raspberry Pi free to roam around the kitchen.

                               T
                                        he Raspberry Pi is a great base for robotics
  DATA                                  projects of all shapes and sizes, and the PiCy
  Web
                                        is about as small as they come. It’s just a
  www.piborg.org               Raspberry Pi case with a pair of motors and wheels.
  Developer                       Assembling the kit requires a little soldering, though
  PiBorg                       none of it is difficult or fiddly (the kit is also available
  Price                        pre-soldered for an extra £7). Everything else can be
  £29.99 (not including
  Raspberry Pi)
                               assembled with no tools at all. The case snaps over
                               the Pi, the motors and battery case are glued on, and
                               the wheels are just pushed into place. It took us about
                               30 minutes to build ours, and that included time to
                               take step-by-step photos.
                                  The only electronics are a small circuit board to
                               power the motors. This board (called a PicoBorg) is
                               just a group of Field Effect Transistors (FETs) that are
                               used to control higher-power devices such as motors.           WThe PicoBorg (the electronics at the heart of the kit) is
                                  Once assembled, controlling it is just a matter of          available by itself for £6.99 including UK shipping.
                               using the GPIO pins. There’s example code on the
                               PiBorg website to do this with Python, though it could           The essence of robotics is compromise, and in
                               be done in other languages if you prefer. Getting this         order to make it easy to get started, the kit sacrifices
                               running was as easy as assembling it. Most other               some things. The glued-together frame doesn’t feel
                               motor control boards for the Pi use special libraries to       particularly strong, so it’s unlikely to cope well with
                               control the hardware. The fact that this works on pure         rough handling. That said, the first thing to break will
                               GPIO output makes it a great first kit for anyone who          almost certainly be the double-sided tape, which
                               wants to learn more about controlling things with the          would be trivial to repair.
                               Pi. However, this does give you less control over the
                               motors – you can only turn each one on or off, so              My First Robot
                               there’s no speed control and no reverse.                       The two video connectors on the Pi are inaccessible
                                                                                              when it’s strapped into the PiCy, so you couldn’t use

“Considering how easy it is to program,                                                       this as a base for anything with a HDMI screen, but

the PiCy is a great introduction to robotics.”
                                                                                              then it’s not likely to be big enough for that anyway.
                                                                                                 To get up and running, you’ll need the PiCy kit, a
                                                                                              Raspberry Pi and the usual paraphernalia (SD card,
                                                                                              power supply, etc). The main base for the chassis is a
                                                                                              ModMyPi case, which is excellent at protecting the Pi,
                                                                                              but doesn’t make a very expandable basis on which to
                                                                                              build. There aren’t any holes or anything else to mount
                                                                                              additional hardware on. The best bet for expanding it is
                                                                                              either gluing parts on or drilling into the case. On the
                                                                                              plus side, there are two unused protected GPIOs on the
                                                                                              PicoBorg (including one with PWM) to add more
                                                                                              motors or other peripherals to your robot. At this price,
                                                                                              and considering how easy it is to assemble and
                                                                                              program, the PiCy is a great introduction to robotics,
                                                                                              and the parts it’s made from can easily be recycled into
                                                                                              to more advanced projects as your skills develop.

                                                                                                LINUX VOICE VERDICT
                                                                                                Possibly the easiest way that we’ve
                                                                                                seen to to build a robot based on the
                                                                                                Raspberry Pi.
Though not strictly necessary, a portable USB power supply will let you run your creation
untethered, and a Wi-Fi dongle will enable you to communicate with it once it’s free.



24                                                               www.linuxvoice.com
                                                                                                          DISTRIBUTION REVIEWS



SolydXK 201401
Does the world really need yet another Debian-based distro?
Well, the answer is yes, as Mike Saunders discovers.


S
       olydXK is an unassuming distro that could very
       easily have missed your radar. After all, how
       many other desktop-oriented Debian spin-offs
are doing the rounds? We’ve lost count now. But after
two readers mentioned SolydXK in last issue’s letters
page, we had to take it for a spin. And we’re glad we
did, because its release model could become the
norm for desktop distros in the future.
   Right now, there are two main ways that distro
makers approach releases: some, like Ubuntu and
Fedora, create one or two big releases each year.
Everyone waits patiently for several months and then
does the big upgrade to get all the hottest new
software. It works fairly well, but sometimes it’s a drag
having to wait. Then there’s the rolling model, as used
prominently by Gentoo and Arch, where you get new
software as soon as it’s released by the original
developers. This lets you live on the bleeding edge, but
things can occasionally break due to a lack of testing
and integration.
   SolydXK is a half-way house; you only have to install
it once, and then every three months you’ll receive         Some people will like the distro’s use of a plain KDE setup, but we’d like to see a bit more
Update Packs to get the latest software. So there are       individuality shine through – or you could follow page 84’s tutorial and tweak it yourself.
no fanfare-surrounded major releases where everyone
rushes to upgrade – you just get the newest                 Mint’s attractive Software Manager is included, and
programs in well-tested bundles. This is a great            the installer is also based on Mint’s.                            DATA
approach, and hope to see it adopted by more                    There are a few rough edges: the presentation and             Web
desktop Linux distributions.                                theming isn’t very slick, and some work could be done             www.solydxk.com
                                                            to tidy up the menus (having both Package Manager                 Developer
What’s in the box?                                          and Package Installer in the System menu could                    The SolydXK team
                                                                                                                              Price
Two versions are available: KDE and Xfce (we tested         confuse new users, for instance). But the SolydXK
                                                                                                                              Free (various open
the former here). In use it’s a fairly vanilla Debian       team has demonstrated real commitment to the                      source licences)
testing-based distro with a stock KDE 4.12 installation,    project, with installation videos on the website, a
supported by LibreOffice 4.1, Firefox 26 and various        growing community, and annual reports explaining
other desktop apps. VLC is included together with a         how things are
                                                            progressing.
                                                                                            “The SolydXK team
bunch of media codecs, so the distro can handle most
formats from the get-go. Along with Synaptic, Linux             Time will tell if the
                                                            Upgrade Packs work as
                                                            intended and the goal of        has demonstrated real
                                                            “you don’t have to reinstall,   commitment to the project.”
                                                            ever” can be achieved. But
                                                            it’s certainly a distribution
                                                            to keep an eye on, and if it gathers enough interest it
                                                            could make some of the others (with their traditional
                                                            timed-interval release cycles) start to look rather
                                                            old-hat.

                                                              LINUX VOICE VERDICT
                                                              A promising distro with a fresh
                                                              approach to updates – it just needs
                                                              more personality of its own.
SolydXK’s Mint-based installer is quick, easy to use and
versatile enough for power users.



                                                              www.linuxvoice.com                                                                     25
     REVIEWS BOOKS



Adventures in Raspberry Pi
& Raspberry Pi USer Guide
Andrew Gregory spends some rainy days with the world’s favourite Linux machine.


T
          he Raspberry Pi came about               installing Raspbian with Noobs, an
          because Eben Upton, the PiFather,        introduction to the command line, the
          decided that something needed to         Scratch programming language, drawing
be done to improve the quality of students         with a Python turtle (just like we’re doing this
applying to study on his university computer       issue with our Python tutorial on p96). The
science courses. So far, so sensible, and you      final project is building a jukebox with the Pi,
can read more about the effect that the            using a speaker, a breadboard an LCD
raspberry Pi is having on education in our         display and the Pi’s GPIO pins. This is the
interview with the Pi Foundation’s education       sort of thing that a supportive parent would
team on page 46. But the Pi has also found         be likely to find were they to simply Google
an audience among the massed legions of            for Raspberry Pi projects, and for most
home tinkerers, shed solderers, robot              people it’s just too challenging. Adventures
builders, beer brewers and people who              in Raspberry Pi slowly builds up the difficulty,
generally have an interest in home hackery.        constantly challenging the newcomer to
   The two books we’re looking at here have        learn more and improve on their skills, and
these two readerships in mind. Adventures          that’s what makes it such an excellent book
in Raspberry Pi, by Carrie Anne Philbin, is        for teachers, kids, parents or just non-
aimed squarely at children, teachers and           technical humans who want to learn a bit.          If we had to sum this book up in a word, that
parents looking for a way into computer                                                               word would be: accessible.
science. Raspberry Pi User Guide, with its         Raspberry Pi User Guide
oh-so-serious graph paper on the cover (a          In contrast, Raspberry Pi User guide is very       reference book. There’s (luxury!) a
brilliant idea) is targeted at the older hacker,   much preaching to the converted. It’s a geek       nice index, and its pages speak of
at adults who have some experience of              fest, and almost seems designed to deter           authority. Even though it’s not
programming, and who want to transfer              casual readers. There’s a discussion on the        especially weighty at 300 pages
their existing knowledge to this relatively        merits of x86 vs ARM chips for instance,           – OK, so it’s not light reading, but
new device.                                        and sections on relatively advanced and            computer tomes often come in at
   It’s not surprising then that Adventures is     stuff like network configuration and HDMI          around the 800 mark – it feels like
the more accessible of the two. The book is        display modes.                                     a definitive, official work. There’s a
divided into nine adventures, beginning with          Whereas Adventures presents a smooth            confidence to the writing that you
                                                   learning curve, User Guide feels like it’s had     can feel as a reader. This feels like a
                                                   facts packed into it rather than projects,         definitive work.
                                                   diminishing its usefulness as a learning tool.        Which of these books work for
                                                   The chapter on Scratch, for example, the           you depends on you. We’d
                                                   programming language aimed at kids,                recommend them both in a
                                                   comes after the chapter on using the Pi as a       heartbeat. You won’t like both of
                                                   web server. This doesn’t make sense to us.         these, but you will definitely like one
                                                      While not that great as a structured            or the other, depending on where
                                                   programme of learning, User Guide is a great       you are in your Linux journey.


                                                     LINUX VOICE VERDICT
                                                     ADVENTURES IN
                                                     RASPBERRY PI                                       RASPBERRY PI USER GUIDE
                                                     Author Carrie Anne Philbin                         Authors Gareth Halfacree & Eben Upton
                                                     Publisher Wiley                                    Publisher Wiley
                                                     ISBN 978-1-118-75125-1                             ISBN 978-1-118-79548-4
                                                     Price £14.99/US $24.99/CAN $29.99                  Price £17.99/US $19.99/CAN $23.99
                                                     Brilliantly thought out, this is the perfect       Contains many facts, all of them true. The
                                                     guide to catalyse computing curiosity.             definitive reference guide.
If we had to sum this book up in a word, that
word would be: authoritative.



26                                                               www.linuxvoice.com
                                                                                                                      REVIEWS BOOKS


A Computer Called LEO                                                                               ALSO RELEASED…
Ben Everard discovers that tea shops and computers go together.


T
           he story of how Silicon Valley grew
           to dominate the computing world
           has been told many times, but it’s
not the only tale of how computers
developed. While IBM were still building
adding machines, a British company
famed for its teashops built its own                                       It’s just like Downton                                    Situational
computer and ran the world’s first office                                  Abbey, just with                                          awareness is
computing jobs. They ran payroll,                                          computers and forty                                       the key phrase
management accounting jobs and others                                      years into the future.                                    for network
long before anybody else realised such                                                                                               analysis
things were possible.                            just don’t expect a tech-heavy geek fest.          Network Security Through Data
   In A Computer Called Leo, Brenda              It’s perfect for reading over a cream tea on       Analysis
Maddox charts the history of this very           a sunny afternoon with the tune of Rule            This book looks like the networking security
British company and how it started the           Britannia gently wafting through the air.          equivalent to Crystal Maze. It gives you the
                                                                                                    tools to snoop on your own network traffic in
office computer revolution. It’s not a
                                                                                                    an attempt to head off the bad guys before
technical exploration of how they worked,          LINUX VOICE VERDICT                              they even know they’ve been found.
but a gentle history of what ultimately            Author Brenda Maddox
became a side-note in technology.                  Publisher Harper Collins
   It is, perhaps, an important story of how       ISBN 978-1-84115-186-1
                                                   Price £11.99
plucky British boffins created some of the
                                                   Computers, tea and cakes. Chuck in a pint
best technology in the world, but                  of real ale and you’ve got the perfect way to
ultimately failed in the face of international     spend an afternoon.
competition. You can read this as a
cautionary tale or an entertaining story,                                                                                            Tin cans and
                                                                                                                                     a piece of
                                                                                                                                     string? You
                                                                                                                                     were lucky. All
Arduino for dummies                                                                                                                  we had were
                                                                                                                                     yoghurt pots.
Ben Everard ignores this book’s cover, then enjoys the contents.
                                                                                                    Remote Pairing


T
         he Arduino is probably the easiest                                                         Feeling lonely? Paired programming is the
                                                                                                    latest thing to help isolated programmers
         way to get started in interactive                                                          develop more of a social life, whilst learning to
         electronics. That said, anything                                                           interact with real human beings. Actually, it’s
that involves programming or electronics                                                            not. It’s a cool new methodology that’s proving
is guaranteed to scare some people.                                                                 two heads are better than one.
Anything that involves both programming
and electronics (as the Arduino does) is
going to scare quite a few people.
   This reviewer has always steered clear
of ‘For Dummies’ titles because they seem
to confuse not knowing about a subject
with stupidity. This book is clearly for
people who don’t know about the Arduino,
dummy or not. A dummy who happened
to know about the Arduino wouldn’t have                                                                                              Python and Pi:
much use for the book and is probably a          Ben isn’t a dummy, but he enjoyed this book.                                        a match made
very dangerous person to have around                                                                                                 in heaven.
(never let them plug anything into your            LINUX VOICE VERDICT                              Learning Python with Raspberry Pi
power sockets).                                    Author John Nussy                                This book looks so wonderful, so learned and
   Title aside, this book is a gentle intro to     Publisher John Wiley and sons                    so entertaining we’ve already enlisted the help
                                                   ISBN 978-1-118-44637-9                           of top book reviewer, Brander Eve, to take a
the Arduino starting from the assumption
                                                   Price £16.99                                     look at this title for us. Early reports indicate
that the reader knows nothing about
                                                   One of the gentlest introductions to the         it’s everything we hoped it would be, but we’ll
electronics or programming and building            Arduino, if you can stomach the title.           wait on Brander’s final verdict next month.
up from there. Despite this, it covers a
wide range of hardware and projects.



                                                                 www.linuxvoice.com                                                                     27
     GROUP TEST ADVANCED TEXT EDITORS




    ADVANCED
 TEXT EDITORS
                 GROUP TEST
                 Mayank Sharma tests five supercharged text editors that
                 can crunch more than just words.



 On Test                                              Advanced Text
 Gedit
                      URL http://projects.
                                                      Editors
                      gnome.org/gedit/                The right editor can be passport to a better Linux.

                                                      I
                      Version 3.10
                      Licence GPL                          f you’ve been using Linux long,            Some simple text editors even
                      Is Gnome’s default text              you know that whether you               exceed their design goals thanks to
                      editor up to the challenge?          want to edit an app’s                   plugins that infuse them with
                                                      configuration file, hack together a            capabilities to rival text-centric apps

 Kate                                                 shell script, or write/review bits of
                                                      code, the likes of LibreOffice just
                                                                                                   from other genres. They can take
                                                                                                   on the duties of a source code
                      URL www.kate-editor.org         won’t cut it. Although the words             editor and even an Integrated
                      Version 3.11                    mean almost the same thing, you              Development Environment.
                      Licence LGPL/GPL                don’t need a word processor for                 Two of most popular and
                      Will Kate challenge fate?
                                                      these tasks; you need a text editor.         powerful plain text editors are
                                                         In this group test we’ll be looking       Emacs and Vim. However, we didn’t
                                                      at five humble text editors that are          include them in this group test for a
                                                      more than capable of heavy-lifting           couple of reasons. Firstly, if you are
 Sublime                                              texting duties. They can highlight           using either, congratulations: you
                                                      syntax and auto-indent code just as          don’t need to switch. Secondly, both
                      URL www.sublimetext.
                      com                             effortlessly as they can spellcheck          of these have a steep learning
                      Version 2.0.2                   documents. You can use them to               curve, especially to the GUI-oriented
                      Licence Proprietary             record macros and manage code                desktop generation who have
                      Proprietary software in         snippets just as easily as you can           access to alternatives that are
                      the land of free with the       copy/paste plain text.                       much more inviting.
                      heart of gold.

 UltraEdit                                            “Some simple text editors even exceed
                      URL www.ultraedit.com
                      Version 4.1.0.4
                                                      their design goals thanks to plugins.”
                      Licence Proprietary
                      Does it do enough to
                      justify its price?
                                                        THE CRUCIAL CRITERIA
                                                        All the tools, except Gedit and jEdit,     of the desktop environment they are
                                                        were installed on Fedora and Ubuntu via    running on. That not only rules it out as
                                                        their recommended installation method.     an evaluation criterion, it also means
 jEdit                                                  The former already shipped with the
                                                        default Gnome desktop and the latter
                                                                                                   that you are no longer bound by the
                                                                                                   tools that ship with your favourite
                      URL www.jedit.org                 stubbornly refused to install on Fedora.   desktop environment.
                      Version 5.1.0                     Since these are relatively simple apps,       In addition to their geekier
                      Licence GPL                       they have no esoteric dependencies,        functionality, we also tested all our
                      Will the Java-based               the only exception being jEdit, which      candidates for general-purpose text
                      editor spoil the party            requires Oracle Java.                      editing. However, they are not designed
                      for the rest?                        Thanks to the continued efforts of      to mimic all the functionality of a
                                                        both Gnome and KDE, all editors look       modern-day word processor and weren’t
                                                        great and function properly irrespective   evaluated as such.




28                                                www.linuxvoice.com
                                                                                     ADVANCED TEXT EDITORS GROUP TEST



Programming                                                                                          Keyboard
language support                                                                                     control
They’re called code editors for a reason.                                                            Flex those fingers!


                                                                                                     U
                                                                                                               sers of an advanced text editor expect
                                                                                                               to control and operate it exclusively
                                                                                                               via the keyboard. Furthermore, some
                                                                                                     apps even allow their users to further
                                                                                                     customise the key bindings for the shortcuts.
                                                                                                        You can easily work with Gedit using its
                                                                                                     extensive keyboard shortcut keys. There are
                                                                                                     keys for working with and editing files as well
                                                                                                     as invoke tools for common tasks such as
                                                                                                     spellchecking a document. You can access a
                                                                                                     list of default shortcut keys from within the
                                                                                                     app, but there’s no graphical way to customise
                                                                                                     them. Similarly, to customise the keybindings
                                                                                                     in Sublime, you need to make modifications in
                                                                                                     its XML keymap files. Sublime has been
Kate can double up as a very versatile and capable integrated development editor.                    criticised for its lack of a graphical interface to
                                                                                                     define keyboard shortcuts, but long-term users



U
           ltraEdit does syntax highlighting,      navigating long code files and lets you            have defended the current file-based
           can fold code and has project           jump between different parts of the file.          mechanism, which gives them more control.
           management capabilities. There’s           One of the best features of Sublime is            UltraEdit is proud of its “everything is
also a function list, which is supposed to         its ability to run code for certain languages     customisable” motto, which it extend to
list all the functions in the source file, but it   like C++, Python, Ruby, etc from within the       keyboard shortcuts. You can define custom
didn’t work for any of our test code files.         editor itself, assuming of course you have        hotkeys for navigating the menus and also
UltraEdit also supports HTML5, and has a           the compiler and other build system tools         define your own multi-key key-mappings for
HTML toolbar with which you can add                installed on your computer. This helps            accessing its plethora of functions.
commonly-used HTML tags.                           save time and eliminates the need to                 In addition to its fully customisable keyboard
   Even Gnome’s default text editor, Gedit,        switch out to the command line.                   shortcuts, jEdit also has pre-defined keymaps
has several code-oriented features such               You can also enable the build system in        for Emacs. Kate is equally impressive in this
as bracket matching, automatic                     Kate with plugins. Furthermore, you can           respect. It has an easily accessible window to
indentation, and will also highlight syntax        add a simple front-end to the GDB                 customise the key bindings. You can change
for various programming languages                  debugger. Kate will work with Git,                the default keys, as well as define alternate
including C, C++, Java, HTML, XML,                 Subversion and Mercurial version control          ones. Furthermore, Kate also has a Vi mode
Python, Perl, and many others.                     systems, and also provides some                   which will let users operate Kate using Vi keys.
   If you’re looking for more programming          functionality for project management.
assistance, look at Sublime and Kate.                 It does all this in addition to highlighting
Sublime supports several programming               syntax for over 180 languages, along with
languages and (as well as the popular              other assistance like bracket matching,
ones) is able to highlight syntax for C#, D,       auto-completion and auto-indentation. It
Dylan, Erlang, Groovy, Haskell, Lisp, Lua,         also supports code folding and can even
MATLAB, OCaml, R, and even SQL. If that            collapse functions within a program.
isn’t enough for you, you can download                The only disappointment is jEdit, which
add-ons to support even more languages.            bills itself as a programmer’s text editor,
   Furthermore, its syntax highlighting            but it struggled with other basic functions
ability offers several customisable                such as code folding and wouldn’t even            Both UltraEdit and Kate have options to print a
options. The app will also match braces,           suggest or complete functions.                    reference guide for all their keyboard shortcuts.
to ensure they are all properly rounded off,
and the auto-complete function in Sublime            VERDICT                                           VERDICT
works with variables created by the user.            Gedit                                             Gedit
                                                     Kate                                              Kate
   Just like Komodo IDE, sublime also                Sublime                                           Sublime
                                                     UltraEdit                                         UltraEdit
displays a scrollable preview of the full            jEdit                                             jEdit
source code, which is really handy for



                                                                  www.linuxvoice.com                                                                 29
     GROUP TEST ADVANCED TEXT EDITORS



Snippets and                                       Ease of use
macros                                             Inviting or intimidating?


                                                   U
                                                            nlike a bare-bones text editor, the      Although at first glance most apps in
Because time is money.                                      text editors in this feature are      this group test have a very similar layout,
                                                            brimming with features to             upon closer inspection, you’ll notice
Macros help you cut down the time spent on         accommodate a wide range of users --           several usability differences. We have a
editing and organising data by automating          from document writers to programmers.          weak spot for apps that expose their
repetitive steps, while Snippets of code           Instead of stripping features from the         functionality and features by making
extend a similar functionality to programmers      apps, their developers are looking for         judicious use of the user interface, instead
by creating reusable chunks of source code.        avenues to add more functionality.             of just overwhelming the user.
Both have the ability to save you time.
   The vanilla Gedit installation doesn’t have
either of these functionalities, but you can       Gedit
enable them via separate plugins. While the        Gedit wears a very vanilla look. It has an     a tool enabled by a plugin. The app will
Snippets plugin ships with Gedit, you’ll have to   easy interface with minimal menus and          detect when an open file is modified by
manually download and install the macro            buttons. This is a two-edged sword             another application and offers to reload
plugin (it’s called gedit-macropy and is           though, as some users might fail to realise    that file.
hosted on GitHub) before you can enable it         its true potential.                               The UI has been given a major overhaul
from within Gedit.                                    The app can open multiple files in tabs      in the latest version of the app yet to make
   Kate takes the same plugins route to            that can be rearranged and moved               its way into Gnome. However it isn’t yet
enable the snippets feature. Once added, the       between windows. Users can optionally          stable, and while it maintains all features,
plugin also adds a repository of snippets for      enable panels on the side and bottom for       several plugins that interact with the
PHP, Bash and Java. You can display the list       displaying a file browser and the output of     menu will need to be updated.
of snippets in the sidebar for easier access.
Right-click on a snippet to edit its contents as
well as its shortcut key combination.
However, very surprisingly, it doesn’t support
macros – despite repeated hails from users
                                                                                                                 There’s a fine balance
since 2002!
                                                                                                                 between stuffing an app with
   jEdit too has a plugin for enabling snippets.                                                                 features and exposing all
But it can record macros from user actions                                                                       of them to the user – Gedit
and you can also write them in the BeanShell                                                                     keeps most of its features
scripting language (BeanShell supports                                                                           hidden.
scripted objects as simple method closures
like those in Perl and JavaScript). jEdit also
has a plugin that will download several            Kate
macros from jEdit’s website.                       Although a major part of its user interface    with multiple files at the same time. But
   Sublime ships with inbuilt ability to create    resembles Gedit, Kate tucks in tabs at         unlike the traditional horizontal tab
both snippets and macros, and ships with           either side and its menus are much fuller.     switching bar in most app, Kate has tabs
several snippets of frequently used functions      The app is approachable and invites users      on either side of the screen. The left
for most popular programming languages.            to explore other features.                     sidebar will display an index of open files.
   Snippets in UltraEdit are called Smart             Kate can transparently open and save        Programmers who need to see different
Templates and just like with Sublime you can       files over all protocols supported by KDE’s     parts of the same file at the same time will
insert them based upon the kind of source file      KIO including HTTP, FTP, SSH, SMB and          also appreciate its ability to split the
you’re editing. To complement the Macro            WebDAV. You can use the app to work            interface horizontally as well as vertically.
recording function, UltraEdit also has an
integrated javascript-based scripting
language to automate tasks. You can also
download user-submitted macros and scripts
from the editor’s website.

  VERDICT
  Gedit
  Kate
  Sublime                                                                                                        KDE’s philosophy of exposing
  UltraEdit                                                                                                      functionality to the user
  jEdit
                                                                                                                 applies to Kate, and works
                                                                                                                 well in this context.



30                                                        www.linuxvoice.com
                                                                                ADVANCED TEXT EDITORS GROUP TEST

Sublime Text
Sublime lets you view up to four files at
the same time in various arrangements.
                                                files. The app ships with several snippets
                                                for popular functions in several              Availability and
                                                                                              support
There’s also a full-screen distraction free     programming languages, which makes it
mode that just displays the file and the         very usable for developers. Another neat
menu, for when you’re in the zone.              editing feature, whether you are working
   The editor also has a minimap on the         with text documents or code, is the ability
right, which is useful for navigating long      to swap and shuffle selections.
                                                                                              Where do you look for help?
                                                                                              There are several similarities between Gedit
                                                                                              and Kate. Both apps take advantage of their
                                                                                              respective parent project, Gnome and KDE,
                                                                                              and are bundled with several mainstream
                                                                                              distros. Yet both projects are cross-platform
                                                                                              and have Windows and Mac OS X ports as
                                                              If you don’t like Sublime’s     well as native Linux versions.
                                                              default ‘Charcoal’ appearance      Gedit is hosted on Gnome’s web
                                                              you can choose one of the 22    infrastructure and has a brief user guide,
                                                              other themes it includes.       information about the various plugins, and the
                                                                                              usual channels of getting in touch including a
                                                                                              mailing list and IRC channel. You’ll also find
UltraEdit                                                                                     usage information on the websites of other
UltraEdit’s interface is loaded with several    fingertips. You can also access remote         Gnome-based distros such as Ubuntu.
toolbars at the top and bottom of the           files via FTP and SFTP. Advanced features      Similarly, Kate gets the benefit of KDE’s
interface. Along with the tabs to switch        such as recording a macro and comparing       resources and hosts detailed user information
between documents, panes on either side         files are also easily accessible.              as well as a mailing list and IRC channel. You
and the gutter area, these leave little room      Using the app’s Preferences window          can access their respective user guides
for the editor window.                          you can tweak various aspects of the app,     offline from within the app as well.
   Web developers working with HTML             including the colour scheme and other            UltraEdit is also available for Windows and
files have lots of assistance at their           features like syntax highlighting.            Mac OS X besides Linux, and has detailed
                                                                                              user guides on getting started, though there’s
                                                                                              none included within the app. To assist users,
                                                                                              UltraEdit hosts a database of frequently
                                                                                              asked questions, a bunch of power tips that
                                                                                              have detailed information about several
                                                              UltraEdit’s UI is highly
                                                                                              specific features, and users can engage with
                                                              configurable – you can
                                                              customise the layout of         one another other on forum boards.
                                                              toolbars and menus just as      Additionally, paid users can also seek support
                                                              easily as you can change        from the developers via email.
                                                              many other aspects.                Sublime supports the same number of
                                                                                              platforms, however you don’t need to buy a
                                                                                              separate licence for each platform. The
jEdit                                                                                         developer keeps users abreast with ongoing
In terms of usability, one of the first          inbuilt help, which will help ease the        development via a blog and also participates
red-flags was jEdit’s inability to install on   learning curve.                               actively in the hosted forums. The highlight of
RPM-based distros. Navigating the editor          jEdit highlights the current line you are   the project’s support infrastructure is the
takes some getting used to, since its           on and enables you to split windows in        freely available detailed tutorial and video
menus aren’t in the same order as in other      multiple viewing modes. You can easily        course. Sublime is lovely.
popular apps and some have names that           install and manage plugins from within the       Because it’s written in Java, jEdit is
won’t be familiar to the average desktop        app, and in addition to full macros, jEdit    available on several platforms. On its website
user. However, the app include detailed         also lets you record quick temporary ones.    you’ll find a detailed user guide and links to
                                                                                              documentation of some plugins. However,
                                                                                              there are no avenues for users to engage with
                                                                                              other users or the developer.

                                                                                               VERDICT
                                                                                               Gedit
                                                                                               Kate
                                                              Thanks to its Java               Sublime
                                                                                               UltraEdit
                                                              underpinnings, jEdit doesn’t     jEdit
                                                              really feel at home on any
                                                              desktop environment.


                                                              www.linuxvoice.com                                                         31
     GROUP TEST ADVANCED TEXT EDITORS


Add-on and plugins
To flesh out new features.


D
         ifferent users have different          all the files in the same tab order as you
         requirements, and a single             saved them.
         lightweight app can only do as            Similarly, you can extend Kate by
much. This is where plugins come into           adding plugins using its built-in plugin
the picture. The apps rely on these             manager. In addition to the impressive
small pluggable widgets to extend their         projects plugins, some others that will
feature set and be of use to even more          be of use to developers include an
number of users.                                embedded terminal, ability to compile            You can run any external command or shell script in Gedit
   The one exception is UltraEdit. The          and debug code and execute SQL                   by defining it as an external tool.
app has no third-party plugins, but its         queries on databases.
developers do point out that third-party                                                                        categories such as File Management,
tools such as HtmlTidy are already              Sublime plugins                                                 Version Control, Text, etc. You’ll find lots
installed with UltraEdit.                       Plugins for Sublime are written in                              of plugins housed under each category.
   Gedit ships with a number of plugins         Python, and the text editor includes a                            Some of the best plugins are the
installed, and you can download more            tool called Package Control, which is a                         Android plugin, which provides utilities
with the gedit-plugins package. The             little bit like apt-get in that it enables the                  to work on Android projects; the
project’s website also points to several        user to find, install, upgrade and remove                        TomcatSwitch plugin, using which you
third-party plugins based on their              plugin packages. With plugins, you can                          can create and control an external
compatibility with the Gedit versions.          bring the Git version control to Sublime,                       Jakarta Tomcat server process; and the
   Three useful plugins for                     as well as the JSLint tool to improve                           Vimulator plugin, for Vi-like capabilities.
programmers are Code Comment,                   JavaScript. The Sublime Linter plugin is                        You can install these plugins using
Terminal Plugin, which adds a terminal          a must have for coders and will point                           jEdit’s using its plugin manager.
in the bottom panel, and the Session            out any errors in your code.
Saver. The Session Saver is really useful           jEdit boasts the most impressive                              VERDICT
when you’re working on a project with           plugin infrastructure. The app has over                           Gedit
                                                                                                                  Kate
multiple files. You can open all the files        200 plugins, which can be browsed in                              Sublime
                                                                                                                  UltraEdit
in tabs, save your session and when             the dedicated site of their own. The                              jEdit
you restore it with a single click it’ll open   website lists plugins under various




Plain ol’ text editing
How good are they as just simple editors ?


D
         espite all their powerful              highlighted text. It’s also got a line
         extra-curricular activities that       modification system which visually
         might even displace full-blown         alerts users of lines which have
apps across several genres, there will          modified and unsaved changes in a file.
be times when you just need to use              In addition, it enables users to set
these text editing behemoths to read,           bookmarks within a file to ease
write, or edit plain and simple text.           navigation of lengthy documents.
While you can use all of them to enter             Sublime has a wide selection of               Sublime
text, we are evaluating them for access         editing commands, such as indenting              Text offers    files via FTP. One unique feature of jEdit
to common text-editing conveniences.            text and formatting paragraphs. Its              some           is its support for an unlimited number
  Gedit which is Gnome’s default text           auto-save feature helps prevent users            unique         of clipboard which it calls registers. You
editor, supports an undo and redo               from losing their work. Advanced users           features to    can copy snippets of text to these
                                                                                                 manipulate
mechanism as well as search and                 will appreciate the regex-based                                 registers which are available across
                                                                                                 text.
replace. It can spellcheck documents in         recursive find and replace feature, as                           editing sessions.
multiple languages and can also                 well as the ability to select multiple
access and edit remote files using               non-contiguous spans of text and act                              VERDICT
Gnome GVFS libraries.                           on them collectively.                                             Gedit
                                                                                                                  Kate
  You can spellcheck documents with                UltraEdit also enables the use of                              Sublime
Kate as well, which also lets you               regular expressions for its search and                            UltraEdit
                                                                                                                  jEdit
perform a Google search on any                  replace feature and can edit remote



32                                                                www.linuxvoice.com
                                                                                    ADVANCED TEXT EDITORS GROUP TEST




  OUR VERDICT
Advanced text editors
A
         ll the editors in this feature   outscores Gnome’s default editor
         are good enough to replace       even after taking their respective
         your existing text editor for    plugin systems into consideration.        Despite being a KDE app, Kate looks good across many desktops.
editing text files and tweaking               Both Sublime and Kate are
configuration files. In fact, chances
are they’ll even double up as your
                                          equally good. They performed
                                          equally well in most of our tests.
                                                                                     1st Kate
                                                                                     Licence LGPL/GPL Version 3.11
IDE. These apps are chock full of         Whatever ground it lost to Sublime
bells and whistles, and their             for not supporting macros, it gained       www.kate-editor.org
developers aren’t thinking of             for its keyboard friendliness and its      The ultimate mild-mannered text editor with super powers.
stripping features, but adding more       ease of use in defining custom              Kate is one of the best apps to come out of the KDE project.
and more and more.                        keybindings.
  At the tail end of this test we have       Kate’s success can be drawn             2nd Sublime Text
jEdit. Not only does it insist on         from the fact that it offers the           Licence Proprietary Version 2.0.2
using the proprietary Oracle Java         maximum number of features with
Runtime Environment, it failed to         minimal learning curve. Just fire it        www.sublimetext.com
install on our Fedora machine, and        up and use it as a simple text editor,     A professionally done text editor that’s worth every penny –
                                                                                     easy to use, full of features and it looks great.

“Kate offers the maximum features with                                               3rd Gedit
the minimum learning curve.”                                                         Licence GPL Version 3.10

the developer doesn’t actively            or easily edit configuration file with       http://projects.gnome.org/gedit
                                                                                     Gets it done from Gnome. It’s a wonderful text editor and does
engage with its users.                    syntax highlighting, or even use it to
                                                                                     an admirable job, but the competition here is too great.
   UltraEdit does little better. This     collaborate and work on a complex
commercial proprietary tool               programming project thanks to its
focuses on web developers, and            project management capabilities.           4th UltraEdit
doesn’t offer anything to non-                We aren’t pitching Kate to replace     Licence Proprietary Version 4.1.0.4
developer power users that makes          a full-blown integrated development
                                                                                     www.ultraedit.com
it worth recommending over free           environment such as [insert your
                                                                                     Focuses on bundling conveniences for web developers without
software alternatives.                    favourite specialised tool here]. But      offering anything special for general users.
   On the third podium position we        it’s an ideal all-rounder and a perfect
have Gedit. There’s nothing               stepping stone to a specialised tool.
inherently wrong with Gnome’s                 Kate is designed for moments
                                                                                     5th jEdit
default editor, but despite all its       when you need something that’s             Licence GPL Version 5.1.0
positive aspects, it’s simply             quick to respond, doesn’t                  www.jedit.org
outclassed by Sublime and Kate.           overwhelm you with its interface           A lack of support, lack of working on Fedora and a lack of
Out of the box, Kate is a more            and is just as useful as something         looking nice relegate jEdit to the bottom slot.
versatile editor than Gedit, and          that might otherwise be overkill.




  YOU MAY ALSO WISH TO TRY…
  The default text editor that ships with your        If you wish to follow the steps of Linux       advanced editors like Emacs and Vim, such
  distro will also be able to assist you with       gurus, you could always try the revered text     as the JED editor and Joe’s Own Editor, both
  some advanced tasks. There’s KDE’s KWrite         editors Emacs and Vim. First time users who      of which have an emulation mode for Emacs.
  and Raspbian’s Nano, for instance. KWrite         want to get a taste for the power of Vim         On the other hand, if you are looking for
  inherits some of Kate’s features thanks to        might want to consider gVim, which exposes       lightweight code editors check out Bluefish
  KDE’s katepart component, and Nano has            Vim’s power via a graphical interface.           and Geany. They exist to fill the niche
  sprung back into limelight thanks to its            Besides jEdit and Kate, there are other        between text editors and full-fledged
  availability for Raspberry Pi.                    editors that mimic the usability of veteran      integrated development platforms.




                                                                www.linuxvoice.com                                                                    33
     SUBSCRIBE




SUBSCRIBE             shop.linuxvoice.com

Not all Linux magazines are the same
                                                                       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
                                                                       UK – £38                                          DIGITAL
                                                                       Europe – £53                                      SUBSCRIPTION
                                                                       US/Canada – £55                                   ONLY £38
                                                                       ROW – £60


          Each month Linux Voice includes 114 pages of in-depth tutorials,
              features, interviews and reviews, all written by the most
                      experienced journalists in the business.
              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.



34                                                        www.linuxvoice.com
                                                                                                                                           NEXT MONTH



                                   NEXT MONTH IN



                                                                                            EVEN MORE AWESOME!
ON SALE
THURSDAY                                                                                                                                      Old Code
1 MAY                                                                                                                                         Arise Sir Alan Turing,
                                                                                                                                              genius coder,
                                                                                                                                              computer inventor,
                                                                                                                                              Nazi code cracker
                                                                                                                                              and 2hr 46min
                                                                                                                                              marathon runner.
                                                                                                                                              What a man.



                                                                                                                                              Shopping
                                                                                                                                              How hard is it to get
                                                                                                                                              a Windows refund?
                                                                                                                                              Are there any decent
                                                                                                                                              machines out there
                                                                                                                                              with Linux installed?
                                                                                                                                              Find out before you
                                                                                                                                              waste your money



                                                                                                                                              It’s full of stars

  GUI VS COMMAND LINE                                                                                                                         Use humble Python
                                                                                                                                              to identify comets in
                                                                                                                                              images taken by the
  The command line will always have its                                                                                                       awesome-sounding
  proponents, but you can’t beat a nicely                                                                                                     SOHO (Solar and
                                                                                                                                              Heliospheric)
  polished slice of graphical user interface                                                                                                  satellite. Astronomy
  for getting things done. Or can you?                                                                                                        for the win.




         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 editor,
  Technical editor Ben Everard     under the GNU GPLv3                             SE1 0SU                                       until December 2014 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 liabiliy 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
         HELLO                                                            HELLO WORLD!
                                                                                                   HELLO
         FEATURE CODE FOR ALL


         WORLD!
D!
         HELLO WORLD!                                                                               WORLD!                                 HEL

             HELLO WORLD!
                                                                                                                 HELLO
                                                                                                                 WORLD!
D! HELLO                                                                                        HELLO H
                                                                                                                   HELLO WORLD!


WORLD!
          WORLD!                                                                                WORLD!
LO HELLO                                                                                      HELLO HE
LD! WORLD!                                                                                    WORLD! WO
                                                                                                                         HELLO WO



                    CODE FOR ALL
                    Programming isn’t just the domain of übergeeks – in the Year of
                     Code, everyone can get involved. Follow our guides and create
                      programs for the desktop, mobile phone and command line.


         I
             t wasn’t long ago that programmers     Today you can tell someone at the pub        With this in mind, we wanted to make
             were viewed by the general public      that you enjoy programming, and not be    this issue’s cover feature all about
             as strange wizards who spent           looked at like you’ve just started        coding. But not just as a generic
         hours alone every day, tapping             speaking Tagalog.                         introduction to a language or platform
         incomprehensible gobbledygook into            We’re all hackers on the Linux Voice   – no, we wanted to show you how to do
         black boxes on the screen. But in recent   team, so we support every effort to       useful things. So over the next nine
         years, the perception of programming       inspire people to code. It’s not all      pages we have three projects explaining
         as a hobby (and profession) has            boring, complicated and alien like some   how to make real-world desktop, mobile
         changed enormously. Today it’s cool to     people claim; coding can be fun,          phone and command line applications.
         hack the Raspberry Pi. Today it’s trendy   stimulating and useful for developing     As you’ll see, coding is for everyone, and
         to write software for iOS and Android.     future skills.                            you can code for any platform.



    36                                                       www.linuxvoice.com
                                                                                                                CODE FOR ALL FEATURE



      Desktop apps with Python
LLOFirst
    WORLD!
         step: building the required skills.


      T
              o kick off, we’re going to use Python, because                                                                   Many good text editors
              it’s an excellent all-round language which                                                                       include syntax highlighting,
              combines highly readable code with oodles of                                                                     to make it easier to read
      advanced features. Python code tends to be self-                                                                         code – here’s Nano, for
                                                                                                                               example.
      explanatory, so it’s a great way to dip your feet into
      programming. We’ll start here with a quick overview of
      the language; if you’re already familiar with Python, you
      may want to quickly skim over this and then turn over




HELLO WORLD!
      the page, where we start using it in our application.

      A Python primer
      Python is installed by default in most major




 !
      distributions, and it’s an interpreted language, so you
      don’t need to compile your code before running it. In
      the following examples, save the source code in plain        specified text in quotes. Then we ask Python: if the
      text format as test.py. Then run it like so:                 contents of x are 1 after the input, print one thing, and




ELLO
      python test.py                                               if the contents are not 1, (shown in the code as the
         Let’s start with a very simple program:                   else statement) print something else. Why the if x ==
      name = “Linux Voice”                                         1 though – why the double equals signs? Well, it’s just
      print name + “ is the best Linux mag”                        to make a very clear distinction from x = 1 (a single




ORLD!
        This demonstrates two aspects of the language:             equals sign), which stores a number or line of text
      variables and output. In the first line, we create a new      within a variable.
      variable (like a storage space) called name – in
      Python, you don’t need to explicitly state the type of a     Funky functions
      variable when you create it. In the second line, we print    Next, we’ll dip our toes into functions. These are

 ORLD!the contents of the variable to the screen, along with
      another string of characters. Dead easy, right?
                                                                   self-contained chunks of code that you can use to
                                                                   build bigger programs. You can re-use them with
        Let’s look at numeric variables:                           different parameters, to keep your code small and
      x=1                                                          easy to understand. For instance:
      while x < 10:                                                def multiplier(a, b):
           print “x is”, x                                             print a, “multiplied by”, b, “is: “
           x=x+1                                                       print a * b
      print “Finished!”                                            multiplier(6, 7)
         Here we declare the x variable to contain 1 at the        multiplier(10, 20)
      start, and then begin a loop. While the contents of x        multiplier(211, 2352)
      are less than 10, we print the contents, and add one to         Here, we ‘def’ine a function called multiplier, which
      x. It’s important to note the indentation here: in Python,   receives two numbers from the calling program, and
      you use tabs to say which lines belong to a chunk of         stores them in the variables a and b. This function
      code. Here we say that the print and x = x + 1 lines         then prints out the result of multiplication (using the *
      belong in the while loop, because they’re indented. If       operator). Note the tab indention again here, and also
      you removed the tab from the x = x + 1 line, the             note that this function is defined at the start of the
      contents of x would never be incremented in the loop,        program, but it isn’t executed immediately – Python
      so the loop would go on forever.                             starts execution in the non-indented part.
         When the loop has finished, the program continues,            So we can call our
      so no indentation is required. (If you have loops inside
      loops, you will have multiple levels of indentation.)
                                                                   multiplier function with
                                                                   different numbers, as                 “Python is installed by
      Next, let’s move on to input and comparisons:                shown in the three lines at           default in most major
      x = input(“Enter a number: “)
      if x == 1:
                                                                   the bottom of the code.
                                                                   This is a trivial example             Linux distributions.”
            print “You entered 1”                                  (you could just do the
      else:                                                        multiplications in the main code), but it shows how
            print “That wasn’t 1”                                  you can build up programs from self-contained units.
        Here we have our x variable again, and we call                So, that’s the basics of Python covered – now turn
      Python’s in-built input routine, which displays the          the page and let’s do something useful.



                                                                     www.linuxvoice.com                                                                37
     FEATURE CODE FOR ALL



A kiosk-like web browser
Write your own locked-down, ultra secure web browser.


                              W
                                           ith our Python skills freshly prepped, let’s                address = networkRequest.get_uri()
                                           make a real application. Here we’re going                   if not “debian.org” in address:
                                           to create a simple, and locked-down web                                  md = gtk.MessageDialog(win, gtk.
                              browser than can only visit certain web pages and not           DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUT-
                              escape onto the big, bad web. Why would you do this?            TONS_CLOSE, “Not allowed to leave the site!”)
                              Well, let’s say you’re setting up a web terminal for a                                md.run()
                              school, shop or museum, and you want to restrict                                      md.destroy()
                              access to certain places. You could use a normal web                                  view.open(“http://www.debian.org”)
                              browser, load it up with kiosk-like extensions and
                              filtering proxies and hope that it’s secure, but clever          view = webkit.WebView()
                              users may still be able to break out of the restrictions        view.connect(“navigation-requested”, navrequest)
                              and cause trouble.
                                 With our browser, we have just the bare essentials.          sw = gtk.ScrolledWindow()
                              And even if setting up a web kiosk isn’t high on your           sw.add(view)
                              list of things to do, it’s well worth following this tutorial
                              to see how a simple web browser is implemented.                 button = gtk.Button(“Back”)
                                                                                              button.connect(“clicked”, goback)
                              The code
                              Here it is – a whole web browser, contained within 35           vbox = gtk.VBox()
                              lines of Python. You probably don’t want to type this           vbox.pack_start(button, False, False, 0)
                              out by hand, so grab it from www.linuxvoice.com/                vbox.add(sw)
                              code/microbrowser.py. This browser is set up to view
                              the Debian website at www.debian.org and nothing                win = gtk.Window(gtk.WINDOW_TOPLEVEL)
                              else, but you can of course change that.                        win.set_size_request(800, 600)
                              import gtk, webkit                                              win.connect(“destroy”, gtk.main_quit)
                                                                                              win.set_title(“Linux Voice browser”)
                              def goback(button):                                             win.add(vbox)
                                         view.go_back()                                       win.show_all()


                              def navrequest(thisview, frame, networkRequest):                view.open(“http://www.debian.org”)
                                                                                              gtk.main()
                                                                                                Now, we’re not going to write the entire HTML, CSS
                                                                                              and JavaScript rendering engine ourselves – that
                                                                                              would take months of hard effort and fill many issues
                                                                                              of the magazine. No, we’ll leave that to WebKit, an
                                                                                              extremely capable rendering engine used in several
                                                                                              notable browsers such as Chrome/Chromium and
                                                                                              Safari. (Well, Chrome now uses the Blink rendering
                                                                                              engine, but this is based on WebKit.)
                                                                                                There’s a great Python module to interface with
                                                                                              WebKit, which we’re using here: you’ll find it in the
                                                                                              python-webkit package in Debian and Ubuntu-based
                                                                                              distros. You’ll also need python-gtk2 for the interface.
                                                                                              So let’s step through the code:
                                                                                              import gtk, webkit
                                                                                                This is simple enough – it just tells Python that we
                                                                                              want to use the GTK module to provide the GUI
                                                                                              widgets, and the WebKit module for the rendering
                                                                                              engine. Then we have two functions:
                                                                                              def goback(button):
                                                                                              ...
                                                                                              def navrequest(thisview, frame, networkRequest):
Here it is: our funky mega skillo web browser, which we can restrict to wherever we want,     ...
written in just 35 lines of Python. How cool is that?                                         We’ll come back to these in a moment, because first



38                                                               www.linuxvoice.com
                                                                                                               CODE FOR ALL FEATURE


we need to set up some code to use them. So                                                                                    And here’s what happens
execution of the program begins here:                                                                                          if users try to stray beyond
view = webkit.WebView()                                                                                                        the limits, as we defined in
view.connect(“navigation-requested”, navrequest)                                                                               the navrequest() function.
   This is the heart of the program. We create a new
object called view (an object is like a variable, but it
can store and do a lot more), which is a WebKit
WebView. Put simply, this is a plain web browser view
– but with no buttons, no surrounding window, or
anything like that. It’s just a canvas to render web
pages inside.
   The second line of this snippet is crucially                      Now we have to pack the button and WebKit view
important, and demonstrates a callback function. We               into a single space, for which we use a vertical box
tell our web page view that if a navigation event                 widget in GTK:
occurs (ie the user clicks on a link), we should call the         vbox = gtk.VBox()
navrequest function as included at the start of the               vbox.pack_start(button, False, False, 0)
code. This function retrieves the address of the clicked          vbox.add(sw)
link (networkRequest.get_uri) and checks to see if                  Then the following six lines, beginning with win,
debian.org is contained in the address. If not, we                create a new application window, set its size, say what
show a dialog box and go back to the Debian home                  to do when the close button is clicked and set a title.
page. (Yes, this doesn’t make it 100% impossible for              They also add the vertical box widget to the
people to escape www.debian.org, but you could                    application window and make sure that all of the
narrow down the allowed links even further with                   widgets inside it are visible. And the last two lines are:
regular expressions – that’s beyond the scope of this             view.open(“http://www.debian.org”)
guide though!)                                                    gtk.main()
   So, we have a web browsing pane which checks                      Here we tell the WebKit view to open a specific
links as they’re clicked. Next are these lines:                   page, and run GTK’s main event loop (where it
sw = gtk.ScrolledWindow()                                         watches for button clicks

                                                                                                  “There’s a great Python module
sw.add(view)                                                      and window operations
button = gtk.Button(“Back”)                                       – we leave it alone from
button.connect(“clicked”, goback)                                 here).
                                                                                                  to interface with WebKit, which
                                                                                                  we’re using here.”
   As mentioned, the WebKit view isn’t attached to                   And that’s it! We’ve
anything yet – it just exists in memory somewhere                 crammed a lot in here, so
and that’s it. Here we attach it to a GTK scrolling               if you have any
window so that users have scroll bars to move around              questions, check out the websites for Python GTK
in the page. We create a new ScrolledWindow and                   (www.pygtk.org) and Python WebKit (https://code.
add the view object to it.                                        google.com/p/pywebkitgtk). If you need further help,         Want to delve into more
   Then we create a new GTK button with the label                 post on our forums at http://forums.linuxvoice.com           advanced Python topics?
Back, and also attach it to a callback function we                and we’ll do our best to answer.                             See http://docs.python.org
wrote earlier: goback. So whenever the user clicks this                                                                        for a wealth of tutorials.
button, the function goback is called. In that function,
we tell the view to step back a page (view.go_back())
and return to the main code.


  Making Python apps directly executable
  It’s easy to run our browser from the command line by
  typing python microbrowser.py, but what if you want to
  make it directly executable – so you can run it by simply
  double-clicking on it? The trick is to add this to the top of
  the file:
  #!/usr/bin/env python
      Now make the file executable (eg chmod +x
  microbrowser.py) and run it (./microbrowser.py). This
  extra first line tells the operating system which interpreter
  should be used with the following code, so you don’t need
  to specify Python manually at the command line. In your
  kiosk setup, you can easily trim down a desktop or window
  manager to the bare essentials, and add a single launcher
  pointing at microbrowser.py somewhere on your system.




                                                                    www.linuxvoice.com                                                                  39
     FEATURE CODE FOR ALL



Mobile Linux
Don’t rely on the app store for software – create your own.


                  O
                            ver the last few years, Linux has taken over
                            the mobile computing marketplace. Android is
                            hugely popular, and there’s also Amazon’s Fire
                  OS, Firefox OS, Sailfish OS, Tizen, Bada and soon
                  there’ll be Ubuntu Touch as well. Developing for
                  mobile platforms isn’t like desktop Linux, where the
                  same code is just repackaged for different distros.
                  This allows developers to make their apps fit the look
                  and feel of the OS, but it also means that you have to
                  spend a long time developing for the different devices.
                     Fortunately, it doesn’t have to be this way. It is
                  possible to maintain a single codebase for use across
                  all the Linux-based mobile platforms (and a few
                  non-Linux ones like iOS and Windows Phone as well).
                  This way is Apache Cordova.
                     Apache Cordova is a framework that enables you to           Don’t forget to consider the size of your computer screen
                  develop in HTML and JavaScript, then package it up             when selecting what type of device to emulate. Modern
                  for each different environment.                                phones have a lot of pixels (often more than monitors).
                     While it may once have been suitable only for
                  displaying web pages, and perhaps a little interaction,        the speed of natively compiled code. This means that
                  JavaScript has grown in to a powerful programming              it’s still not quite there for some high-performance
                  environment. If you don’t believe us, have a look at           applications, but it should be fine for most cases.
                  these examples and see for yourself:                               The people at Mozilla know more than most about
                     The Unreal Engine 3 has been ported to JavaScript           the power of HTML and JavaScript, and they believe in
                  and you can explore Epic Citadel in your browser:              it so much that they built an entire phone operating
                  www.unrealengine.com/html5.                                    system built around it.
                     Tearable cloth: http://codepen.io/suffick/pen/                    Another great advantage of the HTML and
                  KrAwx.                                                         JavaScript approach is that it makes it really easy to
                     Freerider II: www.freeriderhd.com/t/1016-layers.            get started. You can create simple pages in point-and-
                     With the canvas HTML 5 element, you can make 2D             click HTML editors, then progress onwards as you
                  JavaScript graphics as complex as you like, and with           learn more about programming and the environment.
                  WebGL, you can even harness the power of the
                  device’s GPU to create accelerated 3D graphics.                First build
                  WebRTC can be used to set up a communication                   To get started, you’ll need the appropriate SDK for the
                  channel between two browsers, and Webaudio helps               platform (or platforms) you’re developing for, and the
                  you add sound to your creations. We should point out           appropriate version of Cordova (a full list can be found
                  that not all of these features are as yet possible with        at cordova.apache.org/#download). In this tutorial
                  Cordova on all devices (even new ones), but it’s only a        we’re going to use Android, as it’s the most popular
                  matter of time.                                                mobile Linux, but you shouldn’t have any problem
                     The performance of JavaScript has long been                 transferring the work to a different platform such as
                  considered a problem for web app development, but              Ubuntu Phone or Firefox OS. Sailfish OS should be
                  in recent years, this has improved dramatically. Now,          able to run Android apps, but we haven’t been able to
                  well-written JavaScript should perform at about half           test this particular app.
                                                                                    You’ll need the SDK for every environment you’re
                    PhoneGap                                                     developing for. For Android, you can get it from
                                                                                 http://developer.android.com/sdk. You’ll get a ZIP file
                    Cordova is closely related to Adobe PhoneGap. In fact,       that you can extract. You need to add the sdk/
                    they’re so closely related that they’re often mistaken for   platform-tools and sdk/tools directories from this ZIP
                    one another. Officially, PhoneGap is an implementation        to your path. In the author’s environment, this was
                    of Cordova, but it doesn’t add much to the core release      with the following command, though you’ll have to
                    in the same way a distribution of Linux adds a lot of
                                                                                 change it depending on where you unzip the SDK:
                    software around the kernel. For now we prefer to build on
                    a framework released by the Apache Software Foundation       export PATH=$PATH:/home/ben/Downloads/adt-bundle-linux-
                    than one developed by Adobe.                                 x86-20131030/sdk/platform-tools:/home/ben/Downloads/adt-
                                                                                 bundle-linux-x86-20131030/sdk/tools



40                                                    www.linuxvoice.com
                                                                                                                CODE FOR ALL FEATURE


                                                                HTML and JavaScript for phones. In essence, it allows
  Cordova pugins                                                you to create off-line websites. This certainly has its
  To access phone features, you’ll need to use plugins.         uses, and many apps are nothing more than this.
  The standard ones that come as part of Cordova are:
  Accelerometer, Camera, Capture, Compass, Connection,          Harness phone-specific features
  Contact, Device, Events, File, Geolocation, Globalization,    However, to be a true phone app, it should have
  InAppBrowser, Media, Notifications, Splashscreen and
                                                                access to more of the phone’s features, such as the
  Storage. There’s also a good selection of plugins available
  at http://plugreg.com, should the standard ones not do        GPS, accelerometer or filesystem. These aren’t
  everything you need.                                          available through normal JavaScript, but Cordova
                                                                allows plugins that expose certain features to its
                                                                JavaScript API. Take a look at the boxout above for
  You’ll have to re-run this every time you restart your        the standard plugins.
computer unless you add it to the .bashrc file in your               As an example, we’re going to create a simple
home directory.                                                 weather forecast app. It’ll get the current location, then
  Cordova is a node.js application, and you’ll need             display a weather forecast for the area. We’ll also add
both node.js and npm for it to run. On Ubuntu and               the ability to share it using social media, as apparently
derivatives, this can be done with the following code. If       all good apps do this.
you’re using a different distro, check the available                To start with, we need to get the HTML and
packages:                                                       JavaScript to grab a forecast based on latitude and
sudo apt-add-repository ppa:chris-lea/node.js                   longitude. Since everything is in the web technologies,
sudo apt-get update                                             it’s far easier to test it out using web development
sudo apt-get install npm nodejs and                             tools than the Android-specific ones. Once
npm config set registry http://registry.npmjs.org/               everything’s working properly in a browser, you can
sudo npm install -g cordova                                     then transfer it to Cordova and check it in Android.
  Cordova works with a specific directory structure.                 We’ll start with a really simple HTML doc that just
To create a new project directory and appropriate               grabs a forecast for London. Change the www/index.
subdirectories run cordova create myProject, where              html file so that it contains:
myProject is the name of the new project. Now you               <!DOCTYPE html>
can move into the new directory with cd myProject.              <html>
  Projects start off without any platforms. You can             <head>
add as many as you like provided you have the SDKs              <title>Weather Forecast</title>
installed, and Cordova will manage the builds for you.          </head>
We’ll just add Android with:                                    <body>
cordova platform add android                                    Forecast:
  And you can compile the example code (that each               <br>
project is created with) using:                                 <iframe id=”forecast_embed” type=”text/html” frameborder=”0”
cordova build android                                           height=”245px” width=”245px” src=”http://forecast.io/embed/#l
   In order to test your app, you either need an Android        at=51.5072&lon=0.1275&units=uk”> </iframe>
device, or to use an emulator. To create a new                  </body>
emulated device, open the version of Eclipse that               </html>
came bundled with the Android SDK. Go to File > New                Save this as index.html in the www folder of your
> Other > Android > Android Project From Existing               app. You could run this using Cordova on your phone
Code and select the platforms/android folder from               or an emulator, but it’s easier at this stage to open it in
your project’s directory. Then do to Window > Android           your normal web

                                                                                               “Another advantage of HTML
Virtual Device Manager and create a new virtual                 browser.
device. Once this is set up, you can run the project               51.5072, 0.1275 are
from the command line with:                                     the coordinates we’ll use
                                                                                               and JavaScript is that it makes
                                                                                               it really easy to get started.”
cordova emulate android                                         (this is in London). This
  Some of these work far better with a physical                 grabs an iframe with the
device than an emulator, so if you have an Android              current forecast from
phone or tablet, it’ll be easier to follow the rest of this     forecast.io. In order grab the forecast for the current
tutorial on that. The method for doing this varies              location, all you need to do is create an iframe with the
depending on the version of Android you have. Visit             right latitude and longitude.
http://developer.android.com/tools/device.html for                 Writing iframes in JavaScript is easy, since you can
more details. Once you’ve set up your phone, and                manipulate the HTML inside an element. All you need
connected it to your computer via the USB cable, you            to do is create a <div> </div> that you can put the
can load and run the app with:                                  iframe inside. Now we’ll add the ablity to switch the
cordova run android                                             location between London and New York. First change
In its basic state, this enables you to package up              the code between the <body></body> tags to:



                                                                  www.linuxvoice.com                                                   41
     FEATURE CODE FOR ALL


                             Forecast:
                             <div id=”location”></div>                                             Signing apps
                             <div id=”forecast”>Select Location</div>                              Cordova can build a final version of your app using the
                             <br>                                                                  --release option to the build command. However, this won’t
                              <button onclick=”getForecast(51.5072, 0.1275)”>London                install on any phone until it’s been signed. You can create
                                                                                                   a key for signing it yourself, so this isn’t a restriction on
                             Forecast</button>
                                                                                                   distributing your software. There are details of how to do it
                              <br>                                                                 here: http://developer.android.com/tools/publishing/app-
                              <button onclick=”getForecast(40.6700,73.9400)”>New York              signing.html.
                             Forecast</button>                                                         You can distribute your app without an app store if you
                             <br>                                                                  want. Just send the .apk file to people and (as long as they
                                                                                                   have sideloading enabled) they can install it themselves. Of
                             <div id=”getlocalforecast”></div>
                                                                                                   course, you can put your app on the main Google Play store
                             <div id=”forecastDetails”></div>                                      if. You’ll find details about how to do this here:
                               This has two divs with different IDs that we’ll use                 http://developer.android.com/distribute/googleplay/
                             now, and some more that we’ll use in a bit. We’ll use                 publish/preparing.html.
                             JavaScript to update them to what we need them to                         Google Play isn’t the only Android app store though. If
                                                                                                   you open source your app, you may wish to add it to the
                             be. The two buttons call the getForecast(latitude,
                                                                                                   F-Droid store. Take a look at www.f-droid.org for details.
                             longitude) function that we’ll now define.
                               Add the following just before the </head> tag:
                             <script type=”text/javascript”>                                     become clear later. Again, you can test this out in a
                             function getForecast(latitude, longitude) {                         web browser and it should work fine.
                                var element = document.getElementById(‘location’);
                                element.innerHTML = ‘Latitude: ‘ + latitude + ‘<br />’ +         Not just a website!
                                   ‘Longitude: ‘ + longitude + ‘<br />’;                         Now let’s add the phone-specific stuff. Cordova uses
                                window.iframeurl=’http://forecast.io/embed/#lat=’ + latitude +   plugins to add access to different features, so in order
                                   ‘&lon=’ + longitude + ‘&units=uk’;                            for our app to be able to access the location, we need
                                 showSimple();                                                   to use the Geolocation plugin. This is done by running
                                 }                                                               the following command in the root directory of the
                             function showSimple() {                                             web app:
                                var weather = document.getElementById(‘forecast’);               cordova plugin add org.apache.cordova.geolocation
                                weather.innerHTML = ‘<iframe id=”forecast_embed”                 This will add it to every platform you have registered
                             type=”text/html” frameborder=”0”’ +                                 as long as the plugin works on that platform.
                                   ‘height=”245px” width=”245px” src=”’ + window.iframeurl +       In order to access the Cordova features, you need
                             ‘”> </iframe>’;                                                     the cordova.js script, so add the following line just
                                }                                                                below </title>:
                             </script>                                                           <script type=”text/javascript” charset=”utf-8” src=”cordova.
                                This splits the execution up into two stages. The                js”></script>
                             first sets the contents of <div id=”location></div>,                   With this in place, you can add the following
                             and the variable window.iframeurl. By defining this                  functions inside your main <script> tag:
The documentation at         variable as attached to window, it makes it available to            document.addEventListener(“deviceready”, onDeviceReady,
http://cordova.apache.
                             all our functions, rather than just local to the current            false);
org/docs/en/3.3.0/ is a
                             function. The same effect could have been achieved                  function onDeviceReady() {
great place to find help.
It has guides for all the    by using a global variable.                                           localforecast = document.getElementById(‘getlocalforecast’);
standard plugins including      The second function sets the <div id=”forecast”></                 localforecast.innerHTML = ‘<button onclick=”getLocal()”>Local
comprehensive code           div> to be an iframe with the appropriate location. The             Forecast</button>’;
samples.                     reason we’ve split this up into two functions will                    }
                                                                                                 function getLocal() {
                                                                                                   navigator.geolocation.getCurrentPosition(onSuccess,
                                                                                                 onError);
                                                                                                   }
                                                                                                   function onSuccess(position) {
                                                                                                   getForecast(position.coords.latitude, position.coords.
                                                                                                 longitude);
                                                                                                   }
                                                                                                 function onError(error) {
                                                                                                   alert(‘code: ‘ + error.code + ‘\n’ +
                                                                                                      ‘message: ‘ + error.message + ‘\n’);
                                                                                                   }
                                                                                                    The first line listens for the deviceready event. This
                                                                                                 tells it to run the function onDeviceReady once the



42                                                                www.linuxvoice.com
                                                                                                                  CODE FOR ALL FEATURE


app is running properly. We’ve added this to stop                                                                               The app in action.
people trying to get a local forecast too soon.                                                                                 Unfortunately, that’s the
   The function getLocal can just call navigator.                                                                               best weather we’ve had in
geolocation.getCurrentPosition(). We’ve passed it                                                                               months.
two parameters: the first is the name of the function
to call if it succeeds in getting the location; the second
is the function to call if there’s an error.
   onSuccess passes the returned values on to
getForecast(), while onError() displays the error
message as a JavaScript alert.
   With all this entered and saved, it’s ready for its first
proper test. To compile and run it, enter the following
terminal commands in the app’s root directory:
cordova build android
cordova run android
If you’ve got your phone attached, this will send it
across and open it on your device, otherwise it’ll start
the emulator.
   You’ve just created a phone app! It’s quite limited,
but accesses one of the phone’s features. Since all
good mobile applications have social features, we’ll
add this facility now. We won’t make specific links to
social media, but use the phone’s features to share
the forecast with other applications. The user can
then pick how they want to share the forecast.

Engage Twitbook
As you may have guessed, this feature comes from
another plugin, but this time it’s one that’s not part of
the main Cordova release. You can add plugins                    detailed forecast. Fortunately, Forecast.io does most
straight from Git, so in a terminal in the app’s root            of the hard work on this. The only thing we have to do
directory, enter:                                                is change the size of the iframe.
cordova plugin add https://github.com/leecrossley/cordova-          You’ll need to adjust the showSimple() function and
plugin-social-message.git                                        add showDetails() as per the following:
    As with the previous plugin, this exposes more               function showDetails() {
JavaScript functions that we can access. In this case,              var weather = document.getElementById(‘forecast’);
it’s socialmessage.send(). Using this, you can interact             weather.innerHTML = ‘<iframe id=”forecast_embed”
with the other apps on the phone. Add the following              type=”text/html”’ +
function inside the <script></script> tags:                            ‘frameborder=”0” height=”245px” width=”500px” src=”’ +
function share() {                                               window.iframeurl +
  var message = {                                                      ‘”> </iframe><br><button onclick=”showSimple()”>Hide
    subject: “Weather Forecast”,                                 Details</button>’;
    text: “Check out my local forecast”,                            }
    url: window.iframeurl
    }
                                                                 function showSimple() {
                                                                    var weather = document.     “Cordova uses plugins to
  window.socialmessage.send(message);                            getElementById(‘forecast’);    access different features – we
                                                                                                need the Geolocation plugin.”
  }                                                                 weather.innerHTML =
    You’ll also need a button in the body of the HTML to         ‘<iframe id=”forecast_embed”
access it. However, you can’t share the forecast until           type=”text/html”’ +
it’s received, so the button should only appear once                   ‘frameborder=”0” height=”245px” width=”245px” src=”’ +
there’s a forecast. The easiest way to do this is by             window.iframeurl +
adding the lines:                                                      ‘”> </iframe><br><button onclick=”showDetails()”>Show
     var weatherDetails = document.getElementById(‘forecast      Details</button>’;
Details’);                                                          }
     weatherDetails.innerHTML = ‘<button onclick=”share()”>’ +     Of course, it still looks a bit plain, and you could add
‘Share this forecast</button>’;                                  many more options, but this isn’t a tutorial on creating
to the end of the getForecast() function.                        the perfect weather forecasting app, it’s a tutorial on
  We’re almost done with our app now. The last little            getting started with mobile Linux development. It’s up
feature we’ll add is the ability to show a simple or             to you to decide what to do with it now.



                                                                   www.linuxvoice.com                                                                  43
     FEATURE CODE FOR ALL



Programming the command line
Automate everything, then sit back and relax as your computer takes care of itself.


                  S
                           o far we’ve talked about programming in terms           Lets take a look at this in detail. The first line is
                           of making new software. However,                    called a shebang, and it tells the computer that this is
                           programming can also be a way of linking            a Bash script and that it should be executed with the
                  together existing software to automate tasks. In this        command /bin/bash.
                  way, you don’t create anything that you didn’t have              The second line does two things. First, it executes
                  access to before, but you make it much easier to use.        the find command, which we explained above; then it
                  Let’s take a really quick example. Suppose you’re a          pipes the output of the command into a while loop.
                  writer, and you save all your work in ODT files. These        Piping (which is done using the character |) is an
                  files are scattered about your home directory                 essential feature of Bash programming, and it can
                  (because most writers aren’t organised enough to             also be done on the command line. It just tells the
                  keep their files in one place), and you want to do a full     system to take the output of one command and feed
                  backup of all your writing.                                  it into the next. As another example, if you’re using a
                    There are many ways you could do this. One of the          terminal and you’re in a directory with loads and loads
                  easiest is to create a simple program that searches          of files, it sometimes doesn’t work very well if you just
                  for all the files and copies them to a remote computer.       run ls to list them (the filenames can go off the top of
                    Bash is the shell that most Linuxes use, and while         the screen). Instead, you can pipe the output into a
                  many users know it only as a command line                    text viewer such as less with:
                  environment, it’s also a programming language in its         ls | less
                  own right. We can use it to link up a series of Linux           This allows you to scroll up and down through the
                  commands to execute based on the information that            list of files. You can also do it for other commands
                  other commands provide. In this example, we’ll use           that produce a lot of output.
                  the command:
                  find /home/ben -name “*.odt”                                  Digression over
                     To find all the required files. Not surprisingly, the       Back to our backup script though. In this case, the
                  find is command for finding things, and is far more            program outputs the result of the find command into
                  powerful than this command shows. Using other                while read f. This slightly cryptic statement starts a
                  options, you can find files based on the time they were        loop for every line in the output and tells it to store the
                  created, the time they were last modified, and a whole        line in the variable f. In other words, everything
                  host of other things. See the man page (type man find         between do and done is executed once for every line
                  in a terminal) for more details.                             in the output of the find command, that is:
                     We’ll then copy all the files into a backup folder         cp -f “$f” /ben/backup
                  (which could be on an external drive). The bash code         The $f tells Bash to insert the line output from the find
                  to do all this is:                                           command here. It’s in quote marks because otherwise
                  #!/bin/bash                                                  filenames with spaces in them will cause problems.
                  find /home/ben -name “*.odt” | while read f;                     This is a really simple example, but it shows how
                  do                                                           you can build up scripts in Bash. The two main ways
                    cp -f “$f” /home/ben/backup                                of combining commands are piping output, and
                  done                                                         running loops over multiple lines. With these two
                    You’ll need to change /home/ben to the location of         techniques, you can combine all the command line
                  your home directory.                                         tools in Linux into your own powerful scripts.
                                                                                  Before running it, you have to make the backup
                                                                               directory with:
                                                                               mkdir ~/backup
                                                                                   If you save this program as backup.sh, you can run
                                                                               it from the command line with:
                                                                               bash backup.sh
                                                                                 As long as you are in the same directory that you
                                                                               saved the file. Alternatively, if you make it executable
                                                                               with the command:
                                                                               chmod a+x backup.sh
                                                                               you can run it with:
                                                                               ./backup.sh
                  Explain Shell (www.explainshell.com) is a tool for linking     Sometimes, it’s not enough just to send the output
                  bash commands to their help text.                            of one command straight into another. Sometimes



44                                                    www.linuxvoice.com
                                                                                                                         CODE FOR ALL FEATURE


you need to make a decision based on the output
that’s being processed. For example, what if you didn’t                Books
want to copy all files straight into the backup                         Bash scripting is incredibly, but can also get quite technical.
directory? What if you wanted to sort them and put                     If you’re interested in taking it further, there are loads of
different files in different places?                                    good books on the subject. The Linux Command Line and
   In the next example, we’ll find all LibreOffice Writer                The Advanced Bash Scripting guide are both excellent
and Calc files (ODT and ODS respectively) and all MS                    choices. The latter is a bit more technical than the former.
                                                                       What’s more, the both have e-book versions that are free as
Office Word and Excel files (DOC/DOCX and XLS/                           in zero cost and free as in speech. You can get them from
XLSX respectively), and split them into word                           www.linuxcommand.org/tlcl.php and www.tldp.org/LDP/
processor and spreadsheet folders.                                     abs/html/index.html respectively.
   This can be done with the following:
#!/bin/bash
find /home/ben \( -name “*.odt” -o -name “*.ods” -o -name
“*.doc” -o -name “*.docx” -o -name “*.xls” -name “*.xlsx” \) |
while read f;
do
   if [[ $f == *.odt ]] || [[ $f == *.doc ]] || [[ $f == *.docx ]]
   then
      cp -f “$f” /home/ben/backup/wordprocessor
   fi
   if [[ $f == *.ods ]] || [[ $f == *.xls ]] || [[ $f == *.xlsx ]]
   then
      cp -f “$f” /home/ben/backup/spreadsheet
   fi
done
  The Bash if command allows you to execute a code
block only if a particular condition is true. It’s both
hugely powerful and quite complex. Used like this
(with [[ string1 == string2 ]]) it matches filenames,
and you can use asterisks in the same way you can at
the command line, so *.doc matches any file that
ends with .doc. The || is used to group multiple
conditions together so that the code block is run if any               If you prefer your books in paper form, see The Linux
one of them is true.                                                   Command Line website for purchasing options.


Running automatically
Writing scripts like this can really simplify general                  You should now see ‘GNU nano’ In the top-left
tasks like backing up data, but wouldn’t it be great if              corner. Depending on your distribution, you may find
you could automate running them as well?                             that you already have some scheduled tasks, you may
  Almost all versions of Linux (and, for that matter,                have a blank file, or you may have some lines that
Unix in general) come with a tool called crontab. The                start with a # (these are
name doesn’t give much away, but it’s for scheduling
tasks to run at certain times (it’s named after Chronos,
                                                                     comments).
                                                                       To schedule tasks, you
                                                                                                      “Sometimes it’s not enough
the Greek god of time). There are only really two                    need to add a line to this       just to send the output of one
options that you need to know: -e and -l. The first is
used to edit scheduled commands, and the second is
                                                                     file that tells it what to
                                                                     run and when. Schedules
                                                                                                      command into another.”
used to list them.                                                   are broken up into five
  So, to set up our script to back up commands, run:                 parts, each of which can be a number or an asterisk.
crontab -e                                                           For example:
   This will start a text editor (usually either Vim or              0 2 * * * /home/ben/backup.sh
Nano). If blank lines at the bottom of the file are                     The five scheduling segments represent the minute
displayed as ~, then it’s probably opened in Vim. This               of the hour, the hour of the day, the day of the month,
is a powerful editor, but it can be quite confusing if you           the month of the year, and the day of the week. An
haven’t used it before. If you want to switch to                     asterisk means ‘every’. The above line will run the
something easier, exit Vim by pressing Escape, :, Q                  backup script at 2.00am every day. If you were more
and !. They you can tell the system to use Nano                      cautious, you could run it every hour with:
instead by running:                                                  0 * * * * /home/ben/backup.sh
export EDITOR=nano                                                     Or you could run it twice a day with:
crontab -e                                                           0 0,12 * * * /home/ben/backup.sh



                                                                       www.linuxvoice.com                                                       45
     INTERVIEW CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL




EDUCATION
EDUCATION
EDUCATION
Teaching the world to code is a noble goal, but
how is it going to work in practice?


T
       wo years ago, when the               it. To find out more we travelled
       Raspberry Pi launched, it was        west to Manchester, venue for the
       with the intention of                second annual Jamboree – a
improving IT education in the UK.           festival of educators, makers and
Since then more powerful, better            messer-abouters focussed on
connected or cheaper boards have            highlighting how engaging the Pi
come onto the market, but the Pi            can be. There, we met 75% of the
retains its position as the white           Raspberry Pi Foundation’s education
knight of ICT teaching.                     team – Ben Nuttall, Clive Beale and
  Why? Because of the community             Carrie Anne Philbin – to discuss IT
of users that has grown up around           teaching in the UK.



       So, Raspberry Pi education           computing, to teach them how to use a
       team, we were saying earlier         computer. No politician has stepped in
that the obvious place to start is          to say this is not the case and they
with the UK government’s Year of            haven’t asked the teachers who would
Code initiative, but that seems far         tell them this isn’t the case. And that’s   having an impact. It’s just very different
too negative to begin with!                 the problem. Where are the teachers?        to what I was seeing before.
Carrie Anne Philbin: Yeah, but              Where are the people who are actually          Clive always says there’s a massive
there’s so much to say about it!            teaching?                                   difference between teaching and being
Clive Beale: I mean the main issue is                                                   a teacher. There are a lot of people we
how the media portray computing,                    Carrie Anne, you’ve only just       talk to who run Raspberry Jams,
which is a brilliant, creative, rigorous,          left teaching to join the            workshops, Coder Dojos and that kind
hard, challenging, fun thing, and they      Raspberry Pi Foundation – you must          of thing, and they always say ‘Oh, it’s
just reduce to this ‘code’. You start to    have some insights into the                 really easy, you just do this, this and
hear things like ‘We must learn to code’    difference between the reality of           this.’ And that’s great, but you’ve got
and ‘You better learn code or you’re a      teaching in schools and how the             kids coming to you who want to learn
rubbish teacher.’ Which of course is not    latest government wheeze imagines           this stuff. Imagine a class where you’ve
the case at all; it’s so much more than     it to be?                                   got a bunch of kids who aren’t
that. And so the teachers are running       Carrie Anne: It feels like a lot longer     interested or engaged by this subject
around now thinking the sky’s falling       than two months, it feels like an           and actually teaching is much harder…
because they think that by September        eternity! Teaching is so fast-paced, in     Clive: Maybe 15-year-olds on a Friday
2014, if they can’t code, then they’ve      that you’re seeing the results of what      afternoon…
failed and they’ll think their kids have    you’re doing in class straight away,        Carrie Anne: …yes, a six-period day,
failed, and it’s a really bad message.      whereas being out of the classroom for      end of the week…
There hasn’t been a simple message to       the past two months and working for         Clive: …Ofsted saying, ‘Why haven’t
say this is not the case. You can get out   the Foundation, I can’t actually see the    your kids developed after 20 minutes in
into the playground with some chalk         impact I’m having, but obviously people     your lesson? Why haven’t they
and make a maze and do some                 are talking to me and saying I am           progressed?’ It’s very different.



46                                                           www.linuxvoice.com
                          CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL INTERVIEW



                                                             “The Raspberry Jams have done
                                                             an excellent job of bringing people
                                                             together from all walks of life.”




              So you have some idea of how       with the new curriculum. I mean, the         Clive: It would be nice to see [what
              things should be done because      work I did as a teacher producing the        happened with Sonic Pi] as a
       of your recent experience. Are we, in     Sonic Pi was a team of work. That was        microcosm of how these things
       general as a society, doing the right     because I worked with – yes, an              actually happen. So if an academic has
       things to foster the next generation?     academic – but he was an expert. He          a brilliant idea and they’re very good at
       Carrie Anne: I think so. I think what’s   wanted to develop a teaching                 what they do, they should feel that they
       been really nice about the Raspberry Pi   environment that I could use with my         can come to a teacher and say ‘How
       community is that is gives back to the    students to teach tech-based                 can we make this useful in the
       community. So there are experts, there    programming in a fun and engaging            classroom?’, ‘How can we get
       are people who love what they do, who     way, that engaged both genders and           assessment in there?’, which schools
       are reaching out to teachers and          engaged both low- and high-ability           need, frankly, ‘How do we make it
       reaching out to children by running       students. It’s a tech-based                  robust?’, ‘How can we test it?’.
       workshops and clubs and things. And       programming language, which is                  Isn’t that a weird idea, to actually ask
       it’s actually that collaboration that     important at Key Stage 3 [pupils             the people that teach how we should
       produces the best materials and           between the ages of 11 and 14], where        do that? It hasn’t happened really. But,
       produces the best way to move forward     you need to not just be able to teach        yes, as Carrie says, we’re going in the
                                                  Scratch, you need to teach a tech-          right direction, certainly. The
                                                  based language that’s a nice bridge         community and third parties are doing
“The community and third                          between Scratch and something like
                                                  Python, which we can teach later on.
                                                                                              more to push it along.

parties are doing more to push                    So, yeah, I think we are moving in the          From someone outside a little
ICT education along.”                             right direction. It would be nicer if the
                                                  powers that be…
                                                                                                  bit, it kind of looks like a
                                                                                              community has sort of



                                                   www.linuxvoice.com                                                                 47
     INTERVIEW CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL

                                                                                           like Ben and Dave (Honess).
                                                                 Carrie Anne Philbin’s
                                                                                           Ben: Yes, some people have ideas for
                                                                    book, Adventures
                                                                    In Raspbery Pi, is     things and think this could be an
                                                                reviewed on page 26.       engaging exercise, but they may not
                                                                                           know exactly how to deliver it, or how
                                                                                           it’s going to work. They might not know
                                                                                           how exactly a teacher is supposed to
                                                                                           produce something to use that, but
                                                                                           they have an end goal and working with
                                                                                           someone else can help achieve that.
                                                                                           Clive: Yeah, you’re right, the real key is
                                                                                           the mix. So you’re getting teachers and
                                                                                           engineers and developers and families.
                                                                                           Before, they might have been on a Linux
                                                                                           user group, they might have been a
                                                                                           teacher group, and you’re just bringing
                                                                                           a bunch of different people together
                                                                                           and that just (to use a horrible word!)
                                                                                           synergises stuff.
                                                                                           (Everyone LOL)
                                                                                           Clive: Yes, I did it! I said synergises! I’m
spontaneously developed around                Carrie Anne: Well, teachers tend to          buying a copy of the magazine now.
the Raspberry Pi. Has this suddenly           generally get together through things        Carrie Anne: There’s something that
mushroomed, or has it always been             like TeachMeets and through Twitter,         comes about from getting all those
there and it’s just become more               and those kinds of chat tools. There are     different types of people together. It
obvious now?                                  ways that you can get together, but          breeds this wonderful learning
Carrie Anne: I think it’s always been         that’s more talking about teaching           environment that you cannot
there. I was a teacher, so when               practice. Like the different ways you        reproduce. Like, Ben was running a
Raspberry Pi first came out I got one. I      can use a sentence. It’s very teachery, it   Picamera workshop this morning. So
thought, this is brilliant! Someone’s         wasn’t specific to teaching computing.       that was run by people who run Jams
developed something for education. A          Clive: I think that hardware-wise, the       who are from industry. And what was
Linux box that we can use in the              Raspberry Pi was in the right place and      really nice is that there were teachers
classroom. You can mess about with it,        the right time.                              and there were people who had come
it’s cheap, it’s brilliant!                   Ben Nuttall: The Jams have done a            for the Jamboree from industry that
    And then I was like, right, so where      really good job of bringing people           were helping the teachers do stuff. And
are the resources to go with it? Ah,          together from all walks of life. The         there was this environment that was
there aren’t any. So where can I go and       people, like myself, who were attending      like, it’s OK to not know something, it’s
find some? The first obvious place was        user groups and who are interested in        OK to ask a question, it’s OK to get it
Raspberry Jams. There are people              tech and really passionate about it,         wrong and make mistakes. And that’s
running events where they’re doing            have got a chance to share that interest     really powerful, because sometimes
stuff. So I thought I’ll go along and         with the wider community. There were
speak to some people, and see what’s
available. And it was through this that I
                                              families coming in, teachers coming in,
                                              and they were just sharing what they         “You’re bringing a bunch of
met people to work with, and they’d           were doing and the skills they already       different people together and
                                                                                           that just synergises stuff.”
formed that themselves, the                   had, and I was already programming in
enthusiasts from throughout the               Python and things like that just on the
community around the Raspberry Pi.            desktop, and the Pi came along and it
Clive: It’s been a focus, hasn’t it?          opened up this way of plugging into the      teachers are afraid perhaps of saying
There’s been a lot of people sort of          real world and all the other things the Pi   they don’t know.
hanging around, saying ‘Look, I like          brings with it. Just being about to use      Ben: So at this workshop, we gave
tinkering, I like messing, I like coding, I   those skills and pass them on, I got         people an intro to building a real
like making’, and this thing appeared         involved in education through that.          application around the camera. So it’s
that was cheap and cheerful and                                                            not just ‘Oh, there’s a camera and you
fantastic to play around with. It was                 So you weren’t a teacher             can take pictures’. It was ‘OK, let’s plug
waiting to happen really.                             before then?                         in a button, and attach that to the Pi
                                              Ben: No, I was a software developer.         and let’s make that be the button for the
     Was there anything equivalent            Carrie Anne: This is what’s great            camera’. And just a simple intro like that
     to Raspberry Jams before the             about the education team at Raspberry        opens up a world of possibilities.
Raspberry Pi came along to bring              Pi. It’s 50% ex-teachers and 50%             Sometimes a lot of these things, such
people and teachers together?                 software developers. We need people          as Jam, just gives you a lot of



48                                                             www.linuxvoice.com
                                  CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL INTERVIEW




Clive Beale (left) and Carrie Anne
Philbin were both teachers until
recently, while Ben Nuttall comes from
the world of software development.


            inspiration. Or if you see something in a       make one. And some of them would           you’ll find that quite often you’ll get
            magazine or online, or on Twitter, and          need a lot more guidance.                  what are classed as low ability kids who
            you think somebody’s done that with                                                        just rip into that and do fantastic things
            the Pi, I’d really like to do that project in          Are there some kids that just       because it’s the first time they’ve been
            my garden or I’d like to do that myself                don’t get it at all?                allowed to get ideas out of their heads
            and twist it and use some of the                Ben: I think there’s something for         and make something with it, whereas
            libraries they’ve used or, use some of          everyone, but they might not find it       before, if they’ve had problems with
            the codebase they’ve used and take it in        straight away. If you delivered a term’s   writing and numeracy, they haven’t
            their own direction.                            worth of content for a class, with a       been able to do that.
            Clive: Like maybe it’s not a button;            good scope of different projects, I’d be      There are case studies with young
            maybe it’s a sensor for when your               surprised if there was one kid that        boys who aren’t very good at reading
            parents walk into your bedroom, and it          wasn’t interested in any of it or didn’t   and writing but they start telling stories
            then tweets it as they walk in.                 find any of it engaging.                   when you give them an environment
            Ben: And everyone’s got a different way         Clive: It’s almost an antidote for kids    where they can actually do these
            of thinking. If you’re in classroom of 30       not getting it. With teaching music,       things. So it’s not that they don’t get it.
            kids and you show them how to make a            you’ll have people that are level 5 or 6   There’s something for everybody.
            button do this, each of them is thinking        while others can’t read music. Because
            ‘Oh I can make a such and such’. They’ll        computing is creative and engaging, we           Pre-Raspberry Pi, in the dark
            all have a different idea. And some of          don’t all have to become master coders.          ages of about five years ago,
            them will just go straight home and             With Scratch, it’s a visual language and   before the ICT revolution, what
                                                                                                       would those children be doing?
                                                                                                       Would they have responded to ICT in
                                                                                                       school at all?
                                                                                                       Carrie Anne: In a classroom, you have
                                                                                                       a network of computers that are all on
                                                                                                       lockdown. You’ve got your network
                                                                                                       administrator and team of technicians,
                                                                                                       and they do a wonderful job and I
                                                                                                       certainly wouldn’t slate them – I was a
                                                                                                       technician once. But we were living in a
                                                                                                       time where you had to lock down the
                                                                                                       internet, which I disagree with, I think it
                                                                                                       should be open. And all the computers,
                                                                                                       you can’t execute any files on them, so
                                                                                                       you can’t actually teach any
                                                                                                       programming on them. So that was a
                                                                                                       problem for me.
                                                                  This year’s Jamboree was held in
                                                                   conjunction with the Education
                                                             Innovation Conference and Exhibition.           Is that changing?
                                                                                                             Carrie Anne: I think it is



                                                              www.linuxvoice.com                                                               49
     INTERVIEW CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL

changing, and will change with the new        them exactly what they have to do with      government got involved and it
curriculum. For me as a teacher, what         it instead of letting them explore.         snowballed really.
was great when the Raspberry Pi came          Whereas with the computing thing,           Clive: Scratch was a big word-of-
along is that I didn’t actually need those    especially things like Scratch, just lets   mouth thing. It was about mid-2000
computers around the outside of the           them think, ‘OK, I can do a movie, I can    when it came out, and suddenly you
classroom any more. I didn’t need to          do a little flip frame animation, or you    just found that any teacher worth their
seek anyone else’s permission any             know what, I can actually make a            salt was using it for their ICT curriculum
more to do what I wanted to do. Here’s        game’. And then suddenly they’re doing      because it taught about control.
my box full of Pis, let’s just get them       stuff that they haven’t had the             Carrie Anne: HTML as well. HTML
out. You can break it. And that’s OK, you     opportunity to do.                          has been on the curriculum for years.
just flash it and start again.                Carrie Anne: That old ICT curriculum        We’ve been teaching HTML in Notepad
Clive: In 1997, they put the C back in        was about 12 years out of date. It was      for years.
ICT [Information and Communications           created and it wasn’t updated.
Technology] and suddenly it became                                                               What are going to be the big
this thing that you had to teach. The                Obviously quite a lot has                   things pushing it forward over
curriculum wasn’t really that bad. A lot             changed in computing                 the next few years?
of people moan about it, but if you           education according to the media            Carrie Anne: I think more of the same
actually sat down and read it, it was         over the last couple of years in the        really. It’ll be teachers, it’s always the
quite flexible and did let you take control   UK. If the curriculum has only just         teachers. They’re the ones who come
and make programming and coding               changed, what is it that has been           to the Jamboree and this kind of thing,
interesting. But because resources are        driving improvement?                        and learn from people like Ben and that
so important to schools, you just ended       Carrie Anne: I think the teachers.          sort of collaboration. That’s where it
up doing the easy things.                     They’re the ones in the classroom who       starts. The teachers see what can be
                                              have to teach the curriculum. When I        done, and they start doing it, and there’ll
      But when you said about kids            became a teacher, I was already             be more of that. And there are initiatives
      using Scratch and becoming              working in a school and I kept putting      like code clubs, and the Master
motivated to do other things, that            off becoming a teacher because the          Teachers are great.
would never have happened before              curriculum bored me.                        Clive: Teachers are meeting up more
the Raspberry Pi came along.                     But then I realised that, when I         when before they may not have been
Clive: Yes, it was more just following        actually got into the classroom, I was      getting together.
what the teacher said, ‘And now we’re         able to put my own spin on it. I think it   Ben: And as well as there being more
going to write a letter to the cinema         started with the teachers –the people       content, I think there’ll be convergence
using Microsoft Office’ or something.         who are saying: “We want a new              of a lot of this stuff. So, because the
That’s like giving someone a Ferrari and      curriculum, we want to teach this”. I       Raspberry Pi doesn’t have any official
saying you’ve just got to drive in this       think it started there, and then industry   resources right now, some people are
room for half an hour. So you’ve given        picked up on what was happening and         going off and writing their own. I think
them this fantastic tool for exploration      they wanted to get more industry            they’ll be a convergence of people
and creativity, and then you’re telling       experts involved. And then the              pulling their ideas together and there’ll
                                                                                          be a more centralised system for that.
                                                                                          And we’ll be helping the community out
                                                                                          with that.

                                                                                                 You haven’t mentioned
                                                                                                 government policy, or anything
                                                                                          like that at all. Is that a negative
                                                                                          thing or just by-the-by?
                                                                                          Clive: I was at the Westminster forum
                                                                                          yesterday and they had a chap from the
                                                                                          Department for Education there, and I
                                                                                          couldn’t resist it, so I got the mic and
                                                                                          said: “You haven’t really taken it
                                                                                          seriously have you?” He turned round
                                                                                          and said, we have really taken it
                                                                                          seriously. This idea that we can just
                                                                                          bring in a new program of study and
                                                                                          say ‘Oh, aren’t we wonderful’, because
                                                                                          [Google Boss] Eric Schmidt has made a
                                                                                          speech, and suddenly we’ve made it all
                                                                                          better for you. But you haven’t, you just
                                                                                          seemed to have done something that a



50                                                             www.linuxvoice.com
                             CARRIE ANNE PHILBIN, CLIVE BEALE AND BEN NUTTALL INTERVIEW

                                                                                                   mark students’ work. They need time.
                                                                                                   Clive: Science is a good example. If
                                                                                                   you’re a chemistry or biology teacher at
                                                                                                   secondary level, there’s a scheme
                                                                                                   where you can re-skill to physics and
                                                                                                   they will give you free periods, a huge
                                                                                                   bursary, and they’ll also take you off
                                                                                                   timetable one day a week to go off and
                                                                                                   go to other schools and retrain, and
                                                                                                   maybe pay for the cover.
                                                                                                      This is the government doing this,
                                                                                                   and if you do this, this and this, you
                                                                                                   come out as an accredited physics
                                                                                                   teacher. So they took that seriously, but
                                                                                                   yet here’s a brand-new subject and
                                                                                                   they’re expecting people just to pick up
                                                                                                   and run with it, the preparation is
                                                                                                   completely inadequate.
                                                                                                   Carrie Anne: But it’s not just time to
                                                                                                   learn something, it’s also time to go and
                                                                                                   meet industry people. Like go to a
                                                                                                   company and be in there and work and
                                                                                                   learn from them, and see what the
                                                                                                   world is like. Because some people,
        lot of teachers are now scared of. So       skills taskforce, and which I’m part of        they went through education, went to
        there’s a lot of work to do, and we’re      the team. We’re looking at where the           university and became a teacher, so
        really positive. But no, the government     skill shortages are and what digital           they’ve never left this school
        have not, in my personal opinion, given     skills are needed. Because there’s going       environment and they’ve got no idea of
        the money or the support or the             to be a whole group of kids who are            what the world of work is like.
        thought behind this.                        now 14 to 16 who are going to leave the        Ben: I think there are some people in
           If you go to Jersey, there’s such a      education system who haven’t had new           the current government who seem to
        great contrast with what’s been             programs like these. They were on the          think there should just be this package,
        announced for England. They’re going        old program, so we’re looking at who           and this is what you should deliver as
        to spend £6 million on the 100              missed out and what we can do about            your syllabus this year. Everyone is
        thousand people who live on the island      that. So hopefully that report will inform     treated the same. Each teacher has
        – that’s the size of Cambridge. Jersey      government policy.                             their own class, and they’re all different,
        has the infrastructure, fibre to the door                                                  with different ways of engaging their
        in every school, linking into businesses,         If there’s one thing you could           interest. It needs to be tailored, so the
        a £2 million training budget for                  change about government                  teacher needs to take that material, and
                                                    policy, what would it be?                      perhaps look on the Raspberry Pi site in

“Every teacher needs more
                                                    Clive: It really is to do with support for     the next year and say, well this one
                                                    teachers. This idea that teachers –            looks quite suitable for my class, or this
time off their timetable to                         especially primary school teachers             one might be a good one to do.

develop their skills.”
                                                    where you have to teach a range of             Clive: The government also does not
                                                    subjects – would be able to suddenly           understand that this is long term. So if
                                                    go off, and teach themselves from the          you’re going to start teaching five-year-
        teachers… That’s practically what the       third-party resources just doesn’t work.       olds about algorithms and a bit of code
        government pay for the whole of             Carrie Anne: Time. One of the biggest          and Scratch, what happens further
        England with 53 million people.             recommendations that I would say is            down the line? The secondary school
           So, has the government taken the         time. Every teacher needs more time            teacher will be saying, I can’t teach
        scale of the task seriously: no. I think    off their timetable to develop their skills,   them Scratch anymore, which is what
        they’ve completing underestimated           especially in an area like this that they      we do in Year 7 at the moment.
        what’s involved. They thought the           perhaps think they’re weak. Because it            It’s a long term challenge, and things
        teachers would just pick it up and have     takes a while to set things up and start       will continue to change over the next
        the time and resources, which we don’t      your learning. As a teacher, you get a         several years until that pipeline
        have the time for.                          30-period timetable, you’re teaching for       becomes full. And they’ve said “Here’s
        Carrie Anne: Maggie Philbin                 about 22 lessons of that with about 7          £2 million, do some training for
        [presenter of television programmes         free periods, but some of those you’ll be      September 2014”. What’s 2014 got to
        Tomorrow’s World and Bang Goes The          covering for another lesson and some           do with it? This is five, six, seven years
        Theory] has been leading a UK digital       of those I need to plan my lesson and          down the line.



                                                      www.linuxvoice.com                                                                   51
     FEATURE MUNICH




           Munich city council has migrated 15,000 workers from Windows
          to Linux. Mike Saunders and Graham Morrison visited the city and
                     learned just how upset Steve Ballmer was…

              “One of the biggest aims of LiMux was
               to make the city more independent.”


               H
                          irschgarten, in the west of          the last decade. Migrating workers of
                          Munich, is one of Europe’s biggest   Germany’s third-largest city was no easy
                          beer gardens, with over 8,000        task and there were plenty of hurdles along
               places to sit. It’s a spectacular sight in      the way, but by and large the project has
               summer: hundreds of benches as far as           been a storming success.
               the eye can see, trees providing some               We’ve been following the progress of
               shelter from the heat, and a vast number        LiMux (Linux in Munich) for years, and now
               of people relaxing and enjoying the city’s      that the project is effectively complete, we
               famous beers.                                   decided to visit the city and talk to the man
                   But while 8,000 is an impressive number,    in charge of it. Read on to discover how it
               it’s not as impressive as 15,000. That’s        all started, how Microsoft tried to torpedo
               how many people the Munich city council         it, and whether other cities in the world can
               has switched from Windows to Linux over         follow Munich’s lead…



52                                                www.linuxvoice.com
                                                                                                                      MUNICH FEATURE

Humble beginnings
Cast your mind back to 2001, and the state of Linux at
the time. It was well established as a server OS and
fairly well known among computing hobbyists, but still
a small fish in the desktop pond. Gnome and KDE
were still young whippersnappers, while hardware
detection needed improvements and top-quality
desktop applications were lacking in many areas.
   So for an entire city council to even consider
moving to a largely unknown platform was a major
event. Still, it happened gradually, as Peter Hoffman,
the project leader for LiMux, told us in his office:
   “Back in 2001, a member of the Munich city council
asked: are there any alternatives to using Microsoft
software? And based on that question, we put out a
tender for a study, which compared five platform
options. One was purely Microsoft-based, one was
Windows with OpenOffice, one was Linux with
OpenOffice, and so forth.”
   As the study progressed, two main options
emerged as choices for the council: remaining with a
purely Microsoft solution, which would involve
upgrading existing Windows NT and 2000 systems to
                                                                                                                             Peter Hofmann is the
XP; and moving to a purely Linux and open source           would foster the local IT market, as the city would pay
                                                                                                                             leader of the LiMux
alternative. “If you lay more emphasis on the              local consultants and companies to do the work.                   project, and explained
monetary side, the pure Microsoft alternative would                                                                          its ups-and-downs from
have won, or if you lay the emphasis on the strategic      Ballmer marches in                                                his office overlooking the
side, the open source alternative was better.”             In May 2003, the city council was due to vote on                  Frauenkirche.
                                                           whether to make the big switch to Linux. But
Doing the maths                                            Microsoft didn’t stand still: Steve Ballmer, the
That was interesting enough – that staying with            infamously loud CEO, flew over to speak with Munich’s
Microsoft would have been cheaper. Given the cost of
buying licences for Windows and Office, you’d think
                                                             What is the LiMux Client?
that sticking with Microsoft would’ve cost far more
than switching to Linux. However, the calculations           Put simply, it’s a customised version of        it looks rather plain. A new version of the
were based on a five-year period, so they mostly             Kubuntu. We had a chance to explore it in       LiMux Client is due this year; it will be
                                                             Peter’s office, and it’s very much what you’d   based on Kubuntu 12.04, an LTS (Long-Term
covered migration costs (staff, technical support,
                                                             expect from an older Kubuntu release: a         Support) release. With this, LiMux users
retraining users etc.) rather than operational costs         Start menu in the bottom-left, various office   across the city will make the transition to
(buying new hardware, licence fees and so forth). But        and productivity applications installed,        KDE 4, and experience something rather
how did the LiMux team determine that Linux was a            and a generic theme. There’s a bit of LiMux     more polished than the KDE 3 desktop
better choice strategically?                                 theming in the wallpaper, but otherwise         they’ve been used to.
   “With the Linux alternative, we saw that it would be
possible to implement the security guidelines we
wanted to have. At the time there was a lot of
discussion about Windows 2000 and the calling
home functionality. If you asked Microsoft at that
time, ‘which one of your programs are calling home?’,
they said ‘err, yeah, maybe some, or not’. So we didn’t
get a clear answer at that time, and we thought there
would be a great advantage from a security
perspective to using Linux.”
   One of the biggest aims of LiMux was to make the
city more independent. Germany’s major centre-left
political party is the SPD, and its local Munich
politicians backed the idea of the city council
switching to Linux. They wanted to promote small and
medium-sized companies in the area, giving them
funding to improve the city’s IT infrastructure, instead     It’s not pretty or bleeding-edge, but LiMux has done a fine job of replacing old
of sending the money overseas to a large American            Windows NT and 2000 installations.
corporation. The SPD argued that moving to Linux



                                                             www.linuxvoice.com                                                                            53
     FEATURE MUNICH

                                                                                           companies, Gonicus and Softcon, won the tender with
                                                                                           a solution based on Debian.”
                                                                                               Gonicus provided consultants, and the city council
                                                                                           recruited new technicians – eventually there was a
                                                                                           team of 13 working on the LiMux project. They started
                                                                                           creating a custom version of Debian and by 2006 the
                                                                                           roll-out was beginning. But the choice of Debian
                                                                                           caused them some minor headaches further down
                                                                                           the line:
                                                                                               “In 2008 we saw that Debian was clearly stable, a
                                                                                           good thing, but not the best if you want to use new
                                                                                           hardware. They are always a few years behind. We
                                                                                           also wanted to have a clear timetable for when new
                                                                                           versions would be available. In Debian, when it’s ready
                                                                                           it’s ready, so you can’t base a release plan on it. Those
                                                                                           two things were the basis for switching from Debian
                                                                                           to Kubuntu.”

                                                                                           From Debian to Kubuntu
                                                                                           Another reason for using Kubuntu was the KDE
This chart shows the
                              mayor, Christian Ude. But this had an adverse effect,        desktop. It was clear to the LiMux team that some
migration path in 2012:
from 9,000 desktops at the    as Peter explains:                                           users would fight back against the change –
start of the year to 14,000     “Steve Ballmer tried to convince our mayor that it         especially if they regarded the current system as good
by the end.                   would be a bad decision to switch to open source,            enough, and the new one as something forced on
                              because it’s not something an administration can rely        them by politicians. So KDE was chosen as it could
                              on. But some members of the city council said: what          provide an interface very similar to that of Windows
                              are we, if one member of a big company simply comes          NT and 2000, as used by the various departments of
                              here, and he thinks he can just switch our opinions?”        the city at the time. How did people respond?
                                And it just got worse for Microsoft’s boss. “Our               “There are different levels of users. Some would say:
                              mayor was preparing for a meeting with Steve                 ‘This button was green before, and it isn’t green now,
                              Ballmer, and because English is not his native               so I cannot work like this!’ And the others say: ‘Just
                              language, he asked his interpreter: ‘What shall I say if I   give me something, I have to work, and I’ll get used to
                              don’t have the right words?’ And the interpreter replied:    it’. We had that kind of range of users, but most were
                                                            ‘Stay calm, think and say:     the first type.”

“LiMux has been a success,                                  What else can you offer?’
                                                            Later on during the
                                                                                               Peter and his team worked to ease the migration
                                                                                           process by organising meetings and roadshows
and has shown how flexible                                  meeting, our mayor was         around the city where people could come and see

and effective Free Software is.”
                                                            quickly at the point           Linux in action. They had Q&A sessions and even a
                                                            where he had nothing to        Microsoft-free zone set up with Linux computers to
                                                            say to Ballmer, except for     play with. The goal was that users would get a
                              ‘What else can you offer?’ several times. Years later, he    preview of what they’d be using a year or two down
                              heard that Ballmer was deeply impressed by how hard          the line.
                              he was in negotiations!”                                         “Some people came to us and said: ‘Can I use a
                                                                                           mouse? I thought Linux was only command line
                              Alea Jacta Est                                               based’. One person came with a floppy disk and said
                              So Steve Ballmer flew back to Microsoft HQ, the              ‘My most important documents are on this. Is it still
                              Munich city council voted, and it voted in favour of         possible to work with them?’ So we showed that it
                              Linux. History had been made. GNU/Linux and Free             was possible to open them on Linux. We were always
                              Software users around the world were pleasantly              trying to give information to the users: what was
                              surprised by the decision – especially as it had been        happening, and why it was happening.”
                              made in Munich and Bavaria, one of the more                      While LiMux was the central project in charge of the
                              conservative areas of Europe. Something big was              operating system, the roll-out and migration was
                              going to happen, but it needed time to take root, as         handled by individual departments. There was no
                              Peter explains:                                              specific deadline: departments would choose by
                                “We could not to start the migration next day, but         themselves when to handle the transition, and the
                              wanted to do a proof of concept first. In 2004, we           LiMux team would provide the technical know-how to
                              started to take preliminary steps for the migration, and     perform the migration.
                              one of them was to put out a tender for a Linux-based            Not every public sector employee moved to Linux
                              solution. Ten companies approached us trying to sell         though. Education was one area in which LiMux
                              their solutions, and a consortium of two small               couldn’t get involved, because the decisions about



54                                                            www.linuxvoice.com
                                                                                                                       MUNICH FEATURE


  Who’s next?

  Surprisingly, the success of LiMux hasn’t resulted in a flood
  of similar projects across Europe, although we all know how
  slow things move in politics. Peter has been talking to other
  administrations around Germany – but whether anything
  will come from them remains to be seen. A similar project,
  Wienux, aimed to move the city of Vienna over to Linux, but
  hit stumbling blocks in 2008.
      Peter’s reasoning for this: Wienux didn’t have proper
  political backing. You need more than just a couple of
  technically minded councillors to make such a big project
  a success – you need to know that you have the support of
  the majority.
      It all has to start somewhere, though, so maybe if we
  all write to our local councillors, point out the success of
  LiMux and ask them to consider a similar plan, there’ll be a
  lot more FOSS in our towns and cities in 10 years’ time…



educational software are made at a national level in
Germany. In addition, a few systems with very esoteric
requirements are still running Windows, although
Peter tried Wine:
   “We have a very limited Wine installation, because
there’s always the need to save the configuration of
Wine together with the application. They’re deeply
dependent. If you change the version of Wine, you
have to do something with the application, and
vice-versa. We saw that we’d have to use 10 or 15
different configurations of Wine on the same machine
in some cases.”
   Some software vendors won’t support their
programs if they’re running on Wine rather than a
native Windows installation, so in the end the LiMux
team only deployed two Wine installations.
   While the LiMux version of Kubuntu was fairly
standardised across the different departments in the
city, it took a lot of work to provide the same
functionality as the myriad Windows setups
previously out there. Peter and his team counted over
50 different configurations of Windows in use, so even
                                                                                                                              Yes, there are cuddly
when the transition had gone well for one department,             with the migration to the Linux platform. Based on
                                                                                                                              penguins in the LiMux
the requirements of the next one were often                       those parameters, Linux has saved us €10m.”                 offices. All is good in the
completely different.                                               A respectable sum indeed – but some companies             world.
   Today, the IT infrastructure is a lot more centralised,        weren’t happy with it. HP compiled a study which
with the LiMux developers issuing new releases and                concluded that no, actually, switching to Linux had
giving support. It’s much easier to fix problems and              cost the city €60m. Had Munich stayed with Microsoft
help people when you have roughly the same                        and moved to Windows XP and Office 2003, it would
operating system on each PC, rather than non-                     only have cost €17m. What did Peter and his team
standard custom setups with different service packs,              make of this?
patches and so forth.                                               “We contacted HP and said: ‘Nice numbers, how did
                                                                  you calculate them’? And they said ‘Uh, um, that was
Money talks                                                       an internal paper and not supposed to be published…’
While the initial aim of the project wasn’t to save               They published a summary, but it was not clear for
money, it’s still what a lot of people talk about. Today,         anyone to see how they calculated.”
over a decade down the line, has LiMux been a good                  As a major partner of Microsoft, it’s not surprising
idea in terms of finances?                                        that HP would try to put a different spin on the project.
   “Yes, it has, depending on the calculation. We did a           But the proof is in the pudding: LiMux has been a
calculation and we made it publicly available on our              success, has shown how flexible and effective free
information system for the city council. We have the              software is, and will hopefully inspire many other cities
exact same parameters for staying with Windows as                 to follow its lead in the future.



                                                                    www.linuxvoice.com                                                                  55
     FEATURE YOUNG REWIRED STATE




                               Look inside the philanthropic project that’s
                              fostering the next generation of coders, with
                                            Mayank Sharma.


         O
                   pen data teaches you that you can make the         Rewired State, at Google HQ in London with the
                   world a better place – not everything has to       intention of introducing open data to kids under the
                   be closed up, and it’s nice to share things like   age of 18.
          that, as it can be interpreted in many ways, for many          To her surprise, just three kids signed up for the free
          things!” This sage advice doesn’t come from a veteran       event! It took the organisers three months, and a huge
          open data advocate, but rather from 14-year-old             credit card bill for hotels and trains, to find students
          George Streten. Streten is one of the hundreds of kids,     from all over the UK to fill up the quota of 50 seats.
          all under 18, who have received neural enhancement             That experience gave Mulqueeny an unprecedented
          at the Festival of Code event organised by Young            insight into the ICT education in schools around the
          Rewired State (YRS).                                        UK. Students shared their frustrations of being let
             “We are about finding those young programmers            down by a curriculum that did not support technical
          and bringing them together at open events around the        skills or computer science and forced these
          world introducing them to open data, and each other”,       enterprising students to teach themselves.
          explains Emma Mulqueeny, the founder of YRS.                   Rather than being disheartened, Mulqueeny
             At the events, the kids collaborate with their peers     resolved to give these self-taught kids, who had been
          to build projects based on any of the various publicly      programming in isolation, a platform on which they
          available real-world open data sets. Mulqueeny is not       could interact with like-minded peers. By 2010 she
          just a vocal proponent of open data but also played a       had quit her job and founded Rewired State, a
          pivotal role in showcasing its potential to Government      for-profit enterprise that organises hack days and has
          officials, which eventually led to the birth of the UK      a network of more than 1,000 software developers
          government’s open data portal, data.gov.uk.                 and designers. YRS became a philanthropic arm of
             While she was conducting hack days for the               Rewired State, meaning that, unlike Rewired State,
          government, Mulqueeny noticed that all the coders           YRS is a non-profit social enterprise.
          were older than 25 years of age. So in 2009, “a small
          group of us decided that we needed to bring the open        Festive season
          government data revolution to the next generations”,        YRS has been organising hackathons for kids ever
          writes Mulqueeny on her blog.                               since. From a weekend-long session in 2009 the event
             So in August 2009, she along with a bunch of             is now a week-long affair, and the number of
          friends, organised a weekend event, christened Young        participating kids has been gradually rising.



56                                                       www.linuxvoice.com
                                                                                                       YOUNG REWIRED STATE FEATURE


                                                                        Tyriah Taylor, 10
                                                                                              I kept asking my mum for      The first YRS event I went to was at the
                                                                                              a new 3DS and games        Rutherford Appleton Laboratory [in Oxford]. I
                                                                                              for my Nintendo DSi and    learnt some Python, and we made a game in
                                                                                              Wii. Eventually, my mum    Game Maker called Food Fetcher. Last year
                                                                                              got annoyed and told       I went to the Microsoft Campus in Reading
                                                                                              me that I could make my    and I learnt some HTML, CSS and PHP. We
                                                                                              own games. She started     made a website called Top Tweets, which is
                                                                        looking for computer clubs and that is when      a Twitter search engine, where you put in a
                                                                        she found Young Rewired State.                   word or hashtag and it returns the top 3 most
                                                                           I didn’t think it was going to be very        retweeted and favourited tweets containing
                                                                        interesting. However, right from when I          that word/hashtag.
                                                                        got there we had talks and tours of the             We don’t have any workshops at my
                                                                        venues. We had practice sessions for our         school. We have Scratch, but I don’t think
                                                                        presentations for the Festival Of Code, which    anyone else knows how to use it, except me.
                                                                        helped build our confidence. Young Rewired        I can’t wait for YRS 2014 and I am hoping
                                                                        State is one of the best experiences I have      that some of my friends will be coming along
Young Rewired State has grown from 50 participants in                   ever come across and it was great fun!           as well.
2009 to over 1,000 today.

   While YRS is involved in various activities to engage              available on-site at each local centre and even online
with coding kids through the year, it brings young                    at the YRS IRC channel. The mentors assist the kids
coders together from across the UK once a year in a                   with their projects.
meeting called the Festival Of Code. This stretches                      From Monday to Thursday the young programmers
over a week, during which kids create all sorts of                    assemble at their centres and hack on their projects
coding projects. All the apps are built around open                   to create a functional prototype. On Friday, everyone
data -- from something as simple as a website to                      from across all centres
access data to apps that turn that data into
meaningful information.
                                                                      travels to and
                                                                      assembles at a central        “YRS brings young coders
   The event is held in the first full week of August of              location in the UK to         together once a year in an event
                                                                                                    called the Festival Of Code.”
every calendar year. The event works by gathering                     present their work to a
kids at local centres all across the UK. At the centres,              panel of judges.
the kids are encouraged to pair up with their peers,                     Until 2013, the
although they are free to work on their own as well.                  festival culminated in the Custard Factory in
   They can create anything they want, using any                      Birmingham. This year that venue has shifted, and the
types of programs or equipment they’ve brought                        weekend will be held at the University of Plymouth.
along. The only requirement is that the project must                     Over the weekend, the young coders will present
include at least one open data set. Mentors are                       their projects to a panel of judges during the


  George Straten, 14
                      I heard about Young Rewired State from
                      a friend. I hadn’t met him in person
                      before; we’d met on Twitter. He invited
                      me to write for his blog, and while
                      chatting to him on one of the numerous
                      Skype calls that we had, he mentioned it.
                      I don’t really know what I expected from
  the event to be fair. If I’m honest, I expected it to be a little
  dull, but throughout the week, my opinions couldn’t have
  changed more dramatically… I really enjoyed the event!
     We created a lost and found website, for the whole of the
  UK. I created a 30-second video advertisement for it too. At
  school, we never have any experiences like this. We don’t
  ever have-IT based workshops, which is a huge shame, so it
  was different from anything that I’d ever experienced.
     Young Rewired State’s Festival of Code not only is an
  amazing opportunity, but an opportunity to meet people.
  I’ve met a huge community of amazing people, which I’ve
  stayed part of through various social media platforms, such
  as Twitter – without YRS, I would never have met such
  talented people. Once I’m over 18, the maximum age limit
  to attend as a participant, I hope to join Young Rewired
  State, and help other people like me to engage with others
  and share their talents.




                                                                        www.linuxvoice.com                                                                           57
     FEATURE YOUNG REWIRED STATE

                                                                                                    tested in the UK. The events are currently restricted to
                                                                                                    a weekend, just like the first YRS event in 2009. It’ll
                                                                                                    then be extended to a whole week and stretched to
                                                                                                    multiple centres across the new country.
                                                                                                        The first YRS Everywhere event was held in 2013 in
                                                                                                    New York in collaboration with a number of networks
                                                                                                    such as Mozilla Hive and the Museum of the Moving
                                                                                                    Image in New York.
                                                                                                        Just like the first-ever YRS event in 2009 in the UK,
                                                                                                    the event in New York also invited 50 kids for a
                                                                                                    two-day hackfest. During the event they worked with
                                                                                                    open data local to the US and came up with projects
                                                                                                    that were of local interest. The kids programmed
                                                                                                    under the guidance of local developers as well as
                                                                                                    YRS’s worldwide mentor network.
                                                                                                        The event in New York was followed by a similar
                                                                                                    two-day hackfest in Berlin, again with the help of
                                                                     Emma Mulqueeny, Young          well-known local networks such as SAP and the Open
                                                                     Rewired State’s founder,
                                                                                                    Knowledge Foundation. Just before the close of the
                                                                     has in the absence of
                                                                                                    year, the team went back to the USA, this time for an
                                                                     government policy been
                                                                     preparing kids for the         event in San Francisco. In 2014, the network is
                                                                     future since 2009.             planning a YRS Everywhere event in Asia in Singapore.
                                                                                                        The YRS Everywhere events follow the same
                                                                                                    pattern as the Festival of Code. On the first day the
                                                                                                    participants form groups and choose the open data
                                  preliminary heats and the semi-final rounds that will             set that they will work on. They work on their projects
                                  be held on Saturday, and the finale on the Sunday.                till the afternoon of the next day. In the evenings the
                                  Their friends and family members are welcome to                   hacks are presented to the panel of judges.
                                  attend and watch over the proceedings.                                You don’t have to be an ace coder to participate in a
                                                                                                    YRS event. In fact, according to the YRS website, the
                                  Going global
                                  In five years, YRS has grown from a single weekend
                                  event with 50 young coders to a week-long event
                                  across the UK. Now Mulqueeny and the YRS team are
                                  reaching outside the UK in order to foster young
                                  programmers in other countries.
                                     The YRS International events are held under the
                                  banner of the YRS Everywhere program. The idea with
                                  YRS Everywhere is to replicate the scale that has been



 Planning a YRS event
 Organising an event that runs simultaneously       pointing to her website, which details the
 all across the country and involves over a         requirements for a centre. They also have
 thousand kids is no small feat. But Emma           a team that check the credentials of the
 Mulqueeny and her small team manage to             registered mentors. “We do not provide
 pull it with relative ease. So we asked her:       training for them, but we connect mentors
 What does it take to organise a YRS event?         from previous events with new mentors so
     “Crikey, a lifetime!”, exclaimed Mulqueeny.    that they can ask any questions they have.”
 “As with running any hack weekend, the                Beyond their main event, Mulqueeny says
 practicalities are about venue, Wi-Fi and          that the YRS Everywhere events are relatively
 power,” she explains. Once that’s taken care       simple to setup. “The organisers apply and
 they focus on “who and how to recruit”             we check their credentials: have they run
 which applies to both the participating kids       hack weekends before, do they have access
 and their mentors. Next up is selecting the        to a developer network versed in Open Data
 panel of judges and the prizes. An important       to act as mentors, and so on.”
 aspect of any YRS event is access to local            If the organisers meet these criteria,
 open data. Mulqueeny says it “is critical, as      Mulqueeny and her team guide them to
 we try to make this about local challenges.”       find the young participants, based on their
     “For the Festival of Code, centrally we deal   experience, and support them remotely. If
 with all of the logistics and fundraising, but     required, the organisers can pay them to put
 centres act as our outposts,” she continues,       together a team to help run the event.          These kids aren’t just learning a new skill; they’re sharing,
                                                                                                    and learning from each other.


58                                                                     www.linuxvoice.com
                                                                                           YOUNG REWIRED STATE FEATURE

youngest participant in the 2013 edition of Festival of
Code was a mere five years old!
  If you have basic programming skills, you are good
enough to be a part of YRS. The group accepts coders
of all levels; however, it helps if you at least have a very
basic understanding of HTML. There are no lessons in
programming dispensed at the Festival of Code event.
Instead, the event helps young people learn from and
teach each other.

Low barrier to entry
According to an FAQ on its website “The only thing we
ask is that when you come along you get involved and
use your skills to the best of your ability, and we
encourage you to be adventurous in your learning.”
   To encourage more participation YRS has
introduced the Google Assemblies program in
partnership with Google. The idea behind the program
is to introduce kids to YRS and coding.
   During a Google Assembly, a YRS participant gives
                                                                                                                          Young Rewired State isn’t
an assembly presentation at their school. They are
                                                                                                                          about coding for the sake
assisted by YRS mentors to prepare for the                                                                                of it: the emphasis is on
presentation using slide decks, videos and YRS and                                                                        using open data to improve
Google swag.                                                                                                              participants local areas.
   With these assemblies, YRS intends to connect with
young students via one of their peers who can share
their experience about the event and encourage
participation with their enthusiasm. They are hopeful
that the association with Google will help demonstrate
how important their talents are to a multinational             Code event has come to an end. The Hyperlocal
marquee brand that everyone can connect with.                  program is designed to ensure that the prototypes
                                                               designed during the week complete the journey to a
Pitch in!                                                      finished product.
According to Thom Brooks of YRS, organising the                   The Hyperlocal centres will run sessions where the
2014 edition of the Festival of Code will cost them            kids can come back to work on their projects under
around £250,000. That’s quite a sum to raise, and              the guidance of their mentors. The YRS team will help
being a non-profit organisation they rely on                   prepare the centre to run sessions as per the schedule
sponsorship from individuals and institutions.                 that suits the centre.
   If you appreciate the work of Young Rewired State              If you have programming skills but are over 18 and
and wish to donate, you can email Emma Mulqueeny               can’t participate in the events as a coder, you can lend
at emma@rewiredstate.org for the official channels             your skills and expertise and volunteer as a mentor.
of donation. The idea behind all YRS events, including         YRS has a thriving mentor community. Traditionally
the Festival of Code, isn’t to make any profit. All the        mentors for the

                                                                                   “If you’re over 18 and have
funds received are used towards organising the                 YRS events have
festival itself as well as for the fund to support families    been drawn from
who can’t spare the monetary resources required to             the Rewired State
                                                                                   programming skills you can lend
                                                                                   your experience as a mentor.”
cover the associated travel costs.                             network, but that
   Besides direct monetary help there are several other        requirement has
ways you can help the initiative. If you have a large          been relaxed with
room or a conference hall that you can spare for a             their growing popularity.
week, you can sign up with YRS as a Festival of Code              If you fancy getting involved, the YRS website has
Centre. You’ll also have to assign an individual who           loads of information on what it expects from a
will be the centre lead. When you register as a centre,        mentor. Mentors don’t necessarily have to be
YRS will work with you to make sure you’re all set up          physically present at a centre and can even guide the
well in advance. You’ll be listed on their website and         coders remotely from anywhere in the world. YRS is
participants will be assigned to you based on their            growing both within and outside the UK. After
geographic proximity.                                          establishing a model for scaling the hackfest, the
   You can also register your centre as a Hyperlocal           team is replicating it in other parts of the world,
Centre. Such a centre allows participants to continue          encouraging kids to solve their local civic problems
working on their prototypes even after the Festival of         with open data and open source code.



                                                                 www.linuxvoice.com                                                              59
     FAQ DOCKER




DOCKER
The ultimate deployment tool, or just another tech fad?

BEN EVERARD
                                              However, you can have many copies of
                                              everything else. Containers are a way of
                                                                                           independent OSes, but it all runs atop
                                                                                           the same kernel.
                                              encapsulating this ‘everything else’ so         There are advantages and
      Ok, let’s start with an easy            that they can share a kernel, and this       disadvantages to this. Because they
      one: what is Docker?                    enables you to run multiple distros on       run the same kernel, you can’t run
      That’s simple: it’s a tool set for      the same hardware.                           different operating systems like you can
      managing deployments of                                                              with virtualisation. However, on the
containers.                                           Like having a dual-booting           other hand, because they don’t simulate
                                                      Linux system?                        the CPU, the performance is better.
      You’re stretching the definition                No. Using containers, you can run
      of ‘simple’ a bit. Can you break                multiple distros at the same time,         Great! Now I understand it, and
it down for me a bit more? Let’s start        or, as is more common, using the same              we’ve still got a page to go.
by explaining what a container is.            distro multiple times.                       Shall we just stick a picture of Linus
      OK. Remember that Linux is just                                                      Torvalds in there and nip off to the
      the kernel and the operating                   Ah, so containers are a form of       pub early?
system is this plus all the tools that sit           virtualisation, like Virtualbox             Not so fast! That’s containers. We
on top of it?                                 or Qemu?                                           need to get onto Docker itself.
                                                     From a user’s perspective they’re
       Yes, but I thought I got to ask               pretty similar. You have a host               Oh right, yes. You said before
       the questions?                         OS, and within that host OS, you can                 that it’s a tool set for
       Sorry. A mild digression only. The     boot more versions of Linux. However,        managing deployments on
       Linux kernel is the bit that sits on   at a technical level, they work in very      containers. I know what containers
top of the hardware and controls              different ways. In virtualisation, you       are, but why would you want to
access to the CPU, memory, and all the        have an application on the host OS that      deploy them anywhere?
other stuff that makes up your                simulates a CPU, then you have another               The big advantage of containers
computer. Normally, you can only use          entire OS (including kernel) that runs on            is that you can encapsulate an
one kernel on a computer at a time.           this simulated CPU.                          entire environment into a single block.
                                                 In containers, you only ever have one     This enables developers to pull all the
                                              kernel. It’s the same for the host           libraries, data, and software into a
“You could have a Docker                      operating system and the other
                                              operating systems that you run. The
                                                                                           single container and distribute this. By
                                                                                           sending the container, rather than just
image for OwnCloud and                        containers have their own chunk of the       the software, it means they don’t need
another for WordPress.”                       filesystem where they keep all their
                                              data, and behave exactly like
                                                                                           to worry about dependencies, different
                                                                                           configurations, or anything like that.



60                                              www.linuxvoice.com
                                                                                                                               DOCKER FAQ


      So it’s a bit like statically
      compiling software, but
including the whole OS?
      I’d never thought of it like that, but
      I suppose it is really.

       Sounds awesome! What’s the
       inevitable downside?
       Nothing major, but the containers
       will take up more disk space than
just the plain software, and they have to
be updated separately to keep them
current with the latest bugfixes and
security patches.

        So is Docker poised to become
        a universal replacement for
apt-get, Yum, and all the other
package managers?                              You can get a taste for Docker without the hassle of installing anything by trying out the project’s
        Not really. No one’s suggesting        interactive tutorial at www.docker.io/gettingstarted.
        that containers are a sensible
way of installing all your regular                    The main tool is (unsurprisingly)                       just one year old (happy Birthday
software. The main target market for                  called docker, and it has options                       Docker!). In that time it’s come all the
Docker is people providing services            for getting and manipulating containers.                       way to version 0.9. The earliest plan we
across a network. For example, you             There’s a repository of containers that                        heard about was for a release of
could have a Docker image for                  have been made for common purposes.                            version 1.0 in October 2013, but by
OwnCloud, and another for WordPress.           You can grab these with:                                       November that year, it had been pushed
They would each have their own                 docker pull <name>                                             back to February 2014. At the time of
environments with everything installed,        Then, once you’ve got one installed, you                       writing, there was still no sign of it, but
set up, and ready to run.                      can run commands on it with:                                   we don’t expect it to be much longer.
    By keeping everything contained in         docker run <image-name> <command>                              Of course, just because it’s called
this way, it’s really easy to customise            That’s the basic use. There are also a                     version 1.0 and the team behind it say
and deploy. A developer could pull the         few options to help you manage the                             that it’s production-ready doesn’t mean
Docker image to his or her development         containers. It’s complex technology, but                       it’s ready for everyone. Sysadmins are a
machine, make any changes they like,           it’s surprisingly easy to use.                                 conservative species by nature, so we
then push it to the server. They don’t                                                                        don’t expect many people to start using
need to worry about the development                    This all sounds so good, you                           it in important services for a while yet.
environment being different to the live                must have found it really
environment, because the whole                 useful when setting up the Linux                                      I’m not a conservative
environment is included in the container.      Voice web services.                                                   sysadmin, I’m a reckless
It it doesn’t matter if it’s developed on              Actually, no. We didn’t use                            maverick programmer. How can I get
bleeding-edge Arch Linux, and deployed                 Docker. It is, as you say, really                      started with Docker?
on ultra-stable Centos, it will always run     good, but it’s also really new and still                              You won’t find it in many distros’
the same. As well as making it easy to         under heavy development. The current                                  repositories just yet, but there are
develop, this should remove much of            version is 0.8, and the people behind it                       packages for it for most major Linux
the hassle of setting up test servers, or      recommend that you don’t use it for                            distributions at http://docs.docker.io/
migrating to a new environment.                production systems until version 1.0 at                        en/latest/installation.
    The developer can also make any            least. It’s not unstable, but it’s not yet as
changes they need to the environment           mature as we like our server software                                You said it ran on Linux
without worrying about how these may           to be. Of course, some people are using                              containers. I have this friend
affect other software running on the           it on production machines. We’re just a                        who runs a commercial OS and won’t
server, because that software will be in       little conservative about such things.                         listen to reason. Can he run it?
a separate container.                                                                                               Sort of. You can run Linux on
                                                    Ah… so I should expect it about                                 OS X or Windows in VirtualBox,
      I almost understand your first                the same time GNU/Hurd is                                 then run Docker in this. There are
      point now: ‘a tool set for               ready? Perhaps in time for Linux                               instructions at the installation website
managing deployments of                        Voice #100 (or Hurd Voice #1).                                 above. Of course, it’s far better just to
containers’. What sort of tools are                 Less of your cheek! The first                             give your friend a talking to about the
typically in the set?                               release was in March 2013, so it’s                        advantages of open source systems.



                                                                    www.linuxvoice.com                                                                61
     SYSADMIN




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

                        Jonathan Roberts
                        dropped out of an MA
                        in Theology to work
                                                 Linux containers
                        with Linux. A Fedora     Enterprise-grade virtualisation on a real kernel.
                        advocate and systems



                                                 W
                        administrator, we hear
                                                              hile Linux containers have been      administrators to group processes, and all
                        his calming tones
                        whenever we’re stuck                  around for a while, they’ve          their future children, into hierarchical groups.
                        with something hard.                  recently been gaining more           Various subsystems can then be used to
                                                 recognition as a lightweight alternative to       strictly manage the processes and the
 When new products are being developed,          traditional virtualisation products like KVM      resources they interact with.
 one of the most important choices to be         or VMWare. With the arrival of LXC, Docker,
 made is which technologies you’re going
                                                 and the next generation of distributions,         Control groups
 to build on top of. Obviously, the right tool
                                                 we’re all likely to see a lot more of them over   If you have systemd installed, you can
 for the job is the correct answer, but how
 you decide which tool is the right one is       the coming decade.                                quickly inspect what cgroup your processes
 less obvious.                                      As with all virtualisation, the idea of        are running in with the ps command:
    As a sysadmin, my goal is to ensure that     containers is to make it easy to run multiple     ps -aeo pid,cgroup,command
 our technologies are the most secure, the       applications on a single host, all the while         Running this, you should see that all
 most stable and the most familiar. All of       ensuring each remains separate. This              processes are running in cgroups that exist
 these characteristics will reduce the           enables the administrator to carefully            in a hierarchy below the systemd cgroup.
 chances of me being woken early in the          manage the resources assigned to each             You could use systemd unit files to manage
 morning, and when I am inevitably woken         application and to ensure that they can’t         the resources assigned to a service (indeed,
 in the morning, I’ll at least have the          interfere with each other.                        if you’re using systemd, this is probably the
 knowledge and experience to have half a
                                                    What makes containers different to             best way to use cgroups), as described in
 chance of fixing whatever went wrong.
                                                 traditional products is that they don’t do any    the last issue, but you can also interact with
    For developers, however, operational
 requirements often seem restrictive.            hardware emulation. Instead, the                  cgroups directly, too.
 Enterprise distributions come with              applications in question all run directly on         There are a collection of tools available in
 technology that’s more than three years         top of the host kernel, just like any other       the libcgroup-tools package, including
 old and requires the developers to write        process. Separation between the running           cgcreate, for example. You can use this tool
 far more lines of code. This means there’ll     containers is achieved through the careful        to create a new cgroup as follows:
 be more bugs and they may well take             use of a number of Linux kernel features.         cgcreate -g memory,cpu:mysql
 much longer to get the product to market.          Control Groups (cgroups) are the first of        This will create a new cgroup called mysql
    During the two years I’ve worked as a        these features, and are probably the best         which has been tied to the memory and cpu
 system administrator, I’ve seen this            known. They provide a means for                   subsystems. You can then take advantage
 conflict crop up several times, but never
 seen any obvious solutions that make
 both parties happy. I agree with the
 ‘DevOps’ crowd, who argue that part of the
 solution is to ‘better align incentives’,
 making operations more responsible for
 delivering software and developers more
 responsible for maintaining it.
    We also need improvements from
 distributions, providing more reliable
 means for getting recent, but stable,
 software packages on to well tested
 platforms. The Fedora.next wheeze may
 be going some way to address this, as do
 PPAs in Ubuntu. Hopefully we’ll see this
 mentality begin to translate to Debian and
 RHEL in the coming years, too.
                                                 The highlighted area shows the cgroup in which the different processes are running. As you can
                                                 see, all are either in the systemd defaults of systemd:/user.slice and systemd:/system.slice.


62                                                           www.linuxvoice.com
                                                                                                                                    SYSADMIN

of a command, such as cgset, or interact
directly with the virtual filesystem exposed
by cgroups, to manipulate the resource
limits of this newly created group:
cgset -r swappiness=xxx /sys/fs/cgroups/memory/
mysql
  This command will set the swappiness
parameter of all processes running in the
mysql cgroup to xxx. To add a process to
the cgroup, all you need to do is echo its PID
to the tasks file in the cgroup’s filesystem or
use the cgclassify command.

Namespace isolation
Namespace isolation is the other key
technology that makes containers possible
on Linux. Each namespace wraps a
particular system resource, and makes             The output of this long listing in the /sys/fs/cgroup directory shows all the different subsystems
processes running inside that namespace           that are available for managing processes with cgroups on a default Fedora 20 installation.
believe they have their own instance of that
resource. There are six namespaces in Linux:      install the lxc package on Ubuntu and                      lxc.cgroup.cpu.shares = 1234 Sets the
  mount Isolates the filesystems visible to a     Fedora, but in the case of the latter, you               share of CPU that the container has.
group of processes, similar to the chroot         should also install lxc-templates and                      lxc.utsname = linux-voice Sets the
command.                                          lxc-extras for a better experience.                      hostname of the container.
  UTS Isolates host and domain names so              Once that’s done, creating a new container,             lxc.mount.entry = /lib /home/jon/
that each namespace can have its own.             depending on your requirements, can be                   containers/busybox/lib Specifies directories
  IPC Isolates System V and POSIX                 simple. In the /usr/share/lxc/templates                  on the host filesystem that should be
message queue interprocess                        directory, you’ll find a collection of scripts           mounted in the container.
communication channels.                           that will create some default containers,                  This configuration file means you can
  PID Lets processes in different PID             including Debian, Fedora and Ubuntu system               apply the existing templates in quite flexible
namespaces have the same PID. This is             containers, and sshd, BusyBox and Alpine                 ways, but if you really want to create a
useful in containers, as it lets each container   application containers. To put one of these to           custom container, you’re going to have to set
have its own init (PID 1) and allows for easy     use, all you need to do is run lxc-create:               to work creating your own template script.
migration between systems.
  network Enables each network
namespace to have its own view of the             “Creating a Linux container is paradoxically easier
network stack, including network devices, IP      than creating an application container.”
addresses, routing tables etc.
  user Allows a process to have a different       lxc-create -n linux-voice -t /usr/share/lxc/templates/      As the LXC man page says, creating a
UID and GID inside a namespace to what it         busybox --dir /home/jon/containers/linux-voice           system container is paradoxically easier
has outside.                                        -n sets the name of the container.                     than creating an application container. In the
  A quick way to experiment with                    -t says which template you want to use.                latter case, you have to start by figuring out
namespaces yourself is to use the unshare           --dir says where you want the rootfs for               which resources you want to isolate from
command. This will run a particular               the new container to be created.                         the rest of the system, and then figure out
program, removing its connection to a               This command creates a directory in                    how to populate the appropriate parts of the
particular namespace of its parent:               /var/lib/lxc with the name set by the -n flag.           file system etc. In the former case, you
sudo unshare -u /bin/bash                         The contents of this directory are populated             simply isolate everything – much simpler.
  This will create a new bash process that        by the script specified with the -t flag. If you            Once you’ve created your container with
doesn’t share its parent UTS namespace. If        look at, say, the BusyBox template, you’ll see           lxc-create and modified the config file as
you now set the hostname to foo, you’ll then      that this script sets up a filesystem                    you see fit, you can start it with the lxc-start
be able to look, in another shell on the same     hierarchy, copies appropriate binaries and               command, use lxc-console to get a console
system, and see that the hostname in the          installs important pieces of configuration               in it, and shut it down with lxc-shutdown.
root (original) namespace hasn’t changed.         with heredoc statements.                                    While cgroups and namespaces have
                                                    Inside the created directory, you’ll also find         reached a degree of maturity in Linux, the
Linux containers                                  that a config file has been created. This                user experience still has some room for
Now that you have an idea of what the             defines which system resources are to be                 improvement. If you found the lxc-
underlying technologies do, let’s take a look     isolated and controlled by the container. The            commands tricky to use, you might want to
at Linux Containers (LXC), a userspace            man lxc.conf command goes in to detail on                install libvirt-sandbox, which will provide a
interface that brings them together. To           what options can be put in this file, but a few          set of scripts and extensions for using LXC
install the LXC userspace tools, you need to      key examples will be helpful:                            through the familiar libvirt tools.



                                                                www.linuxvoice.com                                                                      63
     CLOUDADMIN




CLOUDADMIN
Nick Veitch opens your eyes to the technology behind the cloud server revolution.

Jenkins
Testing code yourself? Why not get a minion to do that for you?


W
            ouldn’t it be great if things worked      The name sounds like some sort of
            all the time? I mean, software         maths purgatory. Continuous integration
            things, not people things. Gosh,       was born out of the age that gave us agile
the world would be a better place if I worked      programming. The idea is pretty good, and
hardly at all. That’s why software was             all but indispensable in the modern world
invented isn’t it?                                 of group coding on complex software
  But things (including me) do not work all        properties. Commits made by coder #1
the time. In fact, in the world of software        may be all well and good, and coder #2 is
development, particularly in the new world         well known for being cautious and testing
we now call devops, things are almost              everything, but if they both land changes,
perpetually operating in a mode of non-            perhaps the two new parts don’t interact as
functionality. What is very useful to know is      they should?
when, almost miraculously, there is a small           Breaking code is usually ridiculously easy,
window of time when software works as it is        even with parts that seem to be backwardly          If you are bored with butlers, you could always
                                                                                                       replace the Jenkins logo with Chuck Norris.
expected to. In a smart, switched-on world,        compatible – it is often the difference
we can capture this moment so we can               between the programmers’ perception of
work out what went wrong/right. This is the        how a particular block of code works, and           on. The basic principle is that you submit a
world of continuous integration.                   how it actually works, that leads to ripples of     job (maybe triggered automatically by time,
                                                   wrongness in the edge cases.                        or by a merge to a public repository) of code.
                                                      Testing is therefore a good thing, and           Jenkins then spins up a clean environment
                                                   continuous integration is a blessing.               for the code to work in, executes your tests
                                                                                                       and spits out a report. Actually, that is pretty
                                                   At your services                                    much the least it will do. With an active and
                                                   In the early days of Agile, one system rose         productive community, Jenkins has grown
                                                   head and shoulders above the others. Its            a legion of plugins to automate everything
                                                   name was Hudson. Hudson was originally a            from audit trails to uploaders for zubheim
                                                   Sun project, but with the acquisition of Sun        (it’s a mobile app testing platform). There is
                                                   assets by Oracle (remember them), there             a list of plugins so long I couldn’t possibly
                                                   were, erm, tensions. The project decided to         read them all without more gin than is
                                                   rename itself ‘Jenkins’. Oracle went off in a       medically advisable.
                                                   huff and took its newly trademarked name                The only major downside to Jenkins is
                                                   with it. Hudson still exists, but we’ll leave you   that it requires a bit of effort to get it working
                                                   to decide who came off best from that spat.         the way you want. Though it was originally
                                                   Anyhow, the open source Jenkins project             imagined as a Java testing tool, Jenkins now
                                                   became the de facto required tool for those         covers an impressive range of languages
                                                   seeking CI nirvana.                                 and additional functionality, but almost all
                                                      Jenkins itself is a behemothic Java app          of these require adding plugins and some
                                                   (aren’t they all) which requires a server to run    amount of configuration. The results of a




One of the Jenkins plugins can automatically
                                                   “Though it was originally imagined as a Java
control lights to demonstrate build status         testing tool, Jenkins now covers an impressive
(picture by Dushan Hanuska).
                                                   range of languages and additional functionality.”

64                                                             www.linuxvoice.com
                                                                                                                                 CLOUDADMIN


                                                   that’s its primary purpose. And instead of
                                                   editing acres of config files, you can set up              CloudBees
                                                   everything that travis can do in a simple file             Cloudbees is a hosted service that offers
                                                   called travis.yml and add it to your github                free Jenkins capabilities, so you can get
                                                   repository. Register with the Travis website               pretty much everything you ever wanted
                                                   (sign in with your github credentials, flick a             out of Jenkins, but without having to go
                                                   few switches to turn your repositories on                  through the rigmarole of running your
                                                   and Travis will do the rest. Every time you                own service. The cloudbees people should
                                                   push updates to the repository, Travis will                know what they are doing too – the CTO is
                                                   notice and add your jobs to the end of the                 Kohsuke Kawaguchi, the original founder
Log on to the Travis website and you can see                                                                  of the Jenkins project.
the build queue and check out the console          queue. Log in to the website and you can
output from your jobs. If only to find out what    check the queue and see the console output
an idiot you are.                                  of your jobs when they run. But there’s no
                                                   need, because Travis will send you plenty of
well configured, well honed system are very        mails as well, telling you when builds have
worth it though (you should definitely try         succeeded or failed, and helpfully giving you
the Chuck Norris plugin, which replaces the        plenty of version info.
butler image on your reports with a random            If you really want to know how easy it is to
image of a culturally significant martial arts     configure Travis, here are a few examples;                 All the Jenkins service but without the
practitioner). As well as merely testing the       firstly, a simple python project:                          trouble of having one of your own.
build and functionality of your software,          language: python
you can automate all sorts of other tasks          # versions of python to use
like publishing documentation or building          python:                                                  anything. For a C project, the Travis file can
different versions. If you ever have the need       - “3.3”                                                 be as simple as:
to build hierarchical projects, there is really     - “2.7”                                                 language: c
nowhere else to start.                              - “2.6”                                                    That’s because Travis assumes you are
                                                   # command to install dependencies, e.g. pip install -r   using Automake and will default to running
Did anyone prophesise these people?                requirements.txt --use-mirrors                           ./configure && make && make test, so you
Due to the nature of its flexibility and all the   install:                                                 can put any magic in your Makefile. There
gubbins that can be bolted onto it, you may         - “pip install markdown”                                is no real dependency management for C
find it takes quite a while to set Jenkins up       - “pip install configobj”                               projects, but that doesn’t stop you from
in a working fashion. For people who don’t         # command to run tests, e.g. python setup.py test        using the install section (or before_install:,
want to spend half their working day writing       script: python mdconverter.py                            to run first) to fetch such things as you
new configs for Jenkins, there is Travis.             This example declares the language,                   might need. You are also not limited to using
   Travis is quite a bit simpler, but no less      optionally selects a few different versions              GNU make. For example, to use cmake you
capable. Part of this simplicity is due to the     (they will execute as separate jobs) and                 would just need to add something like :
fact that you don’t have to set up a server        has the install command to add any                       before_script:
to run Travis for you; it is a hosted service.     dependencies. The pip tool is used in this                - mkdir build
Actually, you can very much download the           case to install any additional modules                    - cd build
open source code for Travis from github, but       required by the Python file.                              - cmake ..
why go to the trouble of building your own            The final line is the script to run. In this          script: make
service (the docs don’t really give you any        case, as our project is a simple linear                     Currently the Travis CI environment is an
help on this either) when the hosted service       conversion tool, we just execute that, but               image of 64-bit Ubuntu 12.04, so you can do
is free for open source projects. Travis           you could run a separate script to do a                  pretty much whatever you need to with it.
integrates really well with github. In fact,       number of tests, pass special parameters or                 If you have an open source project on
                                                                                                            github and want a free, no fuss service,
                                                                                                            Travis could fit the bill. Jenkins is better at
                                                           The Travis build matrix view gives you
                                                                                                            all-round automation – if you need to do
                                                            a nice overview of your status , but I
                                                           think I would rather have a lava lamp.           more than just build a project and run a
                                                                                                            script, it is infinitely more powerful (with the
                                                                                                            configuration headaches to match). But
                                                                                                            whatever you choose, make sure you write
                                                                                                            good tests! Continuous Integration as a
                                                                                                            discipline means nothing if your tests don’t
                                                                                                            make sure that things are working. Good
                                                                                                            tests don’t end at “well, it compiled OK”, but
                                                                                                            actually running meaningful tests with the
                                                                                                            running code itself. Your code (and users)
                                                                                                            will thank you for it.



                                                                 www.linuxvoice.com                                                                      65
     FOSSPICKS

  Drukkar p66 Android-x86 4.4 RC p67 HotShots p68 rCSSmin p68 Gipfel p69
  Lynx p69 Flpsed p70 Lynis p68 NightmareTris p70 Zatacka p71




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 open
              source treasures. Here’s the result of his latest haul…
Lightweight blog platform


Drukkar 2.0
http://drukkar.sourceforge.net


S
       ituation: you want to set up      entries as simple XML files, and is
       your own blog. Options: a         designed with minimum bandwidth
       million and one competing         overheads, so the “content should
blog platforms, each one trying to       account for most of your web
be more feature-rich, flashy and         traffic” as the developer puts it.
Web 4.0 than the last. End result:
you get tired of trying to work out      Nice and simple
what’s right for you, give up, and go    To install Drukkar, extract its .zip
to the pub instead.                      file directly into a location on your
  Sounds familiar? Most of us            web server (note that it won’t create
don’t need whizz-bang WordPress          a subdirectory during extraction).
installations with all the trimmings     Then edit config.xml and set
for our day-to-day musings, and          the base_url and base_location
Drukkar does a splendid job with         settings to match your installation
minimal requirements. It doesn’t         path. Finally, make sure that the
need a database or special Apache        entries, files and cache directories      Drukkar’s default theme, “flat”, is clean and simple. To change the
modules or anything like that – its      are writable by your web server           text on the right, edit inc/sidebar.php.
only requirement is a web server         account (eg www-data on Debian/
with PHP. Drukkar stores blog            Ubuntu systems).                                                         Now access the Drukkar
                                                                                                               installation in your web browser,
                                                                                                               and voilà: your blog is ready to go.
                                                                                                               You can see that a sample entry
                                                                                                               has been created automatically. To
                                                                                                               add new entries, go to edit.php in
                                                                                                               your Drukkar installation and enter
                                                                                                               the admin password (by default it’s
                                                                                                               just password). You can then add a
                                                                                                               new blog entry in plain text, HTML
                                                                                                               or Markdown. It’s possible to add
                                                                                                               tags to entries for organising them
                                                                                                               later, and add files to them as well
                                                                                                               (go to files.php to manage them).
                                                                                                                  See config.xml for more options,
                                                                                                               such as changing the blog’s title
                                                                                                               and creating a new password. It’s
                                                                                                               all charmingly simple, lightning fast
                                                                                                               and no-nonsense – we’ve got it
The official webpage of Drukkar is made in, you guessed it, Drukkar – a good old                               running for a tech-shy relative who
open source “eating your own dogfood” approach.                                                                wants his own type-and-go blog.



66                                                             www.linuxvoice.com
                                                                                                                                                FOSSPICKS


Operating system



Android-x86 4.4 RC
www.android-x86.org


Y
            es, you can run the world’s          Wi-Fi networks; Android will use the
            most popular mobile                  emulated network adaptor. Also, if
            operating system on your             you can’t see the mouse pointer, try
desktop PC. And no, there are no                 disabling mouse integration from
pressing reasons to do so, other                 the VirtualBox menu.
than out of curiosity. But that’s why              From here, it’s very much
we love Linux and Free Software,                 standard Android: the black bar at
right? If you’re absolutely bursting             the bottom of the screen is almost
to do some Android development                   always present, and includes three
but can’t get your mitts on an                   buttons. The first takes you back to
Android-powered smartphone or                    the previous screen (useful if you’ve
tablet, this project might help you              dived into several levels of settings),
out somewhat. Bearing in mind that               while the second takes you back to
Android was developed specifically               the home screen from whatever
for handheld devices, don’t expect               app you’re using. The third button
to be amazed with this PC port.                  brings up a simple task manager                 The usual gamut
   Still, it’s surprisingly usable.              for switching between apps.                     of Android apps is            included by default: its fonts are
Android-x86 is available from the                                                                bundled, along with a         ridiculously tiny, so click the
project website (and on the Linux                Our new Google overlords                        terminal emulator.            three-dot icon in the top-right
Voice DVD) as an ISO image that                  Click the circle button with six dots                                         (Android’s stock button for settings),
you can burn to a CD-R, or                       inside to view the included                                                   go to Preferences, and finally Font
alternatively, boot in VirtualBox. If            software. Android-x86 bundles                                                 Size. When you’ve selected
you do the latter, make sure that                Google’s apps, so you can                                                     something better (eg 16pt), click the
you provide at least 32MB of video               immediately use Google+, Google                                               back arrow in the bottom bar.
RAM to the VM, and choose                        Maps and other services without                                                  Android as a PC OS is little more
SoundBlaster 16 for the emulated                 extra fiddling. The Play Store is also                                        than a novelty at this stage, but in
sound card. Boot from the ISO                    provided as well. We’re pleased to                                            time it might be a useful desktop
image and at the initial menu, hit               see that a terminal emulator is                                               OS for non-technical users who are
Enter on the first entry to start the                                                                                          already familiar with its interface on
OS in live mode, running straight
from the disc. You’ll be asked a few
                                                 “In time Android might be a useful                                            a smartphone or tablet. If we ever
                                                                                                                               had the time to do our podcast
questions before reaching the home               desktop OS for users who are                                                  challenges, “use Android-x86 as our
screen. If you’re running VirtualBox,
you can skip the question about
                                                 already familiar with its interface.”                                         sole desktop OS for a week” would
                                                                                                                               be a darn good ’un…



How it works: install Android-x86 to your hard drive




  1 Boot                                                    2 Partition                                                3 Install
        Burn the ISO image to a CD-R – you’ll find it            Choose a partition on your drive for the                    Choose ext3 as the file format, choose to
on this mont’s cover DVD – and boot from it. At the       Android files. (This will wipe the data!) If you need to   install Grub, and the files will be copied over.
initial menu, select the 4th option: Installation.        partition manually, the third option runs cfdisk.          Reboot and enjoy exploring the OS.



                                                                        www.linuxvoice.com                                                                               67
     FOSSPICKS


Screenshot creator/editor



HotShots 2.1.0
http://sourceforge.net/projects/hotshots


I
    t’s something of a cliché to say     full details. Once you have it
    “Foo is like Bar on steroids”, but   installed, enter hotshots and the
    that certainly applies here.         main window will pop up. The app
HotShots is a screenshot creation        also drops an icon in your
and editing tool with nigh-on every      notification area, so you can easily
feature you can imagine rolled in,       pop it up when needed.
and it does a sterling job. You might
think: what’s so special about taking    Many, many extras
a screenshot? Just hit the Print         In the main window, the most
Screen key. Well, that’s fine if you     important widget is Capture Mode.
                                                                                  HotShots lets you draw
just want a rather generic capture of    Along with grabbing the whole                                        writing documentation and want to
                                                                                  areas on the screen to
the screen, but if you want to add       screen or a specific region, this also   take as a screenshot,       explain parts of an interface.
effects or annotations, it’s better to   lets you save hand-drawn regions         with the background set         You can save your work as a .hot
use a specialist tool.                   with smoothed edges – something          as transparent.             file for later editing (eg if you want
   HotShots uses Qt4 for its             we haven’t seen in other screenshot                                  to reposition elements), or export it
interface, and the dependencies          creation tools. Click the fire button                                in PNG, BMP, GIF and other formats.
you’ll need on Debian/Ubuntu-            on the left, and after you’ve chosen                                 It’s even possible to upload
based systems are qt4-qmake,             the area to grab, the editor will pop                                screenshots to an FTP server or
libqt4-dev, libxtq-dev and libxfixes-    up. This is a mightily powerful tool                                 image hosting site like Imgur with a
dev. Its installation process            that lets you add snazzy-looking                                     single click – great if you need to
includes several alternative             shapes, arrows, numbered tags and                                    quickly show someone else on the
methods – see INSTALL.txt for the        text boxes; very useful if you’re                                    net your current screen state.


CSS compressor



rCSSmin 1.0.3
http://opensource.perlig.de/rcssmin


I
     f you’re developing a website,      than you do, though. It simply strips
     it’s all too easy to focus on       out spaces, comments, semi-
     home or office users with fast      colons (where possible) and other
connections and unlimited                bits and bobs that aren’t required.
bandwidth. But there’s an                   Two versions are provided: one is
increasing number of people on           written in Python, takes its input via
expensive mobile data tariffs, and       stdin, and spits the results to
there are still some people stuck on     stdout. So if you have a file called
dial-up, so it’s important to consider   style.css, compress it like this:
                                                                                  Before and after: our
all types of users and reduce your       cat style.css | ./rcssmin.py > new.css                               70k to 40k. This isn’t a world-
                                                                                  70k CSS file in the left-
site’s overall data requirements.          Have a look in new.css, and you’ll     hand window, and its        quaking change, but if you’re
   rCSSmin helps in this process by      see that it’s not as readable as         40k crunched version on     running a big website serving up
crunching your CSS files to the bare     before, but considerably smaller.        the right.                  hundreds of thousands of CSS files
essentials. Chances are that your        We tested it with a CSS file from the                                every day, it all adds up and saves
CSS contains lots of whitespace          Linux Voice Forums, and rCSSmin                                      you bandwidth costs too.
and comments to make it easy to          managed to shrink it down from                                          The C version is designed with
read and edit, but the web browser                                                                            performance in mind (it’s up to 50

                                         “It’s important to reduce your
doesn’t care about that – it just                                                                             times faster than the Python one),
wants the information. rCSSmin                                                                                so you can even use it at runtime
doesn’t pull any fancy tricks or
pretend it knows your CSS better
                                         site’s overall data requirements.”                                   on your sites (ie crunching CSS on
                                                                                                              the fly as it’s served up).



68                                                               www.linuxvoice.com
                                                                                                                            FOSSPICKS


Mountain finder



Gipfel 0.4.0
www.ecademix.com/JohannesHofmann/gipfel.html


S
       o you’ve had a lovely holiday    where you can identify two of them,
       in the Alps, and taken plenty    but the rest are unknown to you.
       of photos. Back home, you           With the picture open, click File >
load up the pictures on your Linux      Choose Viewpoint and select the
box and start browsing them. “Aha”,     name of a mountain that you know
you say, “there’s the Zugspitze,        is in the picture. (The database is
Germany’s highest mountain. But         extensive but some of the names
what’s that one behind it?” With        are a bit off – for instance, the
some messing around on Google           Großvenediger in Austria is written
                                                                                  Gipfel can show labels
Maps and Wikipedia, you could           as “Gross Venediger”.) Now                for mountains behind        Peak again, dragging the icon to the
probably find the name of the           right-click on the picture and            the ones in the picture,    other known mountain. If all is well,
mountain in question, but Gipfel        choose Find Peak. Enter the name          so reduce the visibility    Gipfel will calculate the location
makes it easier – and more fun.         of the mountain again, click OK, and      setting to make things      from which you took the photo, and
   Using FLTK for the interface,        a red symbol will appear. Drag this       clearer.                    add labels to the tops of other
Gipfel’s dependencies are libtiff4-     to the top of the known mountain.                                     mountains in the picture.
dev, libjpeg62-dev, libexiv2-dev,          Now repeat this process,                                               It’s possible to manually adjust
libgsl0-dev and libfltk1.3-dev.         right-clicking and choosing Find                                      your latitude and longitude, and also
Once you have the program started,                                                                            tweak various angles and settings

                                        “Gipfel will add labels to the tops
click File > Load Image in the menu,                                                                          to match your photo more closely.
and select a photo from your                                                                                  It’s a clever little app when it works
collection. Choose a picture that
includes several distinct peaks,
                                        of other mountains in the picture.”                                   correctly – it just takes some
                                                                                                              fiddling to get right.


Text-mode web browser



Lynx 2.8.8
http://lynx.isc.org


W
            e love programs that run    attempt to recreate complex
            on almost every OS          layouts, but for text-heavy sites it
            under the sun. Lynx, the    does a respectable job.
venerable text-mode web browser
that has been doing the rounds          Bare-bones browser
since 1992, has just seen a new         The only major requirement to build
release. And this release has been      Lynx is (n)curses. Once you have it
tested on (deep breath): Linux,         running, hit G to enter a URL. Use
FreeBSD, NetBSD, OpenBSD,               the cursor keys to navigate through
                                                                                  Hit O to bring up the
OpenVMS, AIX, HP-UX, Haiku, IRIX,       links, enter to follow a link, the left                               commands; a progress bar that’s
                                                                                  options screen, which
Solaris, Tru64, Mac OS X, and even      cursor key to go back, and Ctrl+P/N       is full of tweakable bits   now compiled in by default and
that weird Windows thing that           to scroll two lines backwards/            ’n’ bobs.                   available in the options screen;
some people still use.                  forwards. Hit Shift+G to edit the                                     improvements to SSL support; and
   Now, Lynx is quite limited as a      current URL, backspace to bring up                                    better interpretation of HTML code.
web browser, given that it operates     the history, and forward slash to do                                    We’re really chuffed to see Lynx
in text mode, but it’s good to have     a search. Lynx has an impressive                                      being updated to support the latest
around. If something goes wonky         range of features tucked away - so                                    web technologies – it’s good to
with your X server and you need to      enter H to bring up the help. When                                    know that it’s always there, even
search the web for help or drivers,     you’re finished, Q quits.                                             when you’re exploring some
you’ll need a browser that runs in         New features in version 2.8.8                                      random, obscure Unix variant that
the plain text terminal. Lynx doesn’t   include: submit, reset and pwd                                        few people have heard of.



                                                              www.linuxvoice.com                                                                69
     FOSSPICKS


PDF and PostScript file annotator



Flpsed 0.7.2
www.flpsed.org/flpsed.html


D
         espite the best efforts of the      Flpsed is a super-simple
         Free Software community,         lightweight little app that lets you
         people still send Microsoft      add text to PDF and PostScript
Word .doc files around as if they         documents, without changing the
were some kind of standard. We            structure of them. You simply add
always recommend that people              lines of text at whatever position
install LibreOffice and use an open       you want, and then re-export the file
file format, but our words often fall     as a PDF. This means you can fill in
on deaf ears. Usually, the best           forms in seconds without having             Flpsed doesn’t alter the structure of PDF documents - it just adds
success we have is asking people          to mess around in a much more               another layer of text on top.
to send us documents as PDFs –            complicated app.
at least they will render the same           It’s built with FLTK, and has a                                      document, and start typing. When
across different platforms.               very sparse interface: click File >                                     you’re done, click File > Export PDF.
   Now, that’s all good and well until    Open File and choose a document.                                          This is good enough, but Flpsed
someone sends you a form to fill in.      Then set your font size and colour                                      has an awesome extra feature:
If your PDF reader doesn’t support        using the widgets in the toolbar,                                       batch processing. It’s possible to
this facility, you might be tempted       click on the relevant position in the                                   add tags to PDFs that will later be
to install the dreadfully bloated                                                                                 replaced by custom text strings, so
Adobe Reader, which makes
your hard drive grind on start-up         “You simply add lines of text, then                                     you can, for instance, automatically
                                                                                                                  add text to a bunch of forms
and perpetually annoys you with
“update me!” pop-ups.
                                          re-export the file as a PDF.”                                           without having to go through each
                                                                                                                  one manually.


Security auditing tool



Lynis 1.4.1
http://cisofy.com/lynis


S
        ecurity is a moving target: you   existence) and can be executed in
        can harden your systems to        place without installation. To use it
        an almost unbreakable             all you need to enter is:
degree, but there’s no guarantee          tar xfv lynis-1.4.1.tar.gz
that they’ll be equally robust            cd lynis-1.4.1/
tomorrow, when new vulnerabilities        sudo ./lynis -c
are discovered. It’s also a vast topic,      (The -c flag performs a complete
and if you’ve been given the job of       check – just run sudo ./lynis on its
making a Linux box ultra secure, it’s     own to see all available options.)          Lynis doing a scan: it
hard to know where to start. You’ve       Lynis works step-by-step through            has some suggestions        colours: green means that
got packages to update, user              different aspects of your setup,            for user and group          everything’s OK, yellow is used for
accounts to maintain, settings in         pausing along the way to help you           settings, which it will     warnings, and red signifies major
/etc to check… it adds up.                see what’s going on. It looks at            explain in more detail at   problems. Once the scan has
                                                                                      the end.
    Lynis provides a one-stop-shop        potential problems in user and                                          completed, you’re given a much
for checking your system’s security.      group settings, looks for vulnerable                                    more detailed set of instructions for
It’s a script that pokes around in        packages, checks file permissions,                                      fixing issues that have cropped up.
various parts of your Linux               tests your networking setup, looks                                         Lynis is no silver bullet and won’t
installation, alerting you to potential   at your compiler configuration, and                                     make your machines impenetrable,
problems. Usefully, it’s written in       many other things.                                                      but it’s well worth keeping around
plain shell script (so it will run on        As the scan progresses, Lynis                                        and running periodically to keep one
virtually every Linux distro in           provides feedback in different                                          step ahead of crackers.



70                                                                     www.linuxvoice.com
                                                                                                                          FOSSPICKS


FOSSPICKS Brain relaxers
Deliberately annoying Tetris variant



NightmareTris 1.0
https://github.com/giacomodrago/nightmaretris


T
         etris does funny things to     of love and liblove available in
         your brain. Play it for long   Ubuntu 13.10’s repositories don’t
         enough, and you’ll start       work properly with the game, so
to wonder if the game is trying to      if you’re using that distro, get the
taunt you, giving you especially        latest packages from www.love2d.
awkward pieces at the most              org. Then run the game as follows:
difficult moments. In reality, most     love NightmareTris.love
Tetris variants pick pieces at          (Add --windowed to the end of the
random, so you just have to hope        command to disable full-screen
that your luck is in. NightmareTris     mode.) Hit F2, and a standard-
                                                                                 How many times are
is different though: it includes        looking game of Tetris begins: use                                  Sometimes the game doesn’t
                                                                                 we going to get a 2x2
an algorithm that deliberately          the left and right cursor keys to        block? Until we lose the   seem to be too evil, but you know
chooses the worst pieces for            move pieces sideways, up to rotate       game, clearly…             that it’s only planning to make
your current situation. Need the        them, and down to drop the piece                                    your life harder down the line.
long thin one to get rid of four        to the bottom.                                                        If you enjoy a spot of Tetris
lines? You ain’t going to get it…                                                                           but got bored with the standard
   As well as being annoying to         Curse my metal body!                                                variants years ago (how could
play, NightmareTris is a bit fiddly     There’s no music or fancy effects,                                  you?!), it’s well worth trying this.
to install. It’s written using LÖVE,    but the gameplay is great: it’s                                     Don’t punch your monitor too
a 2D game engine; the versions          classic Tetris, made extra difficult.                               hard though…




Souped-up Tron-like game



Zatacka X 0.1.6
https://github.com/simenheg/zatackax


W
            e’ve seen countless         Ubuntu-based systems you can get
            Tron-inspired games         these via libsdl1.2-dev, libsdl-
            come and go over the        mixer1.2-dev, libsdl-ttf2.0-dev and
years, and they’re all pretty much      libsdl-image1.2-dev.
the same: you control a moving             Build the game with make and
dot that leaves a path behind it,       run it in place with ./zatackax. The
and CPU-controlled opponents            game is set up for multiplayer, but if
also zip around, leaving trails on      you want to play against the
the screen. Your goal is to survive     computer, go to Settings > Player
                                                                                 Trails occasionally have
for as long as possible without         Config and set the AI for extra                                     opponents. Hit Enter again to
                                                                                 gaps in them, leaving
crashing into any of the trails.        players to On. At the main screen,       possible escape routes     start playing. Use the left and
   Zatacka X takes a slightly           highlight Start Game and press the       when the arena starts to   right keys to change the direction
different approach; it’s based on a     right arrow key to add the AI players    get full.                  of your line, and up to use a
game called “Achtung, die Kurve”        you just enabled, then hit Enter.                                   power-up. You’ll notice your line
(watch out for the curve) with                                                                              changes direction in a smooth
some extra goodies sprinkled on         Race against the machine                                            curve, rather than at right-angles
top. Getting it compiled is fairly      Before the game begins, there’s a                                   like in other Tron-esque games,
simple as it just depends on            choice of power ups: these give you                                 and the power ups make it much
common SDL libraries: in Debian/        temporary boosts, or afflict your                                   more entertaining.




                                                                  www.linuxvoice.com                                                           71
Email andrew@linuxvoice.com to advertise here
                                                                                                                           TUTORIALS INTRO




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


                                             In this issue…
                                                 74                                                        76




Ben Everard                                   Bug reporting                                              Pi arcade
is now developing a secret receipe for the                                                                Get gaming on Linux without
ultimate porter ale.                          You don’t have to program to help make
                                              open source software. Ben Everard                           a trace of Valve’s SteamOS in
                                              introduces bug reporting.                                   sight – with Graham Morrison.



Y
         ou lot were pretty keen to get
         issue 1. As soon as we put it
         online for subscribers, our web         82                                    86                                     92
server was hit pretty hard. Not enough
to take it offline, but enough to slow it
down. Not that we noticed of course,
we were too busy trying to work out
why some people couldn’t get access,
and why some subscribers’ email
addresses weren’t working (it all seems       Grace Hopper                          KDE konfig                              UEFI
to be OK now). Once the dust had
                                              Juliet Kemp uncovers                  Build the perfect KDE                  Conquers the controversial
settled, we needed to work out how our
                                              programming on the                    desktop for you – with                 boot technique – also with
server had coped.
                                              UNIVAC in 1950s America.              Graham Morrison                        Graham Morrison.
  We turned to our sysadmin toolkit to
find out. Piwik (our analytics platform)
kept logs of how long it took pages to
load, and Sar kept track of how much          PROGRAMMING
the processor power was being used.
They’re both great open source tools          Drawing fractals                      Key distribution                       Linux kernel
that make the life of a sysadmin so                  Picasso, Monet and                    Encrypted communication                The Linux kernel is the
                                               96                                    100                                   102
much easier. I’ve been using Linux for              Michaelangelo all used paint          is a great way to protect               product of the combined
                                              and brushes. The fools! It’s far      your privacy online, but how you       effort of thousands of people. If
well over a decade, but they’re both new
                                              better to create pretty pictures by   you get the keys to everyone in the    you want to join the illustrious
to me, and proof that we can always           writing Python code. How, you         first place? After all, without keys,   ranks of kernel developers, the first
keep learning new things in Linux.            ask. Well, with nothing more than     encryption is useless. Through the     step is learning how it all works.
  (In case you’re wondering, our page         a few loops and recursions,           wonders of mathematics and             We’ll walk you through the basics,
load times slowed from about 0.5              beautiful canvases can bloom          physics, you can foil the feds as      and help you get started. Together
                                              from underneath a turtle…             they attempt to listen in.             we can make it even better.
seconds to almost 0.8 seconds, and the
processor usage barely topped 30%.)



                                                               www.linuxvoice.com                                                                             73
     TUTORIAL BUG REPORTS



                            FILING EFFECTIVE
          TUTORIAL
                            BUG REPORTS
                            Found a mistake in your favourite software? Share the knowledge,
  BEN EVERARD
                            help the developers out and we can all help make software better.


                            A
                                     bug is an incorrect behaviour in a piece of        website and find out how to report bugs. Larger
 WHY DO THIS?                        software. This could be anything from the          projects will usually have a website describing what to
 • Feel the warm glow                program crashing, to not rendering graphics        do, and any information in that obviously supersedes
   of helping your fellow
   Linux users.             properly to small things like spelling mistakes in the      any general advice we give here. If there isn’t a bug
 • Gain an insight into     user interface. They’re a fact of life for anyone who       tracker, you’ll need to email either the developer or a
   how Free Software        uses computers and no software is completely                mailing list with information about the problem.
   development works.       immune to them. Open source software will get a lot            There’s no point in flooding bug trackers with
 • Have a say in how your   better if people help the developers by filing good bug     duplicate reports, so before you submit anything,
   favourite software
   progresses.              reports, because unless developers know what the            check to see if the problem is already on the system.
                            problems are, they can’t fix them.                          A bug tracker should let you search the current
                               The most important thing with bug reports is to not      reports, while projects without trackers often have
                            be afraid of them. Anyone who’s written software            information about known problems in release notes,
                            knows that bugs are a part of life and they won’t be        or elsewhere on their website.
                            mortally offended by the suggestion that their
                            software is somehow imperfect. In fact, they’ll             Filling a report
                            probably be grateful for the feedback.                      Regardless of the bug you’ve found, there are a few
                                                                 There are a few        pieces of information that you absolutely must

“Public bug reporting is an                                   simple things that can
                                                              make bug reports
                                                                                        include for the report to be useful at all. This is the
                                                                                        version of the software you’re using, the operating
essential part of the free                                    much more useful, and     system you’re running, and information about the

software development cycle.”                                  we’ll have a look at
                                                              these here. The first
                                                                                        hardware you’re running on. Most of the time, there
                                                                                        will be specific fields in the bug tracker that you need
                                                              step, though, is to       to fill in for this. After that, there is usually a text box
                            make sure you have the latest version of the software.      where you can enter a description of the problem.
                            You should upgrade through your package manager.               The key to a good bug report is reproducibility. If a
                            If possible, you should check the latest version on the     developer can’t reproduce the bug, they can’t
                            program’s web page, and install this if it’s more recent.   investigate it and they certainly can’t test if a fix works.
Bugzilla (a bug tracker
                               As far as filing bug reports are concerned, there are    If you come across a bug, the first step is to make
developed by Mozilla) is
one of the most common      two types of software: those with bug trackers and          sure you know what caused it. This means shutting
bug management tools        those without. Bug trackers are databases of bug            down the software, then re-tracing your steps to see if
used in open source         information, typically with a web front-end. If you         it happens again. If it does, these are the steps you
projects.                   notice a bug, the first stage is to go to the project’s     need to enter into the bug report. If it doesn’t, you need
                                                                                        to look a little bit harder to see what triggered the bug.
                                                                                           Take a look at these two reports:
                                                                                           “Yo, LibreOffice devs. The software breaks when I try to use
                                                                                        a picture. Betta fix it quick or I’m movin back to MS Office”
                                                                                           and
                                                                                           “LibreOffice Writer is crashing when inserting a picture into
                                                                                        a document. Steps to reproduce:
                                                                                           Open LibreOffice Writer
                                                                                           Go to File > New > Text Document
                                                                                           Go to Insert > Image > From File and select image. Note
                                                                                        this isn’t happening with all images. I’ve attached an image
                                                                                        that is causing a problem
                                                                                           At this point, the window becomes unresponsive
                                                                                           This worked fine In LibreOffice 4.1, but has stopped
                                                                                        working in LibreOffice 4.2”
                                                                                           (This is only an example, LibreOffice doesn’t have a
                                                                                        problem with image import.)



74                                                          www.linuxvoice.com
                                                                                                             TUTORIAL BUG REPORTS

  The top report is missing loads of key information.
What does ‘use an image’ mean? What piece of the
LibreOffice suite are they using? What image are they
using? Without knowing this, there’s simply no way to
investigate the problem.
  You might look at the bottom one and think that the
steps are a bit simplistic. After all, surely a LibreOffice
developer knows how to insert an image without
step-by-step instructions? They probably do, but with
most software, there’s more than one way to
accomplish a task, so it helps to go through
everything in little steps. Nothing is too basic to be
included in a bug report! Also remember that English
may not be the developer’s first language, so try to
keep it as clear as possible.
  Most bug trackers also enable you to attach files,
and these are a great way of providing the developers
with the information they need. In the above example,
                                                                                                                               GitHub (shown here)
we attached an image that caused the problem. As a                   If you’re unsure about anything in a bug report,
                                                                                                                               and most other popular
general rule, you should include any files that are               most projects have an IRC (Internet Relay Chat)              source code management
involved in reproducing the bug (make sure they don’t             channel, and this is usually the best place to get           platforms also have bug
include any confidential information). Screenshots of             answers to problems like this, though this does vary         trackers for the software
the problem happening are often useful as well,                   from project to project.                                     they host.
though not always possible if the program is crashing.
                                                                  Fixing the problem
After the report is filed                                         It’s possible that the developer will reject the bug. This
What happens after the bug is filed will depend on the            could be because the problem is caused by
project. On smaller projects, it may go straight to a             something other than the software itself (such as
developer who will look into it. In larger projects, they         incorrect configuration), or because they don’t think
will often be triaged by a bugfixing team who will try to         it’s a problem (for example, you could be doing
reproduce the bug before assigning it to the right                something outside of the program’s intended use).
development team.                                                     Hopefully, though, the bug will be accepted and
  It’s important for you, as the bug submitter, to keep           looked into by the development team. Usually, they’ll
an eye on the bug report at this stage because they               release a fix and ask you (the bug submitter) to test it
may need more information in order to reproduce the               to see if it works. This obviously won’t go straight into
bug. Depending on the problem, they may also                      your distro’s package manager, so you’ll usually need
suggest a workaround so that you can side-step the                to compile the new source code with this fix in. After
bug until it’s fixed.                                             this, you should update the bug with information
                                                                  about whether the fix has worked or not.
                                                                      If all goes to plan, the final step is to mark the bug
  Get more involved                                               as resolved in the bug tracker (see the project’s
                                                                  documentation for details of how to do this), or letting
  If you want to get more involved in testing open source
  software, most large open source projects are looking for       the developer know that it’s worked.
  volunteers to help out. This can include working on bug             There is one exception to the bug submission
  hunts before big launches or helping triage and investigate     process we’ve talked about here: security issues. Most
  reported bugs. It’s a great way to contribute to a project,     bug trackers are public, so you shouldn’t post any
  and it doesn’t require any programming skill.
                                                                  information that could be used to exploit the system,
      LibreOffice is an excellent place to start. The team are
  incredibly friendly to new testers, and they have a three-day   unless the project’s documentation explicitly tells you
  bug hunting session before each point release. The last one     to. If you find a security issue, look at the software’s
  (before 4.2) was in December, and you can see details           website for guidance, or email the developers directly.
  about it on the project website (https://wiki.                  It is possible to track security issues with CVEs
  documentfoundation.org/BugHunting_Session_4.2.0).
                                                                  (Common Vulnerabilities and Exposures) numbers,
  Keep an eye on The Document Foundation’s blog
  (http://blog.documentfoundation.org) for details of             but this isn’t essential.
  upcoming events. Alternatively, you could start using beta          Filing a bug report doesn’t take long, and you should
  releases of software that’s important to you. These early       recoup that time by having working software once the
  releases tend to have more bugs in them than final releases,    bug’s fixed. Public bug reporting is an essential part of
  and they need people like you to find all these problems so
                                                                  the free software development cycle. It doesn’t matter
  they can be fixed before the final release. What’s more, it
  gives you (as a user) a chance to make sure that new            if you’ve never touched a line of code in your life – by
  versions will work properly on your setup with your data.       helping the developers, you can contribute to the free
                                                                  software community and we’ll all benefit.



                                                                    www.linuxvoice.com                                                                75
      TUTORIAL RASPBERRY PI ARCADE MACHINE



                             BUILD A RASPBERRY PI
        TUTORIAL
                             ARCADE MACHINE
                             Relive the golden majesty of the 80s with a little help from a
GRAHAM MORRISON
                             marvel of the current decade.


                             T
                                        he 1980s were memorable for many things;
  WHAT YOU’LL NEED                      the end of the cold war, a carbonated drink
  • Raspberry Pi w/4GB                  called Quatro, the Korg Polysix synthesiser
    SD-CARD.
                             and the Commodore 64. But to a certain teenager,
  • HDMI LCD monitor.
                             none of these were as potent, or as perhaps familiarly
  • Games controller or…
                             illicit, as the games arcade. Enveloped by cigarette
  • A JAMMA arcade
    cabinet.                 smoke and a barrage of 8-bit sound effects, they were
  • J-Pac or I-Pac.          caverns you visited only on borrowed time: 50 pence
                             and a portion of chips to see you through lunchtime
                             while you honed your skills at Galaga, Rampage,
                             Centipede, Asteroids, Ms Pacman, Phoenix, R-Rype,
  DISCLAIMER                 Donkey Kong, Rolling Thunder, Gauntlet, Street Fighter,
                             Outrun, Defender… The list is endless.
  One again we’re
  messing with electrical        These games, and the arcade machine form factor
  components that could      that held them, are just as compelling today as they
  cause you a shock.         were 30 years ago. And unlike the teenage version
  Make sure you get any      of yourself, you can now play many of them without
  modifications you make
  checked by a qualified     needing a pocket full of change, finally giving you an
  electrician. We don’t go   edge over the rich kids and their endless ‘Continues’.
  into any details on how    It’s time to build your own Linux-based arcade
  to obtain games, but
                             machine and beat that old high score.
  there are legal sources
  such as old games              We’re going to cover all the steps required to turn
  releases and newer         a cheap shell of an arcade machine into a Linux-
  commercial titles based    powered multi-platform retro games system. But that
  on the MAME emulator.
                             doesn’t mean you’ve got to build the whole system
                             at the same scale. You could, for example, forgo the
                             large, heavy and potentially carcinogenic hulk of the
                             cabinet itself and stuff the controlling innards into an
                             old games console or an even smaller case. Or you
                             could just as easily forgo the diminutive Raspberry Pi
                             and replace the brains of your system with a much
                             more capable Linux machine. This might make an
                             ideal platform for SteamOS, for example, and for
                             playing some of its excellent modern arcade games.
                                 Over the next few pages we’ll construct a Raspberry
                             Pi-based arcade machine, but you should be able to
                             see plenty of ideas for your own projects, even if they
                             don’t look just like ours. And because we’re building it   Cabinets can be cheap, but they’re heavy. Don’t lift them
                             on the staggeringly powerful MAME, you’ll be able to       on your own. Older ones may need some TLC, such as a
                             get it running on almost anything.                         re-spray and some repair work.


                               1   THE CABINET
                             The cabinet itself is the biggest challenge. We bought     other end of the scale, people pay thousands for
                             an old two-player Bubble Bobble machine from the           machines with original decals on the side.
                             early 90s from eBay. It cost £220 delivered in the back      There are two major considerations when it comes
                             of an old estate car. The prices for cabinets like these   to buying a cabinet. The first is the size: These things
                             can vary. We’ve seen many for less than £100. At the       are big and heavy. They take up a lot of space and it



 76                                                          www.linuxvoice.com
                                                                       RASPBERRY PI ARCADE MACHINE TUTORIAL

takes at least two people to move them around. If                                                                     We took the coward’s
you’ve got the money, you can buy DIY cabinets or                                                                     route, and replaced the
new smaller form-factors, such as cabinets that fit on                                                                CRT with a piece of MDF
tables. And cocktail cabinets can be easier to fit, too.                                                              and a VESA mount for a
                                                                                                                      more modern (lighter, less
   One of the best reasons for buying an original
                                                                                                                      lethal) screen.
cabinet, apart from getting a much more authentic
gaming experience, is being able to use the original
controls. Many machines you can buy on eBay will be
for two concurrent players, with two joysticks and a
variety of buttons for each player, plus the player one
and player two controls. For compatibility with the
widest number of games, we’d recommend finding a
machine with six buttons for each player, which is a
common configuration. You might also want to look
into a panel with more than two players, or one with
space for other input controllers, such as an arcade
trackball (for games like Marble Madness), or a            transfer your twitches and tweaks into game
spinner (Arkanoid). These can be added without too         movement. What you need to consider for when
much difficulty later, as modern USB devices exist.        buying a cabinet is something called JAMMA, an
   Controls are the second, and we’d say most              acronym for Japan Amusement Machinery
important consideration, because it’s these that           Manufacturers. JAMMA is a standard in arcade
                                                           machines that defines how the circuit board                    PRO TIP
                                                           containing the game chips connects to the game
                                                                                                                       For a cheap input
                                                           controllers and the coin mechanism. It’s an interface       interface, buy a PS3 USB
                                                           conduit for all the cables coming from the buttons          controller, dismantle it
                                                                                                                       and rewire the switches
                                                           and the joysticks, for two players, bringing them into a
                                                                                                                       to connect to those on
                                                           standard edge connector. The JAMMA part is the size         your cabinet.
                                                           and layout of this connector, as it means the buttons
                                                           and controls will be connected to the same functions
                                                           on whichever board you install so that the arcade
                                                           owner would only have to change the cabinet artwork
                                                           to bring in new players.
                                                              But first, a word of warning: the JAMMA connector
                                                           also carries the 12V power supply, usually from a
                                                           power unit installed in most arcade machines. We
  Another concession                                       disconnecting the power supply completely to avoid
  to safety was the
                                                           damaging anything with a wayward short-circuit or
  disconnection of the
                                                           dropped screwdriver. We don’t use any of the power
  old power supply.
                                                           connectors in any further stage of the tutorial.


 RASPBERRY PI ARCADE SURVIVAL KIT

  Raspberry Pi:                                                                                                                Powered
  Any Pi will do,                                                                                                              hub: A USB 2
  but a Model B                                                                                                                powered hub
  with USB and                                                                                                                 is essential for
  Ethernet is the                                                                                                              anything you
  best option.                                                                                                                 do with the
                                                                                                                               Raspberry Pi.


  4GB SD card:
  4GB is the                                                                                                              HDMI cable:
  minimum, and                                                                                                            Arcade monitors
  you could choose                                            Controllers: You don’t need
                                                                                                                          can be made to
  to store games                                              an arcade machine. A cheap
                                                                                                                          work, but it’s a
  on the network                                              USB converter and an old
                                                                                                                          crazy hack. The
  or a USB storage                                            generation console controller
                                                                                                                          easy option is to
  device                                                      is almost as good.
                                                                                                                          use HDMI or DVI.




                                                             www.linuxvoice.com                                                                   77
     TUTORIAL RASPBERRY PI ARCADE MACHINE


                                2     J-PAC
                              What’s brilliant is that you can buy a device that
                              connects to the JAMMA connector inside your
                              cabinet and a USB port on your computer,
                              transforming all the buttons presses and keyboard
                              movements into (configurable) keyboard commands
                              that you can use from Linux to control any game you
                              wish. This device is called the J-Pac (www.ultimarc.
                              com/jpac.html – approximately £54).
                                 Its best feature isn’t the connectivity; it’s the way it
                              handles and converts the input signals, because it’s
                              vastly superior to a standard USB joystick. Every input
                              generates its own interrupt, and there’s no limit to the
                              number of simultaneous buttons and directions you
                              can press or hold down. This is vital for games like
                              Street Fighter, because they rely on chords of buttons
     PRO TIP
                              being pressed simultaneously and quickly, but it’s also       Our J-Pac in situ. The blue and red wires on the right
 If you replace the Pi with
 a PC, you can configure
                              essential when delivering the killing blow to cheating        connect to the extra 1- and 2-player buttons on our cabinet.
 it from the BIOS to          players who sulk and hold down all their own buttons.
 automatically boot when      Many other controllers, especially those that create          control to the I-Pac yourself. This might be a little
 it gets some power.
                              keyboard inputs, are restricted by their USB keyboard         ambitious for a first project, but it’s a route that many
                              controllers to six inputs and a variety of Alt, Shift and     arcade aficionados take, especially when they want to
                              Ctrl hacks. The J-Pac can also be connected to a tilt         design a panel for four players, or one that
                              sensor and even some coin mechanisms, and it                  incorporates many different kinds of controls. Our
                              works in Linux without any pre-configuration.                 approach isn’t necessarily one we’d recommend, but
                                 Another option is a similar device called an I-Pac. It     we re-wired an old X-Arcade Tankstick control panel
                              does the same thing as the J-Pac, only without the            that suffered from input contention, replaced the
                              JAMMA connector. That means you can’t connect                 joysticks and buttons with new units and connected it
                              your JAMMA controls, but it does mean you can                 to a new JAMMA harness, which is an excellent way
                              design your own controller layout and wire each               of buying all the cables you need plus the edge
                                                                                            connector for a low price (£8).
                                JAMMA connections
                                                                                            Get connected
                                PIN        TOP                  BOTTOM                      Whether you choose an I-Pac or a J-Pac, all the keys
                                1          GND                  GND                         generated by both devices are the default values for
                                2          GND                  GND                         MAME. That means you won’t have to make any
                                3          +5V                  +5V
                                                                                            manual input changes when you start to run the
                                4          +5V                  +5V
                                5          -5V                  -5V                         emulator. Player 1, for example, creates cursor up,
                                6          +12V                 +12V                        down, left and right as well as left Ctrl, left ALT, Space
                                7          lock/key             lock/key                    and left Shift for fire buttons 1–4. But the really useful
                                8          counter 1            counter 2                   feature, for us, is the two-button shortcuts. While
                                9          lockout              lockout
                                                                                            holding down the player 1 button, you can generate
                                10         speaker +            speaker -
                                11         not used             not used                    the P key to pause the game by pulling down on the
                                12         CRT red              CRT green                   player 1 joystick, adjust the volume by pressing up
                                13         CRT blue             CRT sync                    and enter MAME’s own configuration menu by
                                14         video GND            service                     pushing right. These escape codes are cleverly
                                15         test                 tilt
                                                                                            engineered to not get in the way of playing games, as
                                16         coin 1               coin 2
                                17         P1 start             P2 start                    they’re only activated when holding down the Player 1
                                18         P1 up                P2 up                       button, and they enable you to do almost anything you
                                19         P1 down              P2 down                     need to from within a running game. You can
                                20         P1 left              P2 left                     completely reconfigure MAME, for example, using its
                                21         P1 right             P2 right
                                                                                            own menus, and change input assignments and
                                22         P1 B1                P2 B1
                                23         P1 B2                P2 B2                       sensitivity while playing the game itself.
                                24         P1 B3                P2 B3                          Finally, holding down Player 1 and then pressing
                                25         P1 B4                P2 B4                       Player 2 will quit MAME, which is useful if you’re using
                                26         not used             not used                    a launch menu or MAME manager, as these manage
                                27         GND                  GND
                                                                                            launching games automatically, and let you get on
                                28         GND                  GND
                                                                                            with playing another game as quickly as possible.



78                                                             www.linuxvoice.com
                                                                         RASPBERRY PI ARCADE MACHINE TUTORIAL

   We took a rather cowardly route with the screen,             You might also want to look into using an older LCD
removing the original, bulky and broken CRT that             with a 4:3 aspect ratio, rather than the widescreen
came with the cabinet and replacing it with a low-cost       modern options, because 4:3 is more practical for
LCD monitor. This approach has many advantages.              playing both vertical and horizontal games. A vertical
First, the screen has HDMI, so it will interface with a      shooter such as Raiden, for example, will have black
Raspberry Pi or a modern graphics card without any           bars on either side of the gaming area if you use a
difficulty. Second, you don’t have to configure the          widescreen monitor. Those black bars can be used to
low-frequency update modes required to drive an              display the game instructions, or you could rotate the
arcade machine’s screen, nor do you need the specific        screen 90 degrees so that every pixel is used, but this
graphics hardware that drives it.                            is impractical unless you’re only going to play vertical
                                                             games or have easy access to a rotating mount.
Minimise risk of death                                          Mounting a screen is also important. If you’ve
And third, this is the safest option because an arcade       removed a CRT, there’s nowhere for an LCD to go. Our
machine’s screen is often unprotected from the rear          solution was to buy some MDF cut to fit the space
of a case, leaving very high voltages inches away from       where the CRT was. This was then screwed into
your hands. That’s not to say you shouldn’t use a CRT        position and we fitted a cheap VESA mounting plate
if that’s the experience you’re after – it’s the most        into the centre of the new MDF. VESA mounts can be
authentic way to get the gaming experience you’re            used by the vast majority of screens, big and small.
after, but we’ve fined-tuned the CRT emulation enough        Finally, because our cabinet was fronted with smoked
in software that we’re happy with the output, and            glass, we had to be sure both the brightness and
we’re definitely happier not to be using an ageing CRT.      contrast were set high enough.


  3    INSTALLATION
With the large hardware choices now made, and
presumably the cabinet close to where you finally                                                                        Our Raspberry Pi is now
want to install it, putting the physical pieces together                                                                 connected to the J-Pac
isn’t that difficult. We safely split the power input from                                                               on the left and both the
the rear of the cabinet and wired a multiple socket into                                                                screen and the USB hub.
the space at the back. We did this to the cable after it
connects to the power switch.
   Nearly all arcade cabinets have a power switch
on the top-right surface, but there’s usually plenty of
cable to splice into this at a lower point in the cabinet,
and it meant we could use normal power connectors
for our equipment. Our cabinet has a fluorescent tube,
used to backlight the top marquee on the machine,
connected directly to the power, and we were able to
keep this connected by attaching a regular plug. When
you turn the power on from the cabinet switch, power
flows to the components inside the case – your
Raspberry Pi and screen will come on, and all will be
well with the world.

The creation takes shape
The J-Pac slides straight into the JAMMA interface,          amplifier and connected this to the audio outputs on
but you may also have to do a little manual wiring. The      the Raspberry Pi. You don’t want audio to be pristine,
JAMMA standard only supports up to three buttons             but you do want it to be loud enough.
for each player (although many unofficially support             The J-Pac or I-Pac then connects to your PC or
four), while the J-Pac can handle up to six buttons.         Raspberry Pi using a PS2-to-USB cable, which should
To get those extra buttons connected, you need to            also be used to connect to a PS2 port on your PC
connect one side of the button’s switch to GND fed           directly. There is an additional option to use an old
from the J-Pac with the other side of the switch going       PS2 connector, if your PC is old enough to have one,
into one of the screw-mounted inputs in the side of          but we found in testing that the USB performance is
the J-Pac. These are labelled 1SW4, 1SW5, 1SW6,              identical. This won’t apply to the PS2-less Raspberry
2SW4, 2SW5 and 2SW6. The J-Pac also includes                 Pi, of course, and don’t forget that the Pi will also
passthrough connections for audio, but we’ve                 need powering. We always recommend doing so
found this to be incredibly noisy. Instead, we wired         from a compatible powered hub, as a lack of power
the speaker in our cabinet to an old SoundBlaster            is the most common source of Raspberry Pi errors.



                                                               www.linuxvoice.com                                                               79
     TUTORIAL RASPBERRY PI ARCADE MACHINE

                               You’ll also need to get networking to your Raspberry             it enables you to reconfigure your PI while it’s tucked
                               Pi, either through the Ethernet port (perhaps using a            away within the cabinet, and it also enables you to
                               powerline adaptor hidden in the cabinet), or by using a          change settings and perform administration tasks
                               wireless USB device. Networking is essential because             without having to connect a keyboard or mouse.


  Coin mechanism
  In the emulation community, getting your           its value. It does this with the help of a credit/   Whichever system you choose, we’ve found
  coin mechanism to work with your emulator          logic board, usually attached via a ribbon           a working coin mechanism to be the perfect
  was often considered a step too close to           cable and featuring lots of DIP switches.            piggy bank as long as you don’t raid the coin
  commercial production. It meant you could          These switches are used to change which              reservoir too often, or lose the keys.
  potential charge people to use your machine.       coins are accepted and how many credits
  Not only would this be wrong, but considering      they generate. It’s then usually as simple as
  the provenance of many of the games you            finding the output switch, which is triggered
  run on your own arcade machine, it could           with a credit, and connecting this to the coin
  also be illegal. And it’s definitely against the   input on your JAMMA connector, or directly
  spirit of emulation. However, we and many          onto the J-Pac. Our coin mechanism is a Mars
  other devotees thinking that a working coin        MS111, common in the UK in the early 90s,
  mechanism is another step closer to the            and there’s plenty of information online about
  realism of an arcade machine, and is worth         what each of the DIP switches do, as well as
  the effort in recreating the nostalgia of an old   how to programme the controller for newer
  arcade. There’s nothing like dropping a 10p        coins. We were also able to wire the 12V
  piece into the coin tray and to hear the sound     connector from the mechanism to a small
  of the credits being added to the machine.         light for behind the coin entry slot.
     It’s not actually that difficult. It depends       We’ve not been able to try one, but
  on the coin mechanism in your arcade               apparently the 25-cent coin mechanism used
  machine and how it sends a signal to say how       by nearly all arcade machines in the USA
  many credits had been inserted. Most coin          throughout the 80s, and built by HAPP, are
  mechanisms come in two parts. The large            even easier to use. These embed a simple             Our programmable coin mechanism is a Mars
  part is the coin acceptor/validator. This is       microswitch into the coin path, and wiring           MS111. It accepts 10p, 20p, 50p and £1 coins
  the physical side of the process that detects      this to your JAMMA connector will create a           and will send credit pulses at regular intervals
  whether a coin is authentic, and determines        credit whenever an accepted coin is inserted.        to the JAMMA connector.




                                  4    SOFTWARE
                               MAME is the only viable emulator for a project of                enables you to install new games through a browser
                               this scale, and it now supports many thousands                   connected to your network. This is a great advantage,
                               of different games running on countless different                because getting games into the correct folders is
                               platforms, from the first arcade machines through to             one of the trials of dealing with MAME, and it also
                               some more recent ones. It’s a project that has also              enables you to make best use of whatever storage
                               spawned MESS, the multi-emulator super system,                   you’ve got connected to your Pi. Plus, PiMAME will
                               which targets platforms such as home computers                   update itself from the same script you use to install
     PRO TIP
                               and consoles from the 80s and 90s.                               it, so keeping on top of updates couldn’t be easier.
 MAME is not actually
 Free Software. It uses           Configuring MAME could take a six-page article                This could be especially useful at the moment, as
 a modified version            in itself. It’s a complex, sprawling, magnificent                at the time of writing the project was on the cusp of
 of the BSD licence to         piece of software that emulates so many CPUs,                    a major upgrade in the form of the 0.8 release. We
 restrict commercial
 redistribution.               so many sound devices, chips, controllers with so                found it slightly unstable in early March, but we’re sure
                               many options, that like MythTV, you never really stop            everything will be sorted by the time you read this.
                               configuring it.
                                  But there’s an easier option, and one that’s purpose-         Install MAME the easy way
                               built for the Raspberry Pi. It’s called PiMAME. This             The best way to install PiMAME is to install Raspbian
                               is both a distribution download and a script you can             first. You can do this either through NOOBS, using
                               run on top of Raspbian, the Pi’s default distribution.           a graphical tool from your desktop, or by using the
                               Not only does it install MAME on your Raspberry Pi               dd command to copy the contents of the Raspbian
                               (which is useful because it’s not part of any of the             image directly onto your SD card. As we mentioned
                               default repositories), it also installs a selection of other     in last month’s BrewPi tutorial, this process has
                               emulators along with front-ends to manage them.                  been documented many times before, so we won’t
                               MAME, for example, is a command-line utility with                waste the space here. Just install NOOBS if you
                               dozens of options. But PiMAME has another clever                 want the easy option, following the instructions on
                               trick up its sleeve – it installs a simple web server that       the Raspberry Pi site. With Raspbian installed and



80                                                               www.linuxvoice.com
                                                                                     RASPBERRY PI ARCADE MACHINE TUTORIAL

running, make sure you use the configuration tool to
free the space on your SD card, and that the system
is up to date (sudo apt-get update; sudo apt-get
upgrade). You then need to make sure you’ve got the
git package already installed. Any recent version of
Raspbian will have installed git already, but you can
check by typing sudo apt-get install git just to check.
   You then have to type the following command to
clone the PiMAME installer from the project’s GitHub
repository:
# git clone https://github.com/ssilverm/pimame_installer
After that, you should get the following feedback if the
command works:
Cloning into ‘pimame_installer’...
remote: Reusing existing pack: 2306, done.
remote: Total 2306 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2306/2306), 4.61 MiB | 11 KiB/s, done.
Resolving deltas: 100% (823/823), done.
                                                                                                                                         The latest version of
   This command will create a new folder called                       for the existence of /dev/input/by-id/usb-Ultimarc_I-
                                                                                                                                         PiMAME (0.8) has a
‘pimame_installer’, and the next step is to switch into               PAC_Ultimarc_I-PAC-event-kbd.                                      great user interface that
this and run the script it contains:                                     The default keyboard controls will enable you to                works well with an arcade
cd pimame_installer/                                                  select what kind of emulator you want to run on your               machine.
sudo ./install.sh                                                     arcade machine. The option we’re most interested in
   This command installs and configures a lot of                      is the first, labelled ‘AdvMAME’, but you might also be
software. The length of time it takes will depend on                  surprised to see another MAME on offer, MAME4ALL.
your internet connection, as a lot of extra packages                  MAME4ALL is built specifically for the Raspberry Pi,
are downloaded. Our humble Pi with a 15Mb internet                    and takes an old version of the MAME source code
connection took around 45 minutes to complete                         so that the performance of the ROMS that it does
the script, after which you’re invited to restart the                 support is optimal. This
machine. You can do this safely by typing sudo
shutdown -r now, as this command will automatically
                                                                      makes a lot of sense,
                                                                      because there’s no way
                                                                                                         “After rebooting, you will be
handle any remaining write operations to the SD card.                 your Pi is going to be             logged in and the PiMAME
   And that’s all there is to the installation. After
rebooting your Pi, you will be automatically logged
                                                                      able to play anything too
                                                                      demanding, so there’s no
                                                                                                         launcher will appear.”
in and the PiMAME launch menu will appear. It’s a                     reason to belabour the
great-looking interface in version 0.8, with photos of                emulator with unneeded compatibility. All that’s left to
each of the platforms supported, plus small red icons                 do now is get some games onto your system (see the
to indicate how many games you’ve got installed.                      boxout below), and have fun!
This should now be navigable through your controller.
If you want to make sure the controller is correctly                   Graham Morrison wastes too many hours of his life playing
                                                                       Asteroids and weeping for his lost teenage years.
detected, use SSH to connect to your Pi and check



Step-by-step/How To Copying games to your arcade machine




 1 Browse to the Pi                                         2 Choose the system                                    3 Upload the file
       Open the IP address of your arcade machine in             After clicking on ROM Uploader, choose the             Dragging the file onto the page didn’t work for
a web browser. You can find the IP address from the        destination emulator for your game. This will then    us, but if you click inside the page a file requester lets
Pi by selecting the Tools menu.                            open a new upload page.                               you choose the file.



                                                                        www.linuxvoice.com                                                                             81
     TUTORIAL GRACE HOPPER AND UNIVAC



                              GRACE HOPPER AND UNIVAC:
          TUTORIAL
                              BEFORE THERE WAS COBOL
                              In the days before cheap silicon chips, valves ruled the roost – and
     JULIET KEMP
                              it took a special kind of brain to handle these magnificent beasts.


                              A
                                       fter Babbage and the (never actually built)        UNIVAC was programmable. The first customers
                                       Analytical Engine in the 19th century,             included the US Census Bureau and the US Air Force
                                       computer development languished for a              (who had the first on-site installation, in 1952). In
                              while. During the first half of the 20th century, various   1952, as a promotional stunt, they worked with CBS to
                              analog computers were developed, but these solved           have UNIVAC predict the result of the 1952 US
                              specific problems rather than being programmable. In        presidential election. It correctly (and quickly!)
                              1936, Alan Turing developed the idea of the ‘Universal      predicted an Eisenhower win, beating out the pollsters
                              Machine’, and the outbreak of World War II shortly          who had gone for Stevenson. So let’s take a look at
                              afterwards was a driver for work on developing these        what it was and what it was doing.
                              machines, including UNIVAC, famously worked on by
                              Grace Hopper.                                               UNIVAC: mercury and diodes
                                 Grace Hopper, born in New York in 1906, was an           UNIVAC weighed about 13 tons, and needed a whole
                              associate professor of mathematics at Vassar when           garage-sized room to itself, with a complicated water
                              WWII broke out. Volunteering for the US Navy Reserve,       cooling system and fans. It had 10 UNISERVO tape
                              she was assigned to the Bureau of Ships Computation         drives for input and output, 5,200 electron (vacuum)
                              Project, where she worked on the Harvard Mark I             tubes, 18,000 diodes, and a 1,000 word memory
                              project (a calculating machine used in the war effort),     (more on that in a moment); it required about 125kW
                              from 1944–9, co-authoring several papers.                   of power to run. (A modern laptop uses around
                                 In 1949, she moved to the Eckert-Mauchly                 0.03kW. It also required a lot of maintenance;
                              Computer Corporation (later acquired by Remington           replacing diodes, contacts and tubes, not to mention
Grace Hopper, who             Rand, and later still by Unisys), and joined the UNIVAC     keeping the cooling systems running.
studied mathematics and       team. UNIVAC, which first ran in 1951, was the second          UNIVAC’s memory and operational registers were
physics at Harvard and        commercially available computer in the US, and the          both based on mercury delay lines. The main memory
Vasser universities, at a
                              first designed for business and admin rather than for       consisted of seven ‘long tanks’, each containing
later UNIVAC in 1960. By
                              scientific use. That meant that it was intended to          eighteen ten-word channels. Each channel was a
Unknown (Smithsonian
Institution) (Flickr: Grace   execute many simple calculations rapidly, rather than       column of mercury with quartz crystals at each end,
Hopper and UNIVAC)            performing fewer complex calculations. Punch-card           and held 910 bits (840 bits for the words and 70 for
                              calculating machines already existed, but crucially,        the spaces between each word). The main clock (at
                                                                                          2.25MHz) was in sync with the carrier wave of the
                                                                                          column (11.25MHz) and acted as the timer for all
                                                                                          UNIVAC operations.
                                                                                             To store data in a channel, the sending crystal (at
                                                                                          one end of the channel) was vibrated with the data
                                                                                          bits (ones and zeros) of the word. The rate was
                                                                                          controlled by the main clock, then the signal was
                                                                                          mixed with the carrier wave. The whole signal would
                                                                                          move through the column to the receiving crystal,
                                                                                          where a bunch of circuitry picked it up, amplified it,
                                                                                          analysed it, and sent it back to the sending crystal for
                                                                                          another trip through the mercury. So the data was
                                                                                          constantly rotating through the mercury, which meant
                                                                                          that you could only access a word when it popped out
                                                                                          at the receiving crystal end. The average access time
                                                                                          for a word was 222 microseconds, so a fair amount of
                                                                                          UNIVAC’s time involved waiting for word access, with
                                                                                          obvious practical programming implications.
                                                                                             You may have noticed that seven lots of 18
                                                                                          channels gives 126 channels of 10 words each; so
                                                                                          why only 1,000 words of memory? The remaining 26



82                                                            www.linuxvoice.com
                                                                                      GRACE HOPPER AND UNIVAC TUTORIAL

channels were used for input and output buffering, for
the register, and for the vitally important mercury
temperature control. The mercury had to be at an
exact operating temperature for the correct transit
time and to avoid bit creep; from a cold start, it could
be up to half an hour before the tanks were able to
hold memory.
   Control and computation operations were also run
via mercury delay lines, each tank working with a
single 12-character word. This made access much
quicker, and they also had distribution delay lines to
allow multi-bit access to characters. There were four
types of register:
   Four Input/Output Synchronizers, used for the 60
word read/write buffers.
                                                                                                                             UNIVAC I at the Franklin
   Three Control registers, used for controlling                 would be read into the input buffer, then transferred
                                                                                                                             Imstitute, Philadelphia.
program instruction flow.                                        into memory. The operator would then set the
   One two-word register (rV) used as a holding area             machine back into ‘normal’ mode, hit the Start Bar,
during a two-word move.                                          and UNIVAC would begin executing the instructions
   Several of these registers were duplicated, then              from memory, beginning with the first block. So the
compared bit-by-bit, to increase accuracy.                       programmer would have to make sure that from then
Finally, it had an operator’s console and an                     on in, everything that the program needed to do
oscilloscope connected. The console had switches                 (including reading in more instructions or data from
that allowed any of the memory locations to be                   tape) was referenced in the program itself. The
displayed and monitored on the oscilloscope. A                   operator’s role would be limited (at least in theory!) to
typewriter and printer were also connected for output.           replacing tape reels as indicated by console
                                                                 messages, and rescuing any minor problems such as
Programming UNIVAC                                               a dropped tape loop. Breakpoints could be set in the
UNIVAC had quite a big instruction set, which covered            code (instruction ,) to aid recovery from problems.
transferring the contents of memory into registers,                 Here’s a longer example from the 1954 UNIVAC
moving the contents of registers around, performing              operating manual. The far-left number is the memory
operations, jumping to specific memory addresses,                register that contains the instruction. Instructions
shifting contents of registers a given number of digits,         were saved in memory in pairs, as shown, with the
and controlling input/output. The full list (with                left-hand six-digit instruction run first, then the
explanations) is available at https://wiki.cc.gatech.            right-hand six-digit instruction. In this example,
edu/folklore/index.php/UNIVAC_I_Instruction_Set.                 registers 100–999 contain a set of numbers, and the
Unfortunately there’s no Linux-compatible emulator               code adds them all together.
(see boxout), but here is a small example, with                  000   C00 099   C00 099
comments:                                                        001   B00 099   A00 100
L00 101                                                          002   C00 099   B00 001
  loads contents of memory register 101 into register A.         003   L00 007   Q00 006
A00 102                                                          004   A00 008   C00 001
  loads contents of register 102 into register X, adds X to A.   005   000 000   U00 001
C00 103                                                          006   900 000   U00 001
  stores contents of register A into register 103, clears A.     007   B00 099   A00 999
P00 103                                                          008   000 000   000 001
  print contents of register 103 on the console printer.         Line by line, here’s how that code works:
If you read last month’s article on Ada Lovelace and             000 C 099 stores register A into memory and zeroes
the Analytical Engine, this may look familiar. The               it; so repeating this twice zeros register 099.
instructions (L, A, P) are made up to 3 digits with zero         001 B 099 loads register 099 into register A; A 100
padding. So if register 101 contains the value 2, and            loads register 100 into register Z, then adds it to
register 102 contains the value 3, this will add 2 to 3,         register A.
store 5 in register 103, and output 5 to the console.            002 C 099 stores register A (now containing A+Z) into
    To run this program, it would have been typed onto           register 099, and zeroes register A. B 001 loads the
a program tape as a series of numeric words                      contents of register 001 into register A. The contents
(‘translated’ from the programmer’s mnemonics given              of register 001 are the program instructions in step
here). The tape (and any needed data tapes) would be             001; so we are preparing to alter the instructions
latched onto the UNISERVOs, and the operator would               themselves.
manually set various options and begin the booting               003 L 007 loads the contents of register 007 (see step
process from the console. The first 60 instructions              007 below) into both register L and register X. Q 006



                                                                   www.linuxvoice.com                                                                   83
     TUTORIAL GRACE HOPPER AND UNIVAC

Grace Hopper remains                                                                            Grace Hopper created the first operational compiler,
a source of quotable                                                                         in 1952, while working on the UNIVAC project. Initially,
quotes, our favourite                                                                        no one believed her. “I had a running compiler and
being: “It’s easier to ask                                                                   nobody would touch it,” she said later. “They told me
forgiveness than it it to get                                                                computers could only do arithmetic.” In fact, the A-0
permission.”
                                                                                             system was more like what we would today call a
                                                                                             loader or a linker than a modern ‘compiler’. For A-0,
                                                                                             Hopper transferred all her subroutines to tape, each
                                                                                             identified with a call number, so that UNIVAC could
                                                                                             find it. She then wrote down the call numbers, and any
                                                                                             arguments, and this was converted into machine
                                                                                             code to be run directly. Effectively, A-0 allowed the
                                                                                             programmer to reuse code and to write in a more
                                                                                             human-readable way, and get the machine to do more
                                                                                             of the work.

                                                                                             Programming with A-0
                                                                                             The next versions were A-1 and A-2, with A-2 the first
                                                                                             compiler to be in more general use. I found a short
                                                                                             paper from a 1954 MIT course, which Hopper also
                                                                                             tutored. In it she describes A-2 as handling two types
                                                                                             of subroutine: static ones (stored in memory or on
                                                                                             tape, either from a general library or specific to the
                                                                                             problem) and dynamic ones. Dynamic subroutines
                                checks whether register L is equivalent to register A; if    could be generated from a ‘skeleton’ stored subroutine
                                so, it jumps to register 006 (that is, step 006).            and some specific parameters, or could be generated
                                004 A 008 loads the contents of register 008 into            to handle data. A-2 had four phases of operation:
                                register X, and adds it to register A. As register A             Expands/translates the provided code, adding in
                                currently holds the instruction from register 001, and       data such as call-numbers and operation numbers. (In
                                register 008 holds (effectively) a single 1, this alters     later compilers this translated from ‘code’ into
                                the instruction from register 001 to read B00 099 A00        ‘machine code’.)
                                101 instead of B00 099 A00 101. In other words, next             Divides the result from phase 1 into segments
                                time we run step 001 we’ll add the contents of the           which can be processed in a single storage load, and
                                next register in the list to our running total. C 001        creates references to each subroutine.
                                dumps the contents of register A back into register              Creates the jump instructions needed to complete
                                001, so we’ve edited the program on the fly.                 the necessary jumps (for example between storage
                                005 The LHI is blank; the RHI (U 001) is an                  loads and subroutines) required by the result of phase.
                                unconditional jump back to register 001, ready to add        After this phase, you have a complete description of
                                the next number in the list.                                 the program, but not a complete program that can be
                                006: This simply stops the computer. (Remember               run sequentially.
                                from 003: we jump here if the program is finished.)              Main compilation. All subroutines are read in and
                                007 B 099 A 999. This instruction is never actually run.     transformed as necessary from ‘general’ to ‘specific’
                                It is used in 003 to check against register A. If register   (so any parameters are included), all jumps, reads, and
                                A looks like this at step 003, then we have added the        writes are included, and a complete program is
                                final number (in register 999) and our program is done.      generated which can now be run as-is.
                                003 will then jump to 006 and the program ends.                  (If you check out the PDF course notes in the
                                008 End of program.                                          resources, there are some very cute line drawings
                                    Fundamentally, this is a for loop that sums each         illustrating the four phases.)
                                element in an array. But UNIVAC programmers had to
                                physically rewrite the instruction inside the loop each      FLOW-MATIC & English-language programming
                                time.                                                        A couple of iterations later, Hopper and her team
                                    One apparently excellent emulator for UNIVAC does        produced FLOW-MATIC, which was the first English-
                                exist. It’s by Peter Zilahy Ingerman and is described at     language-like data processing language. (Meanwhile,
                                www.ingerman.org/niche.htm#UNIVAC.                           FORTRAN was completed at IBM in 1957, and is
                                Unfortunately it’s written in Visual Basic 6 and only        generally agreed to be the first complete compiler.)
                                runs on Windows. The download link on that page                 Here’s a quick sample of FLOW-MATIC code, taken
                                doesn’t work, but it can be obtained by contacting the       from the FLOW-MATIC product brochure).
                                author on the given email address. The code above            (0) INPUT INVENTORY FILE-A PRICE FILE-B ; OUTPUT
                                should run on it, but as it’s Windows we haven’t been        PRICED-INV FILE-C UNPRICED-INV
                                able to test it.                                                FILE-D ; HSP D .



84                                                               www.linuxvoice.com
                                                                                  GRACE HOPPER AND UNIVAC TUTORIAL

(1) COMPARE PRODUCT-NO (A) WITH PRODUCT-NO (B) ; IF
GREATER GO TO OPERATION 10 ;                                  More resources
   IF EQUAL GO TO OPERATION 5 ; OTHERWISE GO TO
OPERATION 2 .                                                 My great thanks to Allan Reiter, whose page at
(2) TRANSFER A TO D .                                         http://univac1.0catch.com is invaluable for technical
                                                              details of UNIVAC operation. Check it out for
(3) WRITE-ITEM D .
                                                              much more detailed info and plenty of photos and
(4) JUMP TO OPERATION 8 .
                                                              diagrams.
(5) TRANSFER A TO C .
                                                                There are some other wonderful UNIVAC resources
(6) MOVE UNIT-PRICE (B) TO UNIT-PRICE (C) .
                                                              available online:
(7) WRITE-ITEM C .
(8) READ-ITEM A ; IF END OF DATA GO TO OPERATION 14 .           The 1951 ‘Introduction to UNIVAC’ leaflet.
(9) JUMP TO OPERATION 1 .                                       Remington Rand UNIVAC advertising film from
(10) READ-ITEM B ; IF END OF DATA GO TO OPERATION 12 .          1950-2.
(11) JUMP TO OPERATION 1 .                                      Notes from the 1954 MIT special program on
(12) SET OPERATION 9 TO GO TO OPERATION 2 .                     Digital Computers (see A-0 section above).
(13) JUMP TO OPERATION 2 .                                      Bitsavers have a whole bunch of documents from
(14) TEST PRODUCT-NO (B) AGAINST ZZZZZZZZZZZZ ; IF EQUAL        the early days of UNIVAC. These include operating
GO TO OPERATION 16 ;                                            manuals, programming references, and the course
   OTHERWISE GO TO OPERATION 15 .                               materials for an Advanced Programming Course.
(15) REWIND B .                                                 The FLOW-MATIC brochure from 1957 (includes the
(16) CLOSE-OUT FILES C ; D .                                    FLOW-MATIC sample code above.
(17) STOP . (END)
   The PRODUCT-NO and UNIT-PRICE fields would
have been defined separately, in the DIRECTORY              while working on the Mark II in 1947 was tracked
section of the program. This is just the executable         down to an actual bug (a moth) stuck in a relay. The
part. Let’s step through it:                                term “bug” had been used before in engineering, but
(0) Load in two input files (A is inventory, B is price),   Hopper brought it into popularity.
and set two output files (C is priced inventory, D is         A UNIVAC at US Steel in Indiana, on the other hand,
unpriced).                                                  had a bug that was in fact a fish; its cooling system,
(1) The key part: this compares the current product         which used water from Lake Michigan, got its intake
number from file A with that from file B:                   blocked by a fish and thereby overheated.
   If they match, then product 1 has a matching price,
and we go to section (5)–(9).                               COBOL and later
   If A is greater, we go to section (10)–(13).             After FLOW-MATIC came COBOL, which Hopper and
   If B is greater, we go to section (2)–(4).               her team designed from 1959 onwards. COBOL is still
(2)–(4) this implies that we have an unpriced product       in use today, with the 2002 update including OO
(product 1, for example, exists on list A but on list B     features, and the compiler GNU Cobol (formerly
the lowest number is product 2). We write it out on the     OpenCOBOL) is available
unpriced file D. We then jump to (8), read in the next      for Linux, with plenty of       “Grace Hopper created the first
item A and return to (1).                                   online resources
(5)–(9) Items A and B match; the product has a price.       available. COBOL was            operational compiler while
We write it, together with its price, on file C. Then we    intended to be                  working on the UNIVAC project.”
read in the next item A and go back to (1).                 comprehensible by
(10)–(13) Item A is greater than item B. Read in the        non-programmers, hence
next item B, if there is an item B, and go back to (1).     its use of English-like syntax and structure. Modern
Note that the result of (5)-(9) (a matching pair) will be   COBOL is still recognisably the same language, and
to read in the next A product but not the next B            indeed recognisably inherits from FLOW-MATIC. (The
product, so this balances that out. If we have run out      first COBOL compiler was itself written in FLOW-
of B data, we rewrite (9) so that all the rest of the       MATIC, and was the first compiler to be written in a
products go directly to the unpriced output file.           high-level language.)
(14)-(16): close the output files and/or rewind input          Grace Hopper moved back into the Navy in the late
file B; stop the program.                                   1960s. She was on active duty for several years
   So this would generate a list of priced items with       beyond mandatory retirement with special approval of
their prices, and a list of unpriced items. As you can      Congress, eventually retiring in 1986, at the age of 79,
see, FLOW-MATIC was squarely aimed at the                   as a Rear Admiral. She continued to lecture widely on
business market.                                            early computing and other aspects of user-friendly
                                                            computing until she died in 1992.
When is a bug not a bug?
                                                             Juliet Kemp is a scary polymath, and is the author of
Famously, Grace Hopper popularised the term
                                                             O’Reilly’s Linux System Administration Recipes.
“debugging” about computer programs, after an error



                                                              www.linuxvoice.com                                        85
      TUTORIAL KDE



                               THE AWESOMELY EPIC
        TUTORIAL
                               GUIDE TO KDE
                               Everything you ever wanted to know about KDE (but were too
GRAHAM MORRISON                afraid of the number of possible solutions to ask).


                               D
                                         esktops on Linux. They’re a concept             has been quietly growing more brilliant over the last
  WHY DO THIS?                           completely alien to users of other operating    couple of years, and secondly, because KDE should
  • Make your desktop look               systems because they never having to think      be the first choice for users unhappy with their old
    the way you want it to
    look, not the developer.   about them. Desktops must feel like the abstract idea     desktop – in particular, Windows 8 users pining for an
  • Dazzle your friends with   of time to the Amondawa tribe, a thought that doesn’t     interface that makes sense.
    graphical glitz.           have any use until you’re in a different environment.        But fear not. We’re going to use a decade’s worth
  • Save time with file        But here it is – on Linux you don’t have to use the       of KDE firefighting to bring you the definitive guide to
    manager shortcuts.         graphical environment lurking beneath your mouse          making KDE look good and function slightly more like
                               cursor. You can change it for something completely        how you might expect it to. We’re not going to look
                               different. If you don’t like windows, switch to xmonad.   at KDE’s applications, other than perhaps Dolphin;
                               If you like full-screen apps, try Gnome. And if you’re    we’re instead going to look at the functionality in the
                               after the most powerful and configurable point-and-       desktop environment itself. And while our guinea pig
                               click desktop, there’s KDE.                               distribution is going to be Mageia 4, as found on this
                                  KDE is wonderful, as they all are in their own way.    month’s DVD, this guide will be equally applicable
                               But in our opinion, KDE in particular suffers from poor   to any recent KDE desktop running from almost
                               default configuration and a rather allusive learning      any distribution, so don’t let the default Mageia
                               curve. This is doubly frustrating, firstly because it     background put you off.


                                 1   FONTS
                               A great first target for getting your system looking      isn’t a problem any more. But it’s still worth finding
                               good is its selection of fonts. It used to be the case    a font you prefer, as there are now so many great
                               that many of us would routinely copy fonts across         alternatives to choose between.
 Most distributions don’t
 include decent fonts. But     from a Windows installation, getting the professional        The best source of free fonts we’ve found is
 KDE enables you to quickly    Ariel and Helvetica font rendering that was missing       www.fontsquirrel.com – it hosts the Roboto, Roboto
 install new ones and apply    from Linux at the time. But thanks to generic quality     Slab (Hello!) and Roboto Condensed (Hello!) typefaces
 them to your desktop.         fonts such as DejaVu and Nimbus Sans/Roman, this          used throughout this magazine, and also on the
                                                                                         Nexus 5 smartphone (Roboto was developed for use
                                                                                         in the Ice Cream Sandwich version of the Android
                                                                                         mobile operating system).
                                                                                            TrueType fonts, with their .ttf file extensions, are
                                                                                         incredibly easy to install from KDE. Download the zip
                                                                                         file, right-click and select something from the Extract
                                                                                         menu. Now all you need to do is drag a selection
                                                                                         across the TrueType fonts you want to install and
                                                                                         select ‘Install’ from the right-click Actions menu. KDE
                                                                                         will take care of the rest.
                                                                                            Another brilliant thing about KDE is that you can
                                                                                         change all the fonts at once. Open the System
                                                                                         Settings panel and click on Application Appearances,
                                                                                         followed by the fonts tab, and click on Adjust All Fonts.
                                                                                         Now just select a font from the requester. Most KDE
                                                                                         applications will update with your choice immediately,
                                                                                         while other applications, such as Firefox, will require
                                                                                         a restart. Either way, it’s a quick and effective way
                                                                                         of experimenting with your desktop’s usability and
                                                                                         appearance. We’d recommend either Open Sans or
                                                                                         the thinner Aller fonts.



 86                                                           www.linuxvoice.com
                                                                                                                         KDE TUTORIAL


  2    EYE CANDY
One of KDE’s most secret features is that                                                                                Remove the blue glow and
backgrounds can be dynamic. We don’t find much use                                                                       change a few of the display
                                                                                                                         options, and KDE starts
for this when it comes to the desktops that tells us the
                                                                                                                         to look pretty good in our
weather outside the window, but we do like                                                                               opinion.
backgrounds that dynamically grab images from the
internet. With most distributions you’ll need to install
something for this to work. Just search for plasma-
wallpaper in your distribution’s package manager. Our
favourite is plasma-wallpaper-potd, as this installs
easy access to update-able wallpaper images from a
variety of sources.
   Changing a desktop background is easy with KDE,            Alternatively, if you’d like active windows to have a
but it’s not intuitive. Mageia, for example, defaults to      more pronounced shadow, change the inner and outer
using ‘Folder’ view, as this is closer to the traditional     colours to black.
desktop where files from the Desktop folder in your              You may have seen the option to download
home directory are displayed on the background, and           wallpapers, for example, from within a KDE window,
the whole desktop works like a file manager. Right-           and you can see this now by clicking on the Get New
click and select ‘Folder Settings’ if this is the view        Decorations button. Themes are subjective, but our
you’re using. Alternatively, KDE defaults to ‘Desktop’,       favourite combination is currently the Chrome window
where the background is clear apart from any widgets          decoration (it looks identical to Google’s default theme
you add yourself, and files and folders are considered        for its browser) with the Aya desktop theme. The term
links to the sources. The menu item in this mode is           ‘desktop theme’ is a bit of a misnomer, as it doesn’t
labelled Desktop Settings. The View Configuration             encapsulate every setting as you might expect.
                                                                                                                             PRO TIP
panel that changes the background is the same,                Instead it controls how generic desktop elements are
                                                                                                                          Move any window
however, and you need to make your changes in the             rendered. The most visible of these elements is the         by holding Alt and
Wallpaper drop-down menu. We’d recommend Picture              launch panel, and changing the desktop theme will           click+dragging the
Of The Day as the wallpaper, and the Astronomy                usually have a dramatic effect on its appearance, but       window with your mouse.
                                                                                                                          This also applies to the
Picture Of The Day as the image source.                       you’ll also notice a difference in the widgets system.      KRunner dialog and the
                                                                 The final graphical flourish we’d suggest is to          Plasma cashew widget.
In the glow ring                                              change the icon set that KDE uses. There’s nothing
Another default option we think is crazy is the blue          wrong with the default Oxygen set, but there are better
glow that surrounds the active window. While every            options. Unfortunately, this is where the ‘Get New
other desktop uses a slightly deeper drop-shadow,             Themes’ download option often fails, probably
KDE’s active window looks like it’s bathed in                 because icon packages are large and can overwhelm
radioactive light. The solution to this lies in the default   the personal storage space often reserved for projects
theme, and this can be changed by going to KDE’s              like these. We’d suggest going to kde-look.org and
System Settings control panel and selecting                   browsing its icon collections. Open up the Icons panel
Workspace Appearance. On the first page, which is             from KDE’s System Settings, click on the Icons tab
labelled Window Decorations, you’ll find that Oxygen is       followed by Install Theme File and point the requester
nearly always selected, and it’s this theme that              at the location of the archive you just downloaded.
contains the option to change the blue glow. Just click       KDE will take it from there and add the icon set to the
on the Configure Decoration button, flip to the               list in the panel. Try Kotenza for a flat theme, or keep
Shadows tab and disable Active Window Glow’.                  an eye on Nitrux development.


  3    THE PANEL
Our next target is going to be the panel at the bottom        are unlocked can you re-size the panel, and even add
of the screen. This has become a little dated,                new applications from the launch menu.
especially if you’re using KDE on a large or high-               With widgets unlocked, click on the cashew on the
resolution display, so our first suggestion is to re-scale    side of the panel followed by More Settings and select
and centre it for your screen. The key to moving              Centre for panel alignment. With this enabled you can
screen components in KDE is making sure they’re               re-size the panel using the sliders on either side and
unlocked, and this accomplished by right-clicking on          the panel itself will always stay in the middle of your
the ‘plasma’ cashew in the top-right of the display           screen. Just pretend you’re working on indentation on
where the current activity is listed. Only when widgets       a word processor and you’ll get the idea. You can also




                                                                www.linuxvoice.com                                                               87
     TUTORIAL KDE


 Activities
 No article on KDE would be complete without          Some installations of KDE will include the
 some discussion of what KDE calls Activities.     Activity applet in the toolbar. Its red, blue
 In many ways, Activities are a solution waiting   and green dots can be clicked on to open
 for a problem. They’re meta-virtual desktops      the activity manager, or you can click on the
 that allow you to group desktop configuration     Plasma cashew in the top-right and select
 and applications together. You may have an        Activities. This will open the bar at the bottom
 activity for photo editing, for example, or one   of the screen, which lists activities installed
 for working and another for the internet. If      and primed on your system. Clicking on any
 you’ve got a touchscreen laptop, activities       will switch between them; as will pressing the
 could be used to switch between an Android-       meta key (usually the Windows key) and Tab.
 style app launcher (the Search and Launch            We’d suggest that finding a fast way to
                                                                                                      Activities let you quickly switch between
 mode from the Desktop Settings panel), and        switch between activities, such as with a
                                                                                                      different desktop modes, such as the search
 the regular desktop mode. We use a single         keyboard shortcut or with the Activity Bar
                                                                                                      and launch mode, which is ideal for tablets.
 activity as a default for screenshots, for        widget is the key to using them more. With
 instance, while another activity switches         the Activity Manager open, clicking on Create
 everything to the file manager desktop mode.      Activity lets you either clone the current         applications to the desktop for your current
 But the truth is that you have to understand      desktop, add a blank desktop or create a           setup. To remove an activity, switch to
 what they are before you can find a way of        new activity from a list of templates. Clone       another one and press the Stop and Delete
 using them.                                       works well if you want to add some default         buttons from the Activity Manager.


                              change its height when the sliders are visible by              clicking on the Virtual Desktops tabs and changing
                              dragging the central height widget, and to the left of         the number of rows to ‘1’.
                              this, you can drag the panel to a different edge on your          Finally, there’s the launch menu. Mageia has
                              screen. The top edge works quite well, but many of             switched this from the new style of application
                              KDE’s applets don’t work well when stacked vertically          launcher to the old style originally seen in Microsoft
                              on the left or right edges of the display.                     Windows. We prefer the former because of its search
                                 There are two different kinds of task manager               field, but the two can be switched by right-clicking the
                              applets that come with KDE. The default displays each          icon and selecting the Switch To… menu option.
                              running application as a title bar in the panel, but this         If you find the hover-select action of this mode
                              takes up quite a bit of space. The alternative task            annoying, where moving the mouse over one of the
                              manager displays only the icon of the application,             categories automatically selects it, you can disable it
     PRO TIP
                              which we think is much more useful. Mageia defaults            by right-clicking on the launcher, selecting Launcher
 Spacers can be added to
 your panel so that icons
                              to the icon version, but most others – and KDE itself          Settings from the menu and disabling ‘Switch Tabs On
 don’t push up against        – prefer the title bar applet. To change this, click on the    Hover’ from the General settings page. It’s worth
 one another. This is great   cashew again and hover over the old applet so that the         reiterating that many of these menu options are only
 for separating quick
 launchers from the task
                              ‘X’ appears, then click on this ‘X’ to remove the applet       available when widgets are unlocked, so don’t despair
 manager.                     from the panel. Now click on Add Widgets, find the two         if you don’t see the correct menu entry at first.
                              task managers and drag the icon version on to your
                              panel. You can re-arrange any other applets in this
                              mode by dragging them to the left and right.

                              More sensible defaults
                              By default, the Icon-Only task manager will only display
                              icons for tasks running on the current desktop, which
                              we think is counterintuitive, as it’s more convenient to
                              see all of the applications you may have running and
                              to quickly switch between whatever desktops on
                              which they may be running with a simple click. To
                              change this behaviour, right-click on the applet and
                              select the Settings menu option and the Behaviour tab
                              in the next window. Deselect ‘Only Show Tasks From
                              The Current Desktop’, and perhaps ‘Only Show Tasks
                              From The Current Activity’ if you use KDE’s activities.
                                 Another alteration we like to make is to reconfigure
                              the virtual desktops applet from showing four
                              desktops as a 2x2, which doesn’t look too good on a
                              small panel, to 4x1. This can be done by right-clicking        We’d recommend reducing the size and centrally scaling
                              on the applet, selecting Pager Settings and then               the KDE launch panel.



88                                                             www.linuxvoice.com
                                                                                        KDE TUTORIAL


  4    UPGRADED LAUNCH MENU
You may want to look into replacing the default                                         KRunner isn’t a great
launch menu entirely. If you open the Add Widgets                                       name, but it’s one of the
view, for instance, and search for menus, you’ll see                                    most powerful parts of the
several results. Our current favourite is called                                        KDE desktop, doing away
Application Launcher (QML). It provides the same kind                                   with almost every other
                                                                                        element of the GUI.
of functionality as the default menu, but has a cleaner
interface after you’ve enlarged the initial window. But if
we’re being honest, we don’t use the launcher that
much. We prefer to do most launching through
KRunner, which is the seemingly simple requester that
appears when you hold Alt+F2.
   KRunner is better than the default launcher,
because you can type this shortcut from anywhere,
regardless of which applications are running or where
your mouse is located. When you start to type the
name of the application you want to run into KRunner,
you’ll see the results filtered in real time beneath the
entry field – press Enter to launch the top choice.

More than just a launcher
KRunner is capable of so much more. You can type in
calculations like =sin(90), for example, and see the
result in real time. You can search Google with gg: or
Wikipedia with wp: followed by the search terms, and
add many other operations through installable
modules. To make best use of this awesome KDE
feature, make sure you’ve got the plasma-addons
package installed, and search for runner on your
distribution’s package manager. When you next
launch KRunner and click on the tool icon to the left of
the search bar, you’ll see a wide variety of plugins that
can do all kinds of things with the text you type in. In
classic KDE style, many don’t include instructions on
how to use them, so here’s our breakdown of the most
useful things you can do with KRunner:



  The 11 most useful KRunner commands
  kill <process>                           Terminate the selected process.
  #<command                                Open the man page for the command.
  <argument>                               Open a website, app or document.
  file:/                                   Launch Dolphin on the root directory.
  smb://<share>                            Open a Samba share in Dolphin.
  sftp://<SSH site>                        Open an SFTP folder in Dolphin.
  vnc://<server:1>                         Access a remote desktop.
  desktop 2                                Switch to desktop 2.
  window <app>                             List and switch between windows.
  <name@server>                            Send an email to name@server.
  =solve(x-20=9)                           Solve equations plus many other functions.


                                                             www.linuxvoice.com                                89
     TUTORIAL KDE


                          5    FILE MANAGEMENT
                        File management may not be the most exciting
                        subject in Linux, but it is one we all seem to spend a
                        lot of time doing, whether that’s moving a download
                        into a better folder, or copying photos from a camera.
                        The old file manager, Konqueror, was one of the best
                        reasons for using KDE in the first place, and while
                        Konqueror has been superseded by Dolphin in KDE
     PRO TIP            4.x, it’s still knocking around – even if it is labelled a
 Use your mouse wheel   web browser.
 on KDE’s desktop
 background to switch       If you open Konqueror and enter the URL as file:/,
 between desktops.      it turns back into that file manager of old, with many
                        of its best features intact. You can click on the lower
                        status bar, for example, and split the view vertically or
                        horizontally, into other views. You can fill the view with
                        proportionally sized blocks by selecting Preview File        Konqueror may be vanquished, but many of its best
                        Size View from the right-click menu, and preview many        features have made it into the Dolphin file manager.
                        other file types without ever leaving Konqueror.
                                                                                     view, for instance, albeit one only once, and only
                        Click control                                                horizontally, from the toolbar. You can also view lots
                        Mageia uses a double-click for most options, whereas         of metadata. Select the Details View and right-click
                        we prefer a single click. This can be changed from           on the column headings for the files, and you can
                        the System-Settings panel by opening Input Devices,          add columns that list the word counts in text files,
                        clicking on Mouse and enabling ‘Single-click To Open         or an image’s size and orientation, or the artist, title
                        Files And Folders’. If you’ve become used to Apple’s         and duration of an audio file, all from within the
                        reverse scroll, you’ll also find an option here to reverse   contents of the data. This is KDE’s semantic desktop
                        the scroll direction on Linux.                               in action, and it’s been growing in functionality for the
                           Konqueror is a great application, but it hasn’t been      last couple of years. Apple’s OS X, for example, has
                        a focus of KDE development for a considerable period         only just started pushing its ability to tag files and
                        of time. Dolphin has replaced it, and while this is a        applications – we’ve been able to do this from KDE
                        much simplified file manager, it does inherit some           for a long time. We don’t know any other desktop that
                        of Konqueror’s best features. You can still split the        comes close to providing that level of control.


                          6    WINDOW MANAGEMENT
                        KDE has a comprehensive set of windowing functions
                        as well as graphical effects. They’re all part of the
                        window manager, KWin, rather than the desktop,
                        which is what we’ve been dealing with so far. It’s the
                        window manager’s job to handle the positioning,
                        moving and rendering of your windows, which is why
                        they can be replaced without switching the whole
                        desktop. You might want to try KWin on the RazorQt
                        desktop, for example, to get the best of both the
                        minimal environment RazorQt offers and the power of
                        KDE’s window manager.                                        KDE is perhaps the best desktop for people who run
                           The easiest way to get to KWin’s configuration            applications as windows, rather than full screen.
                        settings is to right-click on the title bar of any window
                        (this is usually the most visible element of any window      to include All Other Desktops in the Filter Windows
                        manager), and select Window Manager Settings from            By section, as that will allow you to quickly switch
                        the More Actions menu.                                       to applications running on other desktops. We also
                           The Task Switcher is the tool that appears when           like the Cover Switch visualisation rather than the
                        you press Alt+Tab, and continually pressing those two        Thumbnails view, and you can even configure the
                        keys will switch between all running applications on         perceived distance of the windows by clicking on the
                        the current desktop. You can also use cursor keys to         toolbar icon.
                        move left and right through the list. These settings            The next page on the window manager control
                        are mostly sensibly configured, but you may want             module handles what happens at the edges of your



90                                                       www.linuxvoice.com
                                                                                                                                         KDE TUTORIAL

screen. At the very least, we prefer to enable Switch                 of all your virtual desktops, any of which can be
Desktop On Edge by selecting Only When Moving                         chosen with a click.
Windows from the drop-down list. This means that                        Two pages down in the configuration module,
when you drag a window to one edge, the virtual                       there’s a page called Focus. This is an old idea where
desktop will switch beneath, effectively dragging the                 you can change whether a window becomes active
window on to a new virtual desktop.                                   when you click on it, or when you roll your mouse
  The great thing about enabling this only for dragged                cursor over it. KDE adds another twist to this by
windows is that it doesn’t interfere with KDE’s                       providing a slider that progresses from click to a strict
fantastic window snapping feature. When you drag                      hover policy, where the window under the cursor
a window close to the left or right edge, for instance,               always becomes active. We prefer to use one of the
KDE displays a ghosted window where your window                       middle options – Focus Follows Mouse – as this
will snap to if you release the mouse. This is a great                chooses the most obvious window to activate for us
way of turning KDE into a tiling window manager,                      without making too many mistakes, and it means we
where you can easily have two windows split down                      seldom click to focus. We also reduce the focus delay
the middle of the screen area. Moving a window into                   to 200ms, but this will depend on how you feel about
any of the corners will also give you the ability to                  the feature after using it for a while.
neatly arrange your windows to occupy a quarter of                      KDE has so many features, many of which only
the screen, which is ideal for large displays.                        come to light when you start to use the desktop. It
                                                                      really is a case of developers often adding things
Bird’s-eye view                                                       and then telling no one. But we feel KDE is worth the
We also enable a mode similar to Mission Control on                   effort, and unlikely some other desktops, is unlikely to
OS X when the cursor is in the region of the top-left                 change too much in the transition from 4.x to 5. That
corner of the screen. On the screen edge layout, click                means the time you spend learning how to use KDE
on the dot in the top-right of the screen (or any other               now is an investment. Dive in!.
point you’d prefer) and select Desktop Grid from the
drop-down menu that appears. Now when you move                          Graham Morrison is the editor and only KDE user on the
                                                                        Linux Voice team. He likes weird synthesizers.
to the top-right of your display, you’ll get an overview


  Visual effects

  There’s a wide variety of visual effects in KDE, all of   dependent on your graphics hardware: although         should also enable the ‘Suspend Desktop Effects
  which can be enabled from the Desktop Effects             most devices now offer accelerated OpenGL, the        For Fullscreen Windows’ option to maximise
  section of the Window Manager Settings dialog. For        option can be selected from the Advanced page of      performance. Here’s a selection of our favourite
  many of them to work, however, you’ll need to be          the Desktop Effects configuration panel. If you run   desktop effects, some of which have a functional
  using the OpenGL compositing type. This is                3D games or other 3D full-screen applications, you    reason to exist:




  Translucency: The window you’re dragging becomes          Magic Lamp: When minimising/maximising windows        Dim Inactive: Windows that aren’t currently active
  partly translucent. Options can be used to adjust         the window will stretch and zoom into the toolbar.    will go slightly dimmer. We prefer to lessen this
  for any kind of window and element.                       It’s useful for checking up on your minimised apps.   effect to a strength of 5 from the Tools page.




  Zoom: Hold down the system meta key (usually the          Present Windows: This effect works in a similar       Wobbly Windows: OK, there’s no functional reason
  Windows one) and press plus or minus to zoom the          way to Apple’s Expose. Press Ctrl+F10 to display      to enable this other than the endorphin released by
  desktop around the cursor.                                thumbnails of all running desktop applications.       contentment. Use the options to change the amount.




                                                                         www.linuxvoice.com                                                                            91
        TUTORIAL UEFI



                             UEFI BOOTING BOOT
            TUTORIAL
                             CAMP (REBOOTED)
                             Upgrade your the way your system boots without installing a
GRAHAM MORRISON
                             distribution or resorting to Grub.


                             W
                                           e’ve been using the BIOS for decades. It’s     to install another operating system. In reality, the
                                           as perennial as your keyboard and mouse,       Secure Boot cataclysm has yet to materialise, as
                                           breathing life into inert hardware when a      many PCs still include a traditional BIOS or allow
                             little electricity is applied. These days, the POST status   you to disable Secure Boot. The latter option should
                             messages delivered after your BIOS initialises the           always be available, and you’ll need to disable Secure
                             system race across the screen so quickly you seldom          Boot unless you want to start dealing with signing a
                             get the chance to read the text, making entering             bootloader shim.
                             the BIOS itself a mad keyboard-bashing mini-game
                             that more often than not ends with Grub than the             Muddy waters
                             configuration menus you’re after. Modern PCs aren’t          Another potentially confusing option is something
                             well suited to the old-school charm of the BIOS. They        called the Compatibility Support Module. To the user,
                             don’t want to wait for permission, they don’t want low-      this will appear as a hybrid between UEFI and the
                             res large white fonts on a blue background. They just        BIOS, a magical panacea that seems to allow us to
                             want to get on with the job at hand, and that’s booting      forget about UEFI and BIOS completely. You’ll typically
                             your computer.                                               see its effects from your computer’s own boot device
                                 And so the BIOS is being wheeled out, albeit slowly,     selection menu, usually the one you get when you
                             while its replacement makes itself comfortable.              hold F12 after turning on your machine. What’s not
                             Initially developed by Intel, the booting heir was called    always made clear is that the mode you boot into
                             the EFI – the Extensible Firmware Interface. But it’s        from this point will affect how your Linux distribution
                             now better know as UEFI. The U is for unified, because       installs itself, which in turn affects whether you’ll be
                             it’s not just Intel anymore. UEFI has been hanging over      able to boot Linux from a UEFI boot. An installer won’t
                             the Linux boot system like the Sword of Damocles,            install a UEFI bootloader, for instance, unless you boot
                             threatening to upend the booting status quo and              into UEFI mode. And if your install medium doesn’t
                             exclude us from installing our own operating systems,        support a UEFI bootloader, you’re stuck.
                             thanks to the spectre of Secure Boot. Secure Boot is             But defaulting to a UEFI installation and forgetting
                             a system that embeds a key without your firmware             about the BIOS and the Compatibility Support Module
                             so that only operating systems signed by the key             is beginning to make more sense. Modern laptops
                             are allowed to boot. It’s primarily a way for Microsoft      are often pre-configured to boot UEFI, and there will
                             – in part, legitimately – to ensure nothing has been         be a time when falling back to the BIOS won’t be an
                             tampered with from the very first moment your PC             option. But these days, there’s nothing to be scared
                             gets power to the moment you get to play with the            of, and in many ways, UEFI can make the whole
                             inspirational Windows 8.1 interface. But it could            booting process more transparent. The bootloaders
                             also make life harder for when you do intentionally          may, at the moment, feel slightly more primitive that
                             want to tamper with your PC by making the choice             their well worn BIOS equivalents, but to us the boot
                                                                                          process actually makes more sense than the black
                                                                                          arts involved in the old methods. If you’ve spent the
                                                                                          last decade thinking about booting in terms of MBR
                                                                                          bootloaders, Grub and old-style partitions, get ready to
                                                                                          update your notes.
                                                                                              We’re going to create our own UEFI boot
                                                                                          environment, and we’ll be doing this primarily from
                                                                                          the Mint Live desktop as found on last month’s DVD,
                                                                                          in much the same way you might fix a broken MBR
                                                                                          installation or reconfigure Grub. You can use any
                                                                                          similar distribution, however, as there’s nothing Mint-
   It doesn’t look much,                                                                  specific about our instructions. We’re also going to
   but this is the Refind                                                                 use a 1GB USB stick to get around the limitation of
   bootloader running from                                                                BIOS-only booting DVD drives, but we’ll only use this to
   our new EFI partition.                                                                 ‘fix’ the installation, rather than initiate it.



   92                                                        www.linuxvoice.com
                                                                                                                           UEFI TUTORIAL

    The system we create won’t be perfect. It won’t                                                                         Depending on which boot
handle distribution updates to the kernel without a                                                                         option you take, your
little further tinkering, and you’ll need to make plenty                                                                    system will boot into either
of considerations for your own hardware rather than                                                                         UEFI or BIOS boot modes.
these instructions for ours. But you will learn how
UEFI works from a practical perspective, and learn
how to troubleshoot the future of Linux booting.

Look into the black box
The great thing about taking control of UEFI yourself
is that you don’t have the problem of which mode
your system has booted from – UEFI or BIOS, which
is especially useful if you’re booting off a DVD that can
only boot in the old BIOS mode. When you get one
distribution running , it’s easy to add more, and it can
also be the only way of running the latest Microsoft
Windows or even Apple’s OS X alongside.
   Mint 16 and many other distributions have their
own preliminary support for UEFI bootloaders, as             and you’ll find it in Mint 16’s Administration menu. It’s
long as you’ve booted into the correct boot mode,            an application that hides a lot of power. In the top-right
but we’ve found its approach a little unpredictable,         you’ll find a drop-down list of all the drives detected
along with many other distributions. We had similar          and connected to your system. When you select one
problems with Mageia, for example. Which is why              of these drives, the horizontal bar beneath the menu
we want to roll our own – the intention being to             will become populated with a graphical representation
learn more about how it works and how you might              of the partitions on that drive. Each partition is a self-
approach installation with a distribution that doesn’t       contained horizontal block and its border colour is
support UEFI. And the real trick isn’t installing the        used to show the filesystem used for each partition.
distribution, it’s configuring your drive in such a way      Within each partition, a yellow bar is used to indicate
that it works with UEFI. The most important part is          how much space is taken up by data, with white used
booting to a Live distribution,                              to indicate free space on the partition. This is handy if
   But before we get to the booting part, we need to         you want to use free space to resize a partition.
start with partitioning. To boot UEFI, need to use a
different partitioning scheme. So you’ll need a spare        Danger: partitioning!
drive – or one you’re willing to sacrifice, as all the       Make sure you select the correct drive from the
                                                                                                                                 PRO TIP
data it contains will be removed in the process, and         drop-down list. If you’ve only got one drive installed,
                                                                                                                             If you’re installing Linux
you’ll need to be confident about your current drive         this isn’t going to be a problem. If you’ve got five, you
                                                                                                                             alongside Windows, make
configuration. We’re going to be reformatting the drive      need to be certain the drive you’re selecting is the one        sure you disable Fast
and you don’t want to overwrite or repartition personal      you intend to partition for a UEFI bootloader, because          Startup and Secure Boot.
data in the process of experimentation, so it may even       you’re going to remove all the data on the drive in the
be wise to disconnect any other drives. With all that in     process. Our drive, for example, already has a Linux
mind, locate your nearest Linux live CD and USB stick        partition on it, but this is going to disappear in the very
and boot your machine.                                       next paragraph – you have been warned.
   There’s nothing wrong with the command line,                 The old partitioning scheme used a table to store
but when it comes to partitioning drives, we like the        the partition data, and this table was stored on the
visual safety net provided by GParted. Fortunately, this     Master Boot Record (MBR), a statically located 512
essential application is part of most live distributions,    bytes allocated to explain the layout of a drive to
                                                             the BIOS. Nearly all Linux drives prior to UEFI used
                                                             MBR, and MBR can still be used in some cases with
                                                             UEFI. But it’s better to make clean break. The first
                                                             thing we need to do with our drive is create a new
                                                             partition table.
                                                                With your drive definitely selected, click on a
                                                             partition on the drive and select Device > Create
                                                             Partition Table from the menu. From the dialog that
                                                             appears, click on ‘Advanced’ and while avoiding the
                                                             temptation to click on ‘amiga’, select ‘gpt’ as the
                                                             partition type followed by Apply. All the data on that
                                                             drive is effectively dead to us now, and you’ll see there
                                                             are no partitions on your drive. Just the cold grey of
You need to create a GPT partition table for UEFI booting.   unallocated space.



                                                               www.linuxvoice.com                                                                     93
     TUTORIAL UEFI

It’s vital that the EFI                                                                      new UEFI boot scheme to your system firmware so
partition you create has                                                                     that it knows there’s a new way to boot the system.
a partition type of EF00.                                                                       You will need to know where your distribution
Either use cgdisk on the                                                                     is installed. The easiest way of doing this is from
command line or enable                                                                       GParted’s drop-down device menu, as you’ll be able to
the ‘boot’ flag for the                                                                      see the device node (/dev/sda1, for instance) along
partition in GParted.
                                                                                             with the partition configuration and the UUID of the
                                                                                             device if you make a note of it.
                                                                                                To mount the partition, open a terminal and type
                                                                                             the following, replacing sda2 with the location of your
                                                                                             own distribution’s root partition:
                                                                                             sudo -s
                                                                                             mount /dev/sda2 /mnt/
                                   We’re now going to create a couple of partitions to          With an MBR installation, Grub uses the /boot
                               fill the space, but the first is mandatory. This is the       folder to not only hold its configuration files, but also
                               EFI system partition, and it’s this that UEFI expects         the kernel and filesystem image for booting. We need
                               to find on your drive and where it will eventually find       both of these for UEFI and the UEFI partition needs
                               your UEFI bootloader. For that reason, it’s operating         to replace /boot on the filesystem tree. Here’s the list
                               system-agnostic, and needs to be formatted as FAT32           of commands we used to move the old boot aside,
                               for maximum compatibility. It should also be a certain        mount the new one and copy the files we need over
                               size. The UEFI standard recommends this as 512MB,             (remember to replace filenames and devices with
                               although in execution we’ve found that 100MB                  ones that match your own system):
                               partitions work just as well. Eventually, you could           cd /mnt
                               install Linux kernel images into this partition, so there’s   mv boot boot_old
                               no harm in making it larger unless you’re working with        mkdir boot
                               an expensive SSD. To create this partition, click on          mount /dev/sda1 /mnt/boot
                               the ‘plus’ icon in the toolbar, set its size to 512MB and     mkdir boot/EFI
                               make sure it uses the FAT32 filesystem.                       cp boot_old/vmlinuz-3.11.0-12-generic boot/vmlinuz
                                   The next step is important. If you were doing this        cp boot_old/initrd.img-3.11.0-12-generic boot//initrd.img
                               from the command line, using a tool like gdisk, you’d           We now need to add the new UEFI partition as
                               need to mark this partition as type EF00. This tells          a mount point, and to do this we need to add the
                               UEFI that this is the system partition (also known as         partition’s unique identifier (its UUID) to the etc/ftsab
                               the ESP – the EFI System Partition), and it’s the one         configuration file. You can get the UUID from GParted
                               to use for booting. GParted doesn’t use hex codes,            or by typing the following:
                               but you still have to tell UEFI about the partition.          blkid
                               You do this by setting the ‘boot’ flag, which is a little     /dev/sda1: UUID=”BD8C-E7B3” TYPE=”vfat”
                               incongruous when you may be used to using a similar           /dev/sda2: UUID=”0abcc4da-c2aa-437b” TYPE=”ext4”
                               flag in MBR systems to tell the BIOS which partition            We’ve shortened the output slightly, but you can see
                               to boot. Right-click on the freshly created partition         the UUID for the UEFI ‘vfat’ partition on the first line.
                               and select ‘Manage Flags’. From the list of flags that        This needs to be added as a new line in etc/fstab on
                               appears, select ‘boot’, this should disable the default       your distribution’s root partition by editing the file with
                               ‘msftdata’ flag as well as cause some drive activity.         nano etc/fstab:
                                   With the EFI partition created, assigned a partition      UUID=BD8C-E7B3 /boot/efi       vfat   defaults     0        2
                               type and formatted FAT32, we can now install the
                               bootloader. There are several that work with EFI – and        Installing the bootloader
                               even Grub can be made to work with the new scheme,            We can now install the bootloader itself. If we’d been
                               although you don’t win any house points for simplicity        able to boot into the distribution using UEFI, we could
                               of you take that route. The two we tried for this tutorial    simply install this through a package manager and
     PRO TIP
                               were Gummiboot and Refind. Both have a couple of              everything else would be handled automatically. But
 GParted can create an
 incompatible EFI boot
                               things in common. Firstly, their names are terrible. But      because our system is currently booted from BIOS
 partition. If this happens,   they’re both straightforward to install and use a simple      mode, we need to copy the files manually, edit a config
 we’d recommend using          directory structure on your UEFI partition plus a             file and then add the bootloader to the UEFI firmware
 the command line tool
 cgdisk to create a EF00
                               configuration file to hold information on the operating       by booting in UEFI mode off a USB stick.
 type partition formatted      systems you want to boot. We went with Refind.                   Let’s first download the binary version of the Refind
 with fat32.                       We’ve now got to the point where we can install           bootloader (refind-bin-0.7.7.zip) plus the image of
                               the UEFI bootloader, and there are two stages to the          the same bootloader (refind-flashdrive-0.7.7.zip)
                               process. The first is to mount the distribution you           we’re going to use to boot off the USB stick. Both
                               want to add, and to now make the boot folder the              can be grabbed from www.rodsbooks.com/refind
                               UEFI partition we just created. The second is to move         via links to SourceForge. To install the bootloader, we
                               all the files you need to the UEFI partition and add the      need to unzip it and copy the folder to the mounted



94                                                              www.linuxvoice.com
                                                                                                                            UEFI TUTORIAL

boot partition on our distribution:
cd ~/Download
unzip refind-bin-0.7.7.zip
cd refind-bin-0.7.7/
cp -r refind /mnt/boot/EFI/
cd /mnt/boot/EFI/refind
   From here you need to remove either the 32-bit
or the 64-bit bootloader, depending on what your
system is capable of, with rm refind_ia32.efi or rm
refind_x64.efi, and edit the configuration file (nano
refind.conf) to add the details about the partition that
contains the distribution you want to boot. Here’s the
contents if ours for booting Mint 16 – you should take
a look at your boot options first, to make sure you get
                                                                                                                             With Refind copied to a
any kernel options specific to your system:                    delete all data at that location, so get it right and make
                                                                                                                             USB stick, you will be able
resolution 1024 768                                            sure there’s nothing on there you want to keep. You           to boot into UEFI mode and
menuentry “Mint Linux” {                                       can now reboot your system and launch your BIOS/              select the EFI shell.
            icon         EFI/refind/icons/os_linuxmint.icns    system boot menu. You should see the USB stick
            loader vmlinuz                                     appear as a UEFI boot source. Select this and from
            initrd initrd.img                                  the graphical boot menu that appears, choose the first
            options “root=/dev/sda2 rw rootfstype=ext4         option, which should take you to the EFI shell.
add_efi_memmap”
}                                                              Welcome to your new shell
  Our final challenge is to tell the UEFI firmware that        The EFI shell is full of commands for adding, removing
we’ve created a new EFI partition and bootloader. Had          and managing storage from the EFI bootloader.
we been able to boot into the live desktop through             Before you get to the prompt itself, you’ll see how
UEFI, the firmware variables would be mounted                  EFI is interpreting your various filesystems and the
as part of the system, and we’d be able to add the             aliases it’s giving them. For us, fs0: was the USB drive
bootloader by typing:                                          and fs1: was the EFI partition we just created on the
sudo apt-get install efibootmgr                                hard drive, but these assignments will depend on your
efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L new_refind   own system. From the command prompt, type fs1:
   But we can’t. Instead, one solution is to create a          to switch to the root folder of our new EFI partition.
USB stick with the Refind bootloaders installed, and           The EFI shell is crammed full of commands to help
from there, use the EFI shell to add the bootloader            you manage storage and booting. Type help if you
manually. This isn’t really what we’d recommend.               want to see what it’s capable of – you can use ls,
You’re better off installing Mint through a UEFI-              cp and rm, for example. But we’re only going to use
booted USB live image, but the EFI shell is much               one command to add our bootloader to the system
more interesting and can be a very powerful tool if            firmware. We’re assuming you don’t have any other
your system doesn’t boot. Plug in your USB stick and           EFI boot loaders installed, because using one of them
use either GParted or dmesg to find for certain what           would have been a much easier solution for all of this,
its device node is and type the following from the             but you can check by typing bcfg boot dump -b. If
unzipped folder of the Refind flash image:                     you do have another installed, you’ll need to adjust the
dd if=refind-flashdrive-0.7.7.img of=/dev/sde                  number 1 to a free slot in the command below, which
  Remember to replace /dev/sde with the location of            is going to add the new bootloader to the firmware:
your own USB drive and also remember that this will            bcfg boot add 1 fs1:\EFI\refind\refind_x64.efi “LV_Refind”
                                                               **bcfg instructions output
                                                               Target = 0001.
                                                               bcfg: Add Boot0001 as 1
                                                                  And that ’s all there is too it. It’s been a challenge,
                                                               but when you now reboot your machine (type reset
                                                               from the EFI shell), you’ll see LV_Refind as a new EFI
                                                               boot option. Hopefully, you’ve learnt how UEFI works
                                                               and how it’s implemented, and also how you might be
                                                               able to troubleshoot UEFI problems in the future.
                                                                  Adding new distributions, for instance, is now a
                                                               case of copying their kernel and filesystem images
                                                               to the partition and adding a new configuration entry.
                                                               You might also want to look into making symbolic
With Refind added to the system firmware, our boot entry       links for these files for when your distribution updates
should appear from the system (press F12) boot menu.           itself. Other than that, you’re ready to go.



                                                                 www.linuxvoice.com                                                                 95
     CODING PYTHON DRAWING



                               PYTHON DRAWING
       TUTORIAL
                               PRETTY PATTERNS
                               Use the Python turtle to illustrate loops and recursion, and
      BEN EVERARD
                               prove that not all art is quite useless.


                               T
                                          here are some programming techniques, like
 WHY DO THIS?                             loops and recursion, that we use all the time,
 • Gain a better                          almost without thinking. However, sometimes
   understanding
   common programming          it’s hard to really see what’s going on. Being able to
   techniques                  really visualise what’s going on behind the code can
 • Draw pretty pictures        help you become a better programmer.
 • Win a T-shirt!                  Python comes with a turtle module. It’s about as
                               simple as a drawing program can be. It enables you to
                               control a turtle with a pen around the screen. You can
                               tell it to go forwards, turn through various angles, put
                               the pen down or lift it up, and change its colour. In a
                               world where almost everything seems to have OpenGL
                               accelerated graphics, sometimes it’s nice to take a
                               step back and look at what you can create with very
                               little. In this tutorial, we’re going to look at how we can
                               build complex pictures using just this turtle module          The empty handed painter from your streets is drawing
                               and few coding techniques.                                    crazy patterns on your screen, with simple Python.
                                   Let’s start really simply, and just draw a square:
                               import turtle                                                 draw_polygon(6,20)
                               jonney = turtle.Turtle()                                      turtle.exitonclick()
                               for i in range(0,4):                                            Because the turtle module only works in whole
                                 jonney.forward(100)                                         numbers, this won’t work properly for polygons where
                                 jonney.right(90)                                            360/sides isn’t a whole number, but it’s good enough
                               turtle.exitonclick()                                          for our purposes.
                                 That’s all you need. Python will take care of creating
                               the window to display it in. For some reason this             Intensify the artiness
                               author always feels the need to give the turtles              This is an article about creating art from code, and
                               anthropomorphised variable names.                             simple polygons aren’t very attractive. With a few
                                 You can turn this code into more general polygon            tweaks, the function can be made a little more artistic:
                               drawing code by moving the loop into a function like          import turtle
                               as follows:                                                   def draw_spiral(angle, length_start, length_increase, sides):
Figure 1. Recursion
                               import turtle                                                   for i in range(0,sides):
can quickly build up the
                               def draw_polygon(sides, length):                                   jonney.forward(length_start+(i*length_increase))
number of lines in a fractal
as you go to greater             for i in range(0,sides):                                         jonney.right(angle)
depths, so it’s best to call        jonney.forward(length)                                   def draw_petals(length, number):
speed(0) to set it to the           jonney.right(360/sides)                                    for i in range(0, number):
fastest speed.                 jonney = turtle.Turtle()                                           jonney.forward(length)
                                                                                                  jonney.right(180-(360/number))
                                                                                             jonney = turtle.Turtle()
                                                                                             draw_spiral(30, 10, 2, 20)
                                                                                             jonney.penup()
                                                                                             jonney.goto(0,200)
                                                                                             jonney.pendown()
                                                                                             draw_petals(50,20)
                                                                                             turtle.exitonclick()
                                                                                               You can also vary the colour through the loops. This
                                                                                             both helps you see how the images are drawn, and
                                                                                             makes the outcomes a little more impressive. We
                                                                                             changed the draw_petals() function to the following to



96                                                                www.linuxvoice.com
                                                                                                       PYTHON DRAWING CODING

fade the lines from blue through purple to red.                                                                             The Kock snowflake
def draw_petals(length, number):                                                                                            was originally designed
  red=0.0                                                                                                                   by taking a triangle and
  blue=1.0
                                                                                                                            placing a smaller triangle
                                                                                                                            on every edge, then a
  for i in range(0, number):
                                                                                                                            smaller triangle on each
     red=red + (1.0/number)
                                                                                                                            new edge, etc.
     blue = blue - (1.0/number)
     jonney.color(red,0.0,blue)
     jonney.forward(length)
     jonney.right(180-(360/number))
turtle.exitonclick()


Fractals and recursion
You can get quite artistic using loops to draw shapes,
but you can take drawing a stage further using
recursion. (Recursion is just when a function calls
itself.) You can use this to progressively process all the
data in a set, or to draw pretty pictures.
    This might sound a little strange if you’ve never                jonney.forward(length)
thought of trying to draw with code, but actually,                else:
recursion is a really versatile tool in the coder-artist’s           draw_fractal(length, depth-1)
toolbox, and it’s all thanks to a mathematical trick              jonney.left(120)
called fractals.                                                  if depth == 1:
    The idea is really simple. You take a simple line                jonney.forward(length)
shape like figure 1 part 1. Then you replace every line           else:
in the shape with a copy of the lineshape. The result of             draw_fractal(length, depth-1)
doing this once is figure 1 part 2. However, you can              jonney.right(60)
keep doing it as many times as you like, each time you            if depth == 1:
replace every line with a copy of the original line shape.           jonney.forward(length)
Figure 1 part 3 shows it done a third time, but                   else:
assuming you had a high enough resolution display (or                draw_fractal(length, depth-1)
if you kept zooming in), you could just go on repeating
this more and more times.                                       jonney = turtle.Turtle()
    The code we used to create figure 1 is:                     jonney.penup()
import turtle                                                   jonney.goto(-200,0)
def draw_fractal(length, depth):                                jonney.pendown()
  if depth == 1:                                                draw_fractal(15,1)
     jonney.forward(length)                                     turtle.exitonclick()
  else:                                                            In this case, we use the depth function to limit the
     draw_fractal(length, depth-1)                              number of times the recursion happens, otherwise it
  jonney.right(60)                                              could go on indefinitely.
  if depth == 1:                                                   This particular fractal is known as a Kock curve after
                                                                its creator, Helge von Kock. However, this isn’t its
                                                                best-known form. If you use a triangle for the first
  Running Python programs                                       iteration, but revert to the line segment for every other
  Python is a very easy programming language to get             iteration, you get a Kock snowflake as shown above.
  started in. It’s interpreted, which means you don’t              This is created with the code:
  need to compile the code you’ve written before you            import turtle
  can run it, and it’s installed by almost every                def draw_snowflake(length, depth):
  distribution of Linux by default. What’s more, the              draw_fractal(length, depth-1)
  turtle module is part of the standard Python library,           jonney.left(120)
  so you don’t need to install anything to run the code           draw_fractal(length, depth-1)
  in this article. Just enter it into a text editor, save the     jonney.left(120)
  file (a .py file extension is usual, but not required),         draw_fractal(length, depth-1)
  then run it from the command line with:
                                                                jonney = turtle.Turtle()
  python filename.py
                                                                jonney.penup()
  If you don’t end your code with the following, then the
  window will shutdown as soon as it’s finished                 jonney.goto(-200,0)
  running.                                                      jonney.pendown()
  turtle.exitonclick()                                          draw_snowflake(7,4)
                                                                turtle.exitonclick()



                                                                  www.linuxvoice.com                                                                97
     CODING PYTHON DRAWING

                                It also includes the fractal() function from the
                              previous example.
                                You can use this same method of recursion in
                              another way. For example, you can use it to continually
                              add lines in a particular place. For example, you can
                              generate a tree by drawing a ‘Y’ shape, then continually
                              adding smaller ‘Y’ shapes to the end of each branch.
                              See right for how this works out. In part 1 to 3, the
                              depth is 1 to 3 respectively. Part 4 has a depth of 7.
                              This was generated with the code:
                              import turtle


                              def draw_tree(length, depth):
                                jonney.forward(length)
                                if depth > 1:
                                   jonney.left(45)
                                   draw_tree(length/2, depth-1)
                                   jonney.left(90)
                                   draw_tree(length/2, depth-1)
                                   jonney.right(135)
                                jonney.right(180)
                                jonney.forward(length)


                              jonney = turtle.Turtle()
                              jonney.penup()                                             With fractals that get smaller and smaller, you’ll quickly
                              jonney.goto(0,-100)                                        reach the limit of the resolution of the screen.
                              jonney.pendown()
                              jonney.left(90)                                              flip = 1
                              jonney.speed(0)                                              for i in range (0, length2):
                              draw_tree(160,7)                                                jonney.left(angle2)
                                                                                              jonney.forward(length1)
                              turtle.exitonclick()                                            if depth > 1:
                                You can extend this. Instead of drawing a Y shape,               jonney.left(angle1*flip)
                              you can expand a herring bone in the same way (see
                              below). Instead of creating the classic tree shape, this           draw_fern(floor((length1/3)-(i/2), 1), angle1*flip,
                              creates a fern-like drawing. The code for this is:         floor(length2-i,1), angle2*flip, depth-1)
 These ferns are depths 3 import turtle                                                          jonney.left(180-angle1*flip)
 and 5. We’ve spaced it out def floor(x,y):                                                   flip = flip * -1
 to make it easier to see     if x > y:
 what’s going on, but you        return x                                                  jonney.left(180)
 can change the parameters return y
 to create more realistic                                                                  for i in range(0, length2):
 plants.
                              def draw_fern(length1, angle1, length2, angle2, depth):            jonney.forward(length1)
                                                                                                 jonney.right(angle2)


                                                                                         jonney = turtle.Turtle()
                                                                                         jonney.penup()
                                                                                         jonney.goto(0,-100)
                                                                                         jonney.pendown()
                                                                                         jonney.left(90)
                                                                                         jonney.speed(0)
                                                                                         draw_fern(40,60,8,4,1)


                                                                                         turtle.exitonclick()
                                                                                            This particular code is very sensitive to the
                                                                                         parameters you give it. You also can customise the
                                                                                         fractal by changing the way the line lengths are passed
                                                                                         to the next level of recursion, or by progressively
                                                                                         increasing the angle so that the fern starts to curl
                                                                                         towards the end.



98                                                                www.linuxvoice.com
                                                                                                            PYTHON DRAWING CODING

   If you’re feeling really adventurous, you could write a        What we’ve covered in this tutorial may seem a bit
program that flips from the tree recursion to the fern         pointless, flippant even, but we’ve used exactly the
recursion at a certain depth. You can develop fractals         same programming techniques that are used in
like this using different shapes. The key is to make           normal software. By learning how to exploit them to
sure that, at the end of each run of the function, you         draw shapes, you hone your knowledge of how to
return the turtle to the same place it started from.           structure code, and this can only make you a better
                                                               programmer whatever language you use.
Fantastic Mr Fractal                                              There are also a few cases where fractals
There are loads of possible fractals you could draw,           themselves are useful to programmers – for example,
and a quick web search will pull some up. One thing to         in creating complex terrain in video games.
remember when programming fractals like the fern
and the tree is to make sure you always finish the
                                                                 Ben Everard is the co-author of Learning Python with
fuction at the same physical location the turtle started         Raspberry Pi, soon to be published by Wiley. He’s also pretty
it. Otherwise it’ll end up chaotic.                              good at turning foraged fruit into alcohol.



                                                               Competition time

  You’ve seen how, by using iteration and loops,          The artwork produced can be in any               colour, and garish entries will be looked upon
  you can create complex drawings with very               category. Abstract, still life,                  favourably.
  little code. In this competition, we’re going to        impressionism, cubeism. Sculpture is             jonney = turtle.Turtle()
  put this to the test. The challenge is to create        probably out, but otherwise, anything            jonney.speed(0)
  a Python program that uses the turtle module            goes as long as it looks good.                   jonney.left(90)
  to draw something. I have to be able to                 Up to three entries per person will be           jonney.width(2)
  output the code, and the winner will be the             accepted.                                        draw_tree(128,6)
  person that creates what we think is the best           You don’t have to buy a copy of Linux            jonney.width(1)
  piece of art. To put your coding skills to the          Voice to be eligible. Feel free to pass on       jonney.penup()
  test, we’re going to give you a limit of 100            the competition details to non LV                jonney.goto(210,0)
  lines of Python – no more.                              readers, and details will be posted on           for i in range(0, 10):
      You may have noticed that we haven’t                www.linuxvoice.com.                                for j in range(0,10):
  really tried to keep our code short in this             Turtles don’t have to be called Jonney,                jonney.pendown()
  tutorial and quite a few of the functions we’ve         and you don’t have to limit yourself to a              draw_snowflake((i+j)%3+1,2)
  used can be shortened if needed.                        single turtle.                                         jonney.penup()
      The rules are:                                    To give you an example of what we’re                     jonney.setheading(90)
        Using only the turtle module, and no         looking for, take a look at figure 5. This was              jonney.forward(30)
        more than 100 lines of Python (2 or 3,       created with the following code (the                    jonney.setheading(270)
        your choice), you must draw a picture.       functions for the tree() and snowflake() as as          jonney.forward(300)
        You may use any of the techniques here,      they’re given earlier in the tutorial, and not          jonney.setheading(180)
        or any others you invent, copy, steal or     repeated here, though if you wish to use them           jonney.forward(50)
        otherwise come across.                       in your example, you WILL have to include             turtle.exitonclick()
        The only module you can use is the turtle    them in your 100 lines). Although this picture        Good luck, have fun, and remember that while
        module. Any other import lines will be       doesn’t make it look like it, the judge does like     good artists borrow, great artisits steal!
        deleted.
        Pictures will be judged on artistic merit.
        The judge’s decision is final.
        Lines of comments are allowed (and
        encouraged) and won’t be included in the
        100 line count. Feel free to add
        information to your program, and all
        programs must be licenced under an OSI
        approved open source licence. Preferably
        the GPLv3, though you can use a
        different one should you so choose.
        In order to enter, send your entries to
        ben@linuxvoice.com by 1 May 2014.
        The winner will receive an exclusive
        Linux Voice competition winner’s T-shirt.
        These are not, and will not, be available
        in the shops. The only way to get one is
        to submit a winning entry to a Linux          It may be spring now, but the long, dark winter is still vivid in our memories. Help us forget
        Voice competition.                           it with some uplifting artwork, and give yourself the opportunity to win clothing!




                                                                  www.linuxvoice.com                                                                        99
      CODING CONCEPTS



                               KEY EXCHANGE: THE
        TUTORIAL
                               SCIENCE OF SECURITY
                               Maths and physics – two ways of keeping your data
      BEN EVERARD
                               safe. Read on, bold explorer…


                               W
                                            e’re used to thinking of secure               exchange algorithm, which doesn’t use public keys.
 WHY DO THIS?                               communications in terms of encryption. If     There’s no long-term data that could be compromised
 • Understand advanced                      an attacker can’t crack the encryption then   that could be used to decrypt past data wholesale.
   cyptography techniques.
                               they can’t get into the data, right? Wrong. The
 • Beat GCHQ (and the CIA
   as well).                   encryption method is only one of the many parts that       Perfect security
 • Gives you an excuse         make up a secure exchange.                                 The Diffie-Hellman algorithm involves three parts that
   to use the laser beams        One chink in the electronic armour is the key            are combined to make the key. It also needs a method
   that you’re stuck to your   exchange. That is, the process by which the two            of combining them that is a form of encryption, which
   sharks’ heads.
                               parties decide on which key to use for the symmetric       has the basic property that (s + a) + b is the same as
                               encryption. They both have to know the key, so this        (s + b) + a. The ‘+’ symbol is used here generically to
                               has to travel between them in order to communicate.        mean any secure form of combination. By secure, we
                               However, an attacker may be listening in, and the key      mean that if you know s and (s+a), you can’t use that
                               has to be sent in such a way as to stop them being         to work out a.
                               able to find it out.                                          If Alice wants to communicate with Bob, and GCHQ
                                 The simplest way to agree on a key is to use public      are trying to listen in, Alice starts by sending Bob a
                               key cryptography. In this, one party can simply            random number that we’ll call s. This is sent in plain
                               generate a symmetric key, encrypt it with the other’s      text, so everyone can read it. Then, both Alice and Bob
                               public key, and send it. Then both parties can             make up their own random numbers. We’ll call these a
                               communicate using the symmetric key.                       and b respectively. They don’t send them, but combine
                                 It’s a very simple method, and it works fine. Anyone     them with s first. Alice then sends (s + a) to Bob, and
                               who intercepts the message won’t be able to read it        Bob replies with (s + b).
                               because they don’t have the private key to decrypt the        Now they have these, Alice can calculate (s + a) + b,
                               message. The only flaw is the fact that the symmetric      while Bob can calculate (s + b) + a. As we’ve said,
                               keys are used over a long period of time, and if one is    these are equal, so they’re used as the symmetric key.
                               compromised once, all previous messages can be                GCHQ knows a, (s + a) and (s + b) , but has no way
                               decrypted. This is a particular problem when               of calculating (s + a) + b provided we have picked a
GCHQ can listen in on          organisations like GCHQ and the NSA are intercepting       suitably secure method for combining the numbers.
steps 1, 2 and 3, but they     and storing huge amounts of data.                          As with all encryption methods, if a suitably powerful
won’t be able to find out        Stopping this is known as Perfect Forward Secrecy        computer could be found, then it would be possible to
the key.                       (or PFS), and is possible using the Diffie-Hellman key     subject this to a brute-force to find the key. However,
                                                                                          this would have to be done separately for each run of
                                                                                          Diffie-Hellman rather than just once, making it a far
                                   Step 1: p=23, g=18                                     less attractive proposition.
                                                                                             The method that Diffie and Hellman used to
                                 Step 2 : (g mod p) = 9                                   combine s, a and b is the fact that for a prime number
                                                                                          (p), and a primitive root (g), (g mod p) mod p = (g
                                  Step 3: (g mod p) = 6                                   mod p) mod b. Therefore, both p and g are sent in
                                                                                          plain text first, then (s + a) was g mod p and (s + b)
                                                                                          was g mod p.

                                                                                          A quantum of security
                                                                                          Diffie-Hellman requires us to have a method of
                                                                                          combining the numbers that can’t be broken. While
                                                                                          there are several options with no known weaknesses,
               Alice                                               Bob
                                                                                          it’s possible that a way will be found to decompose
                a=7                                                b=10
                                                                                          the messages (s + a) and (s + b), and this would allow
       Step 4: 9 mod 23 = 4                               Step 4: 6 mod 23 = 4
                                                                                          an attacker to break the encryption.
              Key = 4                                            Key = 4
                                                                                              Instead of relying on mathematical properties to
                                                                                          allow you to transmit the data securely, you could rely



100                                                            www.linuxvoice.com
                                                                                                                  CONCEPTS CODING

on physical properties. If our key exchange is
protected by the laws of physics, we can be far more           Public and symmetric key encryption
confident that GCHQ isn’t listening in.
   This is possible using the Quantum Key Distribution         There are two different types of            encryption), there is just one key to
algorithm. In this method, each bit of information is          encryption: public key and symmetric        encrypt and decrypt the message.
                                                               key. In public key encryption, everyone        Symmetric key encryption is
encoded as a single photon sent from Alice to Bob.
                                                               has two keys, one public, one private.      much faster the public key, and so is
The data is in the polarisation. If you think of the light
                                                               The public key is made public, while        used for almost all purposes except
wave travelling through space, the wave could be               the private key is known only to that       authentication. SSH, for example,
moving up and down, side to side, or at any other              user. When someone wants to send            will use public key encryption to
orientation. This orientation of the wave is its               data to the user, they can encrypt it       make sure that the server you’re
polarisation                                                   with the public key, and then it’s only     communicating with is really who it
   It is possible to measure the polarisation, but not         decryptable with the private key.           says it is, and once that’s done it will
precisely. Because of quantum indeterminacy, you                 In symmetric key encryption               negotiate a symmetric key using one
can only measure it against two perpendicular axes.            (sometimes known as private key             of these key distribution algorithms.
For example, if you set your axes as vertical and
horizontal (0 and 90 degrees), and a photon is
polarised at 0 degrees, you’ll get a reading as vertical,    90 is 1. She then sends a series of 0s and 1s with
and likewise for a horizontal photon. However, if a          photons and switches between vertical and diagonal
photon has a polarisation of 45 degrees, there’s a 50%       at random.
chance you’ll get a reading of vertical and a 50%               Bob has receiving equipment that he can set up at
chance of horizontal.                                        vertical and diagonal orientations as well. However, if
   What’s more, by reading the state of the photon, you      he is set up vertical while Alice is set up diagonal, he
destroy it.                                                  will receive the photon incorrectly, and likewise if he is
   Using these two properties, Charles Bennet and            diagonal and Alice is vertical. As Alice sends her
Gilles Brassard developed a system to send a key so          stream of ones and zeros, Bob also randomly
that it can’t be intercepted. Again, we’ll look at an        changes between vertical and diagonal.
example where Alice sends a key to Bob and GCHQ
tries to listen in.                                          Keep GCHQ in the dark
   Alice has a photon transmitter that can send              After Alice has sent a long enough string of bits, she
polarised photons in four different orientations: 0          sends Bob a list of what orientations she was using
degrees, 45 degrees, 90 degrees and 135 degrees.             for which bits. Bob compares this to how he had his
These are in two groups: 0 and 90 are vertical, while        receiving equipment set up. On average, they should
45 and 135 are diagonal. For each photon, she                have had the same
randomly selects to use either vertical or diagonal. In
vertical, 0 degrees represents a binary 0 and 90
                                                             orientation for half of the
                                                             bits, so Bob replies by        “Quantum Key Distribution
degrees represents a binary 1. In diagonal, 45 is 0 and      saying which bits he was
                                                                                            sounds fanciful, but there are
                                                                                            already some implementations.”
                                                             correctly set up for. Both of
                                                             these messages can go
                                                             unencrypted since they are
                                                             no use to an attacker. Alice and Bob can then use the
                                                             values of bits that Bob received correctly as the key.
                                                                GCHQ can’t intercept the photons since they don’t
                                                             know what orientation Alice is as she sends them.
                                                                For example, If Alice is vertical, and GCHQ intercept
                                                             the photon, they have to guess between vertical and
                                                             diagonal. If they are diagonal, then there’s a 50%
                                                             chance that they will read it incorrectly. In reading in,
                                                             they destroy the original photon, so they have to
                                                             create a new one to send to Bob. They have no way of
                                                             knowing if they read the original one correctly, so they
                                                             can’t be sure either what value it is or what orientation
                                                             Alice was in. They may get lucky on a few photons,
                                                             but if they’re building up a key of 512 bits, then the
                                                             errors will quickly mount up.
                                                                This might sound fanciful, but there are already
                                                             some implementations, and April 2014 marks the
To see if you’re using PFS, look at the technical details    tenth anniversary of the first bank transfer protected
of the certificate. If you see ECDHE (Eliptic Curve Diffie   by Quantum Key Distribution (see www.secoqc.net/
Hellman Ephemeral) or DHE (Diffie Hellman Ephemeral),        downloads/pressrelease/Banktransfer_english.pdf
then you have perfect forward security.                      for details).



                                                               www.linuxvoice.com                                                                     101
      CODING KERNEL



                            LINUX KERNEL:
       TUTORIAL
                            YOUR FIRST MODULE
          VALENTINE         Ever wanted to start hacking the kernel? Don’t have a
           SINITSYN         clue how to begin? Let us show you how it’s done…


                            K
                                      ernel programming is often seen as a black
 WHY DO THIS?                         magic. In Arthur C Clarke’s sense, it probably
 • Understand the common              is. The Linux kernel is quite different from its
   features shared by all
   kernel modules.          user space: many abstractions are waived, and you
 • Earn brownie points in   have to take extra care, as a bug in you code affects
   job interviews.          the whole system. There is no easy way to do
 • Tinker with the          floating-point maths, the stack is fixed and small, and
   foundations of your      the code you write is always asynchronous so you
   Linux machine.
                            need to think about the concurrency. Despite all of this
                            though, the Linux kernel is just a very large and
                            complex C program that is open for everyone to read,
                            learn and improve, and you too can be a part of it.
                               Probably the easiest way to start kernel
                            programming is to write a module – a piece of code
                            that can be dynamically loaded into the kernel and           LXR (Linux Cross Reference) is a web-based system for
                                                                                         navigating Linux sources (and other large codebases).
                            removed from it. There are limits to what modules can
                            do – for example, they can’t add or remove fields to
                            common data structures like process descriptors. But         implement it at the kernel level as well. A word of
                            in all other ways they are full-fledged kernel-level code,   warning before we start: a bug in your module may
                            and they can always be compiled into the kernel (thus        lead to a system crash and (unlikely, but possible)
                            removing all the restrictions) if needed. It is fully        data loss. Be sure you’ve backed up all your important
                            possible to develop and compile a module outside the         data before you start, or, even better, experiment in a
                            Linux source tree (this is unsurprisingly called an          virtual machine.
                            out-of-tree build), which is very convenient if you just
                            want to play a bit and do not wish to submit your            A module’s anatomy
                            changes for inclusion into the mainline kernel.              As most of the Linux kernel modules are written in C.
                               In this tutorial, we’ll develop a simple kernel module    (apart from low-level architecture-specific parts), it is
                            that creates a /dev/reverse device. A string written to      recommended that you keep your module in a single
                            this device is read back with the word order reversed        file (say, reverse.c). To begin, let’s include some
                            (“Hello World” becomes “World Hello”). It is a popular       common headers and describe the module using
                            programmer interview puzzle, and you are likely to get       predefined macros:
                            some bonus points when you show the ability to               #include <linux/init.h>
                                                                                         #include <linux/kernel.h>

                              The environment                                            #include <linux/module.h>


                              To develop kernel code, you’ll need a decent text          MODULE_LICENSE(“GPL”);
                              editor. Choosing one is actually a matter of taste,        MODULE_AUTHOR(“Valentine Sinitsyn <valentine.sinitsyn@
                              however many kernel developers tend to use either          gmail.com>”);
                              Vim or Emacs, and Linus prefers his own flavor of          MODULE_DESCRIPTION(“In-kernel phrase reverser”);
                              the MicroEMACS editor. If you prefer IDEs (although          Everything is straightforward here, except for
                              they aren’t very useful for kernel development), you       MODULE_LICENSE(): it is not a mere marker. The
                              can easily google for recommendations how to setup         kernel strongly favours GPL-compatible code, so if you
                              Eclipse CDT.                                               set the licence to something non GPL-compatible
                                 Regardless the editor you chose, your code
                                                                                         (say, “Proprietary”), certain kernel functions will not be
                              should always follow Linux Coding Style guidelines
                                                                                         available to your module.
                              (Documentation/CodingStyle). Probably the easiest
                              way to do this is to use indent(1) utility. Simply run       Since kernel programming is always asynchronous,
                              indent --linux-style on your module’s source before        there is no main() function that Linux executes
                              letting anyone to see it.                                  sequentially to run your module. Instead, you provide
                                                                                         callbacks for various events, like this:


102                                                          www.linuxvoice.com
                                                                                                                                 KERNEL CODING

static int __init reverse_init(void)
{
                                                                  Navigation
  printk(KERN_INFO “reverse device has been registered\n”);
                                                                  The Linux kernel is the ultimate source for everything
  return 0;
                                                                  you may need when developing modules. However,
}                                                                 it’s quite big, and you may have trouble trying to
                                                                  find what you are after. Luckily, there are tools that
static void __exit reverse_exit(void)                             make it easier to navigate large codebases. First of
{                                                                 all, there is Cscope – a venerable tool that runs in a
  printk(KERN_INFO “reverse device has been unregistered\n”);     terminal. Simply run make cscope && cscope in the
}                                                                 kernel sources top-level directory. Cscope integrates
                                                                  well with Vim and Emacs, so you can use it without
module_init(reverse_init);                                        leaving the comfort of your favorite editor.
module_exit(reverse_exit);
                                                                      If terminal-based tools aren’t your cup of tea,
                                                                  visit http://lxr.free-electrons.com. It is a web-based
   Here, we define functions to be called on the
                                                                  kernel navigation tool with not quie as many features
module’s insertion and removal. Only the first one is
                                                                  as Cscope (for example, you can’t easily find usages
required. For now, they simply print a message to the             for the function), but it still provides enough for the
kernel ring buffer (accessible from the userspace via             quick lookups.
the dmesg command); KERN_INFO is a log level (note
there is no comma). __init and __exit are attributes –
the pieces of metadata attached to functions (or                  if (!buffer_size)
variables). Attributes are rarely seen in userspace C                return -1;
code but are pretty common in the kernel. Everything              printk(KERN_INFO
marked with __init is recycled after the initialisation                “reverse device has been registered, buffer size is %lu
(remember the old “Freeing unused kernel memory…”               bytes\n”,
message?). __exit denotes functions that are safe to                   buffer_size);
optimise out when the code is built statically into the           return 0;
kernel. Finally, the module_init() and module_exit()            }
macros set reverse_init() and reverse_exit() functions
as lifecycle callbacks for our module. The actual               Non-zero return value from a module init function indicates a
function names aren’t important; you can call them              failure.
init() and exit() or start() and stop(), if you wish. They         Now it’s time to compile the module. You will need
are declared static and hence invisible outside your            the headers for the kernel version you are running
module. In fact, any function in the kernel is invisible        (linux-headers or equivalent package) and build-
unless explicitly exported. However, prefixing your             essential (or analogous). Next, it’s time to create a
functions with a module name is a common                        boilerplate Makefile:
convention among kernel programmers.                            obj-m += reverse.o
   These are bare bones – let’s make things more                all:
interesting. Modules can accept parameters, like this:             make -C /lib/modules/$(shell uname -r)/build M=$(PWD)
# modprobe foo bar=1                                            modules
  The modinfo command displays all parameters                   clean:
accepted by the module, and these are also available               make -C /lib/modules/$(shell uname -r)/build M=$(PWD)
under /sys/module/<name>/parameters as files. Our               clean
module will need a buffer to store phrases – let’s                Now, call make to build your first module. If you
make its size user-configurable. Add the following              typed everything correctly, you will find reverse.ko in
three lines just below MODULE_DESCRIPTION():
                                                                                                                                  Reversing a word is simple,
static unsigned long buffer_size = 8192;
                                                                                                                                  but it is also a main
module_param(buffer_size, ulong, (S_IRUSR | S_IRGRP | S_                                                                          building block for reversing
IROTH));                                                                                                                          a phrase.
MODULE_PARM_DESC(buffer_size, “Internal buffer size”);
Here, we define a variable to store the value, wrap it
into a parameter, and make it readable by everyone via
sysfs. The parameter’s description (the last line)
appears in the modinfo’s output.
   As the user can set buffer_size directly, we need to
sanitize it in reverse_init(). You should always check
the data that comes outside the kernel – if you don’t,
you are opening yourself to kernel panics or even
security holes.
static int __init reverse_init()
{



                                                                  www.linuxvoice.com                                                                     103
      CODING KERNEL

                  the current directory. Insert it with sudo insmod                   static struct file_operations reverse_fops = {
                  reverse.ko, and run:                                                   .owner = THIS_MODULE,
                  $ dmesg | tail -1                                                      .open = reverse_open,
                  [ 5905.042081] reverse device has been registered, buffer size is      ...
                  8192 bytes                                                             .llseek = noop_llseek
                     Congratulations! However, for now this line is telling           };
                  lies – there is no device node yet. Let’s fix it.                      Again, reverse_fops contains a set of callbacks
                                                                                      (also known as methods) to be executed when
                  Miscellaneous devices                                               userspace code opens a device, reads from it, writes
                  In Linux, there is a special character device type called           to it or closes the file descriptor. If you omit any of
                  “miscellaneous” (or simply “misc”). It is designed for              these, a sensible fallback will be used instead. That’s
                  small device drivers with a single entry point, and is              why we explicitly set the llseek method to noop_
                  exactly what we need. All misc devices share the                    llseek(), which (as the name implies) does nothing.
                  same major number (10), so the one driver (drivers/                 The default implementation changes a file pointer, and
                  char/misc.c) can look after all of them, and they are               we don’t want our device to be seekable now (this will
                  distinguished by their minor numbers. In all other                  be your home assignment for today).
                  senses, they are just normal character devices.
                     To register a minor number (and an entry point) for              I open at the close
                  the device, you declare struct misc_device, fill its                Let’s implement the methods. We’ll allocate a new
                  fields (note the syntax), and call misc_register() with a           buffer for each file descriptor opened, and free it on
                  pointer to this structure. For this to work, you will also          close. This is not really safe: if a userspace application
                  need to include the linux/miscdevice.h header file:                 leaks descriptors (perhaps intentionally), it may hog
                  static struct miscdevice reverse_misc_device = {                    the RAM, and render the system unusable. You should
                     .minor = MISC_DYNAMIC_MINOR,                                     always think about these possibilities in the real world,
                     .name = “reverse”,                                               but for the tutorial, it’s acceptable.
                     .fops = &reverse_fops                                               We’ll need a structure to describe the buffer. The
                  };                                                                  kernel provides many generic data structures: linked
                  static int __init reverse_init()                                    lists (which are double-linked), hash tables, trees and
                  {                                                                   so on. However, buffers are usually implemented from
                     ...                                                              scratch. We will call ours “struct buffer”:
                     misc_register(&reverse_misc_device);                             struct buffer {
                     printk(KERN_INFO ...                                                char *data, *end, *read_ptr;
                  }                                                                      unsigned long size;
                  Here, we request a first available (dynamic) minor                  };
                  number for the device named “reverse”; th ellipsis                    data is a pointer to the string this buffer stores, and
                  indicates omitted code that we’ve already seen. Don’t               end is the first byte after the string end. read_ptr is
                  forget to unregister the device on the module’s                     where read() should start reading the data from. The
                  teardown:                                                           buffer size is stored for the completeness – for now,
                  static void __exit reverse_exit(void)                               we don’t use this field. You shouldn’t assume the
                  {                                                                   users of your structure will correctly initialise all of
                    misc_deregister(&reverse_misc_device);                            these, so it is better to encapsulate buffer allocation
                    ...                                                               and deallocation in functions. They are usually named
                  }                                                                   buffer_alloc() and buffer_free().
                    The ‘fops’ field stores a pointer to a struct file_               static struct buffer *buffer_alloc(unsigned long size)
                  operations (declared in linux/fs.h), and this is the                {
                  entry point for our module. reverse_fops is defined as:               struct buffer *buf;
                                                                                        buf = kzalloc(sizeof(*buf), GFP_KERNEL);
                                                                                        if (unlikely(!buf))
                      Avoid root if possible                                                goto out;
                                                                                        ...
                      By default, /dev/reverse is available to root only, so           out:
                      you’ll have to run your test programs with sudo. To               return buf;
                      fix this, create /lib/udev/rules.d/99-reverse.rules file
                                                                                      }
                      that contains:
                                                                                         Kernel memory is allocated with kmalloc() and
                      SUBSYSTEM==”misc”, KERNEL==”reverse”, MODE=”0666”
                        Don’t forget to reinsert the module. Making device            freed with kfree(); the kzalloc() flavour sets the
                      nodes accessible to non-root users is generally not a           memory to all-zeroes. Unlike standard malloc(), its
                      good idea, but it is quite useful during development.           kernel counterpart receives flags specifying the type
                      This is not to mention that running test binaries as            of memory requested in the second argument. Here,
                      root is not a good idea either.                                 GFP_KERNEL means we need a normal kernel
                                                                                      memory (not in DMA or high-memory zones) and the



104                                                    www.linuxvoice.com
                                                                                                                                      KERNEL CODING


                                                                    When not to write a kernel module
                                                                    Kernel programming is fun, but writing                 You develop a filesystem – try FUSE
                                                                    (and especially debugging) kernel code                 (fuse.sf.net).
                                                                    in a real-world project requires certain               You are extending Netfilter –
                                                                    skills. In general, you should descend to              libnetfilter_queue may help you
                                                                    the kernel level only if there is no other             then (www.netfilter.org/projects/
                                                                    way to solve your problem. Chances are                 libnetfilter_queue).
                                                                    you can stay in the userspace if:                    Generally, native kernel code will
                                                                      You develop a USB driver – have a                  perform better, but for many projects
Our first module is small but real: it registers a device             look at libusb (www.libusb.org).                   this performance loss isn’t crucial.
node and has its own entry in sysfs.

function can sleep (reschedule the process) if needed.            method do if there is no data in the buffer yet? In
sizeof(*buf) is a common way to get the size of a                 userspace, the read() call would block until the data is
structure accessible via pointer.                                 available. In the kernel, you must wait. Luckily, there is
   You should always check kmalloc()’s return value:              a mechanism for this, and it is called ‘wait queues’.
dereferencing NULL pointer will result in kernel panic.              The idea is simple. If a current process needs to
Also note the use of unlikely() macro. It (and the                wait for some event, its descriptor (a struct task_
opposite likely() macro) is widely used in the kernel to          struct stored as ‘current’) is put into non-runnable
signify that the condition is almost always true (or              (sleeping) state and added to a queue. Then
false). It doesn’t affect control flow, but helps modern          schedule() is called to select another process to run. A
processors to boost performance with branch                       code that generates the event uses the queue to wake
prediction.                                                       up the waiters by putting them back to the TASK_
   Finally, note the gotos. They are often considered             RUNNING state. The scheduler will select one of them
evil, however, the Linux kernel (and some other system            somewhere in the future. Linux has several non-
software) employs them to implement centralised                   runnable process states, most notably TASK_
function exiting. This results in less deeply nested and          INTERRUPTIBLE (a sleep that can be interrupted with
more readable code, and is much like the try-ctach                a signal) and TASK_KILLABLE (a sleeping process
blocks used in higher-level languages.                            that can be killed). All of this should be handled
   With buffer_alloc() and buffer_free() in place, the            correctly, and wait queues do this for you.
implementation of the open and close methods                         A natural place to store our read wait queue head is
becomes pretty straightforward.                                   struct buffer, so start with adding wait_queue_head_t
static int reverse_open(struct inode *inode, struct file *file)   read_queue field to it. You should also include linux/
{                                                                 sched.h. A wait queue can be declared statically with
  int err = 0;                                                    DECLARE_WAITQUEUE() macro. In our case, dynamic
  file->private_data = buffer_alloc(buffer_size);                 initialisation is needed, so add this line to buffer_
  ...                                                             alloc():
  return err;                                                     init_waitqueue_head(&buf->read_queue);
}                                                                 We wait for the data to be available; or for read_ptr !=
   struct file is a standard kernel data structure that           end condition to become true. We also want the wait
stores information about an opened file, like current             to be interruptible (say, by Ctrl+C). So the “read”
file position (file->f_pos), flags (file->f_flags), or open       method should start like this:
mode (file->f_mode). Another field, file->private_data            static ssize_t reverse_read(struct file *file, char __user * out,
is used to associate the file with some arbitrary data.                        size_t size, loff_t * off)
Its type is void *, and it is opaque to the kernel outside        {
the file’s owner. We store a buffer there.                          struct buffer *buf = file->private_data;
   If the buffer allocation fails, we indicate this to the          ssize_t result;
calling user space code by returning negative value                 while (buf->read_ptr == buf->end) {
(-ENOMEM). A C library doing open(2) system call                        if (file->f_flags & O_NONBLOCK) {
(probably, glibc) will detect this and set errno                           result = -EAGAIN;
appropriately.                                                             goto out;
                                                                        }
Learn to read and write                                                 if (wait_event_interruptible
“Read” and “write” methods are where the real job is                       (buf->read_queue, buf->read_ptr != buf->end)) {
done. When data is written to a buffer, we drop its                        result = -ERESTARTSYS;
previous contents and reverse the phrase in-place,                         goto out;
without any temporary storage. The read method                          }
simply copies the data from the kernel buffer into the              }
userspace. But what should the reverse_read()                       ...



                                                                    www.linuxvoice.com                                                                       105
      CODING KERNEL

                                                                                           reverse_phrase() does all heavy lifting. It relies on the
                                                                                           reverse_word() function, which is quite short and
                                                                                           marked inline. This is another common optimisation;
                                                                                           however, you shouldn’t overuse it, since aggressive
                                                                                           inlining makes the kernel image unnecessarily large.
                                                                                              Finally, we need to wake up processes waiting for
                                                                                           the data at read_queue, as described earlier. wake_
                                                                                           up_interruptible() does just that:
                                                                                             wake_up_interruptible(&buf->read_queue);
                                                                                             Phew! You now have a kernel module that at least
                                                                                           compiles. It’s time to test it.

                                                                                           Surprise, surprise!
                                                                                           Compile the module and load it into the kernel:
                                                                                           $ make
                                                                                           $ sudo insmod reverse.ko buffer_size=2048
                                                                                           $ lsmod
                                                                                           reverse           2419 0
Ever wondered how
                             We loop until the data is available and use wait_             $ ls -l /dev/reverse
the read(2) system call
reaches reverse_read()?   event_interruptible() (it’s a macro, not a function,             crw-rw-rw- 1 root root 10, 58 Feb 22 15:53 /dev/reverse
This diagram explains.    that’s why the queue is passed by value) to wait if it             Everything seems to be in place. Now, to test how
                          isn’t. If wait_event_interruptible() is, well, interrupted, it   the module works, we’ll write a small program that
                          returns a non-zero value, which we translate to                  reverses its first command line argument. The main()
                          -ERESTARTSYS. This code means the system call                    function (sans error checking) may look like this:
                          should be restarted. file->f_flags check accounts for            int fd = open(“/dev/reverse”, O_RDWR);
                          files opened in non-blocking mode: if there is no data,          write(fd, argv[1], strlen(argv[1]));
                          we return -EAGAIN.                                               read(fd, argv[1], strlen(argv[1]));
                             We can’t use if() instead of while(), since there can         printf(“Read: %s\n”, argv[1]);
                          be many processes waiting for the data. When the                   Run it as:
                          write method awakes them, the scheduler chooses                  $ ./test ‘A quick brown fox jumped over the lazy dog’
                          the one to run in an unpredictable way, so by the time           Read: dog lazy the over jumped fox brown quick A
                          this code is given a chance to execute, the buffer can           It works! Play with it a little: try passing single-word or
                          be empty again. Now we need to copy the data from                single-letter phrases, empty or non-English strings (if
                          buf->data to the userspace. The copy_to_user()                   you have a keyboard layout set) and anything else.
                          kernel function does just that:                                     Now let’s make things a little trickier. We’ll create
                            size = min(size, (size_t) (buf->end - buf->read_ptr));         two processes that share the file descriptor (and
                            if (copy_to_user(out, buf->read_ptr, size)) {                  hence the kernel buffer). One will continuously write
                               result = -EFAULT;                                           strings to the device, and another will read them. The
                               goto out;                                                   fork(2) system call is used in the example below, but
                            }                                                              pthreads will work as well. I also omitted the code that
                             The call can fail if the user space pointer is wrong; if      opens and closes the device and does the error
                          this happen, we return -EFAULT. Remember not to                  checking (again):
                          trust anything coming outside the kernel!                        char *phrase = “A quick brown fox jumped over the lazy dog”,
                            buf->read_ptr += size;                                         if (fork())
                            result = size;                                                    /* Parent is the writer */
                           out:                                                               while (1)
                            return result;                                                       write(fd, phrase, len);
                          }                                                                else
                             Simple arithmetic is needed so the data can be read              /* child is the reader */
                          in arbitrary chunks. The method returns the number                  while (1) {
                          of bytes read or an error code.                                        read(fd, buf, len);
                             Write method is simpler and shorter. First, we check                printf(“Read: %s\n”, buf);
                          that the buffer have enough space, then we use the                  }
                          copy_from_userspace() function to get the data. Then              What you expect this program to output? Below is
                          read_ptr and end pointers are reset and the buffer               what I’ve got on my laptop:
                          contents are reversed:                                           Read: dog lazy the over jumped fox brown quick A
                            buf->end = buf->data + size;                                   Read: A kcicq brown fox jumped over the lazy dog
                            buf->read_ptr = buf->data;                                     Read: A kciuq nworb xor jumped fox brown quick A
                            if (buf->end > buf->data)                                      Read: A kciuq nworb xor jumped fox brown quick A
                               reverse_phrase(buf->data, buf->end - 1);                    ...



106                                                            www.linuxvoice.com
                                                                                                                                      KERNEL CODING

   What’s going on here? It’s a race. We thought read
and write were atomic, or executed one instruction at                 Debugging kernel code
a time from the beginning till the end. However the
                                                                      Perhaps the most common debugging                 in the Makefile. After that, use dmesg to
kernel is a concurrent beast, and it can easily                       method in the kernel is printing. You             view debug messages generated by
reschedule the process running the kernel-mode part                   can use plain printk() (presumably with           pr_debug() or pr_devel().
of the write operation somewhere inside reverse_                      KERN_DEBUG log level) if you wish.                   Alternatively, you can send debug
phrase() function. If the process that does read() is                 However, there are better ways. Use               messages directly to the console. To do
scheduled before the writer is given a chance to finish,              pr_debug() or dev_dbg(), if you are               this, either set console_loglevel kernel
it will see the data in an inconsistent state. Such bugs              writing a device driver that has its own          variable to 8 or greater (echo 8 > /proc/
are really hard to debug. But how to fix it?                          “struct device”: they support the                 sys/kernel/printk) or temporarily print
   Basically, we need to ensure that no read method                   dynamic debug (dyndbg) feature and                the debug message in question at the
can be executed until the write method returns. If you                can be enabled or disabled on request             high log level like KERN_ERR. Naturally,
                                                                      (see Documentation/dynamic-debug-                 you should remove debug statements of
ever programmed a multi-threaded application, you’ve
                                                                      howto.txt). For pure development                  this kind before publishing your code.
probably seen synchronisation primitives (locks) like
                                                                      messages, use pr_devel(), which                      Note that kernel messages appear on
mutexes or semaphores. Linux has them as well, but                    becomes a no-op unless DEBUG is                   the console, not in a terminal emulator
there are nuances. Kernel code can run in the process                 defined. To enable DEBUG for our                  window such as Xterm; that’s why you’ll
context (working “on behalf” of the userspace code, as                module, include:                                  find recommendations not to do kernel
our methods do) and in the interrupt context (for                     CFLAGS_reverse.o := -DDEBUG                       development in the X environment.
example, in an IRQ handler). If you are in the process
context and a lock you need has already been taken,
you simply sleep and retry until you succeed. You                            goto out;
can’t sleep in the interrupt context, so the code spins                  }
in a loop until the lock become available. The                       }
corresponding primitive is called a spinlock, but in our               Below is our “wait for the data” loop. You should
case, a simple mutex – an object that only one                      never sleep when holding a mutex, or a situation
process can “hold” at the given time – is sufficient. A             called a “deadlock” may occur. So, if there is no data,
real-world code may also use a read-write semaphore,                we release the mutex and call wait_event_
for performance reasons.                                            interruptible(). When it returns, we reacquire the
   Locks always protect some data (in our case, a                   mutex and continue as usual:
“struct buffer” instance), and it is very common to                  if (copy_to_user(out, buf->read_ptr, size)) {
embed them in a structure they are protecting. So we                     result = -EFAULT;
add a mutex (‘struct mutex lock’) into the “struct                       goto out_unlock;
buffer”. We must also initialise the mutex with mutex_               }
init(); buffer_alloc() is a good place for this. The code            ...
that uses mutexes must also include linux/mutex.h.                  out_unlock:
   A mutex is much like a traffic light – it’s useless               mutex_unlock(&buf->lock);
unless drivers look at it and follow the signals. So we             out:
need to update reverse_read() and reverse_read() to                  return result;
acquire the mutex before doing anything to the buffer                 Finally, the mutex is unlocked when the function
and release it when they are done. Let’s have a look at             ends or if an error occurs while the mutex is being
read method – write works just the same way:                        held. Recompile the module (don’t forget to reload it)
static ssize_t reverse_read(struct file *file, char __user * out,   and run the second test again. You should see no
          size_t size, loff_t * off)                                corrupted data now.
{
  struct buffer *buf = file->private_data;                          What’s next?
  ssize_t result;                                                   Now you have a taste of kernel hacking. We’ve just
  if (mutex_lock_interruptible(&buf->lock)) {                       scratched the surface of the topic, and there is much
     result = -ERESTARTSYS;                                         more to see. Our first module was intentionally simple,
     goto out;                                                      however the concepts you learned will stay the same
  }                                                                 in more complex scenarios as well. Concurrency,
  We acquire the lock at the very beginning of the                  method tables, registering callbacks, putting
function. mutex_lock_interruptible() either grabs the               processes to sleep and waking them up are things
mutex and returns or puts the process to sleep until                that every kernel hacker should be comfortable with,                    OVER TO YOU
the mutex is available. As before, _interruptible suffix            and now you’ve seen all of them in action. Maybe your                Do you want to see some
means the sleep can be interrupted with a signal.                   kernel code will end up in the mainline Linux source                 more kernel magic –
  while (buf->read_ptr == buf->end) {                               tree some day – drop us a line if this happens!                      perhaps intercepting file
                                                                                                                                         access or creating your
    mutex_unlock(&buf->lock);                                                                                                            own iptables module?
    /* ... wait_event_interruptible() here ... */                    Dr Valentine Sinitsyn edited the Russian edition of O’Reilly’s      Tell us what you think at
    if (mutex_lock_interruptible(&buf->lock)) {                      Understanding the Linux Kernel, has a PhD in physics, and is        forums.linuxvoice.com or
                                                                     currently doing clever things with Python.                          letters@linuxvoice.com
       result = -ERESTARTSYS;



                                                                      www.linuxvoice.com                                                                        107
      MASTERCLASS FILEZILLA




                               MASTERCLASS
                               Essential Linux tools explained – this month, say hello
 BEN EVERARD                   to the Filezilla FTP client and learn the power of SSH.


GET TO KNOW FILEZILLA
Does you email have a draconian attachment size limit?
Never mind – learn Filezilla and get your files moving.


                               M
                                            oving files between machines is something
         JOHN LANE                          that most of us need to do at some point.
                                            Whether that’s simply as a backup,
                                updating a web server or another task, it helps to have
                                a flexible tool that can handle multiple file transfer
                                protocols. Today, we’ll take a look at FileZilla, a
                                cross-platform GUI application released under the
                                GPL version 2. It’s implemented using wxWidgets, a
                                cross-platform GUI library that uses GTK on Linux, so
                                it doesn’t have many dependencies. You should find it
                                in your distribution’s package repository:
                                sudo apt-get install filezilla                                 FileZilla’s window has six main areas, but basically your
                                   The first time that you start FileZilla you should take     local files are on the left, with romote files on the right.
                                a minute to familiarise yourself with the layout, but the
                                main thing to grasp is that you transfer files between         listings. The transfer queue lists the files that have, or
                                a local directory, displayed on the left, and a remote         will be, transferred, and the toolbar contains buttons
                                one, which is displayed on the right.                          that you can use to show and hide the individual areas
                                   The main window comprises the toolbar and quick             of the main window.
                                connect bar, a message log, and local and remote file              You can connect to a remote site immediately by
                                                                                               filling in the boxes in the Quickconnect Bar, which lies
                                                                                               across the top of the window. The default protocol is
 SFTP authentication                                                                           FTP, but you can also use SFTP or FTPS by prefixing
 Many SSH servers require that you have           convert its format. It will save a copy of   the host name with the protocol.
 a key for authentication. If you are             your key in a new PPK-formatted file of      sftp://mysite.example.org
 connecting to such a server, Filezilla           your choosing.                               You should enter the username and password for the
 gives you two choices. The first, and               One important point to note is that       site. See the boxout if you are using SFTP and need to
 probably best, is to add the required key        FileZilla does not work with keys that       authenticate with a private key instead of a password
 to your ssh-agent and ensure that the            require a passphrase. If you try to add
                                                                                               (leave the password field empty in this case).
 SSH_AUTH_SOCK environment variable               such a key, you will be prompted to
 is set before launching Filezilla.               convert it. This will require you to enter
    To start an SSH agent and add your            your passphrase and will save a copy of      Secure FTP
 key use this command:                            your key with its passphrase removed.        FileZilla also checks and warns about unmatched
 eval `ssh-agent` && ssh-add                                                                   SFTP server host keys in a similar way to SSH (it
    The second way is to add your keys                                                         internally uses PuTTY code and, if you use that too,
 into FileZilla. To do this, go to Settings >                                                  then they share the same cache file (which can be
 SFTP to add them. FileZilla natively                                                          found at ~.putty/sshhostkeys).
 works with keys saved in PPK format,                                                             Once you are connected to a remote server, its files
 which is the PuTTY Private Key format            If you feel uncomfortable about              and directories are displayed in the remote site part of
 (PuTTY is an SSH client that works on            the security implications of using           the window. The local site window similarly displays
 Windows as well as Linux).                       unprotected private keys, you may            files and directories on your local machine. Navigating
    If, as is most likely, you are using an       prefer not to load them into Filezilla
                                                                                               around both of these areas is done in the same way,
 OpenSSH key, FileZilla will prompt to            and, instead, use the SSH Agent.
                                                                                               and to copy a file you drag and drop between them.
                                                                                               When you do so, the transfer queue updates to reflect



108                                                                 www.linuxvoice.com
                                                                                                      FILEZILLA MASTERCLASS

                                                             which gets closed, or can be opened as a new tab. A
  Settings                                                   tabbed interface is added to the main screen when
                                                             you have two or more sites open, and each tab
  FileZilla has a lot of options that you can tweak to       contains local remote and transfer windows for one
  your taste. The settings dialog, accessed via the Edit                                                                     PRO TIP
                                                             connection.
  menu, enables you to control many aspects of the              Instead of connecting to a site, you can perform a
                                                                                                                         For documentation and
  application, including how connections are made and                                                                    support resources, go to
                                                             manual transfer of a single file. This function,            http://filezilla-project.org
  how the various protocols work. You can also control
                                                             accessed through Transfer > Manual Transfer is a
  how FileZilla performs file transfers and customise
  the user interface.                                        way to move one file to or from a remote site,
                                                             although connecting and using drag and drop is a
                                                             more intuitive way to achieve the same result.

                                                             Memorable paths
                                                             If you find yourself regularly navigating to many local
                                                             and remote paths, you’ll want to check out the
                                                             Bookmarks function. A bookmark defines either local
                                                             or a remote path and can be global or site-specific.
                                                             When a bookmark is selected, the Local and Remote
                                                             windows change to those paths.
  When you’ve tweaked it exactly how you want it, your          A useful feature that can be enabled on a bookmark
  config settings are saved to ~/.filezilla/filezilla.xml.   or on a site as a whole (through the Site Manager) is
                                                             synchronised browsing. This selects a local and
                                                             remote directory path and
the transfers that take place. This is separated into
three tabs: Queued Files shows transfers yet to take
                                                             keeps both in sync as you
                                                             navigate either the local or
                                                                                          “Firefox was one of the first
place; Failed Transfers and Successful Transfers are         remote file views. You’ll be browsers to offer the tabbed
self-explanatory.
  The Local and Remote windows each have a pop-up
                                                             warned if you try to
                                                             navigate to a path on one
                                                                                          browsing model.”
context menu (right-click) that you can use to create        that doesn’t exist on the
and delete files and directories, set permissions and        other; continuing to that location disables
so-on. The options vary depending whether the menu           synchronised browsing.
pops up in the context of a file, directory or neither.         It’s just as important to realise what synchronised
                                                             browsing isn’t: it is not an automated mechanism to
Quick connections                                            synchronise the contents of local and remote
FileZilla remembers connections that you make with           filesystems. Filezilla doesn’t do that. If you want
the Quickconnect bar, as we have done here, and they         automated synchronisation there are other more
can be repeated by selecting them from the drop-             appropriate tools available, not least rsync. But, for a
down beside the Quickconnect button. The                     nice clean GUI-based general-purpose file transfer         Use the Site Manager to
Quickconnect bar allows you to build up a history of         utility, FileZilla has it covered.                         organise the sites that you
                                                                                                                        connect to.
connections that you can re-use quickly and easily,
but there is another way to manage connections if
you want more control – the Site Manager.
   The Site Manager allows you to organise the sites
that you connect to and offers more options to control
how those connections operate. It is, however, distinct
from the Quickconnect bar, and sites added to one do
not appear in the other. You can add a currently
connected site to the Site Manager by using File >
Copy Current Connection To Site Manager. This opens
the Site Manager ready to accept the new site and
defaults its fields with the details for the current
connection. Press OK to complete adding the site.
   There are two ways that you can connect to a site
that is saved in the Site Manager. The first way is to
open the Site Manager, select the site and click
Connect. The other, more direct route, is to right-click
the Site Manager toolbar icon and select the site from
the drop-down menu that is displayed.
   As you use FileZilla to connect to more sites, each
new connection can either replace an existing one,



                                                               www.linuxvoice.com                                                                 109
      MASTERCLASS SSH



AN INTRODUCTION TO SSH
Get to grips with SSH and lord it over remote machines…


                          I
                              f you use more than one computer then you will          is what you asked for, you can enter yes to continue
                              probably, at some point, want to do something on        the connection.
                              one that isn’t in front of you.                         The authenticity of host ‘remotehost (192.168.1.15)’ can’t be
                             SSH (the Secure Shell) isn’t another command-line        established.
                          shell like Bash – it’s a networking protocol that you can   ECDSA key fingerprint is 6d:c4:cf:43:75:a5:79:e0:74:a0:b7:22:b
                          use to connect securely to a remote computer across         7:da:e1:25.
                          an insecure network like the internet. It establishes an    Are you sure you want to continue connecting (yes/no)?
                          encrypted connection to a remote computer, executes            This happens because SSH uses public-key
                          a command there and redirects its input and output          cryptography to authenticate any server you connect
                          across the connection. In SSH, the shell is like a          to. The server responds with its public key as
                          wrapper surrounding a path through an insecure              confirmation of its identity but your SSH client doesn’t
                          network that encrypts everything sent through it.           recognise it. Your client tries to compare keys it
                             The way most people use SSH is as a command-             receives with copies kept in a file at ~/.ssh/known_
                          line to enter commands on a remote machine, which           hosts. When you connect for the first time, it has no
                          you can then work on as if it were there in front of you.   copy to compare against, so it displays the warning
                          This remote login is what SSH does if it isn’t given a      message instead. When you respond yes to continue
                          specific command.                                           connecting, you tell your client to trust the server and
                             Using SSH requires a client on the local computer        it adds the received key to the known_hosts file.
                          and a server on the remote one. The implementation             On subsequent connections, the client compares
                          found on most Linux distributions is called OpenSSH,        the key sent by the server with the one previously
                          and both the client and server packages should be in        recorded and aborts the connection if they don’t
                          your distro’s repository; they may even be installed by     match. It provides some useful information to help
                          default. On Debian-based systems, the client                you investigate and resolve the problem. The
                          (openssh-client) is installed by default, but you may       connection is authenticated if the client and server
                          need to install the server on machines that you want        keys match.
                          to connect to:
                          sudo apt-get install openssh-server                         The keymaster
                          This installs and starts the SSH server. Once you have      SSH requires that each server has a unique key that
                          set up a remote host you can connect like this:             consists of the public key it sends to connecting
                          ssh remotehost                                              clients and a corresponding private key that it keeps
                          where remotehost is the hostname of the remote              secret. Most distributions automatically generate
                          computer (or you can use its IP address). You will be       these server host keys when SSH is installed or
                          prompted for your password on that remote machine.          started for the first time.
                          SSH assumes your local and remote user names are               What has happened so far is that the client and
                          the same unless you tell it to use a different one          server have established a secure communications
                          ssh user@remotehost                                         channel but you have yet to authenticate yourself as a
SSH gives a dark and        You will see a serious-looking warning when you           user. The simplest way to do this is by entering a
foreboding warning when   connect to a remote host for the first time, but            password but you can (and, arguably, should) use a
host keys don’t match.    assuming you’re happy that what you’ve connected to         key exchange instead. Before you can do this you
                                                                                      need to generate your own key:
                                                                                      ssh-keygen -t rsa
                                                                                      which, by default, saves keys in ~/.ssh with the private
                                                                                      key in a file called id_rsa and the public key in id_rsa.
                                                                                      pub. You can choose whether to enter a passphrase
                                                                                      to protect your private key. If you do, you will need to
                                                                                      enter the passphrase whenever you use the private
                                                                                      key. An unprotected private key is only as secure as
                                                                                      the file it’s in.
                                                                                        You need to copy your public key (not your private
                                                                                      key) to any remote server that you want to connect to,
                                                                                      and there is an easy way to do this:
                                                                                      ssh-copy-id remotehost
                                                                                        You will need to authenticate before the key can be
                                                                                      copied, which will require that you enter your



110                                                             www.linuxvoice.com
                                                                                                                   SSH MASTERCLASS

password for the remote machine. If the remote SSH
server has disabled password authentication then this        Server configuration
will not work and you will need to ask the remote
                                                             The SSH server has a configuration file, usually
server’s administrator to copy your public key onto the
                                                             located at /etc/ssh/sshd_config. Some settings you
server for you. Your public key is stored on the remote      should review are listed below.
server in ~/.ssh/authorized_keys.
                                                               Set PasswordAuthentication to No to disable
                                                               password authentication. Users will need to supply
Beyond the command-line                                        their public key before they can connect.
Many people use SSH just to get a command prompt
                                                               Set PermitRootLogin to No to prevent remote
on a remote server, but you can do more than that. If
                                                               logins as the root user.
you enable X forwarding on the server then you can
                                                               Set X11Forwarding to Yes to allow use of X
launch GUI applications and have them display on
                                                               applications over SSH.
your local desktop. The -X parameter enables this
mode. If you wanted, for example, to run a Firefox             Use AllowUsers or DenyUsers if you need to
                                                               restrict the users who can connect.
browser on the remote host, you could do:
ssh -X remotehost firefox                                      Use Banner to display a message when a
  Forwarding the X protocol over SSH is an example             connection is established. Specify a file, usually
                                                               /etc/issue containing the message text.
of ‘tunnelling’, and you can use SSH as a tunnel for any
network traffic. The example below forwards email            After changing the server configuration, reload it
                                                             with
SMTP traffic to a mail server on the remote network:
                                                             sudo killall -HUP sshd
ssh -N -f remotehost -L 25:remotemailhost:25
                                                                If you ever need to re-generate a server’s keys:
   The parameters run SSH as a daemon (-f) without           rm /etc/ssh/ssh_host_* && ssh-keygen -A
executing a remote command (-N) because we’re
tunnelling instead. The -L 25:remotehost:25 tells SSH
to listen on a local port 25 and forward any traffic it       If you need constant access to many remote files,
receives across the SSH connection to remotehost           you may prefer to mount a remote filesystem and use
and onwards to remotemailhost port 25.                     it as if it were a local one. You can use sshfs to do this
   Another use for SSH is to copy files, and there are a   – it’s a userspace filesystem built on top of Fuse.
few ways to do this. The scp (secure copy) command         sudo apt-get install sshfs
enables you to copy files between your local               sudo adduser myuser fuse
filesystem and a remote SSH server. You use it               This installs it and adds your user ID to the fuse
similarly to the regular cp command, except that the       group, enabling you to mount a directory on a remote
remote path is prefixed with the remote host name          SSH server:
(and, optionally, username):                               mkdir ~.mountpoint
scp /local/path user@remotehost:/remote/path               sshfs remotehost:/remote/path ~/mountpoint
  You can also copy files with sftp, which looks and         You can then interact with the remote files as if they
                                                                                                                           PRO TIP
feels like a basic FTP client. It’s also handled by the    were local. When you are ready to unmount the file           With the ‘ssh agent’ you
                                                                                                                        only need to enter your
SSH server, so nothing additional is required to use it.   system, use this command:                                    passphrase the first time
sftp remotehost                                            fusermount -u ~/mountpoint                                   it’s needed.


                                                           Securing SSH
                                                           SSH is a secure protocol, but there are steps that you
                                                           can take to increase its security. The first thing most
                                                           admins will do is insist that users supply their public
                                                           key and disable password authentication.
                                                             You may also restrict what connecting users can
                                                           do. This is another use for the ~/.ssh/authorized_
                                                           keys file. By prefixing a user’s key with a command,
                                                           any connection will run that command regardless of
                                                           what the user requested.
                                                           command=”/usr/bin/something args...” ssh-rsa AAAAB3Nza-
                                                           C1yc...
                                                             You might expose an SSH server on the internet so
                                                           that you can connect to a server in a distant location. If
                                                           you do this, you can change the SSH port from its
                                                           default of 22 to a more obscure port of your choice.

                                                            John Lane is a technology consultant with a penchant for
Gnome has the Gnome Virtual Filesystem (GVFS), which        Linux. He helps new business start-ups make the most of
                                                            open source.
natively supports SSH mounts.


                                                             www.linuxvoice.com                                                                111
      DVDPAGES




Distros, videos, applications, games, podcasts and more…
                                                                                  DVD 002
                                 SHOWCASING THE BEST OF FOSS
                                 Welcome to the second Linux Voice       a whopping nine desktop                 And then there are videos, apps
                                 DVD. It’s been fantastic to hear        environments and window               and other gems to explore – open
                                 your feeback about the first issue,      managers. It’s a great way to         index.html for the full lowdown.
                                 so thank you to everyone who got        explore the different interfaces in   We hope you enjoy the disc, and if
                                 in touch. This issue’s DVD, like last   the Linux and open source world.      you have a digital subscription to
                                 month’s, is an 8GB dual-layer beast       Then we have gNewSense, a           Linux Voice, you can get the DVD
                                 jam-packed with software, videos,       completely pure distribution (ie      ISO image from our website at
                                 podcasts and much more.                 without a single byte of non-free     www.linuxvoice.com.
                                    We have the latest release           software) that even the notoriously
                                 of Mageia, a superb desktop             picky Richard Stallman doesn’t        Mike Saunders, Disc Editor
                                 distribution that boasts                have a beef with.                     mike@linuxvoice.com



Complete desktop distro



Mageia 4
A first-class Mandriva spin-off with over 4,400 packages.


O
        ne of the biggest reasons for distro    you’re a long-time Linux user or are new to
        hopping is trying out a new desktop     the operating system, it’s well worth a try.
        environment. Sure, most big-name        The minimum system requirements are:
distros have a range of desktops, but they’re      32 or 64-bit x86 CPU
often not integrated very well, so you have to     512MB RAM
choose a specific distro to get a good              6GB hard drive space
version of, say, KDE or Gnome.                     Still, we recommend having 1GB+ RAM
  Mageia is different: the version on our       for smooth running. To install Mageia, just
DVD includes nine desktops and window           boot your PC from the Linux Voice DVD – ie
managers, all polished and integrated           start your PC with the disc in the drive. (On
excellently. So you can try the latest versions some older PCs, you may need to change
of KDE, Gnome, Cinnamon, MATE, Xfce,            the boot order in your BIOS so that the DVD          After installation, click the pencil and paper
Enlightenment and more from a single            drive boots first, so consult your PC                 icon in the login screen to choose your desktop
distro. We’ve included the complete 3.7GB       documentation or your local Google.)                 or window manager.
edition of Megeia 4 on the disc, and whether       Choose ‘Install Mageia 4’ from the boot
                                                menu and follow the prompts. If you’re
                                                completely new to Linux, before installing it’s
                                                worth loading up index.html from the disc in
                                                Firefox, scrolling down to the Videos section,
                                                and watching our videos about installing
                                                and using Mageia – they’ll get you prepared
                                                before you do the installation yourself.
                                                   If you want the complete nine-desktop
                                                experience, at the Desktop Selection phase
                                                of the installation, choose the Custom
                                                option. You can then pick and choose which
                                                desktops and WMs you want installed. And
Choose Custom during the Desktop Selection step for more information on Mageia, visit its
of the installation for a big range of options. website at www.mageia.org.



112                                                            www.linuxvoice.com
                                                                                                                                 DVDPAGES


RMS-friendly distro


gNewSense 3.1
Only free (as in speech) software – a very pure distro.


W
             e’re not big fans of the name, but      various small changes and fixes. We’ve
             we really like gNewSense. It’s a        included this release (the 64-bit version) on
             GNU/Linux distro that only              the Linux Voice DVD: to install it, just boot
contains completely free software: that is,          your PC from the disc and choose one of the
no binary-only drivers or patent-iffy media          gNewSense options from the boot menu. As
codecs that many other desktop distros               well as booting the distro in live mode           If you hated earlier versions of Gnome 3, it’s
include. Richard Stallman, creator of GNU            (which runs from the DVD and has an               worth giving the desktop another chance.
and the awesome GPL licence, thinks that             installer icon on the desktop) you can also
most GNU/Linux distributions don’t help to           perform a text-mode installation, which is        and all the usual tools are present. There’s
advance the cause of software freedom by             ideal if you want to install on older machines    nothing especially fancy about it – it’s just a
installing those extras – so he likes                or servers.                                       solid all-round distro with a firm focus on
gNewSense for its purity.                              gNewSense is based on Debian, so any            freedom. If you love the spirit and goals of
  Now, gNewSense isn’t as up-to-date as              skills you’ve learnt during your time with        free software, give it a go. And if you need
many other desktop distros doing the                 Debian and/or Ubuntu will come in useful          any help or support, pop over to the project’s
rounds, but the new 3.1 release does include         here. It uses apt for package management          website: www.gnewsense.org.


Not just software!


Linux Voice videos
Mageia, FOSSpicks, Retrode and newbie guides.


W
           hen we started work on the first           and Vorbis format, so they will play straight
           Linux Voice DVD, we wanted to             away in Firefox without the need for any
           make it much more than just a             extra apps or media codecs.
compendium of the latest Linux software.                Firstly there are the aforementioned
We wanted it to be a part of the magazine,           videos explaining how to install Mageia and
website and community as a whole, so we              explore its KDE desktop. Then we have a           Thanks to the completely free and open
decided to make some videos showcasing               look at some apps covered in FOSSpicks,           Theora+Vorbis video codec, you can watch our
things covered in the mag. And we’ve                 including the rather cool Android-x86. Next       videos straight away in Firefox.
continued that for this month’s DVD.                 there’s a quick look at the Retrode as
   Open index.html in Firefox and scroll             covered on page 22. Finally, Graham made          use it, based on Linux Mint 16 from last
down to the Videos section. Click the links to       some great “new to Linux” videos explaining       issue’s DVD. They’re essential viewing if
watch the videos – they’re in Ogg Theora             what Linux is, how to install it and how to       you’re taking your first steps in Linux.




  And there’s more!
  Podcasts, software, games, Linux From Scratch...
  Legends tell of a faraway group of people,             Also on the disc are a bunch of new desktop
  isolated from the rest of the world, with barely    applications including LibreOffice 4.2 (in Deb
  any contact with mankind. Little is known           and RPM formats), PCManFM 1.2 and Anjuta
  about these beings, but one thing is for sure:      3.11.4. We have a selection of hot games
  they’re missing out on the most important           such as Ember 0.7.1, along with the latest
  development in human history. They’ve never         kernel and GCC code for those who want
  heard the Linux Voice Podcast.                      to live on the bleeding edge. Oh, and if you
     Maybe this issue’s DVD will reach their          have a few hours spare and want to get your
  settlements at some point, so we’ve included        hands dirty with a new project, try Linux From
  the latest episodes for their listening             Scratch: it teaches you how to make your own
  enjoyment. There’s lots of Linux banter, lots       custom Linux distribution, compiling every       Join the online RPG WorldForge using Ember,
  of discoveries, and lots of off-topicness.          little piece yourself. It’s ace.                 and buy pigs from strangers.




                                                                 www.linuxvoice.com                                                                113
      /DEV/RANDOM/




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




M
              oney is great. You can do all sorts
                                                                Lots of phones (not          Desktop PC for
              of things with it. It really is rather            all Ubuntu).                 Linux gaming and
              amazing, and we should all pay                                                 photo/video editing.
due homage to Pheidon, who struck the first
recognised coins (in Argos, or possibly Lydia) in
about 700BC, since which time it has certainly
been a much easier trip to the supermarket.                                                        Panasonic bluetooth
                                                                                                   headphones connected via a
    It is therefore a good thing that Linux Voice               Electronics hobby box on           cable because Bluetooth on
is giving away 50% of its profits to the needy of                floor, contains various            Linux sucks :)
open source. Loads of projects, big and small,                  Arduino/RPi stuff.
useful and silly, will no doubt benefit. But, in a
terrible paraphrasing of Bob Geldof, “it’s not
enough”. Not that I think 50% isn’t enough – I
mean money isn’t enough.
                                                       My Linux setup Alan Pope
    Many a time, when I have been confronted by
a pernicious bug, or some rogue documentation
                                                       @uupc podcaster and Canonical chap shows us the office.
or an unintelligible user interface, I have taken a
crisp £20 out of my wallet and waved it at the               What version of Linux are you           was doing, but the terminal seemed cool!
screen saying “here, for the love of everything              using at the moment?                    Next stop Debian, then Ubuntu where I’ve
that doesn’t suck, fix this”. Sometimes I have got            Ubuntu Trusty (which will become        stayed for nine years.
up to £100, but the screen stares impassively                14.04) on laptop and desktop. Also,
back, taunting my impotence.                           Ubuntu on the Nexus 4’s and Nexus 7’s.              What Free Software/open source
    As I have already mentioned, money is              One 2012 Nexus 7 running Android                    can’t you live without?
incredibly useful. Projects can use it for much-       constantly running irssi-notifier to alert          Linux itself. While I use the entire
needed hardware, or maybe for inescapable ISP          me of IRC pings.                                    stack every day, without the work
costs, attending events or securing an adequate                                                      done by the Linux kernel developers, I can’t
supply of caffeine…                                          What desktop do you use? If we          imagine most of the rest of it would be as
    But. What projects often need, sometimes                 had to guess, we’ say…                  advanced and usable as it is.
even more than Bitcoins, is vitality, effort and             … Unity on the laptop, desktop and
responsiveness. This is usually achieved by                  phone.                                         What do other people love but
having a vibrant, involved community. There                                                                 you can’t get on with?
have been dozens of articles online and                      What was the first Linux setup                  KDE. I promised to try it for a full 6
elsewhere on different ways you can help open                you ever used?                                 months. Got intensely
source software, even if you can’t write code.               Red Hat, which I got with a book in     frustrated with it after a month and gave
    Paying your way in open source is a good                 around 1996. I had no clue what I       up, never looked back.
thing, but getting involved is better. If you like
software, support it. Get involved. Sometimes
little more is required to keep a software project
ticking along than just people turning up.             Follow us on Twitter @linuxvoice!
114                                                           www.linuxvoice.com
                                                                    THANK YOU!




THANK YOU!
Linux Voice would like to say a huge thanks to everyone who
made this magazine possible. If you bought the Founder perk
 during our IndieGogo campaign, and we missed you off the
 Founders’ page in issue 1, we’re sorry. Many, many thanks.




     Anthony Beavis, Auroraskyes,       Patrick Allen, Peter Selley,
     David Banks, Den Weatherall,       Sally Henderson, Samuel Voss,
     Kevan Vautier, Luis Joaquim,       Sebastian Dixon-Lewis, Stephan
     Marius Orintas, Mike Eaket,        Diestelhorst, Tarquin Adams


                           www.linuxvoice.com