DOKK Library

Linux Voice [Issue 7]

Authors Linux Voice

License CC-BY-SA-3.0

Plaintext
    RASPBERRY PI MODEL B+: UNLOCK THE SECRETS OF THE NEW PI




115 PAGES                    October 2014

OF LINUX
                              OVERCLOCKING               BIG DATA                 DESKTOP ENVIRONMENT
                             RASPBERRY PI PYTHON                                  KDE 5
LEARNING                     Push the limits of your
                             Pi’s performance
                                                         Analyse huge data sets
                                                         and draw pretty graphs
                                                                                  Take an early look at the
                                                                                  desktop of tomorrow




                            BEST
                           DISTROWhich Linux flavour is right for you?            2014
                                 Explore the cream of the crop to find
                                      your next favourite distro!

                                                                            34+ PAGES OF TUTORIALS
UDP Use the protocol that underpins the internet
PYUSB Reverse engineer a driver with the power of Python
                                                                                       October 2014 £5.99 Printed in the UK




BASH SCRIPTING Program your machine with the humble terminal

 OPERATING SYSTEM                        OLD CODE

 BSD                                     KONRAD ZUSE
 The OS that could                       Creator of the Z3 and
 have been Linux                         writer of Plankalkül
October   2014
                                                                                                                            WELCOME



From openness comes literacy
The October 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).


                                          I
                                               n a recent interview with Edward Snowden, there’s a point at
       No later than nine months               which the editor of the Guardian newspaper, Alan Rusbridger, is
  2
       after first publication, we will        explaining about when he first sat down with Edward’s leaked
relicense all of our content under        documents. He initially gave them to his most distinguished
the Creative Commons CC-BY-SA             journalists – people with years of experience evaluating stories. At
licence, so that old content can          some points, they literally didn’t understand what they were looking
still be useful, and can live on even     at. Alan then asks Edward, from that context, how are MPs
after the magazine has come off           supposed to understand the technical ramifications of the decisions
the shelves.                              they’re taking, when the technical concepts are so complex.
                                             Edward replies by saying this is probably the single most
      We’re a small company, so           important factor to explain the failures and oversight that we’ve
 3
      we don’t have a board of            seen in almost every Western government, “We need to think
directors or a bunch of                   of it in terms of literacy,” he says. And I think he’s absolutely     SUBSCRIBE
shareholders in the City of London
to keep happy. The only people
                                          right. This is why the UK government’s decision to go with
                                          ODF as its documentation format is such a monumental                  ON PAGE 60
that matter to us are the readers.        decision. It’s the correct decision taken from a literate
                                          perspective, and while we’ve still got a long, long, long way to go,
                                          this is one important step in the right direction.
THE LINUX VOICE TEAM
                                          Graham Morrison
Editor Graham Morrison                    Editor, Linux Voice
graham@linuxvoice.com
Deputy editor Andrew Gregory

                                          What’s hot in LV#007
andrew@linuxvoice.com
Technical editor Ben Everard
ben@linuxvoice.com
Editor at large Mike Saunders
mike@linuxvoice.com
Games editor Liam Dawe
liam@linuxvoice.com
Creative director Stacey Black
stacey@linuxvoice.com
Malign puppetmaster Nick Veitch
nick@linuxvoice.com
Editorial contributors:
Chris Brown, Russell Barnes, Chris
Brown, Mark Crutch, Marco Fioretti,       ANDREW GREGORY                     BEN EVERARD                        MIKE SAUNDERS
Josette Garcia, Juliet Kemp, John         We’ve got a scoop on the team      Our interview with Mir developer   Ben grabbed the entire list of UK
Lane, Vincent Mealing, Simon Phipps,      behind the hottest new distro      Thomas Voß answers many of         house sales and used his
Les Pounder, Valentine Sinitsyn           around, Elementary OS, due to be   the questions we had about why     statistical genius to pull loads of
                                          released any time now p32          Ubuntu didn’t use Wayland p40      ace facts from the data p82



                                                           www.linuxvoice.com                                                                     3
               CONTENTS


                                                                                                                                    October LV007
   Celebrate summer by staying in out of the rain and messing with your Linux machine
                                                                                     20     REGULARS
SUBSCRIBE                                                                                         News
                                                                                            06
ON PAGE 60                                                                                        Governments are saving
                                                                                                  money all over the place by
                                                                                                  adopting Free Software.
                                                                                            08    Distrohopper
                                                                                                  Cast a covetous eye over
                                                                                                  GhostBSD, Siduction, Zorin
                                                                                                  and OpenElec.

                                                                                            10    Gaming
                                                                                                  One of the true masterpieces
                                                                                                  of computer games comes to
                                                                                                  Linux: Civilisation V.

                                                                                            12    Speak your brains
                One dream, one soul. One prize, one goal.                                         Send us your modest proposals
                                                                                                  to share with the world (and
                 There can be only one best distro 2014!                                          give us ideas for the mag).

                                                                                            16    LV on tour
                                                                                                  The kids are alright – they’re
                                                                                                  busy hacking Minecraft in a
                                                                                     28           field in North Yorkshire.

                                                                                            40    Interview
                                                                                                  Canonical’s Thomas Voß
                                                                                                  tells us why Mir is the best X
                                                                                                  replacement know to man.

                                                                                            54    Group test
                                                                                                  Forget Facebook – we’re
                                                                                                  chatting like it’s 1999 on IRC.
                                                                                                  Find the best client for you!

                     The Raspberry Pi takes its next                                        60    Subscribe!
                                                                                                  Never miss another issue –
                     giant leap out of the primordial                                             and get access to our archive
                                                                                                  of Linux Learning.
                      soup. Now examine its DNA!
                                                                                            64    Core technologies
                                                                                                  Get to grips with the glue of
                                                                                                  the internet – the essential
                                                                                                  UDP protocol.
                                                                                            68    FOSSPicks
                                                                                                  Free Software that’s fresher
                                                                                                  and free-er than an unlaid
                                                                                                  free-range egg.
                                                                                            110   Masterclass
                                                                                                  A brace of systems for
                                                                                                  sharing files with Windows
                                                                                                  machines: Samba and SWAT.
                                                                                            114   My Linux desktop
                                                                                                  You may know Thomas
   32
        ELEMENTARY OS           38   FAQ: THE BSDs             18   OSCON                         Voß as the Mir engineer we
        What once was just           But for a quirk of fate        Hear from some of             interviewed on page 40.
        a set of icons is            you might have been            the brightest and             Here’s an insight into his
                                                                                                  development den.
        now the darling of           reading BSD Voice.             best in Free Software
        DistroWatch. Find out        But why did BSD end            about how the future
        how it got so good.          up the nearly man?             is going to look.


   4                                                    www.linuxvoice.com
TUTORIALS                                                                    REVIEWS
  76                                      78




                                                                                  KDE 5
Raspberry Pi model B:                   Sonic Pi: program
                                                                             46

                                                                                  Desktop, eye candy, and
Void your warranty                      electronic music                          incubator for some of the finest
                                                                                  software around. KDE is back.
Add bits, hack bits, then overclock Code bleeps and beats in a
it and fry it. It’s fun to be a geek. wonderfully simple syntax.

  82                                      86




                                                                             48   CamJam EduKit
                                                                                  Learn to build and program
                                                                                  circuits for pennies. Next stop:
Python and MySQL:                       Linux 101:                                robot sharks with lasers.
Big data analysis                       Power up your shell                  49   Mathematica 10
Don’t trust the official statistics – Customise the stock Bash                    A hugely powerful data analysis
take the data and make your own. command line and feel epic.                      tool for professional users and
                                                                                  deep-pocketed individuals.

  90                                      94
                                                                             50   LibreOffice 4.3
                                                                                  The flagship office suite that’s
                                                                                  saving millions of pounds in
                                                                                  unspent MS Office licence fees.


                                                                             51   Stellarium 0.13
                                                                                  Explore the night sky with
                                                                                  this absolutely superb Free
Fargo: write and publish                Write a device driver                     Software observatory.
outlines in open formats                with PyUSB
                                                                             52   Books The ethics and
Turn the web upside-down with a         Reverse engineer the software             aesthetics of hacking, a
simple way to publish content.          to control a USB toy car.                 Quixotic search for the internet
                                                                                  and more.
100
      Bash: Beyond the    102
                                Code Ninja:         106
                                                          Konrad Zuse: The
      command prompt            Programmers’ golf         German Turing
      Automate tasks            Show off your             Computing in
      for more control.         coding skills.            1943 Berlin.



                                               www.linuxvoice.com                                                    5
     ANALYSIS




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



ODF comes of age
The UK Government’s decision to standardise on ODF means Microsoft has lost.

                           Simon Phipps             and ratcheting up the interoperability issues       further collaboration. They have also chosen
                           is president of the      for competing code. Format lock-in was              PDF/A and HTML as standard formats for
                           Open Source Initiative
                                                    what was killing the market. Even worse, it         final-form documents.
                           and a board member
                           of the Open Rights       was one of the factors stifling the open               Which begs the question: has Microsoft
                           Group and of Open        source desktop, since businesses were loath         lost? The answer to that is both yes and no.
                           Source for America.      to adopt a desktop solution that had no             Yes, its initial refusal to join the ODF TC at
                                                    interoperable document software.                    OASIS and its costly and reputationally
                                                                                                        damaging foray into standards
                                                    Open standards                                      gerrymandering with its own XML-based
                                                    We decided that what was needed was an              OOXML format were definitely a “lose” of



A
         t the start of the new millennium, a       open standard. If an open document format           their own making. Even today, despite
         team of us at Sun Microsystems             existed, every product – including MS Office        having got OOXML accepted as an ISO
         decided we had to do something             – could compete on its merits alone, without        standard, Microsoft don’t support the actual
about an obvious problem. A decade later,           the distortion of format lock-in. We decided        standard itself in its product – only a
we’re seeing the fruits of our labour in the        to donate the work we had been doing on a           non-standard variant. It has even had to
decision of the UK government to prefer             new, XML-based document format for                  implement full ODF 1.2 support.
openly-created, openly-maintained open              StarOffice to a standards body and then
standards for document formats.                     invite everyone else in the industry to use         We’re not there yet…
   It was clear to us back then that open           that as a base to collaboratively evolve a          But that final compromise is what prevents
source software was being severely limited          truly open standard. We selected a                  the UK Government’s standardisation on
by the near-monopoly of Microsoft Office on         standards body called OASIS, both for its           ODF being another “lose” for them. Unlike
the desktop. There were several pretty good         focus on XML and for the fact that other            Google Docs, Microsoft has good support for
alternatives available, including the StarOffice    large vendors – notably including Microsoft         ODF in both Office and 365 that interoperates
product we had just acquired with                   – were top-level members.                           well with other software as long as you avoid
StarDivision and then open sourced as                  The initiative was well received and a large     proprietary fonts and marginal features in
OpenOffice.org. All the same, whenever any          group of contributors came together to work         each product. Moreover, Microsoft has other
business tried to adopt our product, subtle         in the new OASIS Open Document Formats              layers of lock-in to fall back on – proprietary
incompatibilities with the way it handled           for Office Applications Working Group –             support for Sharepoint, for example.
documents would emerge and, as the                  OpenDocument to its friends. Microsoft              Competing solutions like LibreOffice – the
newcomer, StarOffice would be blamed                were directly invited to participate, but chose     successor to our original StarOffice work
whether it was at fault or not. The need for        not to. The rest, as they say, is history. Today,   – don’t have a truly level playing field, but at
Office was transmitted not by superior              Open Document Format (ODF) is an ISO                least get to enter a team in the league.
functions or performance, but by the need           standard and is supported in every serious             All the same, our original vision of a truly
for an interoperable document format.               document application on every platform.             open document format – royalty free, with
   Worse, Microsoft kept releasing new                 That history is the reason I was so              no platform dependencies, created and
versions with slightly different document           delighted in July to heard that the UK              maintained in the open – has finally fruited.
formats, forcing unwanted upgrades on their         Government has chosen to set ODF as the             Arguing against ODF as the preferred format
customers in order to remain compatible             standard for all documents intended for             for citizen collaboration will hopefully be
                                                                                                        seen as self-harming by vendors. That’s one
                                                                                                        less barrier to the open source desktop and
“Our vision of a truly open document format with                                                        one more foundation stone for the digital
no platform dependencies… has finally fruited.”                                                         freedoms of the meshed society. Let’s keep
                                                                                                        going – we can do this!



6                                                               www.linuxvoice.com
                                                                                                                    ANALYSIS


    ODF • Swiss, French & Spanish adoption • OwnCloud • LibreOffice • Kernel 3.16




CATCHUP                                        Summarised: the biggest news
                                               stories from the last month

          British government                           Valencia saves €36m by                        OwnCloud 7 released
   1      adopts open formats                   2      switching to Linux                    3      OwnCloud keeps going from
           By Jove! This is jolly                       Another success story: the                  strength to strength, and
good news, eh chaps? Yes, the UK             autonomous region of Valencia in             version 7 brings improved sharing
government has chosen ODF (as                Spain has finished the next version of       features, a faster interface, and
used in Libre/OpenOffice) and PDF/A          its customised Linux distribution, as        support for Microsoft Word files in the
as standard formats for sharing and          used on over 110,000 PCs in schools.         document editing tool. See the full list of
viewing documents. No longer do              The local government claims that using       new features here:
users need to buy proprietary software       Linux has saved them €36m over the           www.owncloud.org/seven
to work with files from government           last nine years – and more savings are
websites, but the use of open formats        to come. Linux has also been thriving in
will also make it easier to access data      another region of Spain, Extremadura,
in the future. It’s a slap in the face for   where Linux is installed on 70,000 PCs
Microsoft and its OOXML format as            and laptops in schools.
well. Time for a cup of tea to celebrate!    http://tinyurl.com/lv3pcwe




          Linus Torvalds releases                      Geneva class rooms                            Microsoft concedes:
   4      shiny new kernel 3.16                 5      switching to FOSS                     6       Windows has just 14%
          Kernel releases aren’t as                     Not to be outdone by Spain,                  market share
exciting as they were in the last decade,    the Swiss canton of Geneva plans to          This can’t be right – surely? Windows is
largely because Linux has matured and        switch its entire school system over         still dominant on desktop PCs, isn’t it?
stabilised a lot. Still, 3.16 brings a       to GNU/Linux. Specifically, the move         Well yes, but the desktop is just one part
bundle of updates, including better ACPI     to Ubuntu in 170 primary schools             of the wider computing world today, and
and power management on Intel CPUs,          has already been completed, and              Microsoft’s very own COO Kevin Turner
improved Radeon graphics support,            the transition in secondary schools          has recognised this. As more people are
and Btrfs fixes galore. If you’re a Dell     is planned for later in the year. The        doing work on tablets and large-screen
Latitude user, your hard drive will now      canton’s IT department claims that           smartphones, Windows on the desktop
stop if you drop the machine thanks to       Linux is easier to maintain, faster, safer   is looking less relevant, and when you
a new Freefall driver. And the best          and more stable than the proprietary         add up the whole desktop and mobile
news? 3.16 is due to be included in          software it was using before.                market, Windows has a paltry 14%
Debian 8, codenamed Jessie.                  http://tinyurl.com/o4m9b4w                   share. While Android grows and grows…




          LibreOffice 4.3 released:                                                                  Toulouse saves €1m by
   7      “you can’t own a better                                                            8       switching to LibreOffice
          office suite”, apparently                                                                  And another success story to
That’s quite a bold statement from The                                                    end with. The French city of Toulouse
Document Foundation, but we can                                                           has saved €1m by switching its
attest that LibreOffice 4.3 is packed to                                                  PCs from Microsoft software to the
the brim with new features. There’s 3D                                                    LibreOffice suite. Sure, it isn’t a full Linux
models in Impress (the presentation                                                       transition and the savings aren’t as
tool), much better support for                                                            huge as in Valencia, but it’s a great step
Microsoft’s OOXML formats, and                                                            in the right direction, especially with the
improved commenting facilities (useful                                                    European economy still in dodgy times.
in collaborative projects). Tons of fixes                                                 Plus, the city’s money goes back to local
have been made as well, and the suite                                                     tech support companies, and not giant
will be heading to a distro near you                                                      megacorps overseas.
very soon. www.libreoffice.org                                                            http://tinyurl.com/ovgpj2l




                                                       www.linuxvoice.com                                                                  7
     DISTROHOPPER




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


Siduction LXQT
Showcasing a new desktop.


M
            any, many words have been
            written about the shift from
            Gnome 2 to Gnome 3, and we
won’t add more here. However, as well as
the desktop shifting, the GTK toolkit also
shifted, and a lot of other desktop
environments relied on that GTK 2. LXDE
was one of those environments, and they
weren’t happy with the direction GTK 3 was
taking, so the developers have decided to
make a clean break and switch to the Qt
toolkit that’s most famously used in KDE.
  This new desktop environment, known as
LXQT, is still in development, so not many
distros have included it yet, but Siduction
has. At first it feels a little strange, because   Siduction was also one of the first distros to feature Razor-qt, another Qt-based desktop.
some parts are reminiscent of KDE, such as
the control centre and the notifications area.     cashew, and none of the KDE apps are                browser. Despite the new toolkit, it still
However, on the whole, it’s a very different       included. PCManFM is still the file manager         retains the no-nonsense feel of LXDE, and
desktop environment. There’s far less eye          (like the desktop, it’s made the transition to      we suspect it will retain its popularity in
candy, no glow behind the window, no               QT), and Qupzilla is chosen as the web              low-end desktops.




Zorin 9
Can Zorin 9 help Linux attract new users from Windows?


Z
         orin pitches itself as the gateway to     probably is, but that mantra isn’t central to
         Linux, a tagline that sums up its goal    Linux (see http://islinuxaboutchoice.com).
         of being a distro for non-technical          Zorin is aimed squarely at new users, and
users new to Linux. As far as we can see,          new users don’t always want lots of options         The Zorin Theme Changer gives a simple way to
this claim is mostly made based on the fact        to endlessly tweak the interface. They want         tweak the look and feel of the desktop.
that it’s themed to look like Windows.             a few choices so they can find a look and
   Zorin gives the user three themes to            feel that somewhat approaches their natural         Underneath, Zorin is based on Ubuntu 14.04
choose from to customise its look and feel         style. For these people, Zorin provides a           which makes a solid, if unremarkable, base.
(though we can’t tell the difference between       natural choice.                                         Zorin is probably the best Windows-alike
Dark and Blue), and three looks (based on                                                              distro, but we’re becoming less and less
Windows 7, Windows XP and Gnome 2).                The easy option                                     convinced that Windows-alike distros are
That makes a total of nine (or six) different      If you’re thinking that this GUI only alters        really necessary. We’ve found that even
visual appearances you can have. If one of         some config files that you could go in and          lifelong Windows users take to interfaces
them isn’t to your taste, go find another          change to tweak this or that element of the         like Mate or Cinnamon without too much
distro. This might seem an anathema to the         interface, you’re probably correct – but            trouble, but for those who can’t cope with
mantra ‘Linux is about choice’, and it             again, Zorin is not the distro for you.             the change, there’s always Zorin.



8                                                              www.linuxvoice.com
                                                                                                                                  DISTROHOPPER



GhostBSD 4.0
FreeBSD + Mate = an easy introduction to the mysterious world of BSD.


G
         hostBSD is a project that builds on
         FreeBSD with the aim of making it a
         bit more palatable for desktop users.
To this end, it comes with the Mate desktop
environment and a set of tools geared
towards desktops rather than servers.
   The basic install leaves you with a fairly
minimal system, but there’s nothing
essential missed out. It’s got LibreOffice,
Firefox and a few other tools, but depending
on what you hope to use it for, you’ll probably
need to install a bit of software to get a
useful desktop. This is quite a surprise, since
the ISO comes in at a fairly large 1.2GB, but
shouldn’t cause any problems.
   Privacy enthusiasts will be pleased to see
that SpiderOak is included by default. This is
a cloud file backup service similar to
Dropbox, but the files are encrypted on your
device before uploading, which makes it far
more secure. This backup software has
gained a bit of popularity recently thanks to
a public endorsement by Edward Snowden.                     GhostBSD comes with an IRC client that will connect you straight to a GhostBSD channel – perfect
   Another slightly unusual program is Fish                 for when you’re having a little trouble and just can’t find the solution.
as the default shell (others are available).
This works in basically the same way as                        GhostBSD is relatively easy to use, though         best place to get answers to most questions
Bash (the default shell environment in                      not quite as beginner-friendly as some Linux          that beginners may have). That said, it’s not
almost all Linux distributions), but comes                  distros. It also has a smaller user base than         hard to use, and anyone with a basic
with far more graphical niceties, which can                 common Linuxes, so you’re not likely to find          knowledge of Unix-like systems who is
come as a bit of a shock to people used to                  as much help online should you get stuck              comfortable on the command-line shouldn’t
simpler shells.                                             (the Ubuntu and Mint forums are still the             have too much trouble.


  OpenElec 4.1.1 Time to take advantage of the new audio on the Raspberry Pi B+

  It’s never been a secret that the Raspberry Pi makes a         audio out into your sound system’s line in, and you’re
  good media player. In fact, the SoC (system-on-chip) at        ready to go.
  its heart was originally intended for set-top boxes.              You can control XBMC (the media player upon which
  However, up until now, it’s been let down by the poor          OpenElec is based) using a smart phone app. There are
  quality of its analogue audio. This hasn’t been a problem      several options available for most types of smartphones
  for people plugging Raspberry Pis into TVs, since the          including an official one created by the XBMC team.
  HDMI audio has always been good. However, Pis have             (XBMC is more commonly used as a video player, and
  been almost useless for anyone wanting to plug them            OpenElec performs admirably at this as well).
  into stereos.                                                     The SD card has a partition that mounts at /storage
      With the improved sound on the new model B+, the           and contains all the media. Adding new music is just a
  situation is a lot better. There’s also a new version of the   case of using the scp command to copy it from another
  OpenElec media player distro, and we took this as a sign       computer to this location on the Pi.
  that we should hook our Pi up to our stereo and rock out          The whole setup took us less than half an hour, and
  in the name of investigative journalism.                       then we had a smartphone controlled sound system.
      Installing was simply a case of downloading a tarball
  and running a script that sets everything up. This is a
  touch more complex than the Noobs install method
  (which is also possible for OpenElec). Once this is done,
  you just need to pop the SD card in your Pi and start the
  machine. For the initial setup (entering Wi-Fi passwords,      We found the XBMC remote by Music Pump to be a
  etc), you’ll need a monitor and mouse, though once set         little easier to use without a screen than the official
  up, these aren’t needed any longer. Just connect the           app from the XBMC team, but it’s not open source.




                                                                        www.linuxvoice.com                                                                   9
     GAMING ON LINUX




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

 BOWLED A GOGLY
                                          Civilization V
                                          Civilization’s finally back on Linux!


                                          O
                                                      ne of the most popular
                                                      PC gaming franchises                                              A large battle is about
                                                                                                                                 to take place
                                                      ever is back on Linux.
                                          We haven’t seen a Civilization
                                          game on Linux since Loki
                                          Software ported Civilization:
                                          Call to Power in 1999, so it’s
 Liam Dawe is our Games Editor and
 the founder of gamingonlinux.com,        incredible to see it back on
 the home of Tux gaming on the web.       Linux considering how popular
                                          it still is today. The game is


 G
         OG.com (formerly Good Old        consistently in the top 10 most
         Games), the biggest DRM-free     played games on Steam and
         gaming store on the internet,
                                          with good reason, as it can get
 has officially launched support for
 Linux games old and new.                 a bit addictive.                     awesome. You get to pick what    do-as-you-please type game.
    This is some of the biggest news         Civilization V is a strategy      nation you play as, which will   You could play as a warlord
 in Linux gaming since Valve started      game where you’re tasked             affect your starting abilities   pillaging towns and cities, or
 paying attention to Linux with Steam.    with controlling a single nation     and how you progress through     as the most peaceful nation on
 The reason for this is that GOG.com’s
                                          as you fight or make peace           the game.                        earth – the choice of how you
 standards closely align with those of
 Linux itself in the respect of freedom   with the other nations in the          There isn’t a traditional      play is up to you.
 and value: if you cannot get your        world. You build cities, research    campaign mode with a linear      http://store.steampowered.
 game to run (and you system is           new technologies, and it’s           story; instead it’s more of a    com/app/8930/
 capable), then you can get a refund.
 That is great, as to get a refund from
 somewhere like Steam is damn-near


                                          Darksiders
 impossible a lot of the time.
    DRM is also a major issue for a lot
 of Linux gamers and is one of the
 reasons many people use Linux
 instead of products from a company
                                          Prepare to get brutal with your enemy.


                                          N
 like Microsoft or Apple due to the
 DRM mechanisms put into it. This is                ow this is exciting!
 the same for gaming, as a lot of                   Darksiders, a popular
 games may require nasty things like                action-oriented
 an always-on internet connection         hack ’n’ slash type game, is
 even for single-player games.
                                          coming to Linux. It’s all thanks
 You won’t find anything like that on
 GOG.com, as they hate DRM as much        to Leszek Godlewski (who
 as we do. GOG also wraps up really       previously ported Deadfall
 old Windows & DOS games that             Adventures & Painkiller) of
 would never get a proper native port     Nordic Games, so that’s
 using DOSBox and Wine, but unlike
                                          another big games company
 other stores that have some
 Wine-wrapped games, GOG.com              making the transition to Linux
                                                                                                                             I’m going to need
 clearly label a game using Wine.         gaming.                                                                              a bigger sword.
    We see a fair few complaints from       Darksiders merges some
 Linux gamers about games being on        excellent graphics with frantic
 Steam and not DRM-free, so it’s time
                                          gameplay as you battle it out        as you wield a massive           game to really get that button
 for those gamers to put their money
 where their mouth is and support this    with the forces of good and          sword and engage in epic         bashing going.
 excellent DRM-free store.                evil. The game itself features       boss battles. A gamepad is       http://store.steampowered.
                                          around 15 hours of gameplay          recommended for this type of     com/app/50620



10                                                              www.linuxvoice.com
                                                                                                               GAMING ON LINUX


Halfway                                                                                         ALSO RELEASED…
Beautiful pixel art…


H
          alfway is a fantastic space sci-fi    game as you get to know your characters
          strategy game recently released       a bit more while searching your spaceship
          on Steam, and when we say             for those pesky aliens.
fantastic, we really mean it. The visuals         The battles are all at pretty close
and story in Halfway are just amazing, and      quarters and luckily, if you run out of
that’s without even getting into how good       ammo (it can and will happen!), then you
the gameplay is as well, which is fantastic.    can just sit next to a foe and smack them
  Halfway is much like XCOM in that it pits     down melee style.                               Grim Fandango
humans vs aliens in a turn-based strategy         We can easily recommend this one.             I’m sure that name rings a bell for a lot of you!
setting, but that’s where the similarities      http://store.steampowered.com/                  Grim Fandago is being re-released and updated
end. Halfway is a much more intimate            app/253150                                      for modern platforms, and Linux is go!
                                                                                                   Originally released in 1998, Grim Fandango is
                                                                                                quite an old game that many gamers would
  Halfway is easy to                                                                            have probably missed, so especially for Linux
  just pick up and play                                                                         gamers this is a great chance to replay a bit of
  thanks to its simple                                                                          gaming history.
  user interface.                                                                               http://bit.ly/U4BK0C




Unity of Command                                Rochard
The war isn’t over yet...                       Show gravity who’s boss!
                                                                                                Mount & Blade: Warband
                                                                                                Mount & Blade: Warband is an open world
                                                                                                sandbox game that allows you to recruit your
                                                                                                own band of merry men and participate in
                                                                                                medieval battles across the land. You can
                                                                                                travel the country taking quests as you see fit,
                                                                                                but be wary about travelling at night, as
                                                                                                bandits roam the lands and they will try to
                                                                                                capture you. The battles are really fun and you
                                                                                                can even fight while mounted on a horse.
                                                                                                http://store.steampowered.com/app/48700


Unity of Command is an epic turn-based          Rochard is one of the first games to come
strategy game in which you battle it out        to Linux built with the Unity game engine,
against the elements as well as your            and it’s an absolute treat too. Rochard is
enemy. The game is set during the               an action platformer with puzzles that pits
Second World War, and you play as either        you against the familiar threat of alien
the Axis or the Soviets, rather than the        invaders aboard your spaceship.
western allies, as is more common.                The puzzles can get pretty tricky in this
   The game is quite brutal and not             one, as you bend gravity to your will using
easy to get into, so it would be a great        your trusty old ‘G-Lifter’, which doubles up    Terraria
game for hardcore strategy fans looking         as a weapon as you throw crates at your         Rumours abound that Terraria, a highly popular
for something to get their teeth into,          enemy, all while running around a beautiful     2D sandbox game, is coming to Linux after the
especially those of you looking for a game      cartoon-like backdrop.                          developers have finished working on the Mac
                                                                                                port. It is similar to the game Starbound on
with a different setting. We highly suggest        Like Braid or Portal, Rochard isn’t just a
                                                                                                Linux, but not on such a grand scale.
trying out the tutorial first to help you get   run, jump and shoot game: you need to             Terraria could be seen as a 2D version of
to grips with the details – and we don’t        engage your grey matter to play it, and         Minecraft, but with more interesting combat
suggest this very often.                        that’s why we like it.                          and boss battles.
http://store.steampowered.com/                  http://store.steampowered.com/                  http://store.steampowered.com/app/105600/
app/218090/                                     app/107800/



                                                              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
  MANY SUGGESTIONS
  I’m a volunteer at a mental           example, a PDF of the “core
  health charity (www.                  technologies” articles would
  contactmorpeth.org.uk) and I          be good – and put them on
  have been encouraging people          your DVD and website.
  there to use LibreOffice and             Because resources are
  Gimp. One particular boon was         always a bit stretched,
  the End-Of-Lifeing of Microsoft       it would be helpful if the
  Windows XP and Office 2003.           “Gaming On Linux” page
  I’ve been putting Lubuntu             included things like cost and
  onto unwanted laptops or              hardware requirements.
  desktops to give away instead            Bling would be good too.         We’ll add prices and hardware requirements for games from next issue.
  of sending them off to landfill.      Stuff like stickers (to be put on
  Your decision to relicense your       computers being given away)         spreading the Free Software         know that eventually we’ll
  content as Creative Commons           or posters (to advertise this       gospel – every pound that           have a load of content that
  is particularly helpful, because      stuff in the activity room). Or     doesn’t go to Microsoft is a        we’re not doing much with,
  not everyone can justify              maybe a booklet specific to a       pound that can be spent doing       and that’s why we took the
  buying a magazine.                    particular topic, similar to the    something better, as you            decision to relicense it as
     There is one more thing            O’Reilly pocket references or       know. It’s always great to see      Creative Commons when
  I’d like you to do with your          Addison-Wesley phrasebooks.         when organisations realise          the time comes. But yes, I do
  content, though. Every year or        Ian Bruntlett                       this, especially charities          like what you’ve suggested,
  so, look back at your content                                             that should be spending it          and we’ll look into bundling
  and group related articles            Andrew says: Wow, that’s a          doing important work in the         collections of related articles
  together as a PDF – for               lot to go at! Well done on          communities they serve. We          for the web.



GROUP TESTS+
Thanks for the great magazine, I                                     feature (accessibility, installation,     Other than that keep up the
love the programming tutorials, the                                  whatever), and then each package        brilliant work, thanks again and I
computer science history, the                                        is assessed on that criterion. It       look forward to the next 6 issues
geeky Group Tests (window                                            would be easier to read if they         and beyond.
managers! Awesome!), and pretty                                      were sorted by package (Emacs,          Chris Beeley, Nottingham
much everything (also the                                            Vim, etc) and then each package
CC-BY-SA licensing, and the                                          were rated on those criteria.           Graham says: A quick defence of the
DRM-free download). If it was up                                        At present to pick the package       Pi; if you replace Pi with Debian,
to me the Raspberry Pi stuff would                                   that suits you it is necessary to       almost everything Pi-ish works on
be out the window, I really don’t                                    read across all the sections and        other Linuxes too. Raspberry Pi
care, but I understand that many                                     remember what does what and             has just become a great standard.
people want it so I can live with it.                                what they’re all called, rather than    Also, in a twist of wonderful
  Anyway, a suggestion for your                                      reading about each piece of             serendipity, we’ve changed the
wonderful Group Tests. At the                                        software in one section and             format of Group Test exactly as
moment they are sorted first by                                      coming to an overall judgement.         you suggest. Thanks!



12                                                             www.linuxvoice.com
                                                                                                                                   MAIL



                                                                                                           ODF FOR UK
NOM DE MINT PART DEUX
                                                                                                           I’d like to send out a hearty
I see that issue six of your                                                                               message of congratulations to
magazine comes with a DVD; so                                                                              The Document Foundation for
as a digital subscriber I looked on                                                                        pushing open formats for the
your website for a link to download                                                                        UK Government, and the UK
the corresponding .iso file, but saw                                                                       Government for accepting that we
only a message that a link will be                                                                         shouldn’t have to spend money
added later. I wondered whether                                                                            licensing a file format in order to
you might be able to send an email                                                                         read data that belongs to us as
when this link is available in the                                                                         taxpayers.
same way that you let me know                                                                                 Unlike a lot of commenters,
when the magazine is available?                                                                            don’t have a problem with
I’m particularly interested in your                                                                        taxpayers’ money going to a big
Raspbian remix.                                                                                            US company. If that offends you
   I had a look at your ‘Intro to                                                                          so much, then follow it to its
Linux’ videos; it left me wondering                                                                        conclusion and you end up paying
who you saw as your target                                                                                 British firms whether they do good
audience. I have been reading                                                                              workor not, just to keep spending
Linux magazines since 2009, so                                                                             local. That’s silly. We need the best,
most of the terms you used I was                                                                           and the best value for money, and
familiar with, but that wouldn’t                                                                           that’s why ODF is the best choice.
be the case if, say, my sisters had                                                                           Here’s hoping that other
a go, as they wouldn’t know the                                                                            governments go the same way,
                                       Digital subscribers who want to take our custom version of
jargon. Having recently set up a                                                                           and more organisations stop
                                       Raspbian for a spin: go to www.linuxvoice.com/torrents/lv006.iso.
laptop to dual boot Ubuntu 14.04       torrent to download last issue’s cover DVD.                         spending money on a product that
and Fedora 20, I couldn’t work                                                                             only makes it more difficult for
out how to set up the installation                                                                         their customers to interact with
such that Grub 2 would be installed    the time issue 6 went on sale, but                                  them. Again, well played UK!
on a /boot partition, while I had a    these should be fixed in time for                                   Remy Barrett, Worcester
separate “/” root, /home (one for      the next issue to have a DVD on
each distro) and swap partition.       the cover(planned for issue 8).                                     Graham says: In any organisation as
So is there any chance of a video      Sorry about that.                                                   big as Her Majesty’s Government,
tutorial on advanced dual booting?       As for the videos, as long as                                     there are bound to be at least
Galen (AKA YorkshireTyke)              they are useful to someone out                                      some sensible people who know
                                       there, they’re doing their job. Keep                                what’s going on. We too are
Andrew says: We had some pretty        your eyes peeled for a dual-booting                                 immensely chuffed that the wise
banal technical problems around        guide soon.                                                         heads have prevailed in this issue.




                                                            www.linuxvoice.com                                                               13
     MAIL



            SCRIBUS
            Why does Linux Voice use
            InDesign instead of Scribus?
            Has LV tried Scribus and found it
            lacking?
            PR

            Andrew says: A recent InDesign
            update followed by half a day
            lost due to a corrupt file crashing
            a machine has made is ask this
            same question. But the answer
            is still the same: the number of
            freelance designers in and around
            Bristol who know how to use
            InDesign is far greater than the
            number of designers who know
            how to use Scribus, so if our art
            boss Stacey ever wanted to go on
            holiday (perish the thought) we’d
            have an extremely small pool from
            which to find some cover for her
            (NB this is another argument in
            favour of open file formats).
               However, we do want to keep
            our options open in future, and as
            such we’ve chosen open fonts that
            will enable us to move to Scribus
            when the situation changes. We’re     Scribus is excellent software, used by a growing number of quality publications
            planning ahead.                       – including The Oxford Drinker, newsletter of Oxford & White Horse CAMRA.




14
                                                                                                                                       MAIL



BORED WITH THE KEYBOARD
I’m enjoying the new mag, but I                                                                                             Kate won the Group
feel that you need a counterpoint                                                                                           Test of text editors in
to your chant of, “Keyboard,                                                                                                LV002 (now online at
Keyboard, Keyboard!”                                                                                                        www.linuxvoice.com/
                                                                                                                            text-editors), but like
   I’ve been an IT pro for 15 years,
                                                                                                                            all other apps that take
and regular computer user for 10                                                                                            text input, it can be
before that, resulting in about a                                                                                           injurious to your health.
year of RSI. Note that I’ve done
everything I could in terms of
seating position, quality ergonomic
keyboards, regular stretches and
screen breaks etc, and it hasn’t
been enough.
   The biggest culprit is the long
list of Ctrl key chord commands,
which results in your weakest           finger. (Minor bonus: Win-Tab now          mouse button.) Finally, strengthen
finger pressing against a spring        tabs between windows.) Then I              your forearms. I know some
with your hand stretched                use compose:menu to turn the               programmers who actually lift
wide. Ouch. All this to actually        MS menu key into Alt-Gr, since I           weights, and I use grip squeezers
slow you down. (See Bruce               want to use accented characters            on days when my arms aren’t
Tognazzini, www.asktog.com/TOI/         correctly. It only took a short time       too sore.
toi06KeyboardVMouse1.html)              to retrain my muscle memory.                  I hope you can publish this,
   So here’s some advice I’ve              Move your hands, both from              and perhaps keep some of your
learned since. Remap your               keyboard to mouse and around               readers away from the anti-
keyboard. The X.org keyboard            the keyboard. Only copy typists            inflammatory pills. Those are really
extension has a large set of            are judged by words per minute –           hard on your stomach lining.
options to fine-tune your layout.       move off the home keys, and use            Dylan
The desktop environments –              a stronger finger for the extreme
Enlightenment for me – often put        end keys.                                  Mike says: Damn right. Remapping
a GUI in front of them. Otherwise,         Repeatedly double clicking the          your keyboard so the most often
put your choices in a file named        mouse will also hurt eventually.           used modifier key is under your
/etc/X11/xorg.conf.d/10-                Many file manglers have a setting          thumb rather than your little finger
keyboard.conf. Some people set          to use a single click to open and          is the number 1 best thing you
the Caps Lock to act as Ctrl, but       hover to select, which is much             can do for your long-term finger
that is still little finger territory   gentler. Sadly the GTK file dialogs        happiness. I’ve had terrible RSI
and not really good enough. I use       don’t have the option, despite             in the past, which is largely why
altwin:ctrl_alt_win to make Alt         repeated requests for it in their          I’m such a fan of tiling window
and Alt-Gr act as Ctrl keys, and the    bug tracker. (Ever hear about the          managers now – it saves you from
MS Windows key function as Alt.         origin of the double click? It was a       having to cripple yourself using
That puts the most-used modifier        workaround for The Steve’s decree          a mouse. Thanks for the tips –
key under my thumb or strongest         that Macs must have just one               everyone, heed Dylan’s words!



THE VIRUS QUESTION
I can accept that there are no          Ben says: People who write malware
computer viruses on Linux, but I’m      probably want to do so to get the
baffled as to why. The internet is      widest exposure for their little scripts
full of theories, but the most          and botnets, so it makes much better
persuasive seems to be that there       sense to target Windows. It still runs
are so many fewer Linux machines        on the majority of desktops and we’d
than there are Windows, that it’s       guess the average user is less able to
too much effort for the virus writer    defend themselves against malware
to even bother targetting Linux.        than the average Linux user. Combine
But I’ve also read that Linux is just   this with some huge (and undisclosed)
inherently safer. So which is it?       security holes, and cracking Linux is      Antivirus vendors do sell software to stop Linux servers spreading
Davey McGregor, Perth                   just not worth the comparative effort.     viruses to Windows boxes, but for desktop users this unnecessary.



                                                              www.linuxvoice.com                                                                  15
     LUGS ON TOUR




LUGS ON TOUR
CHAR(14) & PGDay
Josette Garcia gets some serious database action in Buckinghamshire.


C
        HAR(14) is a ‘must attend’         BDR is an Open Source project that
        international conference for       follows the same licensc as
        anyone interested in               PostgreSQL (TPL), which is an early
Clustering, High Availability and          form of BSD open source licence.
Replication, plus all forms of parallel,      Simon Riggs talked about the
distributed and grid architectures.        Future of Replication. His views on
The joint conferences were                 the future of Bi-Directional
organised by the UK PostgreSQL             Replication and its inclusion into the
User Group.                                PostgreSQL core code.
   Some of the talks included                 Char(14) was followed by PGDay
“Replication in Security” by Magnus        – some attendees left, some arrived
Hagander – Magnus is a member              but I can say that most people
of the PostgreSQL Core Team and a          stayed for both days.
developer and code committer in                                                     Horwood House venue, near Milton Keynes, home of Bletchley
the PostgreSQL Global                      PGDay                                    Park – now the National Museum of Computing.
Development Group. He currently            Mike Fowler – Migrating Rant &
serves on the Core Team and as             Rave to PostgreSQL – engaging                                      available through high quality open
President of the Board for                 with your customer in every                                        source implementations via the
PostgreSQL Europe. I managed to            possible way. Mike narrated the                                    PostgreSQL and Orange products
follow the history of replication up to    pain of migrating from MySQL to                                    (http://orange. biolab.si/). Do visit
replication streaming. Unfortunately       PostgreSQL. He found that all the                                  the AXLE website for more details
the rest was well above my head            pains were well worth it!                                          on http:// axleproject.eu/.
(see: www.2ndquadrant.com/bdr)               Magnus Hagander presented the                                       I must admit that the content of
   There next followed “Logical            new features of PostgreSQL 9.4,                                    this conference was well above my
Decoding for Auditing and                  which is to be made available in                                   understanding. I should have been
Replication” by Gianni Ciolli, a           August or September.                                               bored but the attendees and the
principal consultant for                     Business intelligence with                                       organisers were so kind that I never
2ndQuadrant Italia. He has been            Window Functions by Gianni Ciolli                                  felt out of place or not wanted.
working with Free and Open Source          – please note the absence of “s”                                      The speakers came from Italy,
Software for more than 15 years. He        after Window. Not only has Gianni                                  Switzerland, the USA, Germany,
was co-founder and then president          got the most beautiful Italian accent                              Czech Republic and Sweden
of the Prato Linux User Group              but he is also extremely funny.                                    bringing information, tricks and
                                                                                                              latest developments. I believe
                                                                                                              PostgreSQL is one of the most used
“Speakers came from Switzerland, USA,                                                                         databases, so why are there so few
Italy, Germany, Czech Republic and Sweden.”                                                                   attendees at the yearly conference?
                                                                                                              It doesn’t make sense. If you are a
                                                                                                              PostgreSQL user, I really hope you’ll
(Plug); he has organised many                 Simon Riggs gave an update                                      come to Char(15) and PGday 2015.
editions of the Italian PostgreSQL         on the AXLE project – Advanced
day, and in 2013 was elected to the        Analytics for Extremely Large                                        TELL US ABOUT YOUR LUG!
board of ITPUG, the Italian                European Databases. The AXLE
PostgreSQL Users Group.                    project is an EU funded project                                      We want to know more about your
  Bi-Directional Replication (BDR)         to greatly improve the speed and                                     LUG or hackspace, so please write
                                                                                                                to us at lugs@linuxvoice.com and
by Andres Freund. What is BDR? It is       quality of decision making on real-
                                                                                                                we might send one of our roving
the latest Asynchronous Multi-             world data sets. AXLE aims to make                                   reporters to your next LUG meeting
Master Replication for PostgreSQL.         these improvements generally



16                                                              www.linuxvoice.com
                                                                                                                          LUGS NEWS



Deer Shed Festival Science Tent
Andrew Gregory, worried about the future, is pleased to see that the kids are all right.


M
             usic festivals on           dried and they what saw they’d
             television always look      made. This is a world away from
             so grubby. Yes, it’s good   any electronics lessons we had at
to get several bands you like in one     school. Forget the theory, just show
place, but they also attract hippies,    them the blinkenlights and they’re
henna, batik and tie-dye. And bongo      hooked.
drums. Bloody bongo drums. We               Over on the other side of the
were delighted then to learn of the      tent, Dan, a Raspberry Pi certified
existence of the Deer Shed Festival,     educator, was giving Python
now in its fifth year of glorious        programming lessons for – you
sunshine near Thirsk in the North        guessed it – Minecraft. This was so
Riding of Yorkshire.                     popular that slots for the weekend
    The festival essentials were all     were fully booked within 15 minutes
there (beer, Johnny Marr, burgers),      of the science tent opening, and we
but what piqued our interest was         can see why.
the festival’s science tent. Deer           The children playing with
Shed is a family-friendly event,         Minecraft looked to be around 10
and rather than leave the kids           years old, and Dan had them coding
to pointless displays of tribal          different block types. A few lines of
drumming (Which tribe? It’s never        Python saved into a configuration        planetarium each; again, these were     Deer Shed Festival is
specified!), the organisers had          file and players were wandering          wildly popular. And the Teeside         held in the grounds of
filled a tent with demonstrations        the Minecraft world leaving a trail      University representatives excelled     Baldersby Park, built
of science – Python, Arduino,            of flowers behind them (perhaps          themselves with CST: Teeside, a         for communications
                                                                                                                          technology pioneer
astronomy and more.                      the hippy nonsense had pervaded          mocked-up crime scene complete
                                                                                                                          George Hudson.
    Connor and Paul from Pimoroni        the science tent after all), or flying   with evidence to solve the case.
                                                                                                                          deershedfestival.com
had made the trip to show kids           through the sky leaving a spiral of         For parents of small children
how to build little shrimp kits –        watermelons. After that, you’re only     who want to let their hair down with
tiny, functioning circuits made          a variable away from being able to       kids in tow, Deer Shed is great. For
out of ordinary components. Next         change block types on the fly from       the atmosphere, the brilliant local
door to them, a crowd of six-year-       within the game.                         beer (no flat Carling here, thanks
olds were drawing circuits on                                                     very much), the performances and
cardboard, plugging in LEDs and          More science                             everything else, it’s well worth it.
practically jumping up and down          The universities of Teeside and          If you’re at a loose end in late July
with excitement when the circuits        York brought along a mobile              next year, come along!




                                                                                                                          Far left: The science
                                                                                                                          tent was packed for the
                                                                                                                          whole sun-drenched
                                                                                                                          weekend.

                                                                                                                          Left: Sebastian Jacques
                                                                                                                          helps Paul from
                                                                                                                          Pimoroni out with a
                                                                                                                          simple circuit.


                                                              www.linuxvoice.com                                                              17
     SHOW REPORT OSCON
                                                                                   Tickets to OSCON are expensive, but one of
                                                                                   the free hall or exposition passes will also get
                                                                                   you into many of the sponsored sessions.




                                                                                        4,400 attendees create a buzzing
                                                                                        hive mind of ideas, connections
                                                                                        and possibilities.




         OSCON 2014
          Graham Morrison travels almost 5,000 miles from the Shire to the
                  biggest open source conference on the planet.


         W
                     e’ve been going to O’Reilly’s Open Source     sponsored, for example. Of course, there’s still the
                     Convention – better known as OSCON, for       major backers – bluehost.com, PayPal, Citrix, Google
                     eight years. Not just because of the          and HP plus a plethora of smaller companies. But
         incredible number of fine India Pale Ales on offer, or    many of the extracurricular functions wouldn’t be
         the highest concentration of microbreweries this side     possible without their contributions. Monday night’s
         of the Orion Spur, but because Portland is a friendly,    Attendee Party, for instance, with its surreal
         warm and creative city host to an incomparable            combination of oxygen bar, quad-copters, bungee-
         variety of bars, beards and body art; the perfect         trampolines and glittery cupcakes was funded by
         backdrop to a week of geek communion.                     three different sponsors. However, this year’s event
           And each successive year here helps OSCON               felt hackier, more makery and more open source-
         imbibe more of Portland’s spirit. This year’s event was   friendly than previous events – truer to its roots as a
         noticeably less corporate and less ostentatiously         Perl conference, and we enjoyed the difference. All of




18                                                     www.linuxvoice.com
                                                                                                           OSCON SHOW REPORT

which gave the many, many corridor meetings, the           Shadaj Laddad gave an
Birds of a Feather get-to-togethers, the after-session     impassioned talk about
parties and the sessions themselves an atmosphere          how programming is
                                                           shaping his future.
not unlike a University campus.
   This year’s event started unusually on a Sunday
(and singularly; Monday–Friday service resumes in
2015), and one of the most inspirational parts of this
year’s conference was that you saw children in the
halls and corridors, and sometimes, in the sessions
themselves. This was because on the first day,
Sunday, there was the beta version of an experimental
track that O’Reilly called Kids Day. On this track, 70
kids of all ages – and we spoke to attendees who
could have been anywhere between 6 to 16 – got their
hands dirty learning Python, modding a Java game
with a touchscreen Raspberry Pi or hacking Minecraft.
                                                                                                                         Simon Wardley started his
                                                                                                                         talk by giving a huge
Open Source satellites                                                                                                   shoutout to the
This refreshing approach continued through to                                                                            UK Government for
Tuesday’s keynotes, where you had to pity the                                                                            committing to open
sponsors that followed enthusiastic teenage coder                                                                        document formats.
Shadaj Laddad, after he delivered a talk full of wonder
and the freshly squeezed potential he’s found through
programming. We also loved Wendy Chisholm’s                how best to serve your users, he mentioned gov.uk’s
coming out session for introverts, where she, along        design principles (https://www.gov.uk/design-
with what appeared to be 95% of the other attendees,       principles) document, and how this list is a “fabulous
admitted that they’re not super-confident supreme          idea about how you start with [your users’] needs.”
beings after all, and keeping up appearances can be           Tim Bray (co-creator of the XML specification and
exhausting. But it was Will Marshall’s final talk on the   lots of other good things) is currently concerned about
briefcase-sized imaging satellites his company is          privacy, and his talk was mostly about pleading with
launching that got us emailing Planet Labs to ask for      developers to add proper encryption.
an interview. They’re throwing hundreds of these units        “We don’t want to talk about this stuff because it
into orbit and creating a system that updates a            involves two really horrible things:” he said, “really hard
complete image model of the Earth every 72 hours,          math and… politics.” He went on to make what we
potentially down to individual fields, houses and trees.   think is a vital point, “But I’m going to argue that you
More importantly, they’re going to create an open API      should get interested and here’s why: first of all, you       Below left Wendy Chisholm
to deliver universal access to this data, and to allow     can ignore the math these days. There’s good libraries        admitted she was an
anyone to perform their own analysis. Each satellite is    for that. And as for the politics, politics and policy are    introvert. Along with
also powered by a tiny x86 computer running Ubuntu.        reality, and if you want to blow that stuff off then          almost everyone else.
   On Wednesday, Simon Wardley’s keynote was               you’ve just lost the right to complain.”                      Centre Will Marshall is
preceded by an impromptu slide informing the                  OSCON is always going to be a difficult proposition        holding one of his
                                                                                                                         satellites. It’s tiny, based
audience of the UK Government’s intention to switch        for Europeans and people a long way from the North
                                                                                                                         on an x86 PC and runs
internal documentation to ODF and PDF/A, which was         West coast of the United States. But if you’re lucky
                                                                                                                         Ubuntu!
greeted by an enthusiastic cheer. In a doubly              enough to work for a company with money to spend              Below right Tim O’Reilly
surprising UK reference, Tim O’Reilly later talked about   on training, we can think of no better way of doing so.       shares his usual insight
technological and cultural revolutions, and in a part      For anyone else who can afford it, it’s without doubt         and wisdom into the way
where he’s referencing the difficulty of recognising       worth the trip.                                               things are going.




                                                             www.linuxvoice.com                                                                  19
                      BEST
                     DISTRO
                         Is your current Linux distribution really
                                                                                                  2014
                     the best in town, or are you missing something
                        even better? Graham, Ben and Mike put a
                                    bunch to the test.




     W
                  e’re going to get a lot of flak for writing   pace of development in Linux, it’s always worth
                  these words, but we’re not scared – Linux     keeping your eyes open for something better.
                  Voice drops ice cubes down the vest of           With all these things in mind, we decided to look at
     fear. So here we go: you might be using the wrong          the current state of play in the Linux distro world. We
     Linux distribution. Or to put it more diplomatically,      wanted to see which distros excel in certain
     you might not be running the distro that’s best suited     important areas, to find out who’s leading the charge
     to you. “What a load of codswallop!”, you respond.         here in mid-late 2014.
     “My distro does                                                                                In tests like these,
     exactly what I need it
     to do. I’ve been using  “Given the pace of development in                                   it’s often possible to
                                                                                                 bundle certain distros
     it for years and I’m    Linux, it’s always worth keeping an                                 together as they’re so
     happy with it.”
         That’s great, but   eye out for something better.”                                      closely related. In the
                                                                                                 Packages section, for
     could it still do a lot                                                                     instance, we look at
     more? Have you really tried all of the big-name            Ubuntu and Mint together because they share the
     distros in depth? Could there be another distro out        same repositories. In any case, we want to give you
     there that’s better than yours in a key area such as       all the information you need to make an informed
     security, performance or documentation? Is your            choice about the best distro for you. So if the one
     distro really the best when you’re trying to convert       you’re currently using comes up tops in the
     newbies to Linux? It’s good to settle on a single          categories important to you – congratulations! And
     distro and learn its ins-and-outs, but given the rapid     if not, fire up VirtualBox and start exploring…



20                                                 www.linuxvoice.com
                                                                                                   BEST DISTRO 2014 FEATURE


            Best for beginners                                                                                                       WINNER
            The ideal gateway into Linux for new users.


F
        or beginners, two things are
        important. One is whether you can
        work out how to do something by
yourself. The second is how easy is it to find
a solution if you hit a problem.
   For a long time, the standard distro for any
beginner was Ubuntu. However, since the
introduction of the Unity interface, it has
become less popular. The non-traditional
layout of the desktop could lead to
beginners feeling unfamiliar, and the
Launcher and scopes can take a little getting
used to. People coming from Windows may
also get confused by the way the window
menu bar blends into the top menu bar.
   The others distros we’ve looked at are all
based on a traditional desktop, and the
layout should be familiar to anyone who’s         The KDE desktop can be confusing at first, but Mageia’s implementation is relatively intuitive.
used a computer at any time in the last 20
years. They have a task bar along the             good first impression – no one wants their          However, we can’t really expect a new user
bottom and an applications menu in the            new operating system to look worse than             to know this.
lower right-hand corner.                          their old one.                                         Ultimately, we think that the amount of
   Mint is the most popular of these. Its two        The biggest difference between Ubuntu            help available for Ubuntu outweighs the
main flavours (Mate and Cinnamon) are             and the others from a beginner’s point of           unfamiliar user interface. However, everyone
sufficiently similar that we’ll consider them     view isn’t the interface, but the huge amount       is different, and any of these distros would
together. The last of the contenders in this      of help online in the form of tutorials, forum      make a good choice for beginners. We
category is Mageia.                               posts, and solutions to problems. If you get        would recommend Mint (either version) for
                                                  stuck on Ubuntu, you’re far more likely to          beginners who had trouble getting used to
Simple interfaces                                 find a solution online than if you’re using         Unity, and Mint Mate edition for people with
Overall, we feel the KDE environment of           another flavour of Linux. Of course, an             lower-powered hardware.
Mageia is a bit too cluttered to be ideal for     experienced user will know that if they have
beginners, though it does have an important       a problem on Mint or Zorin (another distro            WINNERS
place. Both of the main Mint desktop              aimed specifically at new Linux users, with              1st Ubuntu
environments (Cinnamon and Mate), are             an interface designed to look and feel like              2nd Mint
clean with unnecessary detail tucked away.        Windows), they could look for a solution for             3rd Mageia
It also looks really nice, which helps give a     Ubuntu and it would probably work.


                                                                                                        When beginners aren’t beginners
                                                                                                        We’ve based this category on the idea that a
                                                                                                        beginner is non-technical. This may not be
                                                                                                        the case. They could be new to Linux but have
                                                                                                        experience configuring Windows systems, in
                                                                                                        which case they may be uncomfortable at the
                                                                                                        command line and editing configuration files,
                                                                                                        but still have a good idea what’s going on. There
                                                                                                        is a certain logic to saying that the best distro
                                                                                                        for people like this is Arch Linux. Using this,
                                                                                                        they’ll have no other option than to learn how
                                                                                                        their new Linux system works.
                                                                                                           Another option would be Mageia, because it
                                                                                                        has the Mageia Control Centre. This enables you
                                                                                                        to configure much of the system from within
                                                                                                        one unified graphical application. Rather than
                                                                                                        having to memorise different commands for
                                                                                                        each task, you just fire up the Control Centre
The Ubuntu Launcher does far more than a typical desktop menu. This can take a bit of getting           and make any changes that are needed.
used to, and has drawn criticism from privacy groups for its internet searching.



                                                              www.linuxvoice.com                                                                        21
     FEATURE BEST DISTRO 2014


             Best looking                                                                                                         WINNER
             An attractive environment makes everything better.


T
         his category is particularly
         contentious for two reasons. First,
         what is beauty, and who gets to
define it? Second, since almost any distro
can be made to look like almost any other
distro, how do we decide which is the best
looking? These are both valid questions, but
we will crush them both with an
authoritarian boot. Firstly, we know beauty
when we see it, so we get to define it (if you
don’t like that, start your own magazine).
Secondly, we’ll look at each distro naked,
straight after installing it.
   Bodhi Linux is based on Enlightenment,
which bills itself as the original eye-candy
desktop environment. Perhaps the most
impressive thing about Bodhi (and
Enlightenment) is how many graphical
treats it can supply with very little strain on
the hardware. This makes it a good choice if
you’re after a slick distro for a low-powered
machine. However, some of the graphical
niceties feel a bit like they’re there to show       The clean, simple style of Elementary OS flows through the desktop and all of its included
off, rather than to make using the desktop a         applications to make a beautiful computing environment.
more pleasing experience.
   Lots of distros come with KDE, but default        the RocketBar replaces the panel, but looks        a souped-up Gnome Dash. All these
KDE is a bit lacklustre. OpenSUSE and                a lot nicer. Along with the usual icons and        enhancements mean it’s not the best distro
Mageia do quite a good job of improving it,          widgets, there’s a Downloads stackfolder           if you prefer to use your own KDE
but they’re not in the top tier. Our favourite       that enables you to see the contents of            configuration, but for people who want a
KDE flavour is Rosa Desktop Fresh. As soon           ~/Downloads without having to open up the          good-looking distro on first boot, it’s great.
as the desktop loads, you can see it’s not           file manager. Simple Welcome takes the                Mint Cinnamon does a good job of getting
standard KDE. At the bottom of the screen,           place of the KDE menu, and works a little like     out of the way, while still being pleasing to
                                                                                                        the eye. It’s the least ostentatious of the
                                                                                                        environments we’ve looked at here, and this
                                                                                                        comes from having a clean desktop and a
                                                                                                        well-themed set of GTK widgets.
                                                                                                           Pantheon – the desktop environment of
                                                                                                        Elementary OS – also uses GTK to provide a
                                                                                                        clean and elegant look. Elementary takes
                                                                                                        this approach further than Cinnamon, and
                                                                                                        the environment is stripped down to its bare
                                                                                                        essentials. Every icon feels like it’s been
                                                                                                        placed for a good reason, and every pixel
                                                                                                        tweaked to fit in perfectly.
                                                                                                           All of these distros look good. However,
                                                                                                        Elementary OS does the best job of carrying
                                                                                                        its style through the wide range of apps that
                                                                                                        comprise it, and so we’re declaring it the
                                                                                                        best-looking desktop distro.


                                                                                                          WINNERS
                                                                                                             1st Elementary
                                                                                                             2nd Rosa
It’s hard for a static picture to capture the eye candy on Bodhi, as it’s all in the movement. But           3rd Mint
picture the menu icon spinning, the terminal pulsating, and everything fading in and out.



22                                                                www.linuxvoice.com
                                                                                                     BEST DISTRO 2014 FEATURE


                      Best for packages                                                                                         WINNER
                      Which distribution has the most software?


B
         race yourself for some controversial
         statistics. Counting the exact
         number of packages in a distribution
can be tricky, and different distributions
package up software in different ways. For
instance: imagine you’ve got a program
called FooApp that has support for 10
different languages for its interface. One
distro might bundle everything together into
a single package – whereas another may
give each language its own package.
Multiply this over thousands of programs
with multi-language support, and it
drastically changes the package counts
between distros, even if they have the same
number of applications.
   Similarly, many programs support the use
of plugins and extensions; again, these may       The Arch User Repository is huge, and new software ends up here more quickly than in other distros.
be placed into the main package in some
distros, or split out across dozens of extra      updated in years, but they’re still being           packages. What gives?” Well, that’s the total
packages in others. Quite a few distros           rebuilt to work with the latest distro versions.    for i686 and x86_64 packages – there’s a lot
make use of “virtual” packages, so installing,                                                        of overlap. It’s unfair to count the packages
for example, the package xfce4 actually           Abaci at the ready                                  for all architectures (otherwise Debian’s bar
pulls in 20+ other packages. And some             Now, let’s talk about Arch Linux. We                in the chart below would extend beyond the
distros that provide long-term support            separated its package statistics into two           top of the page), so in the case of Arch and
include multiple versions of packages for         parts here: one for the main distro                 other distros, we chose the x86_64 and any/
maximum compatibility (eg older versions of       (community, core, extra etc. repositories),         noarch repositories. Basically, the stats
SDL, SDL-mixer, SDL-image etc).                   and the other for AUR, the Arch User                below show the number of packages you
   So the end result doesn’t necessarily          Repository. The latter is enormous and              can install on an x86_64 box.
reflect the range of software in a distro.        updated at a breakneck pace, but the                   After all that a caveat: quality does not
Although it has twice the number of               packages are not in the “official” distribution     mean quantity. If you’re looking for a server
packages in its repositories, Debian doesn’t      (although they often end up there after             box, packages of synthesizers, games etc
simply have twice as many standalone              extensive testing). Officially, Arch only had       aren’t going to be much use to you.
programs as OpenSUSE. But one thing is for        6,836 packages at the time of writing – not
sure: if you’re looking for a lesser-known or     actually that many, but that’s what you get if       WINNERS
obscure piece of software, you’re more likely     you stick to the main distro.
                                                                                                          1st Arch
to find it in the distros with the high package      “But hang on”, you say, scratching your
                                                                                                          2nd Ubuntu
counts. A big chunk of the programs in Arch       head. “I’ve just been to www.archlinux.org/
                                                                                                          3rd Debian
and Debian are old and haven’t been               packages, and it says there are 11,459



                                                           Package counts per distro
 Number of packages




                                                              www.linuxvoice.com                                                                 23
     FEATURE BEST DISTRO 2014


            Best for documentation                                                                                             W I N NE R
            When you need help, who you gonna call?


Q
          uality is a lot more important than
          quantity when it comes to
          documentation. Over the years
we’ve seen many free software projects that
have reams of guides, tutorials and FAQs,
but if the content is badly written,
unorganised or out of date, it’s not much
use. The same applies to distros: a short,
concise and well-written guide is much more
useful than poorly maintained scraps of
information scattered around the web.
   Debian’s official documentation is
generally well crafted, but it suffers from a
lack of centralisation. Go to www.debian.
org/doc and you’ll see that there are plenty
of resources, but it’s not clear where to start
if you’re seeking help about a specific
problem. Should you look at the FAQ? Or           Arch’s guides may look excessively long at first glance, because they include absolutely everything.
Debian Reference? Maybe the wiki has the
answer… It gets a bit messy, but we have to       favourite for documentation. You’d order a         scattered around and would be better
give a mention to the separate Debian             boxed set over the phone, and a few days           organised into a single reference document.
Administrator’s Handbook (http://debian-          later a hefty lump of Linux goodness would         Of course, CentOS users can read the official
handbook.info). This is exactly what we’re        arrive at your door, containing three chunky       Red Hat documentation at http://tinyurl.
looking for as end users and admins:              manuals. It was bliss. Today, OpenSUSE still       com/rheldocs, which is very thorough,
everything you might need, in one place.          has an excellent set of documentation at           straightforward, and polished. You can see
   Ubuntu’s docs (https://help.ubuntu.com)        http://doc.opensuse.org: the Startup guide         the results of Red Hat paying people to work
are mainly focused on desktop end-users,          (for regular end users), Reference (for            full-time on documentation.
with well categorised mini-guides to              administrators) and extra guides for security
common tasks. The Server Guide has more           and virtualisation. There’s some overlap and       Super Arch
advanced user material – but it’s not             we’d like to see them combined more                Finally we come to Arch Linux, and we’ve
                                                                                                     saved the best until last here. Arch’s
                                                                                                     documentation is almost entirely provided
“Back in the days of dialup internet connections,                                                    on the distro’s wiki at https://wiki.archlinux.
SUSE Linux was our favourite for documentation.”                                                     org, which has some of the most in-depth
                                                                                                     and detailed guides we’ve seen of any
                                                                                                     software project. The Beginner’s Guide is
exhaustive. Plenty of other tips are scattered    effectively, but the information contained         especially good, if a bit long-winded (but
around the wiki at https://help.ubuntu.com/       therein is clear and well presented.               then, Arch is targeted at experienced Linux
community, and there’s also                          Then we have Fedora and CentOS. The             users). Then there’s the General
www.askbuntu.com, which is a good way             former, at http://docs.fedoraproject.org, is       Recommendations page, which is a superb
for getting quick-fire responses to questions.    in a sorry state: you’re told to select a          one-stop-shop for all things administration:
   Many guides for Debian and Ubuntu apply        language and then Fedora version, and read         user management, packages, power
to Mint, but the latter also has its own PDF      the docs from there. Our test case was to          management and so forth.
installation guides in various languages:         find a guide to adding new user accounts –           But what makes Arch our winner is this:
www.linuxmint.com/documentation.php.              and for Fedora 20, it wasn’t there. Nothing.       for the large part, its information applies to
Some of the versions are very out-dated,          When we opened up the documentation list           other distros. In discussions on the web,
however, missing the latest Mint releases.        for Fedora 18, however, we saw the System          we’ve seen users of Ubuntu, Debian, Fedora
   Mageia, meanwhile, doesn’t really impress      Administrator’s Guide, which had the               and other distros paste links to the Arch wiki,
with its limited range of guides at               information we needed. So lots is either           simply because its guides are so good.
www.mageia.org/en/doc; there’s some               outdated or badly sorted – it’s hard to
information on the installer and control          navigate and needs to be cleaned up.                 WINNERS
panel, presented in an unwelcoming fashion,       CentOS doesn’t fare much better. The
                                                                                                          1st Arch
but not much else on the wiki.                    manuals at www.centos.org/docs don’t
                                                                                                          2nd CentOS
   Back in the days of dial-up modem              cover the last two major releases, while the
                                                                                                          3rd OpenSUSE
connections, SUSE Linux was our absolute          wiki has some useful guides, but they’re



24                                                            www.linuxvoice.com
                                                                                                                BEST DISTRO 2014 FEATURE


              Best for security                                                                                                             WINNER
              The price of security is eternal vigilance.


T
          here are lots of different aspects to
          security – enough for eight pages on
          its own. Your first step is to
understand your own requirements. If your
first priority is the security of your own data,
for example, you would require a distribution
that’s happy to encrypt your home folder or
root partition and handle the complexity that
that involves. You may also want to extend
that requirement to easy integration of
GnuPG into the default email client, or even
making sure Firefox is pre-configured to
always use HTTPS. But most importantly,
security needs to be easy, because if you
don’t understand what you’re doing, a bad
configuration is worse than no configuration
at all, because it gives you a false sense of
security. This is the problem with Arch. It can
be the quickest distribution to patch a                 Booting Tails from a USB stick will keep your connections anonymous through the Tor network.
vulnerability, and it makes an excellent
server, but you need to know what you’re                feelings about this, especially as there was             machine. This can still be important – you
doing, because a mistake could be costly.               no way of turning it off. But these problems             may only want a web server accessible on
    We have to give credit to Ubuntu here.              have been mostly addressed, and while it’s               your LAN rather than across the internet, for
It took the relatively brave step of moving             still turned on by default, there’s a simple             instance. But it’s more important to worry
its full-disk encryption option from behind             way of turning the shopping scope off. If                about the services and applications you
the advanced settings in its installer to the           you wanted to be certain, for course, we’d               run. This is where most problems occur,
forefront of the installation processes, giving         recommend using an Ubuntu derivative,                    and the recent Heartbleed bug in OpenSSL
many more users the opportunity to encrypt              but Ubuntu is still a good choice for easy,              highlights this issue perfectly. It’s used by
their data. For a distribution as user-friendly         comprehensive encryption.                                so many applications and services that
and as popular as Ubuntu, this was a brave                                                                       many became vulnerable as soon as this
move. Even the EFF was impressed.                       Reactive security                                        bug was found, and consequently, the best
    Ubuntu also made a lot of noise when its            The other principal concern is online                    distribution for security became the quickest
shopping scope searches from the dash                   security. This always used to mean the                   distribution to patch the vulnerability.
sent unencrypted data through its own                   pre-configuration of a firewall blocking                    But it’s not just speed of deployment
servers to Amazon. Many of us had strong                external access to services running on your              that’s important, it’s the quality of any
                                                                                                                 patches as well as the testing that goes
                                                                                                                 into the original distribution. And for that
  Turn on automatic updates
                                                                                                                 reason we’d recommend a distribution with
  When a vulnerability is detected and the                                                                       a proven track record of defending itself
  problems with a package are corrected, you                                                                     online. CentOS, for example, with its Red
  need to install the update to patch the problem                                                                Hat provenance is rock solid, although it still
  on your distribution. You can do this manually                                                                 requires some know-how.
  by triggering the update procedure, but that
  means you also have to be proactive by keeping
                                                                                                                    However, if security and privacy are of the
  an eye on any security issues. This is what                                                                    utmost importance, nothing can touch Tails,
  many Arch users do as a matter of course.                                                                      a distribution designed for anonymity and
  But for more general use, you’re better off                                                                    secure communication, so we’re putting that
  turning on automatic updates, and if possible,                                                                 top of our list, followed by more pragmatic
  limiting those updates to security patches of a
  certain severity.
                                                                                                                 solutions that can be used more as day-to-
     With so many distributions being derived                                                                    day installations.
  from the latest Ubuntu release, they can all take   Don’t worry about security updates. We’d
  advantage of Canonical’s updates. Just open         suggest installing them automatically.
  the ‘Software & Updates’ control panel, switch
                                                                                                                  WINNERS
  to the updates page and use the drop-down           automatically’ option, because then you can simply             1st Tails
  menu to select an option that works best for        forget about it – it takes any hassle out of staying up        2nd Ubuntu
  you. We’d recommend the ‘Download and install       to date.                                                       3rd CentOS



                                                                       www.linuxvoice.com                                                                    25
      FEATURE BEST DISTRO 2014


                 Best for performance                                                                                                      WINNER
                 Forget upgrading your hardware – get a new distro!


B
         ack in the olden days, when every
         megahertz was sacred and PCs                Performance benchmarks
         were beige, the performance of your
distribution was important. It would make
the difference between a system being
snappy and usable, or a system being
re-installed or consigned to the bin.
    Nowadays it’s the case that in some ways,
especially for desktop use, performance has
plateaued. Multi-core CPU cycles, storage            Times are in seconds unless otherwise stated

and memory are cheap, and most of us
barely touch their limits. Your choice of          If you want the best performance from your system, use a low-power window manager and the CLI.
distro normally has much more to do with
package provision and the default desktop          16GB RAM) with dozens of devices                             we’ve learnt from these tests:
environment than whether it’s making best          connected, so it was a good real-world test.                  1 Firefox runs almost identically, regardless

use of your hardware. And because that             It also meant that the test was unfair on                        of your distribution or desktop. If all you do
hardware is always so different from one           some distributions, as they made a much                          is browse, don’t worry about it.
user to the next, it’s almost impossible to        better job of parsing the many USB devices                    2 GUI tools for file management can have

provide a comparative metric that’s going to       than others while taking longer to load for                      an effect on file operations, especially if
have any meaning.                                  their trouble. This is why Arch does well at                     you’re installing third-party applications.
    Therefore, if you care about performance       boot time – we haven’t installed anything to                     Use the command line if you can. If not,
it’s because you need to get the best out of       make it do otherwise.                                            take the time to configure a cut-down
limited hardware, and we can, sort of, test                                                                         window manager or desktop.
for that. In a completely unscientific way, we     Take it with a pinch of salt                                  3 If you’re looking for a distribution for

installed six diffeent distros alongside            All of which is a long way of saying                            low-powered hardware, use a low-
Windows 8 on the same PC and onto the              benchmarking and tests say very little about                     powered distribution. Slacko Puppy 5.7.0
same (large) hard drive. This is a real            the performance you can expect on your                           easily won nearly all the performance
working computer (3.3GHz Core i5 with              own hardware, but there are three lessons                        tests, only failing on the GUI compression.
                                                                                                                    That’s mosty because its creators
Resource usage                                                                                                      wouldn’t imagine the typical user not
                                                                                                                    using the command line.
                                                                                                                    That makes Slacko Puppy our choice
     Scientific beta                                                                                            of distro if you need something to run on
                                                                                                                limited hardware. It’s also pretty addictive
                                                                                                                running it on fast hardware, as you suddenly
           Mint 17                                                                                              realise the reason why the window isn’t
                                                                                                                moving immediately after you click it is
                                                                                                                because your desktop is drawing shadows
                                                                                                                and wobbly windows. Everything else
 Slacko Puppy 5.7.0
                                                                                                                suddenly feels sluggish.
                                                                                                                    But we also have to say that Lubuntu, the
                                                                                                                LXDE-based derivative, did remarkably well,
         Arch KDE
                                                                                                                which makes it our recommendation if
                                                                                                                you’re looking for modern fittings on a frugal
                                                                                                                desktop, and one that still looks fantastic.
     Lubuntu 14.04                                                                                              Our third place goes to Arch simply because
                                                                                                                it’s the easiest way to build your own
                                                                                                                minimal distribution for your own hardware,
                                                                                                                only installing exactly what you need.
      Ubuntu 14.04


                                                                                                                 WINNERS
                       0               1500          3000                        4500                    6000
                                                                                                                     1st Puppy
                                                                                          RAM Used
                           Megabytes                                                      Storage Used               2nd Lubuntu
                                                                                                                     3rd Arch
In a comparison of the amount of RAM and storage used after installation. Slacko wins easily.


26                                                                 www.linuxvoice.com
                                                                                                   BEST DISTRO 2014 FEATURE




  BEST DISTRO 2014
J
         ust as the sports team with the best
         stats doesn’t simply win the game,
         the distro with the best scores in six
areas doesn’t simply get awarded the best
distro status. To come up with an ultimate
winner, we stared deep into each distro, and
drew on our personal experience. We looked
into every option, and meditated on the
concept of distro nirvana.
   We were looking for a distro that performs
well in every area, and excellently in many,
making it a good all-round distro. However
this alone isn’t enough. It needs to have
something that pushes it ahead of the
competition – and the competition is getting
better every year. It needs that certain X
factor to make it stand out. It should be a
distro people want to install; a distro that
people get passionate about; a distro that
makes you remember why you love Linux.
   Arch Linux does all this and more. The two
things that make it stand out aren’t fancy        Arch: Linux that doesn’t disguise itself
bits of software, or slick user interfaces, but
its philosophy and its community. Arch is         different uses people have for Linux. It’s an     don’t fall in love with the distro, you’ll learn a
built around the simple principle that the        endlessly flexible system, so there will never    lot about how Linux works, and get a better
user should control the system. Instead of        be just one form that is perfect for everyone.    understanding of why other distros do the
fancy graphical tools to autoconfigure               That said, we think that Linux users           things they do. It’s not just for super-geeks
everything you need, it provides you with just    should try Arch at least once. Even if you        – it’s a distro for the masses.
the bare essentials you need to build your
own system.
   Just as a mountain climber becomes one
with the raw mountain in order to climb it
without technical assistance, and a surfer
                                                    OUR CHAMPIONS
needs just a carved plank to harness the
power of a wave, so a computer user needs           Best for beginners: UBUNTU
just the basic tools that Arch Linux provides
to get the most out of their system.
   The community keep the documentation             Best looking: ELEMENTARY
up to date, and build the Arch User
Repository – one of the largest collections
of software in the world.                           Best for packages: ARCH
   All this doesn’t mean that we think
everyone should stop here while they go and
install Arch on every computer they have.           Best for documentation: ARCH
While we think it’s the best Linux distro
currently available, it’s not perfect for every
situation. For example, Tails is still the best     Best for security: TAILS
distro for online anonymity, and the
cutting-edge nature of Arch means that only
the bravest sysadmins will use it on                Best for performance: PUPPY
public-facing servers.
   There are hundreds of Linux distros for a
reason, and that reason is the hundreds of



                                                               www.linuxvoice.com                                                                   27
     FEATURE RASPBERRY PI B+




         RASPBERRY PI
                                 Two computers, one SoC. Ben Everard
                                  takes a look at the new Raspberry Pi
                                    that ships with the old processor.                                    B+
          O
                   n Monday 14 July, The Raspberry Pi            sides; the USB ports no longer stick out; and the
                   Foundation officially announced the biggest   mounting holes are now in a rectangle. These
                   change to the design of the Raspberry Pi      mounting holes are also used to support expansion
          model B since its launch at the start of 2012: the     boards, making a far more secure attachment than
          model B+. In a surprise                                                              relying on GPIOs alone
          to some, the new Pi                                                                  (as most did
          doesn’t have a new       “The differences between the B                              previously).
          processor or any more
          memory than the
                                   and B+ are important, and add                                  These are all cosmetic
                                                                                               changes, but together
          previous revision.       up to a much better computer.”                              they do make the device
          However, many things                                                                 nice to use. Perhaps the
          around the System on a Chip (SoC) have changed.        biggest beneficiary of these changes aren’t normal
            The new version is almost exactly the same size as   users, but the people making boxes and enclosures
          before, but again there have been a number of          for the Pi.
          important tweaks to the physical design. The corners     If you’re used to thinking about computer
          are now rounded; the connectors only lead off two      performance in terms of the usual metrics of



28                                                   www.linuxvoice.com
                                                                                                             RASPBERRY PI B+ FEATURE


  Side by side The changes mapped out

                          2          10                                                                                  10
                                                                                                                                          1



                                                                                           2




                                                               5


                                                                                               9

                                                                                                                         7                          5




                                    7

              9

                                                                    8



                                                                                               6




                                                           6




                                                       1
                  4                                                                                                       3
                                                                                                   4
                                                                                                                                              3
                                          3




   1 Status LEDs The Power and ACT LEDs have           4 Ethernet The B+ still connects Ethernet through     good. The B+ improves this dramatically, and is
  moved to a new position on the board and the        the USB hub, so speeds can be affected by heavy        good enough for most applications.
  network LEDs on the B+ are on the network port.     USB usage. The network status LEDs are now on           7 SoC and Memory These are exactly the same on
   2 Power Supply The B+ is still powered by the      the Ethernet port.                                     the B and B+, so performance should be identical.
  same micro USB power supply; however it uses the     5 GPIO Pad 1 This has been expanded from 26 to         8 Composite Video On the B this had its own
  power more efficiently, so it’s less prone to       40 pins. The top 26 pins are identical on both the B   connector, but on the B+ it’s on the fourth pole of
  power-related problems than the model B.            and B+, so and boards that connect to them should      the audio jack. This means you’ll need the
   3 USBs Thanks to the improved power supply, the    work on both. However, some boards designed for        appropriate cable to connect it to a TV.
  USBs on the B+ are capable of running higher-       the B (such as the PiFace) fit closely around the       9 HDMI HDMI video and audio is unchanged.
  powered peripherals, though a powered USB hub is    raised components may not physically fit onto the      10 SD Card The B+ uses a micro SD card rather than
  still recommended if you’re using anything with a   B+ unless you add something to raise the GPIOs.        the full sized SD card. A micro SD card will work in a
  significant power draw.                              6 Audio The audio output on the model B isn’t very
                                                                                                             model B as long as it’s inside an adaptor.



processing power or amount of memory, it would be                    The B+ has a switching regulator. This actually                 The 40 GPIOs on the B+
easy to pass over the differences between the B and                converts the input energy at one voltage to a new                 feature 15 PWM channels,
                                                                                                                                     one UART, one SPI, one
the B+. This is a mistake. The differences are                     output voltage. They still waste a little power, because
                                                                                                                                     I2C, and one connection
important, and add up to a much better computer                    no component is 100% efficient, but far more power
                                                                                                                                     to header flash, plus 26
despite the fact that, underneath it all, it still has the         makes it through than does with linear regulators.                programmable pins.
same engine.
  The key to the new board is the new regulator. A
regulator is a device that adjusts the voltage from a
higher voltage down to a lower one. There are several
on the Pi, but the main one converts the 5V that
comes in from the micro USB power supply into 3.3V
that’s used on many of the components. The original
model B had a linear regulator, which is basically a
device that converts the difference between the input
voltage and the output voltage into heat. This is highly
inefficient, but linear regulators are cheap and simple
to use.



                                                                     www.linuxvoice.com                                                                           29
     FEATURE RASPBERRY PI B+

                                                                                                      USB to Ethernet chip with a Lan9514. The bad news is
                                                                                                      that this still sends Ethernet and USB traffic over the
                                                                                                      same bus to the SoC, so if you connect high-
                                                                                                      bandwidth USB devices and a network connection,
                                                                                                      you will notice the speeds slowing down.
                                                                                                         The good news is that the improved power supply
                                                                                                      on the B+ means that the USB ports are quite usable
                                                                                                      for low-power devices without an external powered
                                                                                                      hub. We had no problems at all with just a mouse
                                                                                                      and keyboard. A mouse, keyboard and USB memory
                                                                                                      stick also worked fine. A mouse, keyboard and two
                                                                                                      memory sticks did work, though the power to the
                                                                                                      mouse dropped out when both the memory sticks
As well as producing better
                                     The new regulator saves between half a watt and                  were active. We had some success with a USB web
sound, the B+’s new AV
jack looks a lot better            one watt of power. This, by itself, isn’t very important           cam, though for this and anything higher power (such
than the hulking black             – it’s not a big enough difference that you’ll notice              as a USB hard drive) we’d still recommend using a
monstrosity that was on            lower electricity bills. It will, however, have an impact          powered hub.
the Model B.                       on anyone running their Pi off solar power or batteries,              The exact number of devices you can drive will
                                   but this isn’t the main reason we’re excited about the             depend on the power supply your using. The above
                                   lower power usage. Most USB power supplies can                     was tested with a supply rated at 1A. More powerful
                                   deliver between one and two amps at 5V, with many                  supplies are available and these will be able to pass on
                                   of the more common ones being much closer to 1A                    the extra power to the USB ports.
                                   than 2A. At 1A, this means there’s 5 watts of power for               We can’t give any hard-and-fast rules, but previously
                                   the Pi, so the saving is equivalent to 10–20% of the               we advised anyone getting a Pi to get a powered USB
                                   total power available.                                             hub as well (unless it was for an embedded project).
                                     By wasting less power, the model B+ effectively                  Now, our advice has changed to: only get a powered
                                   makes more power available for peripherals. This                   USB hub if you find you need one.
                                   10–20% increase is the difference between the model
                                   B not being able to handle and unpowered hub with a                Making music
                                   mouse keyboard and USB memory stick and the B+                     Let’s be honest, the analogue audio on the model B
                                   being able to.                                                     was terrible. It was okay if you just wanted to make a
                                                                                                      few noises and didn’t really care what they sounded
                                   Making connections                                                 like, but for anything more than that, you needed
                                   On the board itself, the thing that stands out more                something extra.
                                   than anything is the addition of two USB ports. This                  The audio over HDMI worked fine, so home theatre
                                   has been made possible by replacing the Lan9512                    systems didn’t have a problem. However, many
                                                                                                      monitors don’t have inbuilt sound (or at least not very
                                                                                                      good inbuilt sound). With the Pi Foundation pushing
  Hardware Attached on Top (HATs) A new way to configure add-ons                                      the musical programming language Sonic Pi
  The Raspberry Pi’s GPIOs allow programmers        does, and how the GPIO pins should be             (www.cl.cam.ac.uk/projects/raspberrypi/sonicpi/
  access to pins that they can both write to        configured to work properly with the Pi. In       index.html – and indeed on page 78 of this
  and read from. They also allow hardware           technical terms, the EEPROM should contain        magazine) as a way to get children interested in
  manufacturers to create add-ons that use          a device tree that can be loaded by the kernel
                                                                                                      programming, the poor audio performance over the
  these GPIOs to communicate with the               and will set up the GPIOs correctly. At the
  processor. There are a number of additional       time of writing, no HATs are available, though    headphone port needed to be addressed.
  functions – such as I2C and SPI                   manufacturers will of course be working on           To test the audio, we’ve had a B+ plugged into our
  communications channels – that can be             them. It’s too early to say if they will become   stereo running XBMC (see Distrohopper on page 8) for
  accessed through these pins. However, at          popular. We suspect that there will continue      the past two weeks. So far, we haven’t noticed any
  present, the process of setting these up is a     to be a significant market for B-style 26-pin
                                                                                                      difference between the quality of the B+ and the
  little awkward.                                   boards without EEPROMs. These will be
      With the B+, the Raspberry Pi Foundation      significantly cheaper to manufacture because      quality of the sound out of the CD player. Of course,
  has introduced what it calls HATs (Hardware       they won’t need as much PCS space if they         true audiophiles seeking top-quality sounds aren’t
  Attached on Top). For a device to be              only cover 26 pins (PCBs are surprisingly         going to get them from the audio output of a Pi (or
  classified as a HAT, it has to conform to a set   expensive, especially for small production        anything else that sells for £30, for that matter). The
  of standards designed to make sure it             runs). The more advanced capabilities won’t
                                                                                                      Wolfson Audio Card for the B will no longer work on
  behaves itself when communicating with the        be needed by many, especially if they only
  Pi. Expansion boards don’t have to conform        rely on turning GPIOs on and off rather than      the B+, because it relies on the P5 GPIOs, which are no
  to the HAT standard to work on a Pi, but they     using a communications protocol. Though           longer available.
  can’t call themselves HATs if they don’t.         the most persuasive reason for hrdware               The B+ has 14 more pins in the GPIO header, but
      The most important of these standards is      manufacturers to keep making devices for          that doesn’t mean there are 14 extra programmable
  that devices must contain an EEPROM (a bit        the Model B is that there are around
                                                                                                      outputs. Only nine of these pins are programmable,
  of memory that the Pi can read). This can be      3,000,000 model B’s in circulation and they
  used to tell the Pi a bit about what the device   aren’t going to be replaced overnight.            three are ground and two are reserved for
                                                                                                      communicating with HATs (see boxout, left).



30                                                                      www.linuxvoice.com
                                                                                                     RASPBERRY PI B+ FEATURE

   A few extra GPIOs aren’t usually that important,
especially as they don’t include any additional support      What’s next?
for low-level communications protocols. There’s still        Eben Upton, founder of the Raspbery Pi          – they are more concerned with providing a
one each of serial, I2C and SPI. It’s easy enough to use     Foundation, has confirmed to us that the        stable base and developing software to use it
the existing I2C or SPI busses to add more GPIOs             Foundation is looking into a model A+, which    efficiently. Schools – which are the primary
anyway should you need to, and this is what many             will do to the model A what the B+ has done     target of the Raspberry Pi – don’t want to
                                                             to the B. We haven’t heard exactly what form    have to spend time and money to change
add-ons do, as it also protects the Pi from damage
                                                             this will take yet, but we suspect that some    their hardware every year or two just to be
due to electrical problems in the circuit they’re            people are particularly interested in a model   able to follow the latest projects.
connected to. Boards like the Protect Your Pi by My Pi       A with a switching regulator, since this will       Having a slow release cycle also helps
(www.modmypi.com/protect-your-pi) use these to               be even more power efficient than the B+,       companies making add-on boards. It enables
provide more GPIOs than the Pi actually has.                 making it the ideal device for running on       them to spend time understanding a product,
                                                             batteries (the Model A is used in many          learning what the users want, and designing
   However, using these port expanders slows down
                                                             embedded projects).                             something properly rather than just rushing
the speed at which you can turn the GPIOs on and off.           Beyond this, many people are waiting for a   to market because it may be obsolete soon.
This is almost imperceptible if you’re just using them       version of the Raspberry Pi with more               The next version of the Pi is expected in
to turn LEDs on, or get input from a button, but if          processing power or memory than those           2017, but don’t expect it to be the most
you’re using them to connect to some other                   currently available, sometimes called the       powerful ARM board on the market. However,
                                                             Model C (though people inside the Raspberry     it will be well supported with a large number
electronics, the delay can be too much. An extra nine
                                                             Pi Foundation refer to this as the Raspberry    of add-ons, it will have a large community
GPIOs is enough to be able to implement some                 Pi 2). It should be obvious by now that the     behind it, and it will be developed by an
communications protocols that require 26 channels,           brains at the Pi Foundation aren’t interested   organisation with the resources to make sure
such as those to drive some LCD displays, so it              in constantly chasing the latest hardware       it runs well.
increases the Pi’s potential enormously.

Shrinking storage                                             The B+ gives us a number of improvements, but still
Of all the changes, perhaps the most superficial is the    keeps almost complete compatibility with the older
switch from full-sized to micro SD cards. The two          device. We used the word almost because of the lack
formats are the same from an electrical point of view,     of Pad 5 GPIO, but this didn’t get much use anyway.
so it shouldn’t have any impact on speed. In fact, it’s    We’re sure that a few people will be disappointed by
perfectly possible to use a micro SD card with a model     lack of a new processor or more memory, but in a
B if you put it in an                                                                            way, we’re not.
adaptor (which many
micro USB cards come
                          “We’re delighted that all the software                                 The Raspberry Pi
                                                                                                 is great because
with). These adaptors     from the Foundation and community                                      it’s a stable
also make it possible to
copy data onto the
                          will still run on the Model B+.”                                       platform we can
                                                                                                 build projects on
small cards from                                                                                 and know they’ll
computers that only have full-sized SD card slots.         work when recreated by other people. As model B
   The only real difference between the two (other         owners, we’re delighted to know that all the software
than size of course) is that micro SD cards have a         from the Foundation and community will still run on
barb that can be used to hold the card in place, which     our devices, and as B+ owners we’re pleased that
should make it a bit more reliable if the Pi’s being       some of the niggling problems of the Model B have
moved around.                                              been solved. Now let’s get building!




                                                                                                                              There’s now a connector
                                                                                                                              labelled as the display
                                                                                                                              waiting for the official
                                                                                                                              display module.



                                                             www.linuxvoice.com                                                                          31
     FEATURE MAKING ELEMENTARY OS FREYA




        Elementary,
                                                  my dear Freya
         Elementary OS started out as a collection of attractive icons, but now
            a small team has taken the ethos and turned it into a completely
                 bespoke top ten distro… Russell Barnes investigates.


         I
               n many respects elementary OS is the perfect           application launcher and even many of the
               microcosm of the open source scene. It’s               applications themselves have been developed
               designed and built by a disparate team working on      especially for Elementary OS.
          a project considerably greater than its parts. Unlike         As we discover from talking to the core
          many modern Linux distros, though, Elementary OS            development team, this is probably why it’s being
          isn’t a hodgepodge of different elements drawn in           embraced by the open source community. But as we
          from different corners of the ecosystem. While it’s built   also find out, Elementary OS’s biggest market isn’t
          on Ubuntu’s solid back-end, every other aspect of the       Linux at all and as such, they’re not afraid to sidestep a
          distro is entirely custom made. Everything from the         few open source norms in their quest to reach the top
          desktop environment to the file manager, the                of the distro pile…



            The core elementary OS team
            They’re separated by thousands of miles, but the core elementary OS team is a tight-knit bunch…




          Name: Daniel Foré                       Name: Cassidy James                      Name: Cody Garver
          Location: Sacramento, California        Location: Denver, Colorado               Location: Jackson, Mississippi
          Career: Design and marketing            Employment: Front-end web dev and        Career: IT Consultant for SMBs
          manager                                 UX designer at System 76                 Project role: Project and Release
          Project role: Founder and UX            Project role: Director of Operations     Manager
          designer                                & UX Designer                            Quote: “I do the packaging and the
          Quote: “I started the project drawing   Quote: “I manage the legal and           ISO builds. I help out with the road
          icons. My role has evolved from         financial side… and help manage the      maps and bug triage among other
          visual design to UX design.”            community and guide the project.”        things.”



32                                                       www.linuxvoice.com
                                                                            MAKING ELEMENTARY OS FREYA FEATURE

      Why do you think the Linux community
      embraced Elementary OS in the way it did?
Cody Garver: I think it’s pretty clear that Elementary
as a project has a strong sense of design and a focus
on simplicity. So the strong reaction to it shows there’s
an appreciation of design in open source software.
The nature of open source development is that
anyone can make anything and just give it away. This
type of creation has typically not had a particularly
strong design process. There’s definitely a growing
community of users who enjoy something that is well
designed and open source.

       Were you surprised when Luna (Elementary
       OS version 0.2, released in August 2013)
took off the way it did?                                                                                                 Freya’s top panel is now
Daniel Foré: Personally, I was pleasantly surprised. I       CG: I know there was a lot of chatter on social media       mildly intelligent, deciding
think it goes to show that an exceptional user               sharing Elementary: “I’m switching my/my                    on the fly if it needs to be
experience can be something that differentiates you          grandparents computer from XP to elementary so              visible at all
regardless of whether you’re an open source or               they can get security updates”. Or “My school is
commercial project – having a good user experience           installing Elementary on the lab computers”. We’ve
is something that users want.                                got a lot of those kinds of stories shared with us since
Cassidy James: We saw an opportunity in the open             then, which is cool.
source space for a top-to-bottom solution. With most         DF: Someone shared a photo on Google+ of a prep
Linux-based distros someone else builds the                  school in China and kids using Elementary on
environment and other people integrate the apps, the         computers there. That was amazing, and it’s really
packages and so on… For us, not only do we do the            validating. We’re making something that not only
integration, but we build all the apps and we build the      friends and family are going to use, but that people
desktop environment. Having that approach is                 around the world and
something that’s really pushed us ahead. You have to
expect a certain level of acceptance when you’re
                                                             are passionate about.
                                                             It’s an incredible feeling.
                                                                                        “Where technology before was
doing something so different.                                CJ: Some of the most       a blocker, we’re enabling people
       So who, in your opinion, is downloading
                                                             rewarding stories are
                                                             the ones related to the
                                                                                        to communicate and do things.”
       Elementary OS? Are we talking about                   accessibility of
creative types, beginners or is it a broad cross-            computing in general. We get Tweets that say things
section?                                                     like: “My mum was using Windows and was having a
CJ: I think the majority of the downloads come from          hard time doing what she wanted... Now she can get
non-Linux users. They’re mostly from Windows,                on Facebook and send email.” Where technology
several from OS X. I think there’s a dissatisfaction with    before was a blocker, we’re enabling people to
proprietary operating systems out there like Windows         communicate, connect and do things.
8 and OS X. People are looking for an alternative and
the simplicity of Elementary draws them in.                        What about the other side of the coin? Luna
                                                                   did a lot of things really well, especially in
      Did you see a bump in the numbers when                 terms of user experience, but what areas were
      Windows 8 stumbled so spectacularly on the             you less pleased with that you’re addressing with
start line or when Windows XP shut-up shop?                  Freya in September?
                                                             CG: File management wasn’t optimal. We suffered
                                                             from a lack of developers in that space. It was a bit
                                                             crashy but we’ve rectified it since then, and I’m really
                                                             excited about it.
                                                             CJ: In a lot of ways Luna was the first release for a lot
                                                             of those apps. It was the first release of our desktop
                                                             environment too. There were a lot of unexpected
                                                             things and users threw a lot of cases at us that we
                                                             hadn’t considered throughout the development cycle.
                                                             As with any new software the first release wasn’t
                                                             jam-packed with features, so we’ve been working on
Freya’s bare desktop has a cleaner look to it than that of   putting in a lot of new features and dealing with those
most Linux distros.                                          issues that we hadn’t encountered ourselves.



                                                               www.linuxvoice.com                                                                 33
     FEATURE MAKING ELEMENTARY OS FREYA

                                                                                         what you want’ approach for software, like the
                                                                                         Humble Bundles. With digital software you don’t have
                                                                                         to pay significants amounts of money for distribution.
                                                                                         If you were sending out physical CDs, that’s expensive,
                                                                                         but as something that’s available for free or cheap
                                                                                         – pay what you want – people really latched onto that
                                                                                         and enjoyed it. We set a default payment of $10 and
                                                                                         people could change it to whatever they want, but
                                                                                         several of those payments come through at the
                                                                                         default amount.
                                                                                             I think it’s exciting that you can be creating open
                                                                                         source software and producing revenue at the same
                                                                                         time. People think it’s worth paying for.
                                                                                             We had 1.5 million downloads of Luna alone. That’s
                                                                                         exciting. I’ve watched payments come in and a lot of
                                                                                         times people either pay £10 or they’ll pay $1 or $2.
The addition of online
                             DF: Another of our weaker areas with Luna was               Most download for free, but if they’re going to pay it’s
accounts will help
integrate popular web apps   networking. There were some issues there that we’ve         either a small payment or the default $10.
into the Elementary OS       gone through and done a lot of work on. One of the          DF: None of us really know what to expect as far as
experience.                  most popular requests was Google Calendar sync in           numbers go. There are so many people in the world it
                             our calendar app, so that’s another thing we’ve been        could be anything, or it could be nothing. I had no idea
                             working on. There are literally hundreds of issues          what to expect. I’m looking at the site we have up and
                             we’ve closed during the current release cycle that          it’s showing 1.45 million. That’s based on figures we
                             were reported by users.                                     can accurately track – how many people have directly
                                                                                         downloaded from SourceForge. Then we have a
                                   Does it pile on the pressure? You’re ranked           percentage of how many people decided to download
                                   in the top 10 on DIstrowatch now... are you           from torrents. We can only estimate downloads from
                             feeling the heat?                                           that. In theory it could be far more – we can’t track
                             CG: No, but now you mention it I feel like I should!        downloads from outside either direct or by torrent.
                             DF: There’s so much that we have in our vision of
                             where we want to be, that we’re not really concerned              With anything between 1.5 to 3 million
                             with ‘how are we possibly going to continue to                    downloads it doesn’t take much napkin
                             compete?’. We know where we’re going and we’ve got          mathematics to realise you’ve made a reasonable
                             such a huge plan for the future that it should naturally    amount of money from Luna in the last twelve
                             keep us there and keep us pushing towards the top.          months. What have you been spending it on and
                             CJ: The only thing I get nervous about is the next          could elementary become your full-time job?
                             release, because I look at all the bugs we closed in the    CG: We obviously incur operating costs like running
                             current one and I wonder how can we find anyone             servers, paying for the website, but beyond that we
                             else or ask anyone to complete something like that,         just have small stuff like office supplies and costs for
                             yet again.                                                  doing in-house shipping of merchandise. Aside from
                                                                                         those kinds of operating costs all the money is being
                                    Has the development process changed since            invested back into fixing elementary OS with bug
                                    the last release?                                    bounties. We’ve been to a few hackathons and
                             DF: The end of the Luna cycle was about learning            meetings too.
                             how to work together as a team and focus on our             CJ: No one takes home a pay cheque. It’s all directed
                             goals. Before then everyone was doing their own             straight to goods and services to benefit the project.
                             thing, and at the end we’d try to tie them all together.
                             Now other developers are more likely to be aware
                             about what everyone else is doing.
                             CG: We do 100% code reviews now too. Any code that
                             changes is peer-reviewed by other members of the
                             team. It slows things down a little, but we find we’re
                             clearing up after ourselves much less now.

                                   When you released Luna, it came with the
                                   option to donate. How was that received by
                             the community, and did it work for you as a
                             source of income for the project?                           The core software offering has expanded and the team
                             CJ: Yeah, it’s worked really well for us. I think there’s   have finally introduced the ability to set applications to
                             this cultural thing that’s been popularised by the ‘pay     start with the system.



34                                                            www.linuxvoice.com
                                                                            MAKING ELEMENTARY OS FREYA FEATURE

In terms of it becoming a full-time job… that’s a
direction we’d like to go in, but currently the money
we’re making doesn’t support full-time employment.
We want to work towards that and we want to put
money into open source developers’ hands. I think
getting involved in doing bounties has been a huge
first step for that.
   We’ve posted over $8,000 in bounties and so far
we’ve paid out $2,500 of that. It’s been a tremendous
help, not only in attracting new developers, but
keeping our current developers engaged and making
sure they feel appreciated. It’s hard work and a lot of
what we do is really boring stuff that nobody’s ever
going to know we did. Having that incentive makes it
better, because you say “Hey, this is hard work, it’s not                                                                 The team put a lot of stock
a lot, but buy yourself something nice”. It’s a small        CJ: We’ve got a new video app too, called Audience, a        in Elementary as a brand.
token of our gratitude.                                      web camera app and a refreshed UI. We’re introducing
DF: Our average bounty size at www.bountysource.             the ability for apps to use a dark theme, like the
com has grown with time. We started out offering $5,         terminal or media-centric apps. And we’re introducing
$10 and $15 dollar bounties on things, but now we            HeaderBar. It’s a new widget created in GTK that
have several at $100 or more for single bugs. As we          enables the applications title bar and tool bar to be
generate more income through people donating or              just one line. It’s space saving for things like
paying for the download, that’s an area we’re going to       notebooks especially.
keep investing more and more money into.                     DF: HeaderBar was something that was introduced in
                                                             either GTK version 3.10 or 3.12. Typically you have this
       You’re currently working towards the latest           area above your toolbar that just shows the app’s
       release, called Freya, of Elementary OS.              name, and that’s it. You’re adding 16 vertical pixels for
Since your focus is on simplicity and cleanliness,           this completely useless area. So it just enables us to
have you been finding it hard to add features                compact that area and
without adding mess and bloat?
DF: That’s one thing we talked about a lot when we
                                                             save that space. In
                                                             general, GTK apps now
                                                                                        “We’ve posted over $8,000 in
started working on the new search back-end. As we            are using what are         bounties and so far we’ve paid
introduce new features we want to make sure that
– no matter what happens – we don’t ever encroach
                                                             called client-side
                                                             decorations. That kind
                                                                                        out $2,500 of that.”
on that original experience of launching apps really         of goes hand in hand
quickly. It’s the primary purpose of the UI after all.       with HeaderBar. What that means on the themeing
While we want to introduce interesting and useful little     side is that the window borders are being drawn by
features, if it gets in the way of the primary purpose       GTK instead of a separate window manager. There’s
we don’t want to add it.                                     no tearing when you re-size, because it’s part of the
   Our app launcher – Slingshot – has a new back-end         contents. Shadows look nicer. We get all the
for its search view. For now that doesn’t mean               advantages of GTK 3-like transparencies, we can
anything for users, but going forward it means we’ll be      animate things – it’s just really nice.
able to add different kinds of plugins. We’ve added a        CG: We’ve also rebuilt our multitasking view in the
calculator plugin, so you can just open Slingshot and        window manager. We have a much more interactive
do some math. Little convenient things like that. It will    and clearer distilled multitasking experience. It’s really
sort all your results by most used too, which is nice.       hard to describe it, but when you see it and use it it’s
                                                             just intuitive. You can move things around and it feels
                                                             really good.

                                                                   You mentioned earlier that you’re finally
                                                                   bringing Google calendar synchronising to
                                                             Elementary OS. Will you be offering similar online
                                                             account integration elsewhere in Freya?
                                                             CJ: We are introducing an online accounts service so
                                                             apps can tie into that, much like you see in Mobile,
                                                             Ubuntu and OS X 10. We’ve added a firewall
                                                             configuration, start-up apps configuration. Every time
Snap, the new webcam app, couldn’t be simpler, and while     you boot up you can start your Twitter client or web
Midori wouldn’t be our first choice for browsing, the team   browser, for example.
are investing heavily in its development.                    CG: We currently support Facebook, Google,



                                                               www.linuxvoice.com                                                                 35
     FEATURE MAKING ELEMENTARY OS FREYA

                                                                                                    CJ: The people who contribute to Elementary on a
 Collaboration made easy                                                                            regular basis and people who are new to contributing
 How do the core developers manage to stay         was just in this cycle that we started using     to Elementary can get in touch with the dev team and
 on the same page when they’re all at least        Slack as opposed to IRC. It’s been huge. In      we can help them get started and give them access to
 1,000 miles apart?                                IRC we had to have all these different           pre-release versions so they can work on their apps.
 Cody Garver: It’s a necessary evil when           services to paste code snippets or share             If you’re involved in development, or want to be
 you’re working with open source. We have          images and we built bots to log the channel
                                                                                                    involved in development and you’re committed to it
 people in all different locations, timezones      and view history… things like that. All these
 and languages. We’ve adapted really well          things come built-in with Slack so we’ve been    you’ll definitely get the opportunity to run the pre-
 because we’re all of the age that we’ve grown     able to take a lot of tools and have them in     release software. It’s mostly about people who are
 up with the internet, so we make heavy use        one place.                                       less involved and are just going to report everything
 of it. We use tools like Launchpad to manage      Daniel Foré: One area we’re still facing         we can see already. It creates a lot of extra bug
 code, but we recently switched over to Slack      some challenges is in animation and motion
                                                                                                    triaging and creates a lot of extra work at our end.
 [www.slack.com] from IRC – it’s actually a        design. I’m making prototypes in CSS and
 pretty effective way of collaborating.            HTML and trying to hand those off to the dev     CG: We know things are broken and we know what
 Cassidy James: One of the things that             team, but it can be hard when you’re trying to   we’re focussed on – it hurts our focus.
 was important as we moved from Jupiter and        do sound or motion and you’re trying to          DF: Throughout Freya’s cycle we’ve picked up quite a
 into the Luna cycle was learning how to work      design something like that remotely. You         few new developers. I don’t think the availability of an
 remotely. We’re still learning and evolving. It   can’t use your hands to gesticulate meaning.
                                                                                                    ISO test image really relates to the ability to hack on
                                                                                                    the source code at all. All the source code is publicly
                                                                                                    available. Running Elementary isn’t really a
                                  Microsoft and FastMail, and there’s work going on for             requirement to build the apps in most cases, so a lot
                                  general IMAP support. The idea is that apps on the                of people are doing dev work in Ubuntu or Arch or
                                  desktop can plug in to the online accounts. You don’t             whatever before they’re working with us with Slack or
                                  have to sign in to everything. It’s perfect for things like       running these test images. People can contribute
                                  Twitter clients and email clients.                                code without having ever run Elementary OS.
                                                                                                    CJ: Release early, release often… we kind of do the
                                        There’s clearly a lot of work going into Freya              opposite of that!
                                        and there’s a lot to be excited about, but do               DF: I think it’s the way that big commercial projects
                                  you agree with people who say you’re being very                   work. They may have a yearly release cycle, but they’re
                                  protective by not publicly sharing your alpha                     not held to a specific date – it comes when it’s ready.
                                  builds?                                                           You expect a new Android every 6–12 months, or a
                                  CJ: Absolutely we have! There’s this interesting thing            new OS X every year, but they could be working on
                                  with open source… because the code is open and                    something really cool and don’t deliver until it’s ready.
                                  available to everyone, people expect to be able to                    Open source has had this other model of release on
                                  download and try it out every step of the way. Even               a really strict schedule – whatever’s ready, just release
                                  with Luna we ran into this.                                       it. That doesn’t work as well for us, because when
                                     Even if we provided a preview to our developers and            you’re building an entire OS you’re not going to be
                                  it would get leaked out to a publication or a website             ready in just six months.
                                  and they would review it as a finished product and                CG: It has to do with target market too. Typically open
                                  say; “This is buggy, this didn’t feel complete, such-and-         source software developers are releasing to other
                                  such doesn’t work well.” Well of course not – it wasn’t           open source software developers, but like we said
                                  complete. It’s really hard when you put so much time              earlier, the majority of people downloading Elementary
                                  and effort into a product we want it to be the best               aren’t coming from Linux.
                                  representation of all our work, people judging it early               We’re seeing a different kind of consumer. Our
                                  can be a big problem.                                             consumers don’t necessarily know how to deal with
                                                                                                    this stuff. We can’t expect them to run through an
                                        It seems that brand management is very                      unstable system and use commands at a terminal –
                                        important to you, and that’s the driving                    we can’t release a product like that.
                                  factor here, not secrecy.
                                  DF: It really does comes down to brand management.
                                  When people hear Elementary OS or see our logo it
                                  needs to make them feel like this product is well
                                  thought out, it’s stable and easy to understand. When
                                  people see others say ‘hey, this is Elementary’s next
                                  release and it’s broken and unstable’, then it really
                                  hurts our potential growth.

                                       On the other side of the coin though, do you
                                       not worry that the lack of crowdsourcing
                                  and testing on the fly is hurting development in                  The app launcher, Slingshot, is adding applications slowly
                                  some way?                                                         but surely – software only gets included when it’s ready.



36                                                                     www.linuxvoice.com
                                                                                         MAKING ELEMENTARY OS FREYA FEATURE


Hands-on with elementary OS Freya
How is the latest release shaping up?


T
         here’s no escaping the fact that Freya, like
         Luna before it, has taken its lead from Apple.
         While Apple has continued to build, add and
augment its proprietary operating system until it’s just                                                        Windows
as complex and bloated as Windows, Elementary has                                                               Linux
been incredibly sparing with extensions to Luna’s                                                               Unknown
                                                                                                                Macintosh
lightweight mix of software and features.                                                                       Android
   This theme continues elsewhere with brilliant use of                                                         Others
GTK’s HeaderBar. They haven’t wasted a pixel in any
open window, and it adds a new edge to Elementary’s
visual appeal and utility. By removing the title bar
there’s much less wasted vertical space, and that’s                                                                                        It came as quite a surprise
sure to go down well with users in the mobile space.                   bases are covered, but they’re resisting community                  to learn that most
   This visual zen doesn’t end there – it’s also                       pressure to include third-party applications in the mix             Elementary OS users aren’t
transformed the top panel too, which works                             like Birdy and the popular podcast app, Vocal.                      Linux users at all – the
particularly well when combined with one of the few                       You certainly get a sense of a more mature                       vast majority of Luna
new applications to appear in Freya, the Audience                      Elementary from our early preview of Freya. Features                downloads come from
video player.                                                          are getting polished, the basic application offering is             Windows and Mac OS X.
                                                                       being refined and it’s all happening on the reliable
Zen minimalism                                                         backbone of Ubuntu 14.04.
Like everything else in Elementary OS, it’s built from                    The only missing piece of the puzzle is App Centre.
scratch in Vala and offers the barebones of media                      Development here, it seems, is going to take much
playback in a very modern, minimalist package.                         more than one release cycle to flesh out, and it’s clear
Audience has been in development since version 0.2                     the team plans to take a firmer grasp of the reins than
Luna and draws inspiration from online players like                    your average package
YouTube and Vimeo as opposed to standalone media
applications. Using GTK 3 for the UI and GStreamer for
                                                                       manager. While this is
                                                                       sure to upset more than
                                                                                                       “The team plan to take a firmer
its back-end, Audience offers animated overlay                         a few in the community,         grasp of the reins than your
controls and preview pop-up that lets you scan
around to find the start of a scene.
                                                                       as the team explain in
                                                                       the boxout below, they
                                                                                                       average package maintainer.”
   Another new application for this release is Snap. As                find unlimited freedom
the name suggests it’s a simple webcam application,                    has a tendency to lead to a lesser user experience.
very much in the style of OS X’s Photo Booth. Like                     We’ll just grab the popcorn, retreat to a safe distance
Audience, there’s very little to say other than it allows              and let that last statement sink in.
users to quickly snap pictures, videos or screencast.                     With development timed to coincide with the
   With these new applications the team are clearly                    release of GTK 3.14, it’s very likely that Freya will see a
fleshing out the core offering to ensure all the major                 final release during September.


  The absence of App Centre
  One of the big banner features people have been waiting for is       making cool apps like Birdy or Vocal, how do they get them to
  App Centre, Elementary’s bespoke app store. Its not                  elementary OS users?
  happening this year, and here’s why…                                    A big piece of making it successful is some kind of curation
  DF: Unfortunately it won’t be in Freya. The thing about App          process. We need to have some kind of rules for apps that we
  Centre is that when you’re looking at building a new app store       present to users... some kind of standard. People in the open
  the easiest part of that is writing a new client. Gnome has a        source community aren’t going to be super-happy about that
  really great client already. When you open up Gnome Software         concept at first, but from our experience unlimited freedom
  it looks new and shiny… but when you dig into it – all the           leads to a lesser user experience in the end. Instead of
  content – is all the same content you had before in the old          browsing through a collection of all these really nice native
  one. You’re not really moving forward. We’re still getting the       apps that are presented well and integrated with the OS, you’re
  same selection of apps written in a billion different toolkits       just looking at everything everyone ever posted to the internet.
  with really horrible descriptions. Some of them are crashy and       CJ: There was an app in the Ubuntu repos for quite a while
  half complete – it’s not curated at all.                             called PornView. We used to use that as our example of how
      The most difficult part in building a new app store is firstly   anything can get in there. App Centre is a big project and we
  a proper app submission process. That’s something we talk            think it’s a very necessary one. It’s just not something we’ll be
  about all the time. When we have third-party developers              able to complete in just one release cycle.




                                                                         www.linuxvoice.com                                                                        37
     FAQ BSD




MIKE SAUNDERS
                                     BSD
Had history been slightly different, you’d be reading FreeBSD Voice today...
                                                   Congratulations – you’ve just
                                                   described GNU/Linux…
                                                                                       Torvalds had announced his kernel,
                                                                                       which, when paired with the GNU
                                                  True. Linux has all of the things    project, formed a complete open source
       So what’s the deal with this                I’ve just mentioned, and that’s     operating system. Linus had been
       Birsa Seva Dal then? Isn’t it a     why a lot of people never investigate       following GNU’s own kernel (Hurd) and
political group in India?                  BSD. In day-to-day usage, there isn’t a     386BSD, and said that had either of
      Very funny – you looked up the       lot of difference between the BSD family    them been ready for daily use, he
       “BSD” disambiguation page on        and Linux, largely because they all have    probably wouldn’t have created Linux.
Wikipedia just to make that joke, didn’t   Unix underpinnings, and also because        So the first few years of the 90s were
you? Here we’re talking about the          they share a lot of software. You could     tremendously lively for open source
Berkeley Software Distribution, a family   be logged into a remote machine,            operating systems, and nobody was
of operating systems that are much         hacking some Python code in Vim, and        really sure which ones would succeed.
more widely used than you might think.     checking your email in Mutt, and you           Then it got messy for BSD. AT&T, the
                                           wouldn’t know you were running BSD.         original developer of Unix, was trying to
       Sorry, I couldn’t help myself.      Or you could be using an internet           monetise its work on the operating
       OK, so what’s the deal with         terminal in a cafe somewhere and not        system and claimed that BSD infringed
these OSes?                                know it’s BSD.                              its intellectual property rights. This
       There are three main BSD               The biggest differences are in the       culminated in a lawsuit in 1992 which
       operating systems in use today.     development model and licence, and to       severely held back BSD development. In
They are based on Unix, they are open      understand this, we need to step back       the end, various chunks of the BSD
source, they tend to be used in server     in time. The B in BSD refers to the         source code had to be rewritten – while
roles, but can also make good desktops     University of California, Berkeley, which   all this time, GNU/Linux was gaining
and workstations as well. They run KDE,    was a hotbed of open source Unix            features, stability and popularity.
Firefox, LibreOffice, Apache, MySQL and    development back in the 1980s. As the          BSD was arguably in a more mature
pretty much any open source                90s came, x86-based PCs were                state than GNU/Linux in the early
application you can name. They’re          becoming popular and many people            1990s, and without these legal
reliable, secure and support a lot of      were interested in having a Unix-like OS    complications it could have become the
different hardware.                        on their home computers. A project          standard on x86 PCs. We could all be
                                           called 386BSD was released in 1992 to       using it today instead of Linux.
                                           provide just that.
“The BSDs are developed                          And where were all the Linux
                                                                                            But you said earlier that BSD
                                                                                            is still widely used, so things
as complete projects from                        distributions at this time?           improved after that?
centralised source code trees.”                  Good question! You might know
                                                 that one year before, Linus
                                                                                            Yes. 386BSD development
                                                                                            stagnated, but two teams of



38                                           www.linuxvoice.com
                                                                                                               BSD FAQ

developers working over the internet
                                            If all of the open source
created separate successor projects.
                                            mascots met up for a
FreeBSD became the most widely used         big scrap, we reckon
flavour of BSD, and is now the closest to   OpenBSD’s Puffy would
Linux as a desktop and server operating     be the last, er, fish
system, while NetBSD focused on             standing.
portability (today it runs on over 50
platforms, all built from the same
codebase). The third flavour, OpenBSD,
forked off from NetBSD just a few years
after NetBSD started due to a developer
spat, and today it’s well known for its
concentration on security. Over the
years, OpenBSD has created many
programs that have become standard
on Linux, such as OpenSSH – and now
we have LibreSSL too.

        So these three flavours of BSD
        are like Linux distributions?
        Yes and no. Each BSD has a
        separate codebase and separate      BSDs also use other open source              we know. For starters, it’s much shorter.
development teams, although there is a      projects that aren’t specifically GNU or     The BSD Licence essentially says: do
lot of code-flow between them               Linux, such as the X Window System           what you want with this code, but give
(especially for hardware drivers). But      (XFree86 and X.org), Perl and so forth.      the original developers credit for writing
they are standalone operating systems       And thanks to standards such as              it, and don’t try to sue them if it blows
with their own features, pros and cons.     POSIX, most programs that run on             up your computer.
   We mentioned that the development        Linux can be recompiled to run on the            So there’s nothing in the licence that
model of the BSDs is one feature that       various BSD flavours.                        forces the code to stay open, unlike with
really distinguishes them from GNU/            So, you could replace the L in a LAMP     the GPL, which requires that users of
Linux. There’s nobody in charge of          (Linux, Apache, MySQL and PHP) stack         the code also make their modifications
GNU/Linux as a whole: some teams are        with FreeBSD, and get pretty much the        freely available. This crucial difference
working on the GNU components,              same environment, with a different set       has sparked countless flame wars over
some are working on the kernel, some        of features (eg variations in filesystem     the years, with BSD fans saying that
on boot scripts, some on manual pages,      and driver support). And there are some      their licence is more free (because it’s
some on libraries, and so forth. The        mega, super, huge users of FreeBSD,          less restrictive), while GNU/GPL fans
development model is often called “wild     such as Netflix, which serve up              say that their licence is actually more
west”, with a lack of central authority,    ridiculous amounts of data every day.        free (because it preserves freedom
and distributions do all the hard work of   While FreeBSD makes a good desktop           down the road).
fitting everything together.                OS, its strengths really lie in the server
   The BSDs, in contrast, are developed     room, with exceptional reliability and                Blimey. Anyway, now that
as complete projects from centralised       network performance.                                  you’ve piqued my interest,
source code trees. The kernel, the             OpenBSD tends to be used in smaller       where can I try out all these lovely
libraries, the system utilities and the     web serving, file hosting, firewall and      BSD flavours?
manual pages are all stored and worked      gateway roles where security is                       You can probably guess the
on in the same place. Many BSD fans         imperative. NetBSD is the least popular               websites – www.openbsd.org,
argue that this gives the operating         of the main BSD flavours – it can run on     www.freebsd.org and www.netbsd.org
systems more coherency and stability,       almost anything though, including old        – where you can download ISO images,
and from our years of dabbling with         Amigas and Acorn boxes, and                  boot them in VirtualBox, and play
BSD we can attest that the manual           sometimes finds itself inside closed-        around. If you’ve been using Linux for a
pages are largely superb.                   source network devices.                      while, you won’t find any of them too
                                                                                         difficult, although you’re expected to
       Don’t the BSDs use anything                 Hang on – how can someone             know your way around the command
       from GNU/Linux?                             close the source code? That           line. If you’re looking for something
      Yes, especially GCC. The GNU          ain’t kosher in Linux!                       more newbie-friendly, PC-BSD
       Compiler Collection has been the            Correct, and here we come to the      (www.pcbsd.org) is a customised
de-facto standard compiler on free Unix            other major difference with GNU/      version of FreeBSD focused on the
systems for decades, although               Linux. The licence for the BSD flavours      desktop, with a fancy graphical installer
FreeBSD has recently moved to LLVM/         (called, funnily enough, the BSD             and super-simple management of
Clang. It’s important to note that the      Licence) is very different to the GPL that   software. Have fun exploring!



                                              www.linuxvoice.com                                                               39
     INTERVIEW THOMAS VOß




MIR VS WAYLAND:
THE BATTLE TO
REPLACE THE X
WINDOW SYSTEM
Mir was big during the space race and it’s a big
part of Canonical’s unification strategy. We talk to
one of its chief architects at mission control.


N
          ot since the days of 2004,            two more – Wayland and Mir, and both
          when X.org split from XFree86,        are competing to win your affections
          have we seen such exciting            in the battle for an X replacement.
developments in the normally prosaic               We spoke to Wayland’s Daniel
realms of display servers. These are            Stone last month, so we thought it
the bits that run behind your desktop,          was only fair to give equal coverage
making sure Gnome, KDE, Xfce and                to Mir, Canonical’s own in-house X
the rest can talk to your graphics              replacement, and a project that has so
hardware, your screen and even your             far courted controversy with some of
keyboard and mouse. They have a                 its decisions. Which is why we headed
profound effect on your system’s                to Frankfurt and asked its Technical
performance and capabilities. And               Architect, Thomas Voß, for some
where we once had one, we now have              background context...



        Let’s go right back to the                  One of the reasons is that X is a       especially over time. But convergence is
        beginning, and look at what X           protocol, in essence. So a lot of things    a use case that was always of interest
was originally designed for. X solved           got added to the protocol. The problem      to us. So we always had this idea that
the problems that were present 30               with adding things to a protocol is that    we want one codebase. We don’t want
years ago, where people had entirely            they tend to stick. To use a 2D graphics    a situation like Apple has with
different needs, right?                         language as an example, XVideo is           OS X and iOS, which are two different
Thomas Voß: It was mainframes. It               something that no-one really likes today.   codebases. We basically said “Look,
was very expensive mainframe                    It’s difficult to support and the GPU       whatever we want to do, we want to do
computers with very cheap terminals,            vendors actually cry out in pain when       it from one codebase, because it’s more
trying to keep the price as low as              you start talking about XVideo. It’s        efficient.” We don’t want to end up in the
possible. And one of the first and              somewhat bloated, and it’s just old. It’s   situation where we have to be
foremost goals was: “Hey, I want to be          an old proven technology – and I’m all      maintaining two, three or four separate
able to distribute my UI across the             for that. I actually like X for a lot of    codebases.
network, ideally compressed and using           things, and it was a good source of             That’s where we were coming from
as little data as possible”. So a lot of the    inspiration. But then when you look at      when we were looking at X, and it was
decisions in X were motivated by that.          your current use cases and the current      just too bloated. And we looked at a lot
   A lot of the graphics languages that X       setup we are in, where convergence is       of alternatives. We started looking at
supports even today have been                   one of the buzzwords – massively            how Mac OS X was doing things. We
motivated by that decision. The X               overrated obviously – but at the heart of   obviously didn’t have access to the
developers started off in a 2D world;           convergence lies the fact that you want     source code, but if you see the
everything was a 2D graphics language,          to scale across different form factors.     transition from OS 9 to OS X, it was as if
the X way of drawing rectangles. And it’s                                                   they entirely switched to one graphics
present today. So X is not necessarily                And convergence is big for            language. It was pre-PostScript at that
bad in that respect; it still solves a lot of         Canonical isn’t it?                   time. But they chose one graphics
use cases, but it’s grown over time.            TV: It’s big, I think, for everyone,        language, and that’s it. From that point



40                                                               www.linuxvoice.com
                                                                                               THOMAS VO ß INTERVIEW




                                                                                “Mir will be significantly
                                                                                more relevant than
                                                                                Wayland in two years.”

        on, when you choose a graphics           toolkit developers – an open graphics                  It’s transparent to them.
        language, things suddenly become         language. That was the part that                       TV: Yes, it’s pixels, right? That’s all
        more simple to do. Today’s graphics      inspired us, and we wanted to have this        they care about. It should be smooth. It
        language is EGL ES, so there was         one graphics language and support it           should be super nice to use. But the
        inspiration for us to say we were        well. And that takes a lot of craft.           display server is not their main concern.
        converged on GL and EGL. From our           So, once you can say: no more weird         It obviously feeds into a user experience,
        perspective, that’s the least common     2D API, no more weird phong API, and           quite significantly, but there are a lot of
        denominator.                             everything is mapped out to GL, you’re         other parts in the system that are
          Obviously there are disadvantages to   way better off. And you can distill down       important as well.
        having only one graphics language, but   the scope of the overall project to               Then you’ve got developers who care
        the benefits outweigh the                something more manageable. So it               about the display server in terms of the
        disadvantages. And I think that’s a      went from being impossible to possible.        API. Obviously we said we want to
        common theme in the industry. Android    And then there was me, being very              satisfy this audience, and we want to
        made the same decision to go that way.   opinionated. I don’t believe in                provide a super-fast experience for
        Even Wayland to a certain degree has     extensibility from the beginning –             users. It should be rock solid and stable.
        been doing that. They have to support    traditionally in Linux everything is super     People have been making fun of us and
        EGL and GL, simply because it’s very     extensible, which has got benefits for a       saying “yeah, every project wants to be
        convenient for app developers and        certain audience.                              rock solid and stable”. Cool – so many
                                                     If you think about the audience of the     fail in doing that, so let’s get that down
                                                  display server, it’s one of the few places    and just write out what we really want
“We want to provide a super                       in the system where you’ve got three
                                                  audiences. So you’ve got the users, who
                                                                                                to achieve.
                                                                                                   And then you’ve got developers, and
fast experience for users.                        don’t care, or shouldn’t care, about the      the moment you expose an API to them,
It should be rock solid.”                         display server.                               or a protocol, you sign a contract with
                                                                                                them, essentially. So they develop to



                                                   www.linuxvoice.com                                                                      41
     INTERVIEW THOMAS VOß

                                                                                           which is interesting because the value
                                                                                           proposition is somewhat difficult.
                                                                                           You’ve got a protocol and you’ve got a
                                                                                           reference implementation. Specifically,
                                                                                           when we started, Weston was still a test
                                                                                           bed and everything being developed
                                                                                           ended up in there.
                                                                                              No one was buying into that; no one
                                                                                           was saying, “Look, we’re moving this to
                                                                                           production-level quality with a bona fide
                                                                                           protocol layer that is frozen and stable
                                                                                           for a specific version that caters to
                                                                                           application authors”. If you look at the
                                                                                           Ubuntu repository today, or in Debian,
                                                                                           there’s Wayland-cursor-whatever, so they
                                                                                           have extensions already. So that’s a bit
                                                                                           different from our approach to Mir, from
                                                                                           my perspective at least.
                                                                                              There was this protocol that the
                                                                                           Wayland developers finished and back
                                                                                           then, before we did Mir and I looked into
                                                                                           all of this, I wrote a Wayland compositor
                                                                                           in Go, just to get to know things.

                                                                                                  As you do!
                                                                                                  TV: And I said: you know, I don’t
                                                                                           think a protocol is a good way of
                                                                                           approaching this because versioning a
                                                                                           protocol in a packaging scenario is
  Whether Mir will dominate over
  Wayland remains to be seen,                                                              super difficult. But versioning a C API, or
  but Thomas is confident.                                                                 any sort of API that has a binary stability
                                                                                           contract, is way easier and we are way
                                                                                           more experienced at that. So, in that
your API – well, many app developers        on and so forth. And funnily enough,           respect, we are different in that we are
won’t directly because they’ll be using     that also helps with convergence.              saying the protocol is an
toolkits – but at some point you’ve got     Because once you start thinking about          implementation detail, at least up to a
developers who sign up to your API.         the API as very important, you really          certain point.
                                            start thinking about convergence. And             I’m pretty sure for version 1.0, which
       The developers writing the           what happens if we think about form            we will call a golden release, we will
       toolkits, then?                      factor and we transfer from a phone to         open up the protocol for
TV: We do a lot of work in that arena,      a tablet to a desktop to a fridge?             communication purposes. Under the
but in general it’s a contract that we                                                     covers it’s Google buffers and sockets.
have with normal app developers. And               And whatever might come!                So we’ll say: this is the API, work
we said: look, we don’t want the API or            TV: Right, right. How do we             against that, and we’re committed to it.
contract to be super extensible and         account for future developments? And              That’s one thing, and then we said:
trying to satisfy every need out there.     we said we don’t feel comfortable              OK, there’s Weston, but we cannot use
We want to understand what people           making Mir super extensible, because it        Weston because it’s not working on
really want to do, and we want to           will just grow. Either it will just grow and   Android, the driver model is not well
commit to one API and contract. Not         grow, or you will end up with an               defined, and there’s so much work that
five different variants of the contract,    organisation that just maintains your          we would have to do to actually
but we want to say: look, this is what we   protocol and protocol extensions.              implement a Wayland compositor. And
support and we, as Canonical and as                                                        then we are in a situation where we
the Mir maintainers, will sign up to.             So that’s looking at Mir in              would have to cut out a set of
   So I think that’s a very good thing.           relation to X. The obvious               functionality from the Wayland protocol
You can buy into specific shells sitting    question is comparing Mir to                   and commit to that, no matter what
on top of Mir, but you can always           Wayland – so what is it that Mir               happens, and ultimately that would be a
assume a certain base level of              does, that Wayland doesn’t?                    fork, over time, right?
functionality that we will always provide   TV: This might sound picky, but we
in terms of window management, in           have to distinguish what Wayland really              It’s a difficult concept for many
terms of rendering capabilities, and so     is. Wayland is a protocol specification,             end users, who just want to see



42                                                            www.linuxvoice.com
                                                                                                     THOMAS VO ß INTERVIEW

            something working.                            something like a full reference              Term Support] release of Ubuntu on a
            TV: Right, and even from a developer’s        implementation of Wayland, where a           new display server without supporting
            perspective – and let’s jump to the           company had signed up to provide             the hardware of the big guys.
            political part – I find it somewhat           something that is working, and
            difficult to have a party owning a            committed to a certain protocol version,            We thought that would be quite
            protocol definition and another party         our decision might have been different.             ambitious anyway – a Long
            building the reference implementations.       But there just wasn’t. It was five years     Term Support release with a whole
            Now, Gnome and KDE do two different           out there, Wayland, Wayland, Wayland,        new display server!
            Wayland compositors. I don’t see the          and there was nothing that we could          TV: Yes, it was ambitious – but for a
            benefit in that, to be quite frank, so the    build upon.                                  reason. If you don’t set a stretch goal,
            value proposition is difficult to my mind.                                                 and probably fail in reaching it, and then
               The driver model in Mir and Wayland                The main experience we’ve had        re-evaluate how you move forward, it’s
            is ultimately not that different – it’s GL/           is with RebeccaBlackOS, which        difficult to drive a project. So if you just
            EGL based. That is kind of the                has Weston and Wayland, because,             keep it evolving and evolving and
            denominator that you will find in both        like you say, there’s no that much           evolving, and you don’t have a
            things, which is actually a good thing,       out there running it.                        checkpoint at some point…
            because if you look at the contract to        TV: Right. I find Wayland impressive,
            application developers and toolkit            obviously, but I think Mir will be                  That’s like a lot of open source
            developers, most of them don’t want           significantly more relevant than                    projects. Inkscape is still on
            Mir or Wayland. They talk ELG and GL,         Wayland in two years time. We just keep      0.48 or something, and it works, it’s
            and at that point, it’s not that much of a    on bootstrapping everything, and we’ve       reliable, but they never get to 1.0.
            problem to support both.                      got things working across multiple           Because they always say: “Oh let’s
                                                          platforms. Are there issues, and are         add this feature, and that feature”,

“We never said we would                                   there open questions to solve? Most
                                                          likely. We never said we would come up
                                                                                                       and the rest of us are left thinking:
                                                                                                       just release 1.0 already!
come up with the perfect                                  with the perfect solution in version 1.      TV: And I wouldn’t actually tie it to a

solution in version 1.”
                                                          That was not our goal. I don’t think         version number. To me, that is
                                                          software should be built that way. So it     secondary. To me, the question is
                                                          just should be iterated.                     whether we call this ready for broad
               So we did this work for porting the                                                     public consumption on all of the
            Chromium browser to Mir. We actually                When was Mir originally                hardware versions we want to support?
            took the Chromium Wayland back-end,                 planned for? Which Ubuntu                 In Canonical, as a company, we have
            factored out all the common pieces to         release? Because it has been pushed          OEM contracts and we are enabling
            EGL and GL ES, and split it up into           back a couple of times.                      Ubuntu on a host of devices, and
            Wayland and Mir.                              TV: Well, we originally planned to have it   laptops and whatever, so we have to
               And I think from a user’s or               by 14.04. That was the kind of stretch       deliver on those contracts. And the
            application developer’s perspective, the      goal, because it highly depends on the       question is, can we do that? No. Well,
            difference is not there. I think, in          availability of proprietary graphics         you never like a ‘no’.
            retrospect, if there would have been          drivers. So you can’t ship an LTS [Long         Usually, when you encounter a
                                                                                                       problem and you tackle it, and you start
                                                                                                       thinking how to solve the problem, that’s
                                                                                                       more beneficial than never hearing a no.
                                                                                                       That’s kind of what we were aiming for.
                                                                                                       Ubuntu 14.04 was a stretch goal –
                                                                                                       everyone was aware of that and we
                                                                                                       didn’t reach it. Fine, cool. Let’s go on.
                                                                                                          So how do we stage ourself for the
                                                                                                       next cycle, until an LTS? Now we have
                                                                                                       this initiative where we have a daily
                                                                                                       testable image with Unity 8 and Mir. It’s
                                                                                                       not super usable because it’s just
                                                                                                       essentially the tethered UI that you are
                                                                                                       seeing there, but still it’s something that
                                                                                                       we didn’t have a year ago. And for me,
                                                                                                       that’s a huge gain.
                                                                                                          And ultimately, before we can ship
                                                                                                       something, before any new display
 Thomas is based on Bochum, but
                                                                                                       server can ship in an LTS release, you
 ventured out to Frankfurt-am-
 Main to talk to us.                                                                                   need to have buy-in from the GPU
                                                                                                       vendors. That’s what you need.



                                                            www.linuxvoice.com                                                                 43
          Back issues are now available at
http://shop.linuxvoice.com/products/single-issues
                                                                                                                          INTRO REVIEWS




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


                                                 On test this issue...
                                                    46                                                      48



Andrew Gregory
The riddle of the broken DVD drive is solved:
there was a broken DVD in it.




T
         his issue we’ve tested two
         products that cost money. One           KDE 5                                                    CamJam Edukit
         is cheap as chips at £5, while          Ardent KDE admirer Graham Morrison                       This tiny beginner’s kit has taught
the other starts at £195 and goes all the        really hopes that the latest version has                 Andrew Gregory more about electronics
way up to £5,965. Which of these offers          learned the lessons of the 4.0 debacle…                  than 13 years in English schools did.
the most freedom, the most potential to
empower intellectual growth? Of                                                           50                             51
                                                    49
course, it’s the one that uses Free
Software. TheCamJam Edukit is limited
in function, but it can be the gateway to
a world of experimentation and
burnt-out motors. Mathematica is also
a superb product, but its licensing
makes it feel like a gatekeeper rather
than a gateway; you can do more, you
                                                  Mathematica 10                        LibreOffice 4.3                 Stellarium 0.13
can unlock more features, as long as              If you want to analyse,               Mike Saunders doesn’t use      This wonderful piece of
you pay more money and accept that                visualise or program with             the 1% of MS Office’s          Free Software makes
you’ll only be able to program what the           some data (and Ben Everard            features that make it worth    Ben Everard’s dark stumble
makers want you to program.                       often does) this tool is              paying money for. If you       home from the pub a far
                                                  aimed at you. Oh, you                 don’t either, you really       more astronomically
Freedom!                                          should be rich too.                   should be using LibreOffice.   educational experience.
I must admit that I take free software
for granted these days, and it’s only
when I come up against a licence                 BOOKS AND GROUP TEST
imposition that I stop to think about
                                                 Facebook is a vampire squid, sucking the vitality out
how lucky we are. You don’t get the
                                                 of our interpersonal relationships and reducing
basic Python interpreter for free and            lifelong friendships to a tap of the F5 key or a
have to pay extra for the most useful            downward swipe of the smartphone. Also, all your
modules. Our only responsibility is that         data are belong to Facebook, so don’t try to delete
we have to do something with all this            anything ever again, because it’s not yours anymore.
                                                 We can’t change Facebook, but we can recommend a
great stuff that we have to play with,
                                                 better alternative: IRC. This ancient chat protocol is
show others how much fun it is and               as open as they come, and there are about a million
helo everyone to learn. Now, import              clients to choose from – we help you find the best
RPi.GPIO…                                        one. Also in old but proven technology – books!
andrew@linuxvoice.com



                                                                  www.linuxvoice.com                                                                45
     REVIEWS KDE 5



KDE Frameworks and Plasma 5 (aka KDE 5)
Previous major updates of this desktop environment have been as popular as the
apocalypse. Fortunately, Graham Morrison is wielding Andúril this time.

                            W
                                         riting two pages on the latest release of      the majority of frameworks (21) falling into tier 1.
  DATA                                   KDE 5 is a tough proposition. But this is a    This means their only dependency is Qt 5, which
  Web kde.org
                                         good thing. Were we to step into Bill and      itself brings many, many performance and feature
  Developer KDE developer   Ted’s telephone box outside the Circle K and take           enhancements. Tier 1 frameworks include those
  community                 ourselves back to 2008, surrounded by the fallout           that deal with archives, codecs, hardware integration
  Licence GPL               from the release of KDE 4, we’d be in a rather different    and specific GUI additions, and developers can now
                            situation. There would be so much to write about,           include these without any further KDE dependencies,
                            nearly all of it negative, that we wouldn’t know where      basically as a KDE-flavoured extension to the
                            to start. KDE 4.0 didn’t work, because its users            considerable features already offered by Qt. This will
                            expected a fully fledged desktop upgrade and the first      help many developers appeal to an audience who
                            major release should have been an early alpha release       don’t want to install the entire KDE desktop just to get
                            instead. It took years before the sum of all the new        hold of an application or two, and this should lead to
                            technologies that were tested in 4.0 became a viable        the development of more KDE applications that run
                            replacement for 3.x.                                        independently of the desktop.
                               This should never have happened, and we think
                            that the KDE team and many other open source                What’s waiting under the tree
                            projects learned from the experience – even though          This is all great for developers, we hear you say, but
                            the Gnome team initially seemed to follow the same          what about us humble users? Is there anything in
                            path with Gnome 3.0. KDE 5 avoids making the same           KDE 5 we can click on now? The answer is yes, but
                                                                mistakes, but not       it’s far from ready. Released a week after frameworks
“KDE 5 avoids making the same                                   in the way you may
                                                                be expecting. It’s
                                                                                        5, Plasma 5 is the beginnings of the KDE 5 desktop
                                                                                        experience. At the moment, Plasma 5 consists of a
mistakes as KDE 4, but not in                                   not a fully fledged     new theme called Breeze, a new panel and notification
the way you may be expecting.”                                  desktop but nor is it
                                                                a direct replacement
                                                                                        system, a window and widget management system
                                                                                        that’s accelerated through OpenGL (ES), a new
                                                                for KDE 4, and          application launcher and a new interface to the Alt+F2
                            that’s the difference. KDE 5 is being developed as          powerhouse known as KRunner. With the exception of
                            a framework from which KDE 4 applications and               the graphics acceleration, all of this could be done
                            technologies can migrate from their old systems to          with KDE 4, and Breeze can already be made to run on
                            the new systems without stunting the development or         older versions of KDE. The advantage with recreating
                            progress of either and in a way that shouldn’t cause        these wheels for KDE 5 is that the design team can
                            any disruption.                                             play to KDE 5’s advantages, and that’s exactly what
Everything in KDE 5 moves      KDE Frameworks 5 was released on 7 July. It              they’ve done.
very elegantly, from the    contains around 50 different libraries that have                Breeze is a flat theme in the same style as Windows
window transitions to the   been designed to be as modular and as portable              7/8 with a default background that seems to borrow
icon resizing.              as possible. These are split into four tiers, with          a triangular motif from the latest Ubuntu. The
                                                                                        window borders are minimal and we like the pastel
                                                                                        vs solarized colour palette. The system tray widgets
                                                                                        look fantastic on our display, and we love the new
                                                                                        notification system. As the KDE team themselves say,
                                                                                        “interaction patterns are left intact”, which we think
                                                                                        means you interact with Plasma 5 in exactly the same
                                                                                        way you interact with KDE 4. And we think is a very
                                                                                        good thing indeed; KDE 4 works brilliantly, and there’s
                                                                                        no reason to mess around with the formula.
                                                                                            With its dependence on a launch menu and panel,
                                                                                        some commentators accuse KDE of being stuck in
                                                                                        the middle of the previous decade, but we’re yet to see
                                                                                        a convincing argument for doing things differently.
                                                                                        The Windows 8 user interface is a disaster, both
                                                                                        Gnome 3 and Unity are still trying hard to convince
                                                                                        their users, and Apple’s OS X hasn’t really changed
                                                                                        in over a decade. KDE’s window management is



46                                                          www.linuxvoice.com
                                                                                                                       KDE 5 REVIEWS


  Plasma 5 in details




   Launcher The launch menu now        App switcher App and activity        Notifications One area now        KRunner The Alt+F2 launch
   has pervasive search and a new      switching, and Plasma widgets,       holds all notifications and the   system is now simpler and has
   flat look tied to your settings.    have all become more discreet.       network manager settings.         had a graphical overhaul.



peerless, the desktop can be as minimal as you want         brightness control worked when you pressed the
it to be and you have access to an unrivalled number        button twice, while the buttons to control audio
of configuration options. This is a desktop that can        volume didn’t work at all until we’d loaded the KDE 4
still be made to look and operate exactly how you           mixer. Both then had different on-screen display
want it to, but it takes effort.                            themes, and integration with KWallet didn’t seem to
                                                            work. Some apps were fine, whereas others – most
High DPI                                                    importantly KMail – became unusable as they asked
This initial release is supposed to support high-DPI        for a password every time they accessed the network.
screens, but we suspect this is coming for free from            KRunner has been humbled, not offering as many
Qt 5. Its support in Plasma 5 suffers in the same way       plugins at its KDE 4 counterpart, but hopefully that
Qt does; it’s very good at scaling GUI elements when it     will come, and we can’t believe the new battery applet
knows the pixel density of your screen, but there’s no      looks so good and
automatic way of telling it. And as you still need to use
other applications, such as those from KDE 4 and
                                                            yet still doesn’t tell
                                                            you how much time
                                                                                      “It won’t be long until Plasma 5
those using GTK, it all quickly becomes a non-              is remaining, only a      improves to the point where many
standard mess of changing font sizes and hoping for
the best. As Aaron Seigo recently posted on Google+,
                                                            useless percentage.
                                                            Convergence has
                                                                                      people will be able to switch.”
“Fonts and screen DPI and scaling and kittens crying.       also been mentioned,
Trust me, it all comes together.”                           and there are different plasma shells for different form
   The good news is that the KDE 5 high-DPI rendering       factors, but we’ve yet to see the point.
looks fantastic on screens with a high pixel count –            For everything else, there’s KDE 4, and we don’t
much better than KDE 4, and with more developers            think it will be long until Plasma 5 improves to the
using laptops with unfathomable resolutions, this           point where many people will be able to switch over.
problem will hopefully receive some much-needed             It will then be a case of waiting for apps to be ported
attention. And not too soon, in our opinion. This is        to KDE 5 for the full native experience, a process that
a long overdue problem for Linux, and one where             looks quite complex to our untrained eyes but not as
Ubuntu’s Unity is currently leading the pack.               difficult as KDE 3 -> KDE 4, and the process will be
                                                            worth the transition.
Don’t upgrade yet!                                              KDE 5 looks good. It’s faster and more efficient and
As you might expect from an early release, there are        it’s the future. But until then, there’s no disadvantage
enough teething problems with Plasma to stop us             to sticking with KDE 4 and waiting a while before
from recommending it now, especially on a machine           making the jump.
you rely on. ‘plasmashell’ crashed five times over two
weeks, and always restarted gracefully. We couldn’t
                                                              LINUX VOICE VERDICT
use the window manager’s effects configuration page
                                                              For developers, the upgrade is worth
because there was an incredibly long delay whenever           the effort. For users, it’s going to take
it loaded. It took many minutes to enable a single            some time before this patient strategy
option, for example. Many of KDE’s settings panels are        pays off.
missing, in particular the panel that configured a
touchpad, which we found tricky. On our laptop,



                                                              www.linuxvoice.com                                                              47
     REVIEWS CAMJAM EDUKIT



CamJam EduKit
Andrew Gregory dips his toe into the ocean of robotics and
GPIO programming with this cheap and cheerful beginner’s kit.

                                  W
                                              hen the Raspberry Pi launched in 2012 it
  DATA                                        was clear that it would rise or fall on the
  Web
                                              strength of the supporting material. And so
  www.camjam.me/edukit            it has proved; there are more powerful and cheaper
  Developer                       devices out there, but the Pi has grown a huge
  Tim Richardson, Michael         community providing how-tos and projects, and
  Horne & Jamie Mann              several third-parties have popped up selling add-on
  Price
  £5.00
                                  equipment.
                                     One of these is the CamJam EduKit. A collaboration
                                  between Michael Horne and Tim Richardson of
                                  Cambridge Raspberry Jam in partnership with The Pi
                                  Hut. The CamJam EduKit is a cheap (£5.00) box of
                                  components and a complementary set of worksheets
                                  downloadable from camjam.me/edukit.                         The documentation is fantastic – everything is clear, even
                                     The components in the box comprise a breadboard,         if you haven’t played with electronics before.
                                  three LEDs, some jump leads, a handful of resistors,
                                  a buzzer and a switch. Using these elements, you            assumes a Raspbian installation, but we used our
                                  can make a simple circuit powered by the GPIO pins          brand new B+ with the Noobs kit. This is no big
                                                                   on the Raspberry Pi,       deal, as Noobs clearly identifies Raspbian as the

“If you want to have a go at                                       gradually adding more
                                                                   functions until you’ve
                                                                                              recommended choice of OS.
                                                                                                  Another consequence of using a B+, rather than
robotics but don’t know where                                      got a little device that   the model B that the worksheets were written for, is

to start, start here.”                                             responds to input from
                                                                   the command line
                                                                                              that the B+ has an extra 14 GPIO pins. This could be
                                                                                              enough to confuse an absolute beginner, but a quick
                                                                   and from the included      Google search reveals that the first 26 pins are laid
                                  switch. And that’s it. At the time of writing, there are    out in exactly the same configuration as they always
                                  six worksheets, which start with the very basics and        were, so any old guides are going to be compatible
                                  move up to importing Python modules and accepting           with the new Pi. Actually, forget that: while we were
                                  input from the user.                                        writing this review, Michael Horne updated the
                                                                                              (excellent) documentation to include a reference to
                                  From the ground up                                          the model B+.
Is it a kid’s spy kit? It could   When we say that the EduKit starts with the basics,             For our money, the EduKit is an unqualified
be... It’s an EduKit, ready       we mean the absolute basics. The first worksheet            success. There are no moving parts; you won’t be
for the making!                   describes the process of plugging in the Pi, booting        building a robot out of an ice cream tub with this kit,
                                  it and writing a Hello World script in Python. This         or anything more advanced than a traffic light system,
                                                                                              but that’s not the point. What it does do is open up the
                                                                                              door, just a crack, into the possibility that you might
                                                                                              build these things in the future, and that’s what makes
                                                                                              it brilliant.
                                                                                                  Like the Pi itself, it’s cheap enough to be a stocking
                                                                                              filler for a curious child, and if they don’t like it, you’ve
                                                                                              only wasted a few quid. But if it takes root and fires
                                                                                              something in your imagination, that £5 becomes
                                                                                              the best value possible. If you want to have a go at
                                                                                              robotics but don’t know where to start, the answer just
                                                                                              got a lot simpler: start here.

                                                                                                LINUX VOICE VERDICT
                                                                                                A perfect introduction into the
                                                                                                complicated world of electronics
                                                                                                tinkering. Our appetite is whetted.




48                                                                www.linuxvoice.com
                                                                                                    MATHEMATICA 10 REVIEWS



Mathematica 10
Ben Everard wonders whether the new version of Mathematica is more intelligent
than he is. Mathematica knows but won’t tell him.

I
     t’s a little hard to say exactly what Mathematica is.
     It’s a programming language, IDE, data source,
     natural language processing toolkit, equation
solver and data visualiser all wrapped up into one
piece of software. If you want to do something, and it
involves data, Mathematica can probably do it.
   Prices start at £195 + VAT for an individual (or £80
for students), but quickly rise if you want more
advanced features (including technical support). The
top level costs £5,695 and includes (among other
things) support for up to 16 processing cores, phone
support, upgrades, Wolfram Workbench and
WebMathematica Amateur.
   That’s quite a lot of money, but there is a one-month
free trial available to help you find out if Mathematica
suits your needs. Be warned, though, the trial version
is crippled to the point that most of the example code
on the Mathematica website won’t run. The trial will
also give you access to the Wolfram Cloud                                                                              As well as its own
(https://programming.wolframcloud.com/app),                  that can take experience to get right if you have to do   programming language,
which is able to run most things, but the trial account      them manually – leaving the user with just the task of    Mathematica can take
is limited there as well, and some of the more               linking in the data set.                                  input in normal English.
processor-intensive tasks exceed the trial limits.
   Version 10 brings three new areas to Mathematica:         Enormous data processing power
machine learning, geographic computation and                 The Connected Device Framework has also seen                DATA
geometric computation, as well as improvements in            some improvements. This is the toolset that’s
                                                                                                                         Web
just about every area, including many in the                 designed to bring data from external sensors into           www.wolfram.com/
Connected Device Framework. There’s a list of new            Mathematica so that you can analyse it, and Wolfram         mathematica
features at http://reference.wolfram.com/language/           is targeting this at hobbyists with example code for        Developer
guide/SummaryOfNewFeaturesIn100.html.                        Arduino. Although this is very powerful, most sensor        Wolfram Research
   Geographic computation is largely based on                data is quite simple, and analysing it in Mathematica       Price
                                                                                                                         £195 +
geovisualisation, which is just a fancy word for             would be like using a sledgehammer to crack a nut.
colouring in maps. This is something that’s becoming         It’s very rare to need this level of processing power
increasingly popular as a method of visualising data.        outside of industrial settings.
The integration of the map data and the graphing                 We’re pleased to see improved testing libraries in
functions with the language are make the new version         version 10. These are part of a push from Wolfram to
of Mathematica probably the easiest tool to do this          make Mathematica a more attractive environment for
available today.                                             software engineering, and are something that’s been
   The best feature of the new machine learning area         lacking in previous versions.
is its ease of use. Mathematica can handle almost all            Mathematica is a uniquely powerful piece of
of the algorithm selection and configuration – tasks         software that, when used well, can help you perform
                                                             incredibly powerful computations very easily.
                                                             However, the price of using it is tying your work up
                                                             with proprietary software. While we do use closed
                                                             source software, we’re uncomfortable with the idea of
                                                             intertwining our programming this closely with
                                                             software that we can’t control.


                                                               LINUX VOICE VERDICT
                                                               Very powerful and easy to use, but
                                                               hampered by a lack of freedom.
The new tools in geovisualisation and machine learning
are especially exciting, and incredibly easy to use.

                                                               www.linuxvoice.com                                                                 49
     REVIEWS LIBREOFFICE 4.3



LibreOffice 4.3
The Document Foundation claims “you can’t own a better office suite” than this.
Mike Saunders gets out his Truthometer 9000™
                                           …

                          O
                                      n the desktop, LibreOffice is arguably the most
  DATA                                important free software project in existence.
  Web
                                      Sure, we all love Linux and sing its praises
  www.libreoffice.org     from the rooftops, but there’s still a long way to go
  Developer               before every home user and business running
  The Document            Windows makes the switch. It’s easier to give people
  Foundation              their first taste of open source by recommending
  Licence
  GNU GPLv3/MPL
                          applications to them, and LibreOffice is a great
                          example: it does 99% of the jobs that 99% of people
                          do in Microsoft Office, for zero cost. Home users and
                          businesses can see that free software is more than
                          capable of replacing proprietary applications, saving
                          huge amounts of money along the way.
                              It’s a 215MB download (for the 64-bit .deb
                          packages), and an empty Writer window consumes                 Here’s an OOXML file containing DrawingML, rendered
                          98MB of your RAM banks, in contrast to 85MB for the            completely broken in an earlier version of the suite.
                          previous version. So it’s slightly heavier, but much
                                                             work is being done to       compatibility with Excel, and in-cell formulas are
“LibreOffice does 99% of the                                 make the overall
                                                             program smaller and
                                                                                         displayed with better highlighting. When you select a
                                                                                         bunch of cells, the status bar now shows the number
jobs that that 99% of people                                 more suitable for use on    of rows and columns. Collaboration, meanwhile, has
do in MS Office, at zero cost.”                              mobile devices.
                                                                But the big changes in
                                                                                         been made easier with improved commenting
                                                                                         features, including nested comments and the ability to
                                                             LibreOffice 4.3 are the     export these comments in various file formats.
                          end-user-facing new features. OOXML documents
                          that previously looked broken in LibreOffice should            Shiny new toys
                          now render much more correctly, especially those that          Impress has seen its share of updates too.
                          use DrawingML (see the screenshots). Other import              Presentations can be made prettier with 3D models
And here it is again in   filters have been added for Microsoft Works                    (created in the emerging glTF format), while initial
LibreOffice 4.3, with     spreadsheets and files from ClarisWorks on the Mac.            support for COLLADA and .kmz files has been
everything in its right       Calc, the spreadsheet, has been boosted in various         incorporated. Then there’s a mountain of bugfixes,
place.                    areas: 30 formulas have been added to enhance                  GUI improvements and documentation updates
                                                                                         covering every aspect of the program.
                                                                                            LibreOffice is miles ahead of Microsoft Office in many
                                                                                         key areas: file format import and export; support for
                                                                                         many different operating systems; cost of ownership;
                                                                                         and so forth. The advancements made in the OOXML
                                                                                         import filters make it increasingly viable as a drop-in
                                                                                         replacement for Microsoft’s products.
                                                                                            But then, we don’t use MS Office and don’t rely on
                                                                                         some of its obscure or rarely used features. Home
                                                                                         users and businesses will have to try LibreOffice 4.3 to
                                                                                         see if it finally does everything they need, and opens
                                                                                         all their files without problems. One thing’s for sure:
                                                                                         there’s never been a better time to switch.


                                                                                           LINUX VOICE VERDICT
                                                                                           New features are good, but it’s the
                                                                                           improved Microsoft Office
                                                                                           compatibility that really makes this a
                                                                                           worthwhile upgrade.




50                                                          www.linuxvoice.com
                                                                                                             STELLARIUM REVIEWS



Stellarium 0.13
View the infinite glory of the night sky through your computer monitor.
Now Ben Everard has another reason not to go outside.

I
     f you haven’t used Stellarium before, you’re in for a
     treat. It creates a skymap of stars, planets,
     comets, and most other astronomical
phenomena. If, like us, you live in a city, and the night
sky is washed out by a sheen of light pollution that
only a few of the brightest stars can break through,
then Stellarium gives you the chance to see what the
sky should look like. If, on the other hand, you’re lucky
enough to live somewhere with a dark sky, Stellarium
provides the tools to learn the different stars and
constellations. If you already know the constellations,
then it gives you the chance to view past and future
astrological events from any position.
  When you start Stellarium, it takes over your screen
and provides an OpenGL-rendered view of the sky at
the current time. You can set the location to anywhere
you want on earth, or you can set off on a virtual tour
of the galaxy and see the night sky from the surface
                                                                                                                           Stellarium can show you
of other planets, moons and stars without needing a          in low-light conditions so that it won’t ruin your night
                                                                                                                           the position of the stars –
NASA-sized budget.                                           vision if you use it in the dark. This makes it perfect for   and constellation artwork
  If a real-time rendering of the sky isn’t exciting         running on a laptop outside on a clear night. You can         – at any time of day or
enough for you, you can speed it up and watch the            also get Stellarium Mobile for Android and iOS devices        night.
stars move at super-speed, or start a meteor shower          (a port by the original author of Stellarium), but this
to add a little graphical delight. There are options to      isn’t free software.
tweak just about every aspect of the scene, including
which astrological objects appear and how bright they        Planets in your pocket
are, what projection is used to compress the universe        Version 0.13 comes with lots of new graphical
onto a 2D screen, and the amount of twinkle the stars        wizardry, though none of it changes the basic way               DATA
have. This might sound like pointless clutter, but as        Stellarium works. Comets and meteors are now a bit
                                                                                                                             Web
you play with the settings, you get a feel for how the       prettier, and there are new plugins to help with field of
                                                                                                                             www.stellarium.org
real physical objects and effects interact to create the     view and time settings. If you’re hoping to be the next         Developer Stellarium
night sky.                                                   Bear Grylls, then you may find the new plugin with              development team
  Aside from the graphical rendering, Stellarium also        navigational stars useful. It should also hog fewer             Licence GPL
has a great user interface, which manages to be both         resources now, so is a useful upgrade for people
powerful and unobtrusive. Unobtrusive in this context        running older hardware. All in all, it’s a gradual –
means that it both stays out of the way and gives the        though not particularly exciting – improvement on the
whole screen to the sky map, and that it works well          previous version.
                                                                Don’t be put off by the low version number:
                                                             Stellarium is a great, stable application that’s been
                                                             around since 2001, and has been widely used for
                                                             much of the past 13 years. It’s fascinating as a
                                                             curiosity, but you can also delve deeper and use it as
                                                             a tool to learn more about the universe and our place
                                                             in it. Be careful though: it will make you want to buy a
                                                             telescope, travel to the desert and stare at the white-
                                                             flecked darkness above.

                                                               LINUX VOICE VERDICT
                                                               Even the least astronomically-
                                                               inclined person is likely to have fun
                                                               with Stellarium. It’s wonderful.

A view of the heavens from the surface of the moon.



                                                               www.linuxvoice.com                                                                   51
     REVIEWS BOOKS



Tubes: A journey to the center
of the internet
Ben Everard is now wondering if he can spend his next holiday on a guided tour.

W
              hat is the internet? Think about    This isn’t a detailed book about the structure
              that question for a moment. Is it   of the internet, though it does leave the
              an abstract concept that doesn’t    reader with a basic overview of this. Instead,
exist in physical space? Or is it a tangible,     this is a book that adds colour to the bland
finite thing that you could reach out and         network topographies that comprise most
touch if only you knew where to find it?          descriptions of the internet.
    In Tubes, Andrew Blum takes the view that        The reader is left with gives a splendid
it’s a set of computers and routers, and the      overview of what goes on behind the scenes
high-bandwidth cables that connect them. In       of the defining engineering accomplishment
this case, then, the internet must exist, and     of our age and one we often don’t give
since it exists, it must be possible to see it.   ourselves the space to think about.
Tubes is a book documenting his quest to
find the internet, or at least the physical
things that comprise it.                            LINUX VOICE VERDICT
                                                    Author Andrew Blum
Where is your mind?                                 Publisher Ecco Press/Penguin
                                                    ISBN 978-0-061-99493-7/978-0-141-04909-0
Blum manages to get access to a surprising
                                                    Price £9.99
amount of infrastructure, and he takes the
                                                    Discover the wondrous locations your data
reader along with him as he tours internet          visits after you send it down the intertubes.
exchanges and cable landing points, and                                                              The looks like some form of abstract PCB
meets the people who keep them running.                                                              routing that has nothing to do with the internet.




Great North Road                                                                 SCI-FI

It took a year, but Graham Morrison finishes a book about Newcastle upon Tyne.


T
         here have been times when we’ve          characters is rain-sodden Newcastle upon
         really enjoyed Peter F Hamilton,         Tyne circa 2142. There are wormholes,
         most recently with the completion        invisible alien threats and lots of Geordie
of the Void trilogy in 2010. This was a           accents, but this is essentially a crime
fantastic series of multithreaded yarns that      drama. Hamilton is also trying to highlight
weaved medieval adventure into a possible         carbon emissions, sustainability and the
future where fictionalised versions of Larry      unforeseen consequences of taking from
Page and Sergey Brin ruled the ultimate           the environment. These elements do feel
philanthropic corporate universe. It had          awkward, and the book never quite feels
moments of brilliance, even if its length         as harmonious as his other work, which is
meant the thrill of those original themes         perhaps why we finished many other books
became a little jaded. But it was another         before finally completing this one.
reason why Hamilton is still one of the best
current proponents of ‘the space opera’ – the
literary equivalent to listening to Bohemian        LINUX VOICE VERDICT
Rhapsody by yourself in the car.                    Author Peter F Hamilton
    The same could be said of Great North           Publisher Macmillan
                                                    ISBN 978-0-230-75005-0
Road, currently a rare one-off title from the
                                                    Price £6.99
same author. It features many characters
                                                    Hamilton’s usual mix of grandiose themes with
in different environments that may or may           many characters, but lacking his usual impact.   Even with wormholes and awesome computing
not come together at some pivotal point                                                              power, those silly humans are still wreaking
in the story. The setting for most of these                                                          havoc on unsuspecting environments.



52                                                             www.linuxvoice.com
                                                                                                                      REVIEWS BOOKS


Dealing With Disrespect                                                                             ALSO RELEASED…
Graham Morrison learnt long ago to never read the comments.



J
         ono Bacon has fought more than
         his fair share of flamewars online,
         and he’s not the only one who has
noticed the vehemence of commentators
increasing. And we completely agree.
Disagreements can reach disproportionate                                                                                             One day soon,
levels of hate, and this can be a real                                                                                               we’ll all need
problem to the average sensitive and                                                                                                 big data tools
introverted geek. Not only can it lead to                                                                                            to search our
depression and diminished self-worth, but                                                                                            photos.
                                                                              We’re on a road to
it’s also pushing valuable contributors out                                   nowhere.              Data Algorithms
of the community. We’ve seen more than                                                              After reading Ben’s excellent data analysis
one insightful mind turn their back on a        be for everybody, we suspect there’s a              tutorial in this very issue (p82), we’ve got a
project simply because of too much bile.        considerable number who will take quiet             genuine taste for big data, which is why this
                                                                                                    book looks rather excellent. It promises to give
    The message behind Jono’s short             solace from its publication.
                                                                                                    you the super-powers to crunch through
book is simple; you’re not alone. Using                                                             petabytes of data. Excellent!
anecdotes and a personal style, the book          LINUX VOICE VERDICT
walks the reader through the mental               Author Jono Bacon
journey we’re assuming Jono went                  Publisher self-published
through in learning to come to terms with         Price CC BY-NC or $2.99 on Kindle
                                                  There’s too little written about this subject,
disrespect, and how to turn any knock in          and it’s great to see Jono highlighting the
confidence and uncertainty into a positive        seriousness of a growing problem.
force. That the book is also available for
free is also rather noble, and while it won’t                                                                                        Create the
                                                                                                                                     next Inception
                                                                                                                                     from the
                                                                                                                                     comfort of

Coding Freedom: The Ethics and                                                                                                       your Linux
                                                                                                                                     box.
Aesthetics of Hacking                                                                               Mastering Autodesk Maya 2015
We’ve been studied, and Ben Everard has the results.                                                Blender is incredible, but we often forget that
                                                                                                    there’s a tier 1 3D application available for



H
                                                                                                    Linux that many studios already use, and that’s
          ave you ever watched National                                                             Maya. It may be expensive, but it’s a native
          Geographic as an anthropologist                                                           application capable of Hollywood-quality
          describes the customs of a tribe                                                          rendering. This books takes it up a level.
and wondered what the tribe thought
about the film? If you have, and you’re a
                                                                           The birds on the front
free software coder, this might be your
                                                                           cover are made up
chance to find out.                                                        of the text of a Perl
   Gabriella Coleman is an anthropologist                                  script to remove
who studies us. By us, I mean the elusive                                  encryption from
tribe of people that work on open source                                   DVDs.
software. In Coding Freedom she takes a
scholarly approach to analysing what it         interesting, but in its current format, it’s
means to be someone who develops free           more suited to reading by social scientists
software, and she’s taken the time to           than computer scientists.                                                            Think of the
understand this properly. In doing so, the                                                                                           children.
book also covers the concept of free              LINUX VOICE VERDICT                               Design for Kids
software, what it means to the community,         Author E Gabriella Coleman                        It’s lovely that there’s a renaissance in teaching
and why people within the community are           Publisher Princeton University Press              technology to kids, but developing interfaces
                                                  ISBN 178-0-691-14461-0                            for children is a completely different challenge
so attracted to it.
                                                  Price £16.95                                      to the ones we’re used to. This is why this
   Coding Freedom is heavy going,
                                                  A detailed, informative, but hard-to-read         ebook looks useful. It helps designers deal
especially to someone not familiar with the       guide to the people behind free software.         with the emotion, ego and impatience of the
languages of the social sciences. If you                                                            average child, while helping them learn.
make the effort to read it, it’s quite



                                                                www.linuxvoice.com                                                                    53
     GROUP TEST IRC CLIENTS




      IRC CLIENTS                  GROUP TEST
                                     Graham Morrison Experiences the old world charm of a group
                                     chat technology that predates Facebook by a generation.


 FIND US ON IRC!
 #linuxvoice is on Freenode, and it’s a friendly and welcoming channel
 for everyone interested in Linux, Free Software and beer.
                                                                             IRC Clients
                                                                             W
                                                                                         e’ve become so used to               to load, video conferencing and

 On Test                                                                                 the idea that newer is
                                                                                         better that it’s difficult to
                                                                             envisage anything old competing
                                                                                                                              voice was impossible, and that left
                                                                                                                              text, and the initial rise of IRC.
                                                                                                                                 That IRC has survived and thrived
  Konversation                                                               with anything new. Web browsers,                 in the 21st Century is a testament
                           URL konversation.kde.org                          desktops, laptops and even distros               to its original design and simplicity.
                           Version 1.5                                       are overhauled so often that                     Get a client, connect to a server and
                           Licence GPL                                       running an old version feels difficult           join any channel you find
                           The strongest of several KDE IRC clients          and anachronistic.                               interesting. Channels in this sense
                           with more config options per pixel.                  But there’s one significant                   are a little like the channels on
                                                                             exception, and that’s something                  Citizens Band radio of the 80s, and
  XChat                                                                      called Internet Relay Chat (IRC).                there are channels for everything,
                           URL xchat.org                                     To the uninitiated, it’s like chatting           from exploring your Arch fetish or
                           Version 2.8.8                                     in Google Talk or Facebook                       early masterpieces of the Ultima
                           Licence GPL                                       Messenger with more than one                     franchise with the Exult channel, to
                           Perhaps the mostly widely used default
                                                                             person at the same time. IRC is a                3D printed psycho robots
                           IRC option for most distributions.
                                                                             child of the BBS-era (Bulletin Board             (#robotics) and your very own Linux
  Smuxi                                                                      Systems), predating the world
                                                                             wide web, the first SMS messages,
                                                                                                                              Voice (look us up on Freenode).
                                                                                                                                 IRC use is also growing, not just
                           URL https://smuxi.im
                                                                             hashtags and the rise of social                  because it’s an open platform out of
                           Version 11.0.0
                           Licence GPL                                       media. And because you’d often                   the control of big corporations; it’s
                           Super powerful, despite its austere GUI           have to dial into a BBS from a                   also mature, secure (if you want it
                           (which is currently being upgraded).              low-bandwidth modem, efficiency                  to be), and globally accessible. Now
                                                                             was everything. Even the fastest                 that more of us are working
  Quassel                                                                    modems of 1988, when IRC was                     remotely, IRC has become the
                           URL www.quassel-irc.org                           created, connected at a mere 2400                perfect medium for both informal
                           Version 0.10.0                                    baud – that’s only 2400 bits per                 chat and serious planning. Which is
                           Licence GPL                                       second in the technology of the                  why finding the perfect client has
                           A lovely GUI for power users with the             time. JPEGs might take 30 minutes                never been so important.
                           best server/client split we tested.

  Irssi                                                                      “IRC has become the perfect medium for
                           URL irssi.org
                           Version 0.8.16                                    both informal chat and serious planning.”
                           Licence GPL
                           Lots of script and a great console GUI,             WHAT MAKES A GOOD CLIENT?
                           but lacking recent development.
                                                                               IRC is a contentious platform, a little like   need to be reliable, transparent and
  WeeChat                                                                      email. Old-school users will swear by
                                                                               their command-line tools, while others
                                                                                                                              flexible, and if possible, accommodate
                                                                                                                              as wide a spectrum of users as possible.
                           URL weechat.org                                     will like the cuddly ease of a nice GUI.       It’s these attributes that we’ve focused
                           Version 0.4.3                                       As far as we’re concerned, it doesn’t          on, so that whichever client you end up
                           Licence GPL                                         matter as long as it gets people using         using, you should be able to use
                           It’s difficult to use, and its command-             IRC instead of Facebook Messenger or           indefinitely until something better
                           line based, but it’s soo powerful.                  Google Hangouts. But a client does             comes along.




54                                                                       www.linuxvoice.com
                                                                                                       IRC CLIENTS GROUP TEST



Get started with IRC
If none of what we’re writing about here makes any sense, read this first


A
         s we’ve mentioned on the first page,      network with a Free Software bias called           #linuxvoice. Other networks include IRCNet,
         IRC is a form of group messaging          Freenode (it’s not really a single server, but a   Efnet and QuakeNet. Channels are usually
         where the groups are hosted on a          portal to a network that’s automatically           moderated by one or more operators who
server. You can create your own server             load-balanced and managed).                        have the power to kick (or ban) people from
using something like UnrealIRCd, but the             Freenode peaks at around 80,000                  the channel if they’re not adhering to the
majority of users connect to servers that are      consecutive users, it’s still growing, and it’s    rules. Any rules will appear when you
already running. The most popular is a             where you’ll find our own channel,                 connect to a network or to a channel.



Konversation 1.5
The KDE Kontender is a tough act to beat.


F
         irstly, we like Konversation’s GUI
         because it’s both minimal and utterly
         configurable. The list of users within
a channel can be discreetly slid over to the
side of the main window, and while it’s a
difficult option to find, you can expand the
input box to use multiple lines. Font support
is excellent and you can change the colours
for everything. We wish these options could
be encapsulated into a theme engine to aide
easy import, export and sharing, or take
some hint from the global colour scheme,
because we like to change between dark
and light themes depending on the time of
day, but it can be made to look exactly how
you want it to.
    Server logs and messages for each
channel are tabbed. Tabs can be moved to
the lower, upper or left borders of the main
window, and the clever Watched Nicks, URL
catcher service and the DCC status panel
can exist within their own tabs too.You get
on-screen notifications containing new             If this group test were about the number of configuration options, Konversation would win.
messages, and the system tray icon flashes
with new updates. A channel list can also be       containing the excellent KDE terminal              both work and for social networking. There
opened on a separate tab, and kept open,           console, Konsole. We also like the way             are plenty of options that enable you to
which is a better solution than the pop-up         Konversation handles multiple connections          connect to channels automatically, register
windows offered by most other IRC                  and servers, although it’s a little counter-       your nicks or accomplish almost anything
applications. Entering messages themselves         intuitive. This is because, to add a new           else through a script. A separate field for
is easier with the multi-line input, and we rely   server, you need to link a server with an          identities is useful if you use ZNC for multiple
on the excellent auto-spellchecking. As with       identity. We think this is to facilitate KDE’s     servers and need different login values, but
other clients, pressing Tab will complete a        global identity functionality, so that your        you’ll need different identities for different
nickname, and you can right-click on various       name and contact details are set in one            servers as there’s only one field per identity
GUI elements to create shortcuts to a variety      place and used in many. If you use multiple        (and not per nick).
of IRC commands. Right-click on a nick, for        servers with the same nick, you can simply
example, and you can enter message mode            add them from the identity dialog.                   VERDICT
or perform a ‘whois’ on a user. All useful            You can also have more then one nick per          A excellent option for KDE
                                                                                                        users, and worth the KDE
stuff for people without IRC in their DNA.         identity (this is getting complicated), but the      library install for everyone
    Finally, this wouldn’t be a KDE application    separation between identities, servers, nicks        else.

if it didn’t enable you to open another tab        and channels is useful if you use IRC for



                                                               www.linuxvoice.com                                                                 55
     GROUP TEST IRC CLIENTS


XChat
This is the client you’ve probably already got installed.


I
     f there’s an Old Pretender to the IRC    or download a searchable list from
     client crown, it’s XChat. It’s been      the server. It’s easy and works well,
     around since 1999 and it’s also one      although we wish it cached the channel
of the most portable graphical clients        list for a while.
we’re looking at. There are versions for         We really like the hierarchical view of
Windows, Linux and OS X, and it’s also        connections over on the left. This lists
possible to run the client as both a          the servers and channels you’re
graphical application and a command-          connected to, and if you’re connected to
line utility.                                 a few, takes up less space than a
   XChat is also the default IRC client for   tabbed view. But you can also choose a         XChat is a great application if you use lots of desktops and
many distributions, and the first client      tabbed view if that’s what you prefer.         require the same interface.
many people go to when they start             The GUI is drawn using an older version
experimenting with IRC. This isn’t a bad      of GTK, and this gives the application                        one). We also miss proper desktop
thing at all. XChat is stable, functional     something of an old Unix feel. This isn’t                     notifications and a system tray icon
and easy to use. When you first launch        bad – and it also means you’ll be able                        that highlights unread or missed
the application, for instance, it’s one of    to use XChat wherever you install it, but                     messages. And while there is a plugin
the few clients that gives you a list of      neither is its appearance going to                            system in XChat, it’s little more than a
servers and a pre-configured username         satisfy the eye candy brigade (if there is                    scripting engine.
based on your login name (albeit one
that will change to Guest??? when
you’re connected to a server where that
                                              “XChat is the first client many                                 VERDICT
                                                                                                              An good option if you’ve

nick is already taken).                       people go to when they start                                    never used IRC before. It’s
                                                                                                              uncomplicated, but also
   Clicking on a server will connect, and
you can easily join a channel you know
                                              experimenting with IRC.”                                        unimaginative.




Smuxi 11.0.0
Ignore the name and there’s lots to like here.


S
        muxi is an unassuming IRC             groups on a small selection of well
        application that can also connect     known addresses, and the ‘Find Group
        to Twitter, Facebook and several      Chat’ function lets you quickly search
other instant messaging protocols. But        through the channel list (and caches
this in no way diminishes its IRC             that list for a time), which feels very
credentials, unlike in Pidgin, for example,   intuitive. Despite a GTK-based GUI
where its inclusion is more of a              that’s in transition to version 3, and
convenience. It can also be launched in       still looking like a throwback to the
console-only mode, in server mode             late 1990s, we love the nick colouring
(referred to as the engine) and with a        that keeps the same colours across
straightforward Gnome-based GUI. It’s         channels, and it’s definitely an upgrade       Smuxi is perfect for the power user or anyone who wants
                                                                                             a single application for GUI, console and remote work.
one of the most powerful applications         from XChat. System tray notifications
in this group test, while remaining easy      also work across desktops,
to use.                                           We also love the inclusion of a                           brilliant option if you’re not fussed
   On launch, it will helpfully connect       powerful filter interface that can be                         about austere GUIs. It’s perfect for the
to its own support IRC channel while          used to cut almost anything out of your                       power user or the new user who knows
also asking which server you’d like           chat windows, from ‘join’, ‘left’ and ‘quit’                  they’re going to need room to grow.
to connect to. Its interface is XChat-        events through to only highlighting
like, and you can start using IRC             conversations you may be interested in.                         VERDICT
immediately without any further               It’s not simple to confgure, but it is                          A decent upgrade to
                                                                                                              XChat, and worth keeping
familiarisation. We like any application      powerful and it’s a feature unrivalled in                       an eye on for a GTK3+
that includes presets for servers, as         any of the other graphical clients we’ve                        overhaul.

most of us will only be browsing for          looked at. All of which makes Smuxi a



56                                                              www.linuxvoice.com
                                                                                                   IRC CLIENTS GROUP TEST


Quassel                                                                                         IRC Commands
It’s powerful and good looking. Just like us.
                                                                                                Our 200 word guide to
                                                                                                interacting with IRC


                                                                                                T
                                                                                                         here are many guides to getting
                                                                                                         started with IRC, but to help with the
                                                                                                         demystification, here’s our tips to
                                                                                                getting started. Anything you type will appear
                                                                                                to everyone else in the channel unless it’s a
                                                                                                command preceded by the / character. Typing
                                                                                                /help will give you some hints from the server
                                                                                                on getting started. /connect SERVER will
                                                                                                connect from the command-prompt, while
                                                                                                /join #CHANNEL will join the channel. /nick
                                                                                                changes your nickname, but this will need to
                                                                                                be unique to your network. You can send a
                                                                                                private message to someone with /msg Mike
                                                                                                MESSAGE, and you can connect peer-to-peer
                                                                                                to someone using the /dcc command (ie not
                                                                                                through the server). /dcc chat Mike will open a
                                                                                                chat session with Mike, for example, or we can
                                                                                                ask to send a file to him using /dcc send Mike
                                                                                                file.odt. Though not necessary, many people
The split between the core and the client versions of Quassel makes it a powerful option.       animate their chat with /me (/me has another
                                                                                                glass of wine will appear as Graham has



I
       f you include Konversation (and Kirc,     channels, and a channel will turn green        another glass of wine), and /describe. Finally,
       though we’re not covering it) via KDE’s   when a new message is posted. Senders          if you step away from your machine for a
       dependency on Qt, the Qt tookit is        can have a different colour (as they can in    while, use /away (your client may do this
doing rather well in our group test. Quassel     Konversation) and the search highlighting      automatically), or /quit to leave.
is another Qt application, similar to the        is very easy to see. There are also plenty
other two but without the dependency on          of notification options including a working
KDE. It uses a similar array of identities,      event for the system tray.
servers and nicks to Konversation, which            But we’ve kept Quassel’s best feature
can make configuration a little tricky, but      until last. While you can run it as a
it’s also easier to install and more portable.   standalone application just like any other
Like XChat, you can find Quassel on both         IRC client, Quassel also provides two split
Windows and OS X, as well as your                components – a core and a client, which
favourite Linux distribution.                    can be run separately. It can split the core
    It’s also an application that borrows        and the client components so that the
its visual style from XChat – there’s a          core connects to your servers and
hierarchical server and channel panel on         channels while the client(s) provides the
the left, the chat window in the middle and      input and interface. This has one huge
the nick panel on the right. Any of these        advantage – create a core user from the
elements can be moved around, giving             command line and you can run the core
you maximum flexibility in how you like          on a server that’s always connected to
your IRC sessions organised. There’s even        your channels. Connecting from a client
an option to remove the input field, which       will then play back messages while you’ve
could be useful if you’re only monitoring a      been away. It’s a simple way to get offline
channel, although we missed the option           buffering of your channels, which can be
for multi-line visualisation even when the       essential if you use IRC for work, but it
input lines can be increased.                    also integrates perfectly with the client.
    There are some great GUI touches.
Hover over an image URL, for example,              VERDICT
and you get an image preview. You can              Looks fantastic, and
                                                   almost matches
also configure custom chat lists, which is         Konversation for                             If you start spending more time on a network, it’s
useful if you want to limit a list to a            configurability.                             worth reading its policy guide.
specific server or a specific number of



                                                                   www.linuxvoice.com                                                           57
     GROUP TEST IRC CLIENTS


Irssi vs WeeChat
It’s the battle for the command-line!


W
               e’re about to dive into a       they choose, from custom highlights
               couple of command-line          and showing a nick list alongside the
               clients, which means we’re      chat view, to themes and music
heading into contentious territory.            playback. There are already hundreds,
Users typically invest so much time            and it’s quite easy to write your own.
getting terminal clients exactly how
they like them, and the command-line is        WeeChat
perfect for such modification, that they       WeeChat has become a popular
become wedded to their favourite. And          alternative to Irssi, as it’s been able to
we’re particularly fortunate because           capitalise on Irssi’s development            Don’t be put off my the console colours: Irssi is simple
there are two awesome command-line             doldrums over the last few years. It’s       enough for anyone to use.
tools that are both brilliant and probably     what we’ve run on our VPS for a couple
good enough to tempt many of us                of years, and while complex to start                         You can enable some to show the nick
away from the padded luxury of point                                                                        list, and some to not, and save multiple
and click.
    Irssi is the one to beat. It’s been        “Irssi has been around for a                                 screen layouts and configurations with
                                                                                                            the same commands you use within
around for a long time and is the default      long time and is the default                                 the app itself. We also love the instant

                                               choice for many CLI users.”
choice for many CLI users.                                                                                  keybinding and the spellchecking that
Development has been slow over the                                                                          can highlight spelling errors on the
last few years, but in June, the project                                                                    editing line, and the Tab command
moved over to GitHub in the hope of            with and somewhat unforgiving, we’ve                         completion that works for internal
attracting a new developer community.          not found a better client.                                   parameters. It all works brilliantly.
It’s not even difficult to get started with.     At its core is the idea of a buffer.                          Many of the IRC clients we’ve looked
Install the package, run irssi and the         You can have many buffers, and each                          at support scripting, but WeeChat has
example config command, then                   buffer can host and cache a server and                       taken this to a new level. Type /script
connect to Freenode and join your              session, as well as multiple sessions.                       and the display lists hundreds of scripts
favourite channel. Servers and                 You can switch between buffers and                           that have been written and can be
networks can easily be added through           sessions using the function keys                             installed and activated in-place. Almost
further commands (type /help to see a          and split the views horizontally or                          everything has been thought of. There’s
list) and you can switch between them          vertically many times between buffers.                       a variety of different notification
and servers and channels using Ctrl or         This means that you can configure                            systems, which is important as there’s
Alt shortcuts. It’s quick, powerful and        WeeChat to show many channels at                             no desktop integration. You can run
easy to use. More importantly, most            once, usually more efficiently than you                      shell commands from within your IRC
users download and install third-party         can with a GUI application, and switch                       sessions, and even play Snakes or Tetris.
Perl scripts to extend Irssi in any way        between them using the function keys.                           Working with both Irssi and WeeChat
                                                                                                            are a little like working with Emacs and
                                                                                                            Vim – you have to go through a
                                                                                                            considerable learning curve and use
                                                                                                            IRC regularly enough to keep what
                                                                                                            you’ve learnt in your local cache. But if
                                                                                                            you do, you’ll find both more productive
                                                                                                            and efficient than their GUI equivalents.
                                                                                                               These applications are always going
                                                                                                            to be a tough proposition for GUI users
                                                                                                            as beginners to IRC, but they’re also a
                                                                                                            reminder of why the terminal is still so
                                                                                                            important even today, and why, in many
                                                                                                            ways, it’s likely to outlast the desktop in
                                                                                                            its usefulness.

                                                                                                             VERDICT
                                                                                                             Irssi Smart and simple     WeeChat …then if you
                                                                                                             to use. If you think you   find yourself needing
                                                                                                             might like CLI IRC, try    more control, perhaps
                                                                                                             this first…                level-up to WeeChat.

WeeChat has some extra features, such as split views, that can become essential.


58                                                              www.linuxvoice.com
                                                                                                        IRC CLIENTS GROUP TEST




  OUR VERDICT
IRC Clients
W
            ithout exception, each        activity – which is something we
            client we’ve looked at        often want to do. The tabbed
            has a reason for it to be     interface also makes it great for
chosen as our favourite. Quassel, for     managing a large number of
example, has the best no-fuss             channel connections at once.
separation option for client and             But we’re not going with              A splittable view, in-line spell checking, inotify and hundreds of
server. It means you could run the        Konversation. We have to admit           hot-pluggable scripts – WeeChat is difficult to beat.
core on a Raspberry Pi, for example,      we’re smitten by WeeChat. In our
and catch up with your channels           opinion, it’s the Arch of IRC clients.
whenever you’re connected. Several
other clients offered similar
                                          Its forums are not friendly to
                                          newbies, and it’s slightly bewildering
                                                                                    1st WeeChat
                                                                                    Licence GPLv3 Version 0.4.3
features, but only Quassel combined       to get started with. But we think it
this with what we consider a              offers enough of an advantage on          weechat.org
powerful GUI.                             the command line that it’s worth          Yep, it’s a terrible name. But whenever have we let that get in
   If we were to choose a GUI             ditching the desktop for.                 the way of great software?
application, and we should to try to         When you add all the advantages
                                                                                    2nd Konversation
“WeeChat offers enough of an advantage                                              Licence GPLv2 Version 1.5

that it’s worth ditching the desktop for. ”                                         konversation.kde.org
                                                                                    This is our favourite option if you’re looking for the most
encourage new people to use IRC,          that the terminal brings for free –       powerful GUI client.
we’d go with Konversation. Apart          such as persistent screen sessions
from a lack of scripts and                on a Raspberry Pi server, or              3rd Quassel
extensions, we found it to be the         low-bandwidth access from almost          Licence GPLv3 Version 0.10.0
most powerful desktop application.        any SSH client, we think WeeChat is
It did everything we asked for, and       the best client to grow into. It’s got    quassel-irc.org
                                                                                    If you want to experiment with a simple graphical client–server
after getting our heads around the        the same feeling of liberation you
                                                                                    setup, try this option first.
identities for networks, we found it      get if you switch from a GUI email
easy to configure in even complex         client to Mutt, or start using Bash
and bespoke IRC setups (which we          more, but without sacrificing any         4th Irssi
use for putting the magazine              function. Let us know if we’ve            Licence GPL Version 0.8.16
together). The GUI can be                 missed your favourite client out and
                                                                                    irssi.org
subverted into almost any                 we’ll make sure we mention it next
                                                                                    If WeeChat is over-engineered and you need something on the
appearance, and there were easily         time. Why not let us know on our          terminal, Irssi is the best.
accessible functions for filtering the    own IRC channel? You can find us
most common chat annoyances,              as #linuxvoice on Freenode. See
as well as watching nicks for             you there!
                                                                                    5th smuxi
                                                                                    Licence GPL Version 11.0.0


  YOU MAY ALSO WISH TO TRY…
                                                                                    smuxi.im
                                                                                    It’s incredible that such a brilliant app can come fourth in our
                                                                                    list, but that’s only because they’re all so good.
  There are so many IRC clients, it’s     because we were already looking at
  difficult to know where to start.       two KDE-based applications and we
  You can coerce Pidgin into talking      thought three would be too many.          6th XChat
  IRC, for example, and if you’re a       Also worth a look is the old Mozilla      Licence GPL Version 2.8.8
  KDE user, KVirc is rather excellent.    client, ChatZilla, which works
  It will already be included in many     perfectly well and is very easy to        xchat.org
  KDE-centric distributions, so you       use, especially alongside Firefox.        The same can be said for XChat. It’s a great little app that works
  won’t need to do anything more to       It’s still being developed and needs      perfectly and is perhaps the best place to start with IRC.
  try it out. We missed this out purely   to be installed as a Firefox addon.



                                                               www.linuxvoice.com                                                                       59
     SUBSCRIBE




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

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

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


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

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



60                                                         www.linuxvoice.com
                                                                                                                                          NEXT MONTH



                                  NEXT MONTH IN



ON SALE                                                                                    EVEN MORE AWESOME!
  THURSDAY                                                                                                                                   The birth of ARM
25 SEPTEMBER                                                                                                                                 Without Reduced
                                                                                                                                             Instruction Set
                                                                                                                                             Computing (RISC)
                                                                                                                                             and ARM, the
                                                                                                                                             smartphone enabled
                                                                                                                                             world would not
                                                                                                                                             exist. Thanks,
                                                                                                                                             Sophie WiIlson…

                                                                                                                                             Get your hack on
                                                                                                                                             Be inspired by the
                                                                                                                                             clever, creative
                                                                                                                                             things that people
                                                                                                                                             just like you are
                                                                                                                                             doing right now with
                                                                                                                                             free software. Damn,
                                                                                                                                             us humans are
                                                                                                                                             brilliant sometimes.

                                                                                                                                             Space

 BUILD YOUR OWN DISTRO                                                                                                                       Tiny Linux-powered
                                                                                                                                             satellites are in
                                                                                                                                             low-Earth orbit,
 Whatever your level of technical ability, you                                                                                               building up an open
 can create a Linux distribution tailored to                                                                                                 data map of the
                                                                                                                                             globe. Find out who,
 your exact needs. Do it – feel the power, the                                                                                               how and why they’re
 mastery, and build the perfect Linux for you.                                                                                               running Ubuntu.




        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 May 2015 when all content (including
 ben@linuxvoice.com                                                               Tel: +44 (0) 20 3148 3300                     images) is re-licensed CC-BY-SA.
 Editor at large Mike Saunders    Printed in the UK by                                                                          ©Linux Voice Ltd 2014
 mike@linuxvoice.com              Acorn Web Offset Ltd                            Circulation Marketing by Intermedia Brand     ISSN 2054-3778
 Creative director Stacey Black                                                   Marketing Ltd, registered office North Quay
 stacey@linuxvoice.com            Disclaimer We accept no liability for any       House, Sutton Harbour, Plymouth PL4 0RA       Subscribe: shop.linuxvoice.com
                                  loss of data or damage to your hardware         Tel: 01737 852166                             subscriptions@linuxvoice.com

                                                                     www.linuxvoice.com
      CORETECHNOLOGY




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

UDP: Get plugged in
Peek inside your machine to find out how it transmits data packets.


L
        ast issue we implemented a simple            interacting with two clients. The server has a       parcel up the per-client state information
        server using the TCP protocol, which         single endpoint (UDP socket) and may well            into a structure, and place them into some
        turned any string you typed into it into     find itself retrieving datagrams from several        sort of indexed data structure that uses as
upper case letters. While the following              clients in an arbitrary, interleaved order. If the   its search key a composite value formed
examples should make sense on their own,             server is stateless (that is, if it does not need    from the client’s IP address and port
we’ve put that article up as a PDF at                to remember anything from one client                 number. Another approach is for the server
www.linuxvoice.com/coretech06/ so you                interaction to the next) then this does not          to create a child process for each client it
can read it alongside this month’s.                  present a problem. The server simply reads           finds itself dealing with. Each child can
   This month I want to re-cast this server to       a request, formulates a reply, returns it to the     create a new UDP socket, whose port
use UDP. In some ways it’s simpler than TCP          client, then forgets about it. Classic UDP-          number is duly reported back to the client,
– there are no connect or accept operations.         based services such as DNS are stateless in          and which is used by the client for the
I’ve drawn a flowchart that shows the typical        this sense.                                          remainder of the interaction. The TFTP
sequence of operations for a UDP-based                  Things get more complicated for servers           (Trivial File Transfer) server works this way,
service. Here we see a single server                 that maintain state. One approach is to              for example.


  Peer-to-peer architecture using UDP broadcasts                                                          The power of Python
                                                                                                          Most of our code examples this month are
                                                                                                          in Python, because Python hides some of
                     Server
                                                                                                          the fiddly data structures that would be
                     Create                                                                               exposed if we wrote them in C. So here’s a
                     socket                                                                               UDP version of our upper-case server:
                                                      Client 1                                            import socket
                                                                                                          port = 4444
              Bind a port number                       Create                                             s = socket.socket(socket.AF_INET, socket.SOCK_
                 to the socket                         socket
                                                                                                          DGRAM)
                                                                                                          s.bind((“”, port))
                                                                                                          while 1:
              Receive datagram                     Send datagram                 Client 2                   data, addr = s.recvfrom(1024)
                                                                                                            s.sendto(data.upper(), addr)
                                                                                 Create                       Pretty simple, huh? We create a socket
                                                    Receive reply                socket                   and bind our “well-known” port to it. Then we
                  Send reply
                                                                                                          enter our service loop, retrieving messages
                                                                                                          from clients, converting them to upper case,
              Receive datagram                                               Send datagram                and sending them back. Last month, in
                                                                                                          showing the equivalent code for a TCP
                                                                                                          server, I briefly made the point that the
                                                                              Receive reply               server doesn’t really need to know the
                  Send reply
                                                                                                          address of the client, unless it wants to use
                                                                                                          it for logging or access control. Here it’s
         A connectionless server interacts with multiple clients using a single socket.                   different -- we definitely need the address of
                                                                                                          the client’s endpoint (addr in the example) so



64                                                                  www.linuxvoice.com
                                                                                                                                  CORETECHNOLOGY


  Try It Out – Create a UDP server
  To create and test the upper-case server, place its       it works!                                               clearly see that messages we enter are returned in
  code in a file called ucserver.py.                        IT WORKS!                                               upper case – our server is working.
     To test the server, start it in one terminal window:   ^C                                                         We can extend the experiment. Leave the nc
  $ python ucserver.py                                          The XXXXX string appearing in the output above      program running in the second terminal window,
     Now we can open a second terminal and test             is an artifact resulting from a series of probe         open a third terminal window and run the same
  server using the the jack of all trades nc (network       datagrams that nc apparently sends to the server        nc command there as well. You should find that
  client) command:                                          (and which our server duly echoes back). The            you can interact with the server via both windows.
  $ nc -v -u localhost 4444                                 connection suceeded message is a little confusing;      That’s the simplicity of a connectionless service;
  Connection to localhost 4444 port [udp/*] succeeded!      this is UDP and there is no connection as such.         you don’t need any multi-processing or multi-
  XXXXXThis is a test                                       If you omit the -v (verbose) command option you         threading or other fancy tricks in the server to get
  THIS IS A TEST                                            won’t see the X’s or the message. But we can            concurrent operation with multiple clients.


that we know where to send the reply.                       and they must all be on the same network,               10 int sock;            /* Socket descriptor */
Python’s dynamic typing is hiding a little                  because routers and gateways are almost                 11 struct sockaddr_in server; /* Broadcast address
complexity here, because addr is actually a                 never configured to pass broadcast traffic.             */
(host, port) pair. See the box above if you                 There isn’t a lot to it really; you have to             12 struct sockaddr_in client;
would like to build and test this server. We                explicitly enable broadcasting on the socket,           13 int client_len, yes = 1;
could write a little Python program to act as               and use a special destination host address              14 int value;
a client to our upper-case server, but let’s                of “all ones”, or 255.255.255.255 in dotted             15
switch to a different example. There is an                  decimal notation.                                       16 /* Create a datagram socket and enable
ancient UDP-based service called daytime,                       The example presented here is both a                broadcasting */
which listens on port 13 and simply sends                   client and server all rolled into one. The idea         17 sock = socket (AF_INET, SOCK_DGRAM, 0);
back a string with the current time and date.               is that the client piece periodically generates         18 setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
It’s a sort of speaking clock but without the               an item of data, which it broadcasts. The               (char *) &yes, sizeof yes);
speaking. This service is implemented by a                  server piece receives the broadcasts and                19
daemon called xinetd; the box below shows                   displays the item of data. For simplicity the           20 /* Bind our well-known port number */
how to install and enable it.                               ‘item of data’ is a simple randomly generated           21 server.sin_family = AF_INET;
    Once the daytime service is up and                      integer, but could be something more                    22 server.sin_addr.s_addr = htonl (INADDR_ANY);
running, we can write a client for it. Again                interesting in the real world – a weather               23 server.sin_port = htons (UPDATE_PORT);
using Python, it looks like this:                           forecast or a stock price, perhaps.                     24 bind (sock, (struct sockaddr *) &server, sizeof
#!/usr/bin/python                                               The code here is in C, and it looks more            server);
# UDP daytime client                                        complicated than the Python examples                    25
import sys                                                  we’ve seen so far, but conceptually it’s                26 server.sin_family = AF_INET;
import socket                                               not really any harder. As always, the line              27 server.sin_addr.s_addr = 0xffffffff;
# Get server host name from command line                    numbers are for reference; they are not part            28 server.sin_port = htons (UPDATE_PORT);
host = sys.argv[1]                                          of the code:                                            29
port = 13                                                   1 #include <stdlib.h>                                   30 /* Create an additional process. The parent acts
s = socket.socket(socket.AF_INET, socket.SOCK_              2 #include <netdb.h>                                    as the client,
DGRAM)                                                      3 #include <stdio.h>                                    31 periodically broadcasting values to anyone who
# Send an empty datagram to wake the server up              4 #include <arpa/inet.h>                                happens to be
s.sendto(“”, (host, port))                                  5                                                       32 listening on port 2066. The child acts as the
data, addr = s.recvfrom(1024)                               6 #define UPDATE_PORT 2066                              server,
print “time from”, addr, “ is “, data                       7                                                       33 receiving the broadcasts and displaying the
  And we can run it like this:                              8 void main ()                                          data.
$ chmod u+x daytimeclient.py                                9{                                                      34 */
$ ./daytimeclient localhost
time from (‘127.0.0.1’, 13) is 01 JUL 2014 10:26:42
BST                                                           Try It Out – Install the daytime service
  Notice how Python automagically                             To get the daytime service running we first need       service xinetd restart instead.) Now verify that the
converts the client address into a printable                  to install xinetd (this is on Ubuntu, but the story    daytime server is listening:
(host, port) representation.                                  should be similar on other distros):                   $ sudo lsof -i | grep daytime
                                                              $ sudo apt-get install xinetd                          xinetd 27465 root 5u IPv4 165011         0t0 UDP
                                                                 Even if xinetd were already installed, the          *:daytime
Broadcasting                                                  daytime service is probably disabled. So, edit            If you don’t see an encouraging line of output
One thing that you can do with UDP sockets                    the file /etc/xinetd.d/daytime, find the stanza        here, you’ll need to investigate before moving
that you cannot do with TCP is                                that relates to the UDP version of the service and     forwards. We can test this service using nc again:
broadcasting. That is, you can send a single                  change the line disable = yes to read disable = no.    $ nc -u localhost daytime
copy of a message and have it received by                     Now restart xinetd:                                    01 JUL 2014 10:16:20 BST
                                                              $ sudo invoke-rc.d xinetd reload                         You will need to send the daytime server a
many listeners. The constraints are that all
                                                              (On a Red Hat-style system you would need              datagram of some sort (just enter a blank line).
the listeners must be using the same port,



                                                                         www.linuxvoice.com                                                                                65
      CORETECHNOLOGY


                                                           address’. When I first met this years ago
                                                           I thought that the “in” meant “input”, and          Get the code
                                                           spent some time looking for a sockaddr_out,         A tarball of the programs used in this tutorial
                                                           which my sense of symmetry told me must             can be downloaded from www.linuxvoice.com/
                                                           be there, like the Higgs Boson. But I digress.)     mag_code/lv07/coretech007.tar.
                                                               At line 17 we create our socket and at line
                                                           18 we set the SO_BROADCAST option on              raw sockets enable an application program
                                                           it. Just look at the hoops we have to jump        to reach right down to the IP layer and
                                                           through to pass in a Boolean TRUE value.          ‘hand-craft’ the headers of whatever the
                                                               Lines 20–24 bind our chosen port number       overlying protocol is. For example, the port
                                                           (2066) to the socket. At lines 26–28 we           scanner Nmap uses raw sockets to build
                                                           re-use the ‘server’ structure to hold the         non-conformant TCP headers for its own
                                                           broadcast address. Notice the 0xffffffff          special purposes. As another example, ping
The Berkeley sockets library, dating from 1983,            value, which is the “all ones” of the broadcast   (which sends and receives ICMP packets)
remains the standard sockets API to this day.              address.                                          also uses raw sockets. On Linux, the rule is
                                                               Now we get cunning, rolling the client        that only processes running with root
35 if (fork ())                                            and server pieces of the application into         privilege can use raw sockets. This is a
36 {                      /* PARENT (client) here */       one program by creating another process.          security precaution, because a program
37     while (1)                                           The parent process (lines 37–45) is the           using raw sockets can intercept all traffic
38 {                                                       client. Once a second, it generates a             entering the system. A common way to deal
39      value = rand () % 1000;                            random integer value, and broadcasts it in        with this is to have the program run “set UID
40      /* Broadcast update packet to servers */           a tiny 4-byte datagram. The child process         to root”. This enables it to create its raw
41      sendto (sock, (char *) &value, sizeof value, 0,    (lines 52–62) is the server. It receives the      socket, then drop its privilege back to a
42           (struct sockaddr *) &server, sizeof           broadcast packets and prints out each value,      non-root user. If you look at the ping
server);                                                   along with the IP address of the client that      program for example, you’ll find it runs
43      sleep (1);                                         sent it. The important thing to keep in mind      setuid for this reason:
44 }                                                       here is that this loop is not only receiving      $ ls -l /bin/ping
45 }        /* End of parent (client) code */              the broadcasts from its own client, it will       -rwsr-xr-x 1 root root 44168 May 7 22:51 /bin/ping
46                                                         also receive the broadcasts from all other          Notice the s in the permissions.
47 /* -------------------------------------------------    instances of the client running elsewhere on
*/                                                         the network.                                      Staying in the Unix domain
48                                                                                                           We’ve focussed here on sockets in the
49 else                                                    Raw sockets                                       internet domain, which means that (among
50 { /* CHILD (server) here */                             I won’t inflict any more code on you this         other things) the socket is identified by an IP
51     /* Enter service loop, receiving values and         month, but I wanted to wrap up by                 address and a port number. But there are
displaying them */                                         mentioning two more socket types. First,          other naming domains for sockets; in
52     while (1)
53 {
                                                             Timeline for connectionless server
54      /* Receive an update packet */
55      client_len = sizeof client;                                                                                                            update
56      recvfrom (sock, (char *) &value, sizeof value,
0,
57            (struct sockaddr *) &client, &client_len);
58
                                                                                                                                  2066
59      /* Display the broadcast value and where it
                                                                                update
came from */
60      printf (“got %3d from %s\n”, value, inet_ntoa
(client.sin_addr));                                                             Parent (client)
                                                                                  Generate
61 }                                                                                                                 Local
                                                                 Create            update
62 } /* End of child (server) code */
                                                                 socket                              2066           Network
                                                                                                                                               update
63 }                                                                             Child (client)
  Now there’s quite a bit of code here,                                          Receive and
and some of it is messy. So grab a brown                                        display update
paper bag (so that you can breathe into it
for a bit if you start to panic) and let’s work                                                                                    2066
through it. First, the declarations at lines
11 and 12 refer to the endpoint addresses
                                                             Multiple instances of our ‘update’ program broadcast
used for sending and receiving. (The                         to each other in a peer-to-peer relationship.
name sockaddr_in means ‘internet socket



66                                                                     www.linuxvoice.com
                                                                                                                      CORETECHNOLOGY

particular, the so-called “Unix domain
sockets” are identified by a name within the          Try It Out – Build a peer-to-peer update service
filesystem. You can find all of these with the        If necessary, install the gcc compiler:            got 886 from 192.168.1.69
command:                                              $ sudo apt-get install gcc                         got 421 from 192.168.1.73
$ sudo find / -type s                                   Enter the code into a file called update.c and      To do a meaningful test you’ll need to copy the
                                                      compile it:                                        executable across onto at least one other machine
  A classic example is /dev/log, which                                                                   on the same network, and run it there as well. (You
                                                      $ gcc update.c -o update
syslog (or rsyslog) uses to collect log                  Run it like this:                               can’t run multiple instances on the same machine
messages from local applications. But you             $ ./update                                         -- why not?) In the output above, you’ll see that
will probably find many others.                       got 383 from 192.168.1.69                          we’re receiving interleaved broadcasts from two
  There’s no command for creating a                   got 649 from 192.168.1.73                          machines.
named socket analogous to mkfifo for
creating named pipes. Your server creates           running on the same machine. There are               in LV005) but unlike pipes, which are
the socket and binds the name to it, and            also anonymous Unix domain sockets                   unidirectional, a socket pair is bidirectional.
your client needs to know that name in              created with the socketpair() system                 Also, you can create both stream and
order to connect. Unix domain sockets only          call; these are somewhat similar to good             datagram socketpairs, whereas pipes are
support communication between processes             ol’anonymous pipes (see Core Technologies            inherently stream-oriented.




Command of the month: dig
My command of the month is dig.                     explicitly enable the sections you want              we end up with the four octets of the IP
According to its man page it stands for             to see. For example, this shows just the             address reversed. So here’s the hard way to
“domain information groper”, though that            ANSWER section:                                      do the lookup:
sounds like a retrofitted acronym if ever I         $ dig ubuntu.com +noall +answer                      $ dig +short 172.101.138.213.in-addr.arpa ptr
heard one! Anyway, dig is a command-line            ; <<>> DiG 9.9.5-3-Ubuntu <<>> ubuntu.com +noall     mainsite.default.linuxvoice.uk0.bigv.io.
tool for performing DNS queries.                    +answer                                                An easier way is to use the -x option of
  In my view, dig has two main uses. First,         ;; global options: +cmd                              dig, which lets us enter the IP address in the
you can use it to test your DNS service.            ubuntu.com. 577 IN A 91.189.94.156                   usual format:
Second, you can use it as an exploration              If there are options you always want to            $ dig +short -x 213.138.101.172
tool. It’s this second use we’ll focus on here.     specify, just put them into ~/.digrc. For            mainsite.default.linuxvoice.uk0.bigv.io.
We’ll use Linux Voice’s own site as a target        example, if you put this line into the file:         What’s interesting is that the IP address is
for our exploration. First let’s just find the IP   +noall +answer                                       allocated to a machine in the bigv.io
address of the website; this is the simplest        then by default your dig queries will only           domain. A quick search reveals that BigV is
type of lookup:                                     show the ANSWER section.                             a virtual machine hosting provider – now we
$ dig www.linuxvoice.com                              The +short option really cuts to the chase         know who Linux Voice uses to host its site.
;; QUESTION SECTION:                                and shows just a bare-bones response:
;www.linuxvoice.com.          IN        A           $ dig +short linuxvoice.com                          A handy tool for stalkers
;; ANSWER SECTION:                                  213.138.101.172                                      Let’s try something a little different, by
www.linuxvoice.com. 600 IN CNAME linuxvoice.                                                             asking DNS where its root name servers are:
com.                                                Dig deeper                                           $ dig +short . ns
linuxvoice.com. 600 IN A 213.138.101.172            Next let’s investigate who handles mail for          f.root-servers.net.
   I’ve edited a lot of detail from this output     the linuxvoice.com domain. For that we               i.root-servers.net.
but you’ll see it shows that we requested           need to get the MX (Mail Exchanger) record:          d.root-servers.net.
an ‘A’ record from DNS for the name www.            $ dig +short linuxvoice.com mx                          Here, ns means we’re looking for name
linuxvoice.com. (‘A’ records are the records        10 smtp.linuxvoice.com.                              server records and . refers to the top level
in DNS that map machine names to IPV4               $ dig +short smtp.linuxvoice.com                     domain. It is analogous to / in a filename,
addresses.) What we actually got was a              213.138.101.172                                      which names the root directory (the top-level
CNAME record (an alias, in effect) pointing            So… mail is handled by a machine called           directory) in a filesystem. I’ve cut the output
to the name linuxvoice.com. Dig then kindly         smtp.linuxvoice.com, and it turns out that           down again; there are actually 13 root name
looked up the A record for linuxvoice.com,          this is the same machine (same IP address)           servers, I’ve shown only three.
finally reporting the IP address.                   as the web server. So, Linux Voice apparently           By default, dig consults the file /etc/
   There are command-line options for dig           hosts its own web and mail servers on a              resolv.conf to figure out which name server
that control how much output we see. For            single machine. No surprises there.                  to consult, just as normal DNS lookups
example, +noquestion suppresses the                    Let’s try a reverse lookup on that machine.       do. But we can direct dig to a specific DNS
question section from the output. You can           That is, let’s look up the PTR record for that       server like this:
turn off other output sections using options        IP address and convert it back to a machine          $ dig @8.8.8.8 +short jamieoliver.com
such as +nocomments, +noauthority,                  name. The PTR records are stored under               85.233.160.22
+noadditional and +noanswer, or you can             the in-addr.arpa domain, and because DNS               Here, 8.8.8.8 is the IP address of Google’s
turn everything off using +noall and then           names are written in a “little endian” form,         public DNS service.



                                                                  www.linuxvoice.com                                                                       67
     FOSSPICKS




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

             Mike Saunders has spent a decade mining the internet for free
             software treasures. Here’s the result of his latest haul…
Shiny statistics in a browser


Web VMStat
M
            any distros, especially        Here’s where Web VMStat comes
            those targeted at           in. It’s a system monitor that runs
            advanced users, ship        an HTTP server, so you can connect
with shiny system monitoring tools      to it via a web browser and see
on the desktop. Conky is one such       fancy CSS-driven charts. Before you
tool, while GKrellM was all the rage    install it, you’ll need to get the
in the last decade, and they are        websocketd utility, which you can
genuinely useful for keeping tabs       find at https://github.com/
on your boxes, especially when          joewalnes/websocketd. Helpfully,
you’re an admin in charge of            the developer has made pre-
various servers.                        compiled executables available, so
   Now, pretty much all major           you can just grab the 32-bit or
distros include a useful command        64-bit tarball, extract it and there
line tool for monitoring system         you have it: websocketd. (Of course,
                                                                                 Here’s the standard output for vmstat – not very interesting, right?
resource usage: vmstat. Enter           if you’re especially security
vmstat 1 in a terminal window and       conscious, you can compile it from                                   copy the aforementioned
you’ll see a regularly updating (once   its source code.)                                                    websocketd into the same place.
per second) bunch of statistics,           Next, clone the Web VMStat Git                                    Then just enter:
showing CPU usage, free RAM,            repository (or grab the Zip file and                                 ./run
swap usage and so forth. It’s all       extract it). Go into the directory and                                  And that’s it – Web VMStat has
very useful, but it has one major                                                                            started an HTTP server on port
problem: it’s ugly. Very ugly. Sure,
most admins don’t care about
                                        “Web VMStat is a way to keep an                                      9231, so you can access that in
                                                                                                             your browser (eg http://
fancy bells and whistles, but the       eye on servers on your network                                       localhost:9231). Straight away,
information could be presented in a
more readable and clean fashion.
                                        without having to log into them.”                                    you’ll see that the charts are
                                                                                                             smooth and silky, with processes,
                                                                                                             CPU, memory, IO and swap usage
                                                                                                             depicted. Hover your mouse over
                                                                                                             the numbers for more detailed
                                                                                                             descriptions.
                                                                                                                In all, Web VMStat is a simple way
                                                                                                             to keep an eye on servers on your
                                                                                                             network without having to log in to
                                                                                                             them. You could create a bookmark
                                                                                                             group for a bunch of machines, for
                                                                                                             instance, and open them up in tabs
                                                                                                             for a quick glance of how they’re
                                                                                                             performing. And all the information
                                                                                                             is gathered by the ‘real’ vmstat tool,
                                                                                 With Web VMStat,
                                                                                                             so you know it’s legit.
                                                                                 resource usage is
                                                                                 shown in a much clearer
                                                                                 and prettier manager.        PROJECT WEBSITE
                                                                                                              https://github.com/joewalnes/
                                                                                 Look at the smooth
                                                                                                              web-vmstats
                                                                                 curves!



68                                                           www.linuxvoice.com
                                                                                                                                               FOSSPICKS


Operating system


NetBSD 6.1.4
B
          ack on page 38, our FAQ               understanding it. Some terminology
          looked at the BSD family of           in the BSD world is considerably
          operating systems, so                 different though: for instance, hard
hopefully that has whetted your                 drive devices tend to be called wd0
appetite sufficiently to try one. We            (for the first), wd1 (for the second)
thought we’d look at NetBSD here.               and so forth.
It’s the most ported of the BSDs,                  Also, NetBSD installations
running on over 50 hardware                     normally use one large primary
platforms (www.netbsd.org/ports).               partition on the hard drive, which is
“Big wow”, you might say. “Linux                then split up into sub-partitions for
runs on everything from                         root (/), the home directories, swap
supercomputers to wristwatches”.                space and so forth. The installer
    True – but many of these ports              provides plenty of help about this,
                                                                                               Although NetBSD’s base
are in unofficial source code                   but if you’re unsure, run through the                                         something, it’s almost certainly
                                                                                               system is very minimal,
branches, not always remaining                  installation in a virtual machine              you can spruce it up           covered in the extensive guide at
up-to-date with the mainline kernel.            before trying it on a real box!                with most common               www.netbsd.org/docs/guide/en/
In NetBSD, everything is built from                                                            desktop apps included          index.html.
the same source tree, and this often            Bare-bones setup                               in Linux distributions.          Try entering startx to fire up the X
helps with the overall stability and            After the first boot from the hard                                            Window System; if that fails, these
security of the OS.                             drive, you can log in as root with no                                         commands (as root) should help by
    Anyway, NetBSD for x86 and                  password. NetBSD is in a very bare                                            providing a fresh X configuration:
x86-64 is available in CD ISO (eg               state here, but fortunately there’s an                                        X -configure
NetBSD-6.1.4-i386.iso) and USB                  excellent manual page describing                                              mv xorg.conf.new /etc/X11/xorg.conf
flash drive (NetBSD-6.1.4-i386-                 the next steps to take. Enter man                                               After running startx now, you’ll
install.img.gz) formats. For the                afterboot and you’ll see a helpful                                            land at a completely unremarkable
former you can write it to a CD-R               guide to changing the root                                                    TWM desktop. NetBSD doesn’t try
and boot it on a real machine, or try           password, setting up a normal user                                            to second guess what you want,
it in VirtualBox. The latter can be             account, configuring the network                                              however, so you can start adding
written to a flash drive with the               (enabling DHCP on boot) and so on.                                            applications like so:
usual dd command (see http://                   Documentation in the BSD family is                                            export PKG_PATH=”http://ftp.netbsd.org/
tinyurl.com/bsdusbinstall).                     largely superb, and if the afterboot                                          pub/pkgsrc/packages/NetBSD/i386/6.1.4/
    When you boot it up, you’ll see a           page doesn’t help you with                                                    All/”
text mode installer akin to those of                                                                                          pkg_add -v xfce4 firefox24
Debian and Slackware. It’s menu
driven, so it’s a bit simpler to
                                                “In NetBSD everything is built from                                             Again, check out the superb
                                                                                                                              online guide for more information.
navigate than the installer in                  the same source tree, which helps
OpenBSD, and experienced Linux
users won’t have major troubles
                                                with stability and security.”                                                   PROJECT WEBSITE
                                                                                                                                www.netbsd.org




How it works: Installing NetBSD




  1 Boot                                                   2 Choose sets                                              3 Finish
       Boot your PC or VM from the CD or USB key,               You’ll be asked which ‘sets’ should be installed.          After you’ve partitioned the drive (you can give
and a bunch of green NetBSD kernel messages will         These are groups of software, such as development          NetBSD the whole disk for simplicity’s sake), the OS
whizz by. After a few moments, you’ll arrive at the      tools and the X Window System – in most cases, it’s        files will be copied over, and you can reboot into your
installer; use the cursor keys and Enter to navigate.    best to choose Full Installation.                          shiny new installation.



                                                                       www.linuxvoice.com                                                                              69
     FOSSPICKS


Prettified classic window manager


FVWM-Crystal 3.3.2
R
        ant mode activated: there’s       that there’s a program launcher bar
        a lot of NIH (Not Invented        in the top-left, workspace switcher
        Here) syndrome in the             in the top-middle, and taskbar along
software development world. Too           the bottom. Right-click on the
many programmers would rather             desktop and a terminal window will
write something from scratch just         appear. The program launcher has
to say they’ve done it, than use or       a series of icons that open
improve a mature and existing             submenus for different categories
project. Nobody has the right to          of applications, while the crystal
dictate how FOSS developers               button in the far top-left has a menu
spend their time, but we like to see      for tweaking FVWM’s settings.
                                                                                     FVWM-Crystal takes the
people working more constructively,          If you’re used to graphical dialogs                                   Much of the documentation for
                                                                                     ultra configurability of
reducing duplicated effort.               for configuring every part of your         FVWM and puts a shiny       the FVWM applies to FVWM-Crystal,
  So we love FVWM-Crystal: it’s a         desktop, you might find FVWM-              layer on top.               and on the FVWM-Crystal website
gorgeous, shiny and functional            Crystal somewhat limiting – you                                        you’ll see that the Documentation
desktop that hasn’t written               have to spend a lot of time poking                                     tab holds some resources such as
everything from the ground up. No,        around in text files. On the other                                     an FAQ and tips page. (If you want
instead it uses FVWM, one of the          hand, this makes it somewhat                                           to see what a standard FVWM setup
oldest (and ugliest) window               easier to back up and move your                                        looks like, just choose it from your
managers in existence.                    configuration across multiple                                          login screen, it will be installed via
  FVWM-Crystal takes this                 machines, so once you’ve fine-                                         the FVWM-Crystal package.)
venerable WM and adds layers of           tuned everything to perfection, you
polish. When you start it, you’ll         can keep your desktop pixel-perfect                                      PROJECT WEBSITE
                                                                                                                   http://fvwm-crystal.sourceforge.net
notice (in the default configuration)     regardless of your distro.


Command progress viewer


Cv 0.4
Y
         ou might not have heard of       run make and make install (the
         Coreutils before, but it’s an    latter as root) inside the directory.
         essential part of every major    Now run a few commands that will
Linux distribution. It’s a software       take a while to execute, such as
bundle from the GNU project that          copying a multi-gigabyte file. In
provides all the little tools you use     another terminal, run cv and you’ll
at the command line – ls, rm, cp          see the PID (process ID) of the
and so forth. While the GNU               command, along with a percentage
Coreutils programs are regarded as        value showing how close it is to
the most featureful in the Unix           completion.
world, they still have some                  Cv can probe running instances
limitations. It’s not easy to see the     of these tools: cp, mv, dd, tar, g(un)
                                                                                     Copying a file in one terminal and seeing its progress with Cv in
progress of some commands, for            zip, cat, grep, cut and sort. If you add   another – we see that it’s 74.2% complete.
instance, which can be annoying           the -w flag to the cv command, it
when you’re performing a large file       will try to work out the I/O                                           can vary depending on your system
operation and want to know how            throughput of the file operation and                                   load. Another useful flag is -m,
much time is remaining. Cv, the           show an estimated time for                                             which runs cv in monitoring mode;
Coreutils Viewer, is a tiny program       completion – but, of course, this                                      this shows updated statistics every
that fixes this, showing statistics for                                                                          second, until the file operation
running commands.
   To install it, clone the Git
                                          “Cv is a tiny program that shows                                       completes.

repository (or just download the Zip      statistics for running commands.”                                        PROJECT WEBSITE
                                                                                                                   https://github.com/Xfennec/cv
file from the project’s website) and



70                                                              www.linuxvoice.com
                                                                                                                                        FOSSPICKS


Interactive filtering


Percol
L
         ast issue, we looked at a         percol /boot/grub/grub.cfg
         classic tome called The Unix        This will show the entire contents
         Programming Environment. At       of the file, with a prompt at the top.
the start of this book, the authors        Start typing some characters,
outline the Unix philosophy, stating:      though, and you’ll see that the
“Many Unix programs do quite               display is narrowed down to lines
trivial things in isolation, but,          containing the text that you’ve
combined with other programs,              entered. Use the cursor keys to
become general and useful tools.”          select a line, hit Enter, and you’ll see
                                                                                              Here’s the output of ps
   Percol adheres to this philosophy       that the line’s text is printed at the                                        we can type the name of a process
                                                                                              aux being piped through
– it doesn’t appear to do anything         shell prompt.                                      Percol – we’ve entered k   and use the cursor keys to select a
useful on its own, but combined              By combining Percol with other                   here to narrow the list    specific line. After you hit Enter, awk
with other tools it turns out to be        commands, we can provide a level                   down a bit.                pulls out the PID (process ID) part of
rather useful. It’s essentially an         of interactivity. Look at this:                                               the text, and passes it on to the kill
interactive filter for text, so you pipe   ps aux | percol | awk ‘{ print $2}’ | xargs kill                              command via xargs. So ultimately
some data into it, type some letters         Here we’re generating a list of                                             you have an interactive process
to narrow down the selection, and it       processes with the ps command,                                                killer, without any coding – just by
spits out the resulting selection to       and piping them into Percol (as in                                            linking tools together. If you do a lot
stdout. You can install it with pip        the screenshot). In the percol part,                                          of Bash scripting, you’ll find plenty of
install percol, or if you grab the                                                                                       ways to add interactivity to your
code from GitHub, sudo python                                                                                            scripts with this.
setup.py install.                          “Combined with other tools, Percol
   To get a feel for how Percol
works, use it to view a text file, eg:
                                           turns out to be rather useful.”                                                PROJECT WEBSITE
                                                                                                                          https://github.com/mooz/percol




Python web framework



Bottle 0.12
I
     f you’re new to web                     return template(‘<b>Hello {{name}}</b>!’,
     development and want to give it       name=name)
     a try without all the layers of       run(host=’localhost’, port=8080)
complexity – then Bottle is a sound           Now visit http://localhost:8080/
choice. It’s a “micro web                  hello/you in your browser, and you’ll
framework”, helping you to create          see a message. There you have it
small web apps with relatively few         – a web application in just 5 lines of
lines of code.                             code! OK, so this is totally trivial
   To install it, just run pip install     right now, but it shows you how to
bottle and Python’s built-in package       get started.
                                                                                              Web application
manager will retrieve the code.               Bottle has a built-in template                                             framework is the documentation,
                                                                                              frameworks – such as
Failing that, you can grab the             engine and can also use Mako,                      Django and Zope – can      and Bottle does a very respectable
source code from https://pypi.             Jinga2 and Cheetah templates. It                   be daunting for            job here. The PDF at http://
python.org/pypi/bottle. Bottle has         provides easy ways to access and                   beginners, but Bottle is   bottlepy.org/docs/dev/bottle-
no dependencies other than the             manipulate data from forms, file                   a friendly way to get      docs.pdf includes tutorials and
standard libraries that ship with          uploads, cookies and HTTP                          started.                   reference guides, with plenty of
Python, so you don’t need to bloat         headers. And along with the                                                   sample code, and the text is clear
your system with piles of extra            supplied web server, it can also use                                          and well-written. Even though Bottle
cruft. Once you have it installed, test    other WSGI-capable servers such                                               is only at version 0.12/13, it’s
it out with this Python script:            as Python Paste, Bjoern and Google                                            showing a lot of potential.
from bottle import route, run, template    App Engine.
                                              Of course, one of the most                                                  PROJECT WEBSITE
@route(‘/hello/<name>’)
                                                                                                                          www.bottlepy.org
def index(name):                           important features of any



                                                                      www.linuxvoice.com                                                                     71
     FOSSPICKS


Notification daemon


Dunst 1.0.0
M
             ost desktops (and many     daemon – or if you have one
             window managers)           already running, get its PID with ps
             include a notification     aux first, and then kill it. Now you
system, allowing applications and       can create notifications like so:
background daemons to pop up            notify-send -t 0 -u low “This is a test”
important information. The system         The -t flag here determines for
might show you when your laptop         how long the notification should
                                                                                   Different urgency levels
battery is getting low, for example,    appear (zero = forever), while -u                                     text pattern. You can left-click to
                                                                                   have different colours,
or when someone comes online in         chooses the urgency level (low,            and you can see for how    disable a single notification or
your instant messaging service.         normal, critical). You might find that     long a notification has    right-click to disable all – and there
   Now, if you’re happy with your       the default Dunst configuration            been displayed.            are keyboard shortcuts too. You
desktop’s notification system, great.   doesn’t look very good; in this case,                                 can even add some formatting to
But if not, or you’re interested in     copy dunstrc into ~/.config/dunst/                                    your notifications, using , for
dabbling in a tiling window             and edit it to your liking.                                           example, <u>underline</ul> tags
manager (as covered in last issue’s       Dunst includes a bag of features                                    for a bit of variety.
group test), then you’ll need an        such as multiple monitor support, a                                       One day we plan to create the
alternative. Dunst is one of the best   history of previous notifications,                                    Ultimate Mega Linux Voice Desktop
we’ve seen, due to its low resource     and custom scripts that can be run                                    Turbo Championship Edition, with a
requirements and customisability.       when notifications match a certain                                    tiling WM and various other tools,
   Extract the tarball, check out the                                                                         and Dunst is sufficiently awesome
INSTALL file for the list of                                                                                  to be included.
dependencies, and then run make.        “Dunst is one of the best
All being well, you can then run
./dunst to start the notification
                                        notification managers we’ve seen.”                                     PROJECT WEBSITE
                                                                                                               www.knopwob.org/dunst




Machine emulator


Qemu 2.1.0
H
          ere at Linux Voice HQ, we     SDL to provide graphics; it’s
          tend to use VirtualBox for    possible to run Qemu solely in text
          testing Linux distros and     mode, though, if you’re planning to
other x86 operating systems, but        run a text-based operating system.
we’re big fans of Qemu as well. It        To run the x86 version of Qemu
includes emulation for a wide range     with a hard drive image, enter:
of CPUs, including ARM, MIPS,           qemu-system-i386 -hda drive.img -m
SPARC and PowerPC, so you can           1024
use it to try out some very obscure       This uses drive.img as the virtual
and esoteric OSes.                      hard drive, and provides 1024MB
                                                                                   Here’s MikeOS (x86)
   Qemu 2.1 was released as we          RAM to the emulated PC. Enter                                         x86 guests, full support for USB3
                                                                                   running in Qemu on a
were finishing this issue, but we       qemu-system at your shell prompt           Raspberry Pi (ARM) in a    passthrough devices, and AArch64
managed to find time to take it for a   and hit Tab to see the other               terminal window over an    (64-bit ARM) SHA and Crypto
spin thanks to an Ubuntu PPA.           platforms that are supported. Note         SSH connection. It’s the   instruction support.
While it’s certainly possible to        that on x86 systems, when                  future!                       It’s a major release with many
compile Qemu from source, the           emulating an x86 machine, Qemu                                        changes all over the codebase; see
large range of CPU architectures        can use KVM for a performance                                         http://wiki.qemu.org/
and emulated devices make the           boost – it then uses virtualisation to                                ChangeLog/2.1 for the full list. Now,
process a long one – it could take a    pass the grunt work on to the host                                    time to dig out that old version of
few hours on older machines. (And       CPU, rather than emulating every                                      Coherent Unix from 1994…
code that emulates processors is        CPU instruction in code.
                                                                                                               PROJECT WEBSITE
always a good stress test for the         New features in Qemu 2.1 include
                                                                                                               www.qemu.org
compiler.) The main dependency is       support for memory hotplugging on



72                                                               www.linuxvoice.com
                                                                                                                                 FOSSPICKS


  FOSSPICKS Brain Relaxers
https://launchpad.net/pybik/
 Penguin-based slippy-slider


 Extreme Tux Racer 0.6
 H
           ooray – Tux Racer lives!     will get it installed. After that, run etr
           Back in the early 2000s,     to start the game. There are two
           this was one of the          main gameplay modes: event and
 flagship 3D games for Linux. It        practice. In the former, you
 was smooth, polished and had           compete in a series of cups, making
 you controlling a penguin sliding      progress in Mario Kart-style. The
 down a mountain collecting fish…       practice mode lets you try courses
 what’s not to love?                    in a less competitive environment.
    Things are very different today
 in the Linux gaming world, with        Left turn, Clyde
 Steam and GOG providing a              Control-wise it’s simple stuff: use
 stunning range of triple-A titles to   the arrow keys to turn left and right,
                                                                                     The Path of Daggers is an especially hairy course to navigate...
 explore. So we thought that Tux        press up to race faster, and down to
 Racer had long been abandoned          dig your flippers into the snow (to
 and the code was suffering from        slow down). It’s also possible to                                        livening things up. It doesn’t have
 excessive bitrot, but with Extreme     jump by holding Space until the                                          the depth or complexity of most
 Tux Racer it’s still going strong.     gauge in the bottom-right is full –                                      commercial racing games, but it’s
    To compile it, you’ll need          you don’t get a great deal of lift                                       still good fun, especially for kids.
 version 1.2 of SDL and its related     though. The 18 courses range from
 mixer and image libraries; then the    very tame to full-on crazy, with                                          PROJECT WEBSITE
 standard ./configure, make and         some hairpin turns, spiky                                                 http://sourceforge.net/projects/
                                                                                                                  extremetuxracer/
 make install (as root) procedure       mountains and chasmic jumps




 City construction romp



 Micropolis 1.6
 S
         imCity has been a hugely       from the project’s website, but note
         popular franchise over the     that it doesn’t extract into a
         years, with each release       subdirectory – just the current one.
 adding more complexity and             (All Zip files should extract into their
 variation to the gameplay. But we      own subdirectories in our opinion
 still have a soft spot for the         – write in if you disagree!)
 original – and especially the             But anyway. Run:
 Super NES conversion which             java -jar micropolisj.jar
 added cheerful music and                  In the middle of the screen you
 Mario-themed add-ons. It seems         have icons for building commercial,
 quite primitive compared to the        residential and industrial zones,
                                                                                     Only 61% of Mikeville’s
 later games, but still has its         along with power lines and roads/                                        your virtual inhabitants think of
                                                                                     residents are happy with
 charms and is enjoyable to play.       railways to connect them. Just like          the mayor. Let’s see how    your city. They’re always
    Micropolis was the original         in the original, your goal is to keep        they fare when we close     moaning about something
 working title for SimCity, and         growing the population, keeping              the police stations…        though: even if your city is
 today it refers to a freely GPLed      people safe, happy and free of                                           heaven to live in, they’ll say it’s too
 version of the original source         pollution.                                                               expensive. Humans, eh?
 code. This has been rewritten in          You can add natural disasters for
 various languages; the version         an extra challenge, and under the                                         PROJECT WEBSITE
 we’re looking at here uses Java.       Windows menu you’ll find                                                  https://code.google.com/p/
                                                                                                                  micropolis/
 Grab the micropolisj-1.6.zip file      Evaluation, which shows you what




                                                                    www.linuxvoice.com                                                                  73
                                                                                                                                 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…
                                                    76                                       78                                     82



Ben Everard
is wondering what the best way of sneaking an
arcade machine into his new house is.

                                                 Extreme Pi                               Sonic Pi                               Data analysis

I
      ’m currently packing up to move            Now he’s got a new model                 Les Pounder introduces                 There are lies, damn lies,
      house. This is an exciting time for a      B+, Ben Everard’s started                a musical programming                  and statistics. Ben Everard
      geek because it means I’ll have a          conducting experiments                   language designed to                   doesn’t trust anyone, so
blank canvas on which to wire my                 on his older model B to see              prevent the next generation            makes his own statistics
geeky thoughts. In my current place, we          just how far he can push it.             liking Justin Bieber.                  from raw data.
have cable TV, which doesn’t allow
much hacking, but I’ve already got the
hardware ready for a DVB-based
                                                    86                                       90                                     94
TV-Headend box to control the TV in my
new place.
   Of course, if I’m going to have a
system set up to record TV shows, then
it may as well have NAS functionality. I
mean, it’s basically there already isn’t it?
   And if I’m going to be running a
machine 24/7 for a NAS/TV tuner, well,
                                                 Beginning Bash                           Fargo 2                                PyUSB
it would be sensible to get as much              Power up your shell, as                  What’s an outliner, and why            Valentine Sinitsyn rolls up
functionality out of it as possible              Mike Saunders guides                     do you need one? Marco                 his sleeves and gets elbow
wouldn’t it? I’ve got a few adaptors to          you through creating a                   Fioretti introduces Fargo 2,           deep in some hardware
control sockets so I can turn things on          swanky custom prompt,                    which helps you structure              as he reverse-engineers a
and off. It may as well include a security       multiplexing and more.                   your writing better.                   device driver.
camera – one that uploads footage to
an external server obviously.
   Oh, and I think I’ve got a servo that         PROGRAMMING
could control the cat flap quite nicely –
the cat gets in fights if he stays out at        Bash scripts                             Programmer’s golf                      Konrad Zuse
night. Of course, the cat’s a fluffy little       100 There’s more to Bash than           104 It’s a simple game to see          106     As Alan Turing and his
Luddite and scared of anything                          just an interactive shell. It’s          who can write a program in              colleagues were developing
                                                 also a programming language in           the shortest amount of code.           computers for the Allied military’s
technological, so he might never leave
                                                 its own right. However, some of          However, completing this task can      code breaking effort during World
the house anyway.                                the syntax is a little archaic, and it   be fiendishly complex as you try       War II, the Germans had their own
   If you notice my absence for a few            can get confusing. Fear not! We’re       even more obscure methods to           electrical engineer. Konrad Zuse,
issues, it’s nothing to worry about.             here to help – with this beginner’s      shave just one or two bytes off.       working alone, also managed to
Moving house can take a little time, as          guide to Bash Scripting, you’ll be       Read this tutorial to find out more,   build calculating machines and
                                                 writing your own programs in no          but be warned, it can be addictive.    the first programmable computer
I’m sure you can appreciate.
                                                 time at all.                             Don’t say we didn’t warn you!          in continental Europe.
ben@linuxvoice.com



                                                                    www.linuxvoice.com                                                                             75
     TUTORIAL RASPBERRY PI



                              RASPBERRY PI MODEL B:
          TUTORIAL
                              VOID YOUR WARRANTY
                              Now we have a shiny new B+, it’s time to try some dangerous
   BEN EVERARD
                              experiments on our old Raspberry Pi model B.


                              N
                                        ow the Raspberry Pi B+ has come out, we’ve            Before going any further, we should say that there’s
 WHY DO THIS?                           found ourselves with some of the original          a chance that following this tutorial will void your Pi’s
 • Learn the limits of your             model B’s that we’re not going to use any          warranty, and there’s a small chance that it’ll explode
   Raspberry Pi.
                              more. These are still fully functional computers, so it      in a shower of sparks (and a slightly larger – but still
 • Let an old model B go
   out in a blaze of glory.   seems a waste to let them rot in a drawer, or worse,         small – chance that it’ll break in a less spectacular
 • Add new features and       throw them out. Instead, we decided to use one as a          way). In other words, don’t try this if you’re not
   personalise your Pi.       test bed for some riskier experiments.                       prepared to accept the risk that your Pi will stop
                                We didn’t break a Pi while researching this article,       working permanently.
                              but we certainly could have done. We accept no                  If you’re already in Turbo mode, you should find the
                              responsibility should you slip and fry your Pi, but what     following options set:
                              better way is there to get to know a device than to          arm_freq=1000
                              push it to its limits?                                       core_freq=500
                                                                                           sdram_freq=600
                              Overclocking                                                 over_voltage=6
                              Raspbian comes with raspi-config, a tool that lets you          You can mess with these to boost the performance.
                              set various configuration options for your Raspberry         The three frequency settings are all in MHz, so this
                              Pi. One of which is the overclocking level. It has a         configuration has the main ARM processor running at
                              series of safe levels that can give you a bit of a speed     1GHz, the GPU running at 500MHz, and the SD RAM
                              boost without damaging your Pi (though not all Pis           running at 600MHz. We found that we couldn’t
                              will work at the highest speeds). This is useful for         squeeze any more speed out of the GPU or the SD
                              getting a bit more oomph, but it obviously raises the        RAM. However, there does tend to be a little headroom
                              question of just how fast you can push your Pi.              in the ARM frequency.
                                 To take things further than raspi-config’s menu will         In order to take advantage of this, though, you’ll
                              allow, you’ll need to edit the config.txt file on the boot   need to increase the voltage. The voltage for the core
                              partition of the SD card. It’s easiest to do this after      defaults to 1.2V, and each increase in the over_voltage
                              you’ve set the Pi to Turbo overclocking (one of the          setting sends an extra 0.025V. With a setting of 6, the
                              options in the config tool) since this makes most of         core is running at 1.35V. Increasing the voltage
The de-soldering pump we
used. The orange button       the options visible. You can edit this file either by        enables you to increase the speed, but it can also
triggers the suction and      putting the SD card in another computer, or from             decrease the life expectancy of the chip. Since we’re
pulls the molten solder off   within the Pi with:                                          seeing how much speed we can get, we whacked this
the board.                    sudo nano /boot/config.txt                                   up to its maximum setting of 8 (1.4V).
                                                                                              There’s another option that you’ll need to set if you
                                                                                           want to take it beyond the normal overclocking levels:
                                                                                           force_turbo = 1
                                                                                           Just add this line to the config.txt file, and it’ll let you
                                                                                           push the performance up.
                                                                                              There are a couple of things you need to be aware
                                                                                           of as you increase the clock speed. The most obvious
                                                                                           is that it will become more prone to crashing, so don’t
                                                                                           use a heavily overclocked machine for any important
                                                                                           work. The second important thing is that it will tend to
                                                                                           run hotter than at slower speed, so you need to keep
                                                                                           an eye on the temperature to make sure it doesn’t get
                                                                                           too hot.
                                                                                              You can check the temperature at any time with the
                                                                                           command:
                                                                                           cat /sys/class/thermal/thermal_zone0/temp
                                                                                             This gives the temperature in 1000ths of a degree
                                                                                           Celsius, so 45000 is 45°C. As a general rule of thumb,



76                                                            www.linuxvoice.com
                                                                                                           RASPBERRY PI TUTORIAL

you want to keep the temperature below 70000, but
again this depends on how much you’re willing to risk
breaking your Pi. We gradually increased the clock
speed in 50MHz increments, and performed a simple
benchmark of unzipping an archive.
  We found that we could run our Pi at 1.2GHz,
though it wasn’t very stable. At this speed, our
benchmark ran about 40% faster than at non-
overclocked speeds, and about 20% faster than Turbo
overclocking, with a core temperature of around 60°C.
This was, however, quite a simple benchmark. A more
complex task may well have proved too much for the
SoC at this speed. However, we did find that our Pi
was reasonably stable at around 1.1GHz.

Modifying the board
You may think that, unlike desktop PCs, you can’t
change much on single-board computers like the
Raspberry Pi. You may think that the Raspberry Pi
Foundation choose what goes on the board and you
just have to go with it. This isn’t necessarily true.         The board after our modifications. If nothing else, it now feels like it’s truly our board and
They’re certainly not as flexible as desktop PCs, but         not just another Raspberry Pi model B that’s rolled off the production line.
with a little soldering, you can certainly tweak them to
your needs. We stripped off a component we didn’t             software, but to turn it on you have to unplug the
need, and added one we did.                                   power cable, then plug it back in. That’s not the most
    The analogue video output may be useful to some           user-friendly way of doing things, and it could be
people, but not for us. It just takes up space and            awkward in embedded settings. Fortunately, there’s
makes the board look cluttered. This wasn’t enough            an alternative. Between the HDMI and power
for us to risk removing it before, but now we’ve had          connectors, you should see two holes labelled P6.
enough, and decided to take it off. It’s only attached by     These are mounting points for a reset switch.
three soldered points that are quite large and easy to           All you have to do is make a connection between
access, so it’s easy to remove.                               these two points and the Pi will reset. You can test
    You will need either a desoldering pump or wick –         this out using a flat-head screwdriver. This will reboot
we used a pump. This is a device that looks a bit like a      your Pi whether it’s switched on or off.
synringe from a sci-fi film. It has a spring-loaded              In order to be able to reset your Pi, you simply need
plunger that you press down, then a button that               to add a normally-open push switch between these
releases the plunger. As the plunger shoots up, it            two points. The best way to do this will depend on
sucks air in through the nozzle. If the nozzle is placed      how your Pi is set up. We use ours without a case, so
near molten solder, it’ll suck the solder off the board.      we simply soldered the switch straight onto the board.
    The trick of desoldering is to heat the solder up until   However, if your Pi is inside a case or some other
it’s molten, then use the pump or wick to remove it           enclosure, you may find it easier to solder wires onto
before it cools. If you get enough off, you should find       the board and attach those wires to a switch in a
that the component slides out. Be careful not to heat         more convenient location. On the B+, the connections
up the board too much, or pull too hard on the                for the reset button are labelled Run, and are located
component, or you could damage the board. It’s made           next to the micro SD card slot.
of several layers stuck together, so there could be              Not many of the holes in the model B are useful.
wiring you can’t see.                                         There are a couple of extra GPIOs on the P5 header
    This might seem a bit pointless, and on its own it is     that you could find functions for. If you really want to
a bit, but for some projects where size or weight is          modify your Pi, you could replace components on
important, removing unnecessary components can                there with better ones. For example, it is possible to
be useful.                                                    take off the linear regulator from a model B and
                                                              replace it with a switching reg. In doing this, you’ll gain
Extra features                                                one of the best features of the B+. It’s not a
You may have noticed that there are loads of extra            particularly simple process, but there’s some guidance
holes in model B Pis that don’t seem to be used. The          on Dave Akerman’s excellent blog at
two larger ones are mounting holes. Some of the               www.daveakerman.com/?page_id=1294.
others are used for manufacturing and testing, but               Despite being superseded by the B+, there’s still
some of them allow access to extra features. One              plenty of fun left to be had with model B’s, so don’t let
mildly annoying feature of the Raspberry Pi is the fact       yours rot in a drawer. Get it out and void its warranty
that there’s no power button. You can halt it from            – and learn more about it in the process.



                                                                www.linuxvoice.com                                                                      77
     TUTORIAL SONIC PI



                                  SONIC PI: PROGRAM
           TUTORIAL
                                  ELECTRONIC MUSIC
                                  Learn a new style of coding and get instant musical feedback with
  LES POUNDER
                                  this great tool for the Raspberry Pi.


                                  I
                                       n this month's tutorial we will take a break from
 WHY DO THIS?
                                       Scratch and Python and try something new. Let’s
 • Programming is much                 jam with Sonic Pi! Sonic Pi v1 is the creation of
   more than logic and
   control, and creating          Sam Aaron, with the full support of the Raspberry Pi
   music shows us how             Foundation. Sonic Pi v1 comes as a pre-installed
   simple logic can be            application available to all Raspbian Raspberry Pi
   used with creativity to
   make music. Musicians          users and enables anyone to make music using a
   around the world have          programming language called Ruby. Ruby is a simple
   learnt how to create           to learn language that has some similarities to Python,
   music using logic and
   maths and to sequence          so it's handy for those already competent in Python.
   their compositions for            For this tutorial we will be using the latest version of
   better sounding tunes.         Sonic Pi, v2, which at the time of writing is still a         At the end of this project you will have created your own
                                  release candidate but fully up to the task at hand.           version of the 'London Bridge' nursery rhyme.
                                     Using Sonic Pi we will first create a basic song and
                                  then use programming logic to refine our work. The            then exit out of raspi-config. For best results reboot
                                  song chosen is the classic nursery rhyme 'London              the Raspberry Pi
                                  Bridge is Falling Down', but any song can be played              Once the reboot is complete, plug in your
                                  with Sonic Pi, so feel free to experiment. During the         headphones/speakers and test that they are working.
                                  course of this project we will learn some important           If you need to fine-tune the general volume settings,
                                  programming concepts:                                         open a terminal and type in the following:
 TOOLS REQUIRED                   Sequences In order for our tune to play correctly we          alsamixer
 • Raspberry Pi, any model        need to understand how we can translate the musical             Alsa Mixer is a terminal application that enables a
   will do.
                                  sequence into code, otherwise our tune would not              user to control the volume level; you can alter the
 • Keyboard, mouse
   and screen for your
                                  sound very good.                                              volume by pressing the up and down arrows on your
   Raspberry Pi.                  Loops Using a loop introduces recursion into our              keyboard. Once you're happy with the levels, press Esc
 • Sonic Pi v2 installed, we      programming and with it comes the art of creating the         to exit.
   will show you how to do        correct structure so that our loops are seamless, as a
   that later in this tutorial.
                                  note in the wrong place can ruin our tune.                    Installing Sonic Pi v2
 • Headphones / Speakers
   if using the 3.5mm             Data storage Computers have a great memory and                To download, install and start Sonic Pi, open a terminal
   headphone socket.              can remember lots of things, but only if we tell them         and type in each line followed by Enter at the end of
                                  to. Variables are used to temporarily store data for use      each line:
                                  in our project.                                               wget http://sonic-pi.net/sonic-pi-RC11.tar.gz
                                                                                                tar -xvzf sonic-pi-RC11.tar.gz
                                  Configuring audio                                             ./sonic-pi/bin/sonic-pi
                                  By default the Raspberry Pi will use the HDMI                 With Sonic Pi started, let's take some time to
                                  connection to your television for audio and video. But        familiarise ourselves with the layout.
                                  if you would like to use the headphone socket, say to           Towards the top of the screen there's an area that
                                  connect to your Hi-Fi, speakers or headphones then            contains buttons to handle the following actions.
                                  you will need to tell your Pi that you would like to.           Run/Play our tune.
                                     The best way to accomplish this is by using the              Stop playback.
                                  raspi-config menu. Open a terminal and type in:                 Save our tune in the Ruby file format.
                                  sudo raspi-config                                               Record the tune as a WAV file so that we can share
                                    In the menu that appears, look for 'Advanced                  it with others.
                                  Options', navigate to it using the cursor keys and press        Moving further along we can see some more
                                  Enter to select it.                                           buttons in the row.
                                    Inside the Advanced Options menu there will be an             Size – and Size + decrease and increase the size of
                                  Audio option; select this option and a new menu will            the text in the project window.
                                  appear. This new menu enables you to choose the                 Align is a tool to automatically align any indented
                                  output method, select the analog audio output and               code, helping to format the project correctly and



78                                                                 www.linuxvoice.com
                                                                                                                 SONIC PI TUTORIAL

  minimise any potential bugs.
  Info opens an about window, telling us who made
  this great application.
  Help will change the bottom left of the screen and
  introduce a series of tabs which contain information
  on how to use Sonic Pi and its instruments.
  Prefs is the preferences menu, where volume levels
  can be adjusted.
  Underneath these buttons there are three main
sections of the screen. To the top-left is a project area
where we write the code that makes our tune. To the
top-right there is an output window, which will show
the progress of our project. Finally, to the bottom-left
are the workspaces, numbered 1 to 8. Sonic Pi can
work with eight projects at once, so we can have one
workspace to contain our main piece of work, and
                                                                                                                           There are three choices
others to try out new ideas and logic.                      another, so Sonic Pi will try and play all at once, leaving
                                                                                                                          in the audio output menu,
                                                            us with a horrible noise rather than beautiful music. To
                                                                                                                          auto, force 3.5mm and
First tune                                                  fix this we can insert a delay using the sleep function.      force HDMI. If you are
For our first project we will create the nursery rhyme      This function adds an element of control to our code.         listening via headphones
'London Bridge Is Falling Down'. We will be using the          Between each of the notes that we used previously,         connected to your Pi
MIDI (Musical Instrument Digital Interface) number for      insert the following:                                         choose the second option.
each of the notes. In this notation, G is 67, A is 69 and   sleep 0.3
so on (see the boxout over the page for more                This uses a float value of 0.3 seconds to delay the
information on MIDI numbers).                               playback of the notes. Listen for yourself, and it should
   Nursery rhymes are a great way to introduce music        sound much better.
theory and Sonic Pi due to their simple melodies and          Now that we have our basic code, let's improve it
limited use of notes and chords. Once we understand         and make it more compact.
the basics we can then tackle much larger                     Sonic Pi has a great feature which enables you to
compositions, indeed if you can find the notes for your     play a pattern of notes much more simply than
favourite song then you can easily recreate it in Sonic     playing each note individually. The function play_
Pi. Sam Aaron has used Sonic Pi to recreated 'Blue          pattern can take multiple MIDI notes and play them in
Monday' by New Order – take a look at his video             succession. So let us rewrite our code to use this new
http://bit.ly/LVSonicPi.                                    function:
   'London Bridge Is Falling Down' is a simple melody       play_pattern [67,69,67,65,64,65,67]
that starts in the key of G, and the opening motif goes     When it's completed, play the code. It should sound a
as follows                                                  little slow, so let's speed it up a bit using a tempo.
   London            G, A                                       To introduce tempo into our project we need to use
   Bridge            G                                      a BPM (Beats Per Minute) value. Go back to your code
   Is                F                                      and make sure that the following is the first line of
   Falling           E, F                                   code, with all other lines being underneath.
   Down              G                                      use_bpm 120
   So how can we code this in Sonic Pi?                       Now click on the run button, and the music should
   To play a note we first need to understand how we        sound a lot better. Congratulations: you've taken the
instruct the computer to do so. Sonic Pi can play a         code from a simple line-by-line sequence and using
single note via the play function. So to play a G we will   the play_pattern function created a more compact
need to do the following in Workspace 1:                    and robust project.
play 67
  And to play the other notes we would need to add          Using variables
the following after play 67:                                Variables are a temporary method of storing data, and
play 69
play 67
play 65
play 64
play 65
play 67
With this code in our workspace, click on the run                                                                         The simple, uncluttered
button to play your tune.                                                                                                 layout of Sonic Pi V2 is
  How does your tune sound? Is the speed wrong?                                                                           a credit to the team
We didn't tell the computer to play the notes one after                                                                   behind it.



                                                              www.linuxvoice.com                                                                     79
     TUTORIAL SONIC PI

                                                                                                play_pattern [d,g]
                                                                                                play_pattern [e,c]
                                                                                                   That sounds better, but how can we make this code
                                                                                                even better? By adding a delay between each of our
                                                                                                patterns. Sonic Pi uses the sleep function to delay a
                                                                                                step in the sequence of code. If we use the sleep
                                                                                                function with another variable we can set a universal
                                                                                                delay to our code.
                                                                                                   On a line below our previous variables, create the
                                                                                                following:
                                                                                                delay = 1
                                                                                                  Now insert the following in between each of the
                                                                                                play_pattern lines of code, then run your code:
                                                                                                sleep delay
                                                                                                  How does it sound? Perhaps a little slow in between
Our simple melody should        they can greatly improve our coding. So far we have             each of the play_patterns? In that case, reduce the
look like this to start with,   been using the MIDI numbers that represent the notes            delay value by using a float instead of an integer. This
but over the course of the      in our tune. But it can be difficult to remember what           will enable you to use fractions of a second. Try a few
tutorial we will alter and      number is for which note. Using a variable we can               lower numbers and see what works for you.
re-work the code.
                                store the MIDI number and label the variable to match
                                the pitch of the note, so you don't have to remember            Taking our music to the next level
                                the MIDI values. At the top of your code, create the            Our tune sounds great – all of the timings and logic
                                following variables:                                            we used have sharpened our tune to perfection, but
                                c = 60                                                          something is still missing. Perhaps we could add an
                                d = 62                                                          instrument or two? As Sonic Pi uses MIDI, we can
                                e = 64                                                          introduce new instruments to our project relatively
                                f = 65                                                          easily.
                                g = 67                                                             Currently we use the default tone for our tune, but
                                a = 69                                                          we can investigate some other instruments.
                                b = 71                                                             Sonic Pi comes with a plethora of instruments that
                                  Now, using the variables instead of their MIDI                we can use in our project. From simple pretty bell
                                numbers, let's rewrite our code to reflect this and write       chimes to dark and melodious “fm” which at times
                                the rest of the song. Once written, try out your code.          can sound like playing a Beatles record backwards.
                                play_pattern [g,a,g,f,e,f,g]                                       To introduce an instrument into our project we
                                play_pattern [d,e,f]                                            must first tell Sonic Pi that we wish to use it and the
                                play_pattern [e,f,g]                                            best place to do so is underneath where we said
                                play_pattern [g,a,g,f,e,f,g]                                    use_bpm 120 like so:
                                                                                                use_bpm 120
                                                                                                use_synth :pretty_bell
                                  Midi notes
                                                                                                  Now play your tune – instead of the standard
                                  Sonic Pi uses numbers to represent the notes played in        sound you should now hear a bell like chime.
                                  music. These numbers are MIDI representations of those
                                  notes. MIDI (Musical Instrument Digital Interface), has       Looping
                                  long been used in the professional music community as a
                                  method of working with computers and external musical
                                                                                                Looping is the practice of repeating a section of code
                                  instruments, commonly keyboards. With MIDI you can            either many times or infinitely. For our tune we will use
                                  easily make a change to a song without having to re-record    it to repeat the sequence of code that makes up our
                                  the instrument, as the data is saved in the MIDI format.      tune.
                                     Sonic Pi has access to the full range of MIDI numbers,
                                  but to keep things simple we're using just seven of them:
                                  C,D,E,F,G,A,B. These are more than enough for simple tunes.
                                     To use these notes in our project, we must learn their
                                  MIDI value – below is a table of this information.
                                   C                      60
                                   D                      62
                                   E                      64
                                   F                      65
                                   G                      67
                                   A                      69
                                   B                      71
                                     There's a great resource for MIDI notes included in the
                                  readme file on the GitHub repository for this project at      play_pattern is a handy function that can considerably
                                  https://github.com/lesp/LinuxVoiceSonicPi.                    reduce the number of lines in our code, making it much
                                                                                                easier to read.



80                                                                  www.linuxvoice.com
                                                                                                                         SONIC PI TUTORIAL

  To use a loop we use the following line of code
2.times do                                                   What is Ruby?
  #What code would you like to repeat?                       Ruby was designed and developed in the               In Ruby the function to do that is called puts
end                                                          mid-1990s by Yukihiro "Matz" Matsumoto in            and you would use it like this:
  You can see that the second line is indented; this         Japan to be a general-purpose programming            puts “Hello”
                                                             language. Ruby can be used in both a                   So now let's use a loop to print hello twice:
shows that this is the code to be repeated, under our
                                                             functional capacity, where code happens in           2.times do
instruction of 2.times do. This indentation is not as        a sequence, such as our project, and in an           puts “Hello”
restrictive as Python, which requires 4 spaces to            object-oriented capacity, where code can be          end
signify indentation. Sonic Pi will accept a single space     written using objects and classes.                      Can you see how the loop works? That's
or a tab indentation, but don't mix the two together, or        Ruby is an excellent language to learn due        right – exactly the same way as the loop in
                                                             to its very clear syntax and legibility. The         our project does.
you will have a headache debugging your code.
                                                             programming logic learnt via Scratch and                The official 20-minute guide to Ruby
  If we wanted to play a C note twice using the              Python can be applied to Ruby, and in turn           is available at www.ruby-lang.org/en/
looping method we could approach it like this:               can be applied to Sonic Pi. If you would like        documentation/quickstart, and is a fantastic
2.times do                                                   to learn more about Ruby, there is a great           resource for learning this great language.
play 60                                                      interpreter called IRB, which can be installed
                                                             via the terminal.
end
                                                                For Raspberry Pi- and Debian-based
   To use the code in our tune we must do the                distros you can install as follows:
following:                                                   sudo apt-get install ruby
2.times do                                                      And for yum-based systems.
use_synth :pretty_bell                                       sudo yum install ruby
                                                               Using Ruby is remarkably simple, and the
                                                             best way to get started is to open a terminal
play_pattern [g,a,g,f,e,f,g]                                 and type irb followed by Enter.
…. all of the code to play our tune.                           We are now in an interactive session of
End                                                          Ruby and can write Ruby code line by line.           Like Python, Ruby is designed to have a
After all of our coding, your program should look this         First of all, let's print “Hello” on the screen.   simple, easy-to-read syntax.
#Variables to contain our notes
c = 60
d = 62                                                      sleep 0.5
e = 64                                                      play_pattern [d,g]
f = 65                                                      sleep 0.2
g = 67                                                      play_pattern [e,c]
a = 69                                                     end
b = 71                                                        Congratulations, you have now created your first
2.times do                                                 piece of music using Sonic Pi. Using what you have
  use_bpm 120                                              learnt, try the following extension activities:
  use_synth :pretty_bell                                    1 Add a drum beat to the London Bridge project by

  play_pattern [g,a,g,f,e,f,g]                                using another function called in_thread. This
  sleep 0.5                                                   function will enable you to have two or more
  play_pattern [d,e,f]                                        independent threads of code running at once. Code
  sleep 0.5                                                   in a thread runs completely isolated from the main
  play_pattern [e,f,g]                                        body of code. For example to play a G note every
  sleep 0.5                                                   half a second we would write the following:
  play_pattern [g,a,g,f,e,f,g]                             in_thread do
                                                            play 67
                                                            sleep 0.5
                                                            end
                                                             Have a play with this code and see what works for
                                                             you.
                                                           2 Find a song that you like on YouTube and then use

                                                             a search engine to find the sheet music to play it,
                                                             then convert the tune into something that Sonic Pi is
                                                             familiar with. Remember that any piece of music
                                                             can be written using Sonic Pi.
                                                             Finally, a great resource of Sonic Pi material is
                                                           provided by Dan Aldred's blog www.tecoed.co.uk/
                                                           sonic-pi.html – head over and take a look.

Variables enable us to store the MIDI numbers inside a      Les Pounder is a maker and hacker specialising in the
                                                            Raspberry Pi and Arduino. Les travels the UK training
container which, for ease of use, have been labelled to
                                                            teachers in the new computing curriculum and Raspberry Pi.
match the note.



                                                             www.linuxvoice.com                                                                                    81
     TUTORIAL PYTHON AND MYSQL



                               DATA ANALYSIS USING
          TUTORIAL
                               PYTHON AND MYSQL
                               Graphing data makes it easier to understand, and graphing lots of
   BEN EVERARD
                               data is easy with a script and a database.


                               I
                                    n recent years, governments around the world         much better access to the data from programming
 WHY DO THIS?                       have been opening up their information archives      environments, and can also handle much larger data
 • Pull out the information         to the public, and now there’s more data available   sets than spreadsheets.
   that’s pertinent to you     than ever before. However, the raw data is hard to           First you need to grab the software we’ll be using.
   from a swarming mass        digest, and it’s often analysed by people with an         That’s MySQL (both a client and server), and two
   of numbers.
                               agenda, whether that’s newspapers trying to make a        Python modules (MySQLDB and Matplotlib). These are
 • Improve your Python
   and SQL skills.             story sound exciting to sell more copies, or a company    all quite common, and should be in your package
 • Get your computer to        trying to make their product look better than the         manager. To get them in Debian-based systems, use:
   draw pretty pictures that   competition. It’s hard to know whether data is being      sudo apt-get install mysql-client mysql-server python-mysqldb
   make you seem smart         properly represented, so the solution is to dive in and   python-matplotlib
   to friends, family and
   co-workers.                 analyse the figures for yourself. Let’s take a look at       If your package manager hasn’t asked you to set up
                               how to do this using UK house prices.                     a root password for MySQL, you can do that now with:
                                  You can get a complete list of every house sold in     sudo mysqladmin -u root -p password newpass
                               the UK along with its location, type (eg terrace,         Replace newpass with a password of your choice.
                               semi-detached) and price from data.gov.uk. The data
                               goes back to 1994, and is licensed under the Open         Get the data
                               Government Licence, which is allows us to manipulate      Now you’ve got the software, you just need to grab the
                               the data and publish it – so that’s what we’ll do.        data. The easy way to do this is to download our
                                  Spreadsheets, such as LibreOffice’s Calc, can easily   database dump from www.linuxvoice.com/house-
                               handle small data sets. However, this data set is too     price-analysis.
                               big and needs something a little more capable. We’re        This is an xzipped SQL file, so you can load it with:
                               going to use Python and MySQL, though you could           unxz house_prices.sql.xz
If you’re using SQL for
                               use most programming languages and most                   mysql -u root -p < houseprices.xz
more than a few basic
                               databases for the task.                                      This will create a database called houses, and a
queries, there are some
SQL clients (such as              The data comes in a CSV file, which is a text file     table within it called house_prices that contains all the
Emma, shown here) that         containing the values separated by commas. These          information we’re going to work with.
can make your life a little    are usually used with spreadsheets, but are also fairly      That’s the easy way. The hard way (which you’ll
easier.                        easy to upload into databases. Databases enable us        need to do if you want to load data other than UK
                                                                                         house prices), is to download the raw CSV files and
                                                                                         load them into MySQL. This isn’t too hard, but it can be
                                                                                         a little fiddly.
                                                                                            First you need to get the CSV files. The ones we’ve
                                                                                         been using are from data.gov.uk. However, there are
                                                                                         loads of sources of open data you may wish to use
                                                                                         (see the boxout over the page for more details). CSV
                                                                                         files are often created with Windows encoding rather
                                                                                         than Unix. There’s a utility called dos2unix that can fix
                                                                                         this, which you use with:
                                                                                         dos2unix <filename>
                                                                                            MySQL is really designed as a server tool, not a
                                                                                         desktop one. This means that it has a few security
                                                                                         features that you may not expect. One such feature is
                                                                                         that by default, it won’t usually load local files. You can
                                                                                         get around that by starting the client with the --in-file
                                                                                         flag:
                                                                                         mysql --u root -p --in-file
                                                                                            This will drop you into the MySQL commandline.
                                                                                         First you need to create a new database to use:
                                                                                         create database houses;



82                                                            www.linuxvoice.com
                                                                                                       PYTHON AND MYSQL TUTORIAL

use houses;
   Now you need to create a new table to store the
data. This has to have the same layout as the CSV
files that you want to upload. For example:
create table house_prices (id varchar(50), price int, date
datetime, postcode varchar(10), type varchar(1), newbuild
varchar(1), leasefree varchar(1), address1 varchar(50), address2
varchar(50), address3 varchar(50), address4 varchar(50),
address5 varchar(50), address6 varchar(50), address7
varchar(50), dontknow varchar(1));
   With all this set up, you can load the files with the
following SQL statement:
load data local infile “file_name.csv” into table house_prices
fields terminated by ‘,’ enclosed by ‘”’;
  The UK house price data comes in separate files for
each year. You can use the cat command to join them
together into one big file, or import them individually
(which makes it easier to identify problems).

Getting started with SQL
Now you’ve got everything in the database, you can
use SQL to pull out the information you want.
  The basic usage of SQL to pull information out of a
                                                                                                                              The MatPlotLib project
database is in the form:                                           and graph the information we pull out of MySQL to
                                                                                                                              maintains a gallery of
select <something> from <table> where <condition>;                 make everything easy to understand.                        different chart types, and
  This is quite simple, but it enables you to get almost             In this case, our Python program will be acting as a     examples of how to use
anything you need from the data store, and gives you               glue between a module that access the database and         them at http://matplotlib.
a quick way of getting data (although complicated                  a module that outputs graphs. Let’s first look at          org/gallery.html.
queries on large bodies of data can be slow).                      MySQLdb, which we’ll use to access the database.
  For example, to get all of the price and house                     Using the MySQLdb module is a fairly
numbers for a particular postcode, you can use:                    straightforward process. You have to connect to the
select price, address1 from house_prices where postcode = “XX1     database, and then create a cursor object. This cursor
1XX”;                                                              can then be used to execute queries and fetch the
where XX1 1XX is the postcode. As well as getting                  results. Take a look at the following example, which
specific bits of data, you can aggregate it using                  prints out the average house price in the data set.
functions such as avg(), which returns the average.                import MySQLdb
  For example, the following line returns the average
price for houses in Bristol:                                       db = MySQLdb.connect(host=”localhost”, user=”root”,
select avg(price) from house_prices where address6 =               passwd=”xxxx”, db=”houses”)
“BRISTOL”;
  You’ll see a few more SQL techniques as we go                    cur = db.cursor()
through the article, but they all follow this same basic           cur.execute(“select avg(price) from house_prices;”)
process. If you’re unsure of anything, MySQL has
excellent documentation at dev.mysql.com/doc.                      result = cur.fetchone()
                                                                   print str(result[0])
Drawing pictures with Python                                       You’ll need to change the password and possibly user
SQL is great for pulling out bits of information, but it’s         in the connect command, depending on how your
not great at combining and comparing it. That’s were               database is configured.
Python comes in. We’re going to use it to compare                     Once the connection to the database is set up, you
                                                                   can call execute() with a string containing an SQL
                                                                   query, and then get the result with fetchone(). This
  MariaDB
                                                                   returns a tuple containing an entry for each column
  We decided to do this tutorial using MySQL, because it’s         returned by the SQL (in this case, there’s just one). If
  probably still the most widely used database for Linux.          you expect the query to return more than one result,
  However, we know that a lot of people aren’t happy with
  Oracle’s handling of the project, and so may wish to use
                                                                   you can loop through them with:
  MariaDB instead, a fork of MySQL led by the original creator     for row in cur.fetchall():
  of MySQL, Michael “Monty” Widenius.                                          #do what you need to here
     It should be completely compatible with MySQL, and so if        Since you just need to pass a string to cur.
  you’d rather use this database, you should be able to follow     execute(), you can build this up with the usual Python
  along with this tutorial without any problems.
                                                                   tools. For example, if you want to get the average



                                                                     www.linuxvoice.com                                                               83
     TUTORIAL PYTHON AND MYSQL


                                 Big data and NoSQL
                                 Big data is one of the industry’s current buzzwords. Like most    to share the load across many machines. They tend to process
                                 tech buzzwords, there aren’t any hard-and-fast rules to define    data using the map-reduce method, which goes through each
                                 it, but loosely speaking, it refers to any chunk of data that’s   item in turn and maps it to a value. These values can then be
                                 too big to process on an ordinary computer, meaning you need      combined (or reduced) to a result.
                                 some special setup to handle it efficiently. That could be a         The data set we’ve used here is 19 million items big. We’ve
                                 high-powered server, or a cluster of servers.                     certainly heard people calling much more mundane analyses
                                     It is possible to use SQL databases to handle huge data       than this big data, but in our view, it doesn’t qualify. MySQL
                                 sets, but specialist tools have sprung up to make it easier,      handles the task perfectly well, and it’s a technology that’s far
                                 and one common type is the so-called NoSQL variety of             more useful in most circumstances than NoSQL.
                                 database. These are databases that don’t use tables to hold          However, if you happen to be in the job market at the
                                 structured information; instead they hold all the data in one     moment, NoSQL is one of the hottest skills around (according
                                 non-structured mass. This means that for some processes,          to www.indeed.com/jobtrends, MongoDB – a NoSQL database
                                 they can be quicker than SQL databases, and it can be easier      – is the second hottest skill to have after HTML5).


                               prices for a few different counties, you could use:                     This code stores the data in a list as well as printing
                               for county in [‘GREATER MANCHESTER’,’GLOUCESTERSHIRE’]:             it on a screen. This list (rounded to whole numbers),
                                           query = “select avg(price) from house_prices where      can be used to create graphs. One option is to output
                               address7 = ‘” + county + “’;”                                       it to a file in CSV format. CSVs can be loaded into
                                           cur.execute(query)                                      most spreadsheets (such as LibreOffice Calc), and
                                           result = cur.fetchone()                                 from there you can generate any graphics you need.
                                           print “Average house price in “ + county + “ : “ +      This can be a good way to experiment with different
                               str(result[0])                                                      types of graph, because it enables you to quickly try
                                                                                                   various visualisations on the data. However, it’s bad if
                                 Alternatively, you could see how the house prices                 you need to produce lots of graphs based on the data,
                               have changed over the 20 years we have data for                     because it requires quite a bit of manual intervention.
                               using the following. You’ll need to include the previous            For this, it’s much easier to use the MatPlotLib module
                               code to connect to the database as well.                            to automatically draw any charts you want.
                               years = range(1995, 2015)
                               data = []                                                           Get Matplotlib
                                                                                                   To use this, you’ll need to import it. We’ll pull it in with
                               for year in years:                                                  pylab, which provides some other functions as well as
                                            query = ‘select avg(price) from house_prices where     chart drawing. You’ll need to add the following to the
                               data between “’ + str(year) + ‘-01-01” and “’ + str(year) +         start of your program:
                               ‘-12-31”;’                                                          from pylab import *
                                            cur.execute(query)                                       The following two lines can then be added to the
                                            result = cur.fetchone()                                end of the previous program to plot the data, and
                                            print str(year) + “ : “ + str(result[0])               show the chart:
You can change some
parameters of the figure                    data.append(int(result[0]))                            plot(years, data)
after it’s created using the     If you’re an SQL user, you’ll probably notice that this           show()
Configure Subplots button      could be done in a single query. We’ve done it this way                This is the most basic use of the plotting module,
(second from the right).       to make the code a bit easier to follow.                            and it can do far more than this. Let’s take a look at a
                                                                                                   slightly more complicated example. This time, we’ll
                                                                                                   see how the average price of houses has changed for
                                                                                                   detached and semi-detached houses. First we need to
                                                                                                   pull the appropriate information from the database
                                                                                                   with the following code (this will also need the code to
                                                                                                   connect to the database):
                                                                                                   def get_value(cur, query):
                                                                                                                cur.execute(query)
                                                                                                                row = cur.fetchone()
                                                                                                                return int(row[0])
                                                                                                   val_of_semi = []
                                                                                                   val_of_detatched = []
                                                                                                   years = range(1995, 2015)
                                                                                                   for year in years:
                                                                                                                query = ‘select avg(price) from house_prices where
                                                                                                   data between “’ + str(year) + ‘-01-01” and “’ + str(year) + ‘-12-31”
                                                                                                   and type=”S”;’
                                                                                                                val_of_semi.append(get_value(cur, query))



84                                                                  www.linuxvoice.com
                                                                                                             PYTHON AND MYSQL TUTORIAL


                                                                                      House prices by percentile in Hartlepool between 1995 and 2014
           query = ‘select avg(price) from house_prices where            450,000
data between “’ + str(year) + ‘-01-01” and “’ + str(year) + ‘-12-31”     400,000                                                               Hartlepool 10%
and type=”D”;’                                                           350,000                                                               UK 10%
                                                                                                                                               Hartlepool 30%
           val_of_detatched.append(get_value(cur, query))                300,000
                                                                                                                                               UK 30%
   Now you have two lists; you just need to put them                     250,000                                                               Hartlepool 50%
in the plot. The following code does this:                               200,000                                                               UK 50%
                                                                                                                                               Hartlepool 70%
fig = figure()                                                           150,000
                                                                                                                                               UK 70%
                                                                         100,000
                                                                                                                                               Hartlepool 90%
fig.set_size_inches(10,4,forward=True)                                    50,000                                                               UK 90%
ax = subplot(111)                                                              0
                                                                               1995           2000            2005           2010       2015
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width, box.height*0.80])
                                                                                                                                          Hartlepool (among other
semi_line = ax.plot(years, val_of_semi, label=”Price of average        and dashed (linestyle “--”).
                                                                                                                                          towns and cities) hasn’t
semi-detached”)                                                        setp(semi_line, “color”, (1,0,0))                                  seen the same rise in
detached_line = ax.plot(years, val_of_detached, label=”Price of        setp(detached_line, “color”, (0,1,0))                              house prices as south-
average detached”)                                                     setp((semi_line, detached_line), “linestyle”, “--”)                eastern England. See
                                                                           Other line styles are “-” (solid line), “:” (dotted), and      www.linuxvoice.com/
ax.legend(bbox_to_anchor=(0., 1.02, 1., .102), ncol=2,                 “-.” (dash-dot). You can also use setp to change the               house-price-analysis for
prop={“size”:7})                                                       alpha (transparency) settings. In fact, there is a                 the rest of our analysis.
suptitle(‘Average price of houses sold in UK by type between           mind-boggling set of different options you can set to
1995 and 2014’)                                                        make the graph look exactly how you want. If you
                                                                       want to create your own graphs, it’s best to spend a
show()                                                                 little time perusing the set of examples at http://
   First, this code creates a figure, and resizes it to                matplotlib.org/gallery.html to see what’s available.
1000 pixels by 400 pixels (it defaults to 100 pixels per                   Once you’ve got everything for the subplot
inch). The parameter forward=True allows you to                        organised, you need to make sure your graph is
re-size the window.                                                    labelled properly. Adding a title is easy, as you can see
   Instead of just calling plot() like we did in the                   in the above call to suptitle(). Adding a legend is a bit
previous example, this time we create a subplot and                    more complex, because positioning in Matplotlib is
shrink it down to 80% of its original height. This gives               something of a dark art.
us space to put a title and legend above it.                               If you want to save figures rather than just
   The value returned by plot() is a line object that we               displaying them, you can use:
can manipulate to alter the way the line will be                       savefig(‘filename’)
displayed. Although we don’t do it in this example, you                  There are loads of ways you can drill down to
can use this object to alter the way they’re displayed.                almost any level of detail, and pull out whatever you
   For example the following (placed before show())                    want. Of course, this does require an ability to
would make the lines red and green (by (r,g,b) values),                program, and the time to do it.
                                                                         The end goal, of course, isn’t to draw pretty pictures,
                                                                       but to get a better understanding of what the data
   Data sources
                                                                       means. In this case, we’ve been looking at how the
   There are loads of other sources of data that are crying out        prices of houses have changed over the past 20
   for analysis. Here are a few places to start looking:               years. We won’t tell you exactly how to do this
     Data.gov.uk The official source of all UK government
                                                                       because it would defeat the point of this tutorial
     data (this is where the housing data for this article
     comes from).                                                      (which is to learn how to analyse the data for
     www.data.gov The US government’s data sets.                       yourself), but we looked into how the house prices
     bitly.com/bundles/bigmlcom/i A bundle of links to                 changed across different locations and different
     the data websites for many governments from around                values of house.
     the world.
                                                                         You can see our results at www.linuxvoice.com/
     data.worldbank.org The world bank publishes financial
     data on the state of the world economy.                           house-price-analysis. This challenges the view that
     epp.eurostat.ec.europa.eu Eurostat is the directorate             house prices are rising in the UK. In fact, our analysis
     general of the European Commission, and is responsible            shows that in most places house prices are quite
     for compiling and publishing statistics about the                 static, but that rapid rises in London are pushing the
     European Union.
                                                                       average price up across the UK, distorting the picture.
     www.eea.europa.eu/data-and-maps The European
     Environment Agancy publishes a lot of data about the              Don’t take our word for it though. Dive into the data
     state of Europe.                                                  and see what it tells you.
     aws.amazon.com/datasets A list of some of the most
     popular data sets from around the world.                           Ben Everard is the co-author of the best-selling Learn Python
     www.reddit.com/r/datasets A subreddit dedicated to                 With Raspberry Pi, and is working on a best-selling follow-up
     seeking out data on all topics.                                    called Learning Computer Architecture With Raspberry Pi.




                                                                         www.linuxvoice.com                                                                       85
     TUTORIAL GET A BETTER CLI



                               LINUX 101: POWER UP
          TUTORIAL
                               YOUR SHELL
                               Get a more versatile, featureful and colourful command line
MIKE SAUNDERS
                               interface with our guide to shell basics.


                               A
                                         s a Linux user, you’re probably familiar with    it’s powerful enough for most jobs, it could still be a lot
 WHY DO THIS?                            the shell (aka command line). You may pop        better. In this tutorial we’ll show you how to pimp up
 • Make life at the shell                up the occasional terminal now and then for      your shell to make it more informative, useful and
   prompt easier and
   faster.                     some essential jobs that you can’t do at the GUI, or       pleasant to work in. We’ll customise the prompt to
 • Resume sessions after       perhaps you live in a tiling window manager                make it provide better feedback than the defaults, and
   losing a connection.        environment and the shell is your main way of              we’ll show you how to manage sessions and run
 • Stop pushing around         interacting with your Linux box.                           multiple programs together with the incredibly cool
   that fiddly rodent!            In either case, you’re probably using the stock Bash    tmux tool. And for a bit of eye candy, we’ll look at
                               configuration that came with your distro – and while       colour schemes as well. So, onwards!


                                 1   MAKE YOUR PROMPT SING
                               Most distributions ship with very plain prompts – they     things. The \u part, for instance, tells the prompt to
                               show a bit of information, and generally get you by,       show the username, while \w means the working
                               but the prompt can do so much more. Take the               directory.
                               default prompt on a Debian 7 installation, for instance:      Here’s a list of things you can use in the prompt:
                               mike@somebox:~$                                               \d The current date.
                                 This shows the user, hostname, current directory            \h The hostname.
                               and account type symbol (if you switch to root, the $         \n A newline character.
                               changes to #). But where is this information stored?          \A The current time (HH:MM).
                               The answer is in the PS1 environment variable. If you         \u The current user.
                               enter echo $PS1 you’ll see this at the end of the text        \w (lowercase) The whole working directory.
                               string that appears:                                          \W (uppercase) The basename of the working
                               \u@\h:\w\$                                                    directory.
                                 This looks a bit ugly, and at first glance you might        \$ A prompt symbol that changes to # for root.
Here’s our souped-up
prompt on steroids. It’s a     start screaming, assuming it to be a dreaded regular          \! The shell history number of this command.
bit long for this small        expression, but we’re not going to fry our brains with        To clarify the difference in the \w and \W options:
terminal window, but you       the complexity of those. No, the slashes here are          with the former, you’ll see the whole path for the
can tweak it to your liking.   escape sequences, telling the prompt to do special         directory in which you’re working (eg /usr/local/bin),
                                                                                          whereas for the latter it will just show the bin part.

                                                                                          Get customising
                                                                                          Now, how do you go about changing the prompt? You
                                                                                          need to modify the contents of the PS1 environment
                                                                                          variable. Try this:
                                                                                          export PS1=”I am \u and it is \A \$”
                                                                                            Now your prompt will look something like:
                                                                                          I am mike and it is 11:26 $
                                                                                             From here you can experiment with the other
                                                                                          escape sequences shown above to create the prompt
                                                                                          of your dreams. But wait a second – when you log
                                                                                          out, all of your hard work will be lost, because the
                                                                                          value of the PS1 environment variable is reset each
                                                                                          time you start a terminal. The simplest way to fix this
                                                                                          is to open the .bashrc configuration file (in your home
                                                                                          directory) and add the complete export command to
                                                                                          the bottom. This .bashrc file will be read by Bash every
                                                                                          time you start a new shell session, so your beefed-up



86                                                            www.linuxvoice.com
                                                                                                             GET A BETTER CLI TUTORIAL

prompt will always appear. You can also spruce up
your prompt with extra colour. This is a bit tricky at             Shell essentials
first, as you have to use some rather odd-looking                  If you’re totally new to Linux and have just picked up this
escape sequences, but the results can be great. Add                magazine for the first time, you might find the tutorial a bit
this to a point in your PS1 string and it will change the          heavy going. So here are the basics to get you familiar with
text to red:                                                       the shell. It’s usually found as Terminal, XTerm or Konsole in
                                                                   your menus, and when you start it the most useful
\[\e[31m\]
                                                                   commands are:
   You can change 31 here to other numbers for                         ls (list files); cp one.txt two.txt (copy file); rm file.txt
different colours:                                                 (remove file); mv old.txt new.txt (move or rename);
   30 Black                                                        cd /some/directory (change directory); cd .. (change to
   32 Green                                                        directory above); ./program (run program in current
                                                                   directory); ls > list.txt (redirect output to a file).
   33 Yellow
                                                                       Almost every command has a manual page explaining
   34 Blue                                                         options (eg man ls – press Q to quit the viewer). There you
   35 Magenta                                                      can learn about command options, so you can see that ls
   36 Cyan                                                         -la shows a detailed list including hidden files. Use the up
   37 White                                                        and down cursor keys to cycle through previous commands,
                                                                   and use Tab after entering part of a file or directory name to
   So, let’s finish off this section by creating the
                                                                   auto-complete it.
mother of all prompts, using the escape sequences
and colours we’ve already looked at. Take a deep
breath, flex your fingers, and then type this beast:             combination and working directory. If you’re feeling
export PS1=”(\!) \[\e[31m\][\A] \[\e[32m\]\u@\h \[\e[34m\]\w \   especially ambitious, you can change the background
[\e[30m\]\$ “                                                    colours as well as the foreground ones, for really
  This provides a Bash command history number,                   striking combinations. The ever useful Arch wiki has a
current time, and colours for the user/hostname                  full list of colour codes: http://tinyurl.com/3gvz4ec.


  2    TMUX: A WINDOW MANAGER FOR YOUR SHELL
A window manager inside a text mode environment                     When you originally ran screen, it created a new
– it sounds crazy, right? Well, do you remember when             shell session that was independent and not tied to a
web browsers first implemented tabbed browsing? It               specific terminal window, so it could be detached and
was a major step forward in usability at the time, and           reattached (hence the -r option) later.
reduced clutter in desktop taskbars and window lists                This is especially useful if you’re using SSH to
enormously. Instead of having taskbar or pager icons             connect to another machine, doing some work, and
for every single site you had open, you just had the             don’t want a flaky connection to ruin all your progress.
one button for your browser, and then the ability to             If you do your work inside a screen session and your
switch sites inside the browser itself. It made an awful         connection goes down (or your laptop battery dies, or
                                                                                                                                      Here’s tmux with two
lot of sense.                                                    your computer explodes), you can simply reconnect/                   panes open: the left has
   If you end up running several terminals at the same           recharge/buy a new computer, then SSH back in to                     Vim editing a configuration
time, a similar situation occurs; you might find it              the remote box, run screen -r to reattach and carry on               file, while the right shows a
annoying to keep jumping between them, and finding               from where you left off.                                             manual page.
the right one in your taskbar or window list each time.
With a text-mode window manager you can not only
run multiple shell sessions simultaneously inside the
same terminal window, but you can even arrange
them side-by-side.
   And there’s another benefit too: detaching and
reattaching. The best way to see how this works is to
try it yourself. In a terminal window, enter screen (it’s
installed by default on most distros, or will be available
in your package repositories). Some welcome text
appears – just hit Enter to dismiss it. Now run an
interactive text mode program, such as nano, and
close the terminal window.
   In a normal shell session, the act of closing the
window would terminate every process running inside
it – so your Nano editing session would be a goner.
But not with screen. Open a new terminal and enter:
screen -r
And voilà: the Nano session you started before is back!



                                                                   www.linuxvoice.com                                                                          87
     TUTORIAL GET A BETTER CLI

                                                                                            one on the left and one on the right. You can switch
                                                                                            between them Using Ctrl+B followed by O. This is
                                                                                            especially useful if you want to see two things at the
                                                                                            same time – eg a manual page in one pane, and an
                                                                                            editor with a configuration file in another.
                                                                                               Sometimes you’ll want to resize the individual panes,
                                                                                            and this is a bit trickier. First you have to hit Ctrl+B
                                                                                            followed by : (colon), which turns the tmux bar along
                                                                                            the bottom into a dark orange colour. You’re now in
                                                                                            command mode, where you can type in commands to
                                                                                            operate tmux. Enter resize-pane -R to resize the
                                                                                            current pane one character to the right, or use -L to
                                                                                            resize in a leftward direction. These may seem like
                                                                                            long commands for a relatively simple operation, but
                                                                                            note that the tmux command mode (started with the
                                                                                            aforementioned colon) has tab completion. So you
                                                                                            don’t have to type the whole command – just enter
                                                                                            “resi” and hit Tab to complete. Also note that the tmux
                                                                                            command mode also has a history, so if you want to
In tmux, hit Ctrl+B followed
                                 Now, we’ve been talking about GNU screen here, but         repeat the resize operation, hit Ctrl+B followed by
by ? to get a list of the
default key bindings.          the title of this section mentions tmux. Essentially,        colon and then use the up cursor key to retrieve the
                               tmux (terminal multiplexer) is like a beefed up version      command that you entered previously.
                               of screen with lots of useful extra features, so we’re          Finally, let’s look at detaching and reattaching – the
                               going to focus on it here. Some distros include tmux         awesome feature of screen we demonstrated earlier.
                               by default; in others it’s usually just an apt-get, yum      Inside tmux, hit Ctrl+B followed by D to detach the
                               install or pacman -S command away.                           current tmux session from the terminal window, which
                                                                                            leaves everything running in the background. To
                               Multiplexing magic                                           reattach to the session use tmux a. But what happens
                               Once you have it installed, enter tmux to start it. You’ll   if you have multiple tmux sessions running? Use this
                               notice right away that there’s a green line of               command to list them:
                               information along the bottom. This is very much like a       tmux ls
                                                                taskbar from a                This shows a number for each session; if you want

“Tmux enables you to have                                       traditional window
                                                                manager: there’s a list
                                                                                            to reattach to session 1, use tmux a -t 1. tmux is hugely
                                                                                            configurable, with the ability to add custom
multiple programs running                                       of running programs,        keybindings and change colour schemes, so once

inside a single terminal window.”                               the hostname of the
                                                                machine, a clock and
                                                                                            you’re comfortable with the main features, delve into
                                                                                            the manual page to learn more.
                                                                the date. Now run a
                               program, eg Nano again, and hit Ctrl+B followed by C.
                                                                                              Zsh: an alternative shell
                               This creates a new window inside the tmux session,
                               and you can see this in the taskbar at the bottom:             Choice is good, but standardisation is also important as
                               0:nano- 1:bash*                                                well. So it makes sense that almost every mainstream Linux
                                  Each window has a number, and the currently                 distribution uses the Bash shell by default – although there
                                                                                              are others. Bash provides pretty much everything you need
                               displayed program is marked with an asterisk symbol.
                                                                                              from a shell, including command history, filename
                               Ctrl+B is the standard way of interacting with tmux, so        completion and lots of scripting ability. It’s mature, reliable
                               if you hit that key combo followed by a window                 and well documented – but it’s not the only shell in town.
                               number, you’ll switch to that window. You can also use            Many advanced users swear by Zsh, the Z Shell. This is a
                               Ctrl+B followed by N and P to switch to the next and           replacement for Bash that offers almost all of the same
                                                                                              functionality, with some extra features on top. For instance,
                               previous windows respectively – or use Ctrl+B
                                                                                              in Zsh you can enter ls - and hit Tab to get quick
                               followed by L to switch between the two most                   descriptions of the various options available for ls. No need
                               recently used windows (a bit like the classic Alt+Tab          to open the manual page!
                               behaviour on the desktop). To get a window list, use              Zsh sports other great auto-completion features: type cd
                               Ctrl+B followed by W.                                          /u/lo/bi and hit Tab, for instance, and the full path of /usr/
                                                                                              local/bin will appear (providing there aren’t other paths
                                  So far, so good: you can now have multiple
                                                                                              containing u, lo and bi). Or try cd on its own followed by
                               programs running inside a single terminal window,              Tab, and you’ll see nicely coloured directory listings – much
                               reducing clutter (especially if you often have multiple        better than the plain ones used by Bash.
                               SSH logins active on the same remote machine). But                Zsh is available in the package repositories of all major
                               what about seeing two programs at the same time?               distros; install it and enter zsh to start it. To change your
                                                                                              default shell from Bash to Zsh, use the chsh command. And
                                  For this, tmux uses “panes”. Hit Ctrl+B followed by %
                                                                                              for more information visit www.zsh.org.
                               and the current window will be split into two sections,



88                                                              www.linuxvoice.com
                                                                                                           GET A BETTER CLI TUTORIAL


  Fine-tune your colour scheme
  We’re not obsessed with eye-candy at Linux Voice, but we
  do recognise the importance of aesthetics when you’re
  staring at something for several hours every day. Many of
  us love to tweak our desktops and window managers to
  perfection, crafting pixel-perfect drop shadows and fiddling
  with colour schemes until we’re 100% happy. (And then
  fiddling some more out of habit.)
     But then we tend to ignore the terminal window. Well,
  that deserves some love too, and at http://ciembor.github.
  io/4bit you’ll find a highly awesome colour scheme designer
  that can export settings for all of the popular terminal
  emulators (XTerm, Gnome Terminal, Konsole and Xfce4
  Terminal are among the apps supported.) Move the sliders
  until you attain colour scheme nirvana, then click on the
  Get Scheme button at the top-right of the page.
     Similarly, if you spend a lot of time in a text editor such
  as Vim or Emacs, it’s worth using a well-crafted palette
  there as well. Solarized at http://ethanschoonover.com/
  solarized is an excellent scheme that’s not just pretty, but
  designed for maximum usability, with plenty of research          The Solarized colour scheme might not look so swish on paper, but it works brilliantly
  and testing behind it.                                           on the screen to reduce eye strain during long coding sessions.



  3    THE TERMINALS OF THE FUTURE
You might be wondering why the application that                    have anti-aliased fonts now, better colours and the
contains your command prompt is called a terminal.                 ability to click on URLs, but by and large they’ve been
Back in the early days of Unix, people tended to work              working in the same way for decades.
on multi-user machines, with a giant mainframe                        Some programmers are trying to change this
computer occupying a room somewhere in a building,                 though. Terminology (http://tinyurl.com/osopjv9),
and people connected to it using screen and keyboard               from the team behind the ultra-snazzy Enlightenment
combinations at the end of some wires. These                       window manager, aims to bring terminals into the
terminal machines were often called “dumb”, because                21st century with features such as inline media
                                                                                                                                      PRO TIP
they didn’t do any important processing themselves                 display. You can enter ls in a directory full of images
                                                                                                                                  Many command line and
– they just displayed whatever was sent down the                   and see thumbnails, or even play videos from directly          text-based programs
wire from the mainframe, and sent keyboard presses                 inside your terminal. This makes the terminal work a           match their GUI
back to it.                                                        bit more like a file manager, and means that you can           equivalents for feature
                                                                                                                                  parity, and are often much
   Today, almost all of us do the actual processing on             quickly check the contents of media files without              faster and more efficient
our own machines, so our computers are not                         having to open them in a separate application.                 to use. Our
terminals in a traditional sense. This is why programs                Then there’s Xiki (www.xiki.org), which describes           recommendations: Irssi
                                                                                                                                  (IRC client); Mutt (mail
like XTerm, Gnome Terminal, Konsole etc. are called                itself as “the command revolution”. It’s like a cross          client); rTorrent
“terminal emulators” – they provide the same facilities            between a traditional shell, a GUI and a wiki; you can         (BitTorrent); Ranger (file
as the physical terminals of yesteryear. And indeed, in            type commands anywhere, store their output as notes            manager); htop (process
                                                                                                                                  monitor). ELinks does a
many respects they haven’t moved on much. Sure, we                 for reference later, and create very powerful custom           decent job for web
                                                                   commands. It’s hard to describe it in mere words, so           browsing, given the
                                                                   the authors have made a video (see the Screencasts             limitations of the
                                                                                                                                  terminal, and it’s useful
                                                                   section of the Xiki site) which shows how much                 for reading text-heavy
                                                                   potential it has.                                              websites such as
                                                                      And Xiki is definitely not a flash in the pan project       Wikipedia.
                                                                   that will die of bitrot in a few months. The authors ran
                                                                   a successful Kickstarter campaign to fund its
                                                                   development, netting over $84,000 at the end of July.
                                                                   Yes, you read that correctly – $84K for a terminal
                                                                   emulator. It might be the most unusual crowdfunding
                                                                   campaign since some crazy guys decided to start
                                                                   their own Linux magazine…


                                                                    Mike Saunders remembers using a mouse once. On the
Xiki aims to be both a more welcoming shell for new
                                                                    Amiga. Now he just wants kids to get off his damn lawn.
users, and a step-up for experienced CLIers.



                                                                     www.linuxvoice.com                                                                     89
     TUTORIAL FARGO 2



                              FARGO: WRITE AND PUBLISH
          TUTORIAL
                              OUTLINES IN OPEN FORMATS
                              Turn the web upside down with this text outliner – without
MARCO FIORETTI
                              installing a single piece of software.


                              W
                                            hen you look at it closely, much written text
 WHY DO THIS?                               has the same basic structure. Newspaper
 • Prepare yourself for the                 articles, philosophy essays, novel
   open, distributed web      summaries, courseware, recipes… are all outlines –
   of tomorrow, in an easy    that is, hierarchical trees of topics and sub topics. If
   and fun way.
                              this is true, the more a software editor takes it into
 • Publish a nice-looking
   personal blog for free,    account, the more efficient it is, right?
   in five minutes, without       Fargo is an outliner – that is a text editor designed
   installing anything.       to handle outlines in the most efficient way. Any
 • Get familiar with OPML.    outliner program provides tools to quickly navigate the
   You may need it again
   some day. Trust us.        elements of an outline and rearrange them at will, with
                              the smallest possible effort. Above all, outliners can
                              instantly hide certain levels or branches of an outline,
                              so that at any moment you only see the exact amount
                              of content and level of detail that you want to see.
                                  Outliners are nothing new. In fact, the real value of     Eye candy and formatting functions in Fargo are limited to
                              Fargo is not in what it does, but in how and where it         the bare minimum, and there are two powerful menus for
                              does it. This tutorial explains how Fargo works and           viewing and managing outlines.
                              how to use it, mainly from the point of view of a Linux
                              user who would like to integrate it with their other          10 or even just five years ago. No question about that,
                              online and desktop activities.                                but the other points deserve more reflection.
                                  Now, the Fargo user interface is deceptively simple.         Fargo also works on the assumption that today “the
                              It’s easy to find the menus and buttons that perform          cloud is ubiquitous and reliable” (not to mention, we
                              an action, but to work with this tool (rather than            may add, affordable). Residents in rural areas of
                              against it) you must first understand the Fargo               Western countries, plus almost everybody else, may
                              philosophy and what it does under the hood. We may            disagree on this. The final point is about lock in and…
                              even say that assimilating where the hood is is the           let’s discuss it at the end of the tutorial.
                              hardest part here. Consequently, we will devote more
                              space to explaining what Fargo provides, and how,             Fargo architecture and requirements
                              than to explain how to actually use single menus or           Installing Fargo is really simple: there is nothing to
We see two very important
                              panels.                                                       install! The only requirements are a browser that can
things here: first, text
                                  There are three points that were the origin, and still    handle JavaScript and HTML5 and a Dropbox
written in Fargo looks very
clean and easy on one’s       are at the core, of the Fargo proposal. The first is the      account. Log in to Dropbox, point your browser to
eyes. Second, that all your   observation that modern JavaScript-capable                    http://fargo.io and accept the request to let the Fargo
works remain available in     browsers are very powerful and run on hardware, even          app work in a dedicated subfolder of your account. If
open source formats.          including mobile devices, much more powerful than             you don’t see that request, it is because you’ve already
                                                                                            been there. Tell your browser to erase all the cookies
                                                                                            from the fargo.io domain and reload.
                                                                                               Thirty seconds later, you will be able to start writing
                                                                                            outlines and publishing them online using an
                                                                                            interface, and with a final result, already close to what
                                                                                            you could get at Tumblr.com or WordPress.com, but
                                                                                            without the lock-in.
                                                                                               This happens because, while Fargo is a static
                                                                                            JavaScript app that runs entirely in the browser of
                                                                                            your own computer or smartphone, it behaves as if it
                                                                                            were a traditional CMS engine and produces the same
                                                                                            results: you can always write and archive outlines in
                                                                                            the same way from any device and location. From the



90                                                             www.linuxvoice.com
                                                                                                                                 FARGO 2 TUTORIAL

viewer’s point of view it’s the same too: everybody can
access all the outlines that you made public as if they
were a traditional website. Fargo can also generate
static HTML versions of your outlines and upload
them to a web server whenever you want.
   This is why Fargo has the potential to turn the web
upside down. The current model of web self
publishing and working “in the cloud” is based on
central CMS servers doing all the really heavy work,
from database queries to page rendering, for many
thousands of authors and visitors simultaneously.
This architecture demands servers and data centres
with very high costs and environmental impacts.
   In the Fargo model, as much as possible is
                                                                     Fargo would be very useful even as a purely private editor, but it couldn’t be easier to
decentralised. Only sensible data such as passwords
                                                                     transform content in to a blog.
are stored in your device. Raw outlines are still stored
on servers; that is, in a private folder of your Dropbox
account, but all the processing happens in the                       date or author-defined data, or be commented out. In
browsers that run Fargo, or in those that display its                the latter case, the headline will remain in the OPML
static HTML pages.                                                   file, but out of sight, and it will never be included in the
   For authors, Fargo has another big advantage on                   HTML versions. We will explain how to comment or
server-based publishing systems like WordPress:                      assign attributes in a moment.
since all the CMS logic runs in a browser, it can have a                All your Dropbox files are private, until you ask Fargo
much more flexible and responsive interface, and                     to create public, but read-only links to them. An outline
provide a structure that naturally matches the                       can even embed content from external websites, if
structure of most writing.                                           you pass them to Fargo with the browser Bookmarklet
                                                                     linked from the right bar.
Structure of Fargo content                                              When an outline grows unwieldy, you can archive all
At the low level, each Fargo outline is a separate OPML              its headlines that you don’t need to edit anymore, and
file stored in your Dropbox account (see the OPML                    still make them show up (and render) in the outline. To
box below to understand what OPML is, and why it is                  do that, you have to archive those headlines as
great regardless of Fargo). Using Dropbox as                         “includes”. Do do this, place the cursor on them, select             PRO TIP
filesystem also provides automated backups and                       File > Archive Cursor, and they will be moved to the              If you have a lot of texts
versioning for free, even if you still have to backup                archive sub-folder of your Fargo folder in Dropbox.               on your hard drive that
                                                                                                                                       you would like to import
everything outside Dropbox regularly.                                                                                                  in Fargo, don’t worry.
   The single elements of each outline, which can be                 Images and interactive content? Of course!                        It’s very likely, you can
nested at will, are called headlines (or even summits, if            In case you were worrying that a system optimised                 automate much of that
                                                                                                                                       work. One of the best
at the top level). We would have preferred terms like                for outlines doesn’t support anything but static text,            tools for the is Pandoc
node or paragraph, because each Fargo headline can                   relax! You can tell Fargo to keep an eye on a Dropbox             (http://johnmacfarlane.
be as long as you want, and each time you press                      subfolder for generic media (images, audio, PDFs,                 net/pandoc): a very
                                                                                                                                       versatile converter that
Enter, you create a new one, but headline it is.                     whatever). Then, any time you upload something                    can transform any of
   Besides its unique position in the hierarchy, which               there, Fargo will notice it and give you a URL for it in a        dozens of formats into
of course you can change as you want, each headline                  pop-up window. You can add as much interactivity as               any of the others.
can have attributes like identification code, creation               you want to your Fargo outlines… as long as you write



  What is OPML?
  Really open file formats and communication standards are           websites and software programs that generate, process and
  arguably even more important than free software. If somebody       syndicate such feeds.
  else sends you files in one of those formats, you can merrily         From a technical point of view, OPML is nothing other than
  ignore if they use proprietary software, and open those files      another application of XML. In practice, this means that an
  with whatever application you prefer, directly on Linux.           OPML file, while terribly verbose, is just plain text that you
      In the open formats family, the Outline Processor Markup       can generate, parse and process automatically with many free
  Language (OPML – http://dev.opml.org/spec2.html), was              software tools, from custom scripts to specialised editors.
  developed specifically to process and exchange outlines.              It is equally important to realise that there’s nothing to
  You have probably already seen it, or at least one of its          limit OPML to handling lists of headlines and relative links
  applications: the list of links on the side of many websites       and abstracts. Formally speaking, OPML can handle anything
  known as “blogrolls” are just that: outlines that under the hood   whose structure is a hierarchic tree of nodes, each containing
  are most probably OPML files.                                      named attributes in text format. If you think about it for just
      The most frequent application of OPML, at least on the web,    a moment, you will realise that even your family tree, or your
  is the automatic exchange of lists of RSS feeds between the        company’s organisation chart, match this description.




                                                                       www.linuxvoice.com                                                                           91
     TUTORIAL FARGO 2

                                                                                                 autosave behaviour and your contact information
                                                                                                 (profile page, email, Twitter and Facebook accounts).
                                                                                                 In the same place, you can define separate CSS styles
                                                                                                 for each level of your outlines, or a background image.
                                                                                                    Fargo can handle multiple outlines simultaneously,
                                                                                                 each in a different tab. The editor marks each headline
                                                                                                 with a wedge on the left, which will be black if there is
                                                                                                 unexpanded test underneath it, or grey otherwise. The
                                                                                                 actual content of a headline can be formatted with
                                                                                                 HTML or Markdown syntax.
                                                                                                    Setting the standard attributes of a headline, or
                                                                                                 giving it custom ones, is easy: select the headline,
                                                                                                 click on the suitcase icon (or select Outliner > Edit
                                                                                                 Attributes) and enter the attribute name on the left
                                                                                                 and its value on the right. Click on the + button if you
                                                                                                 also need to add custom attributes, and repeat.
What looks just like very well structured text, automatically becomes a simple blog,             Headlines can also be individually commented by
complete with Disqus comments, with just a few clicks.
                                                                                                 pressing Ctrl+\. When you do that, their wedges will
                                                                                                 become chevrons. To uncomment them, press
                               it in JavaScript, as Fargo itself. In general, the                Cmd+\ again.
                               developers have already started to think about
                               JavaScript “verbs” for Fargo that would make such                 Working with Fargo
                               tasks easier. See http://docs.fargo.io/fargoScripting/            Looking at Fargo as just an editor, its two main
                               for details.                                                      features are the ‘Outliner’ and ‘Reorg’ top menus. The
                                   You can already add snippets of JavaScript to a               first is used to control how much you see of the
                               headline (including calls to internal Fargo functions)            current outline and toggle between Non-Render and
                               and run them by pressing Ctrl+/. It is also possible to           Render mode: use the first mode to write or edit raw
                               run some JavaScript code automatically, every time                markup inside an outline, and the other to see what
                               you reload Fargo or publish an outline.                           the results looks like.
                                                                                                    As the name suggests, the ‘Reorg’ menu helps to
                               The Fargo user interface                                          reorganise your writings. The entries to move one or
     PRO TIP                   The first thing you want to do in your Fargo outliner is          more headlines up or down the outline they are in, or
 Take advantage of Fargo       click on ‘Cribsheet’ in the right sidebar, to get a               to change their indentation levels, are all there.
 to reorder all those          cheatsheet with all the main commands. Next, you                     The main functions found in both those top menus
 disorganised folders that
 you likely have in your       should take a look at the many resources in the Docs              are also available in ‘Pad’ format, to work faster on
 Dropbox account! This         top menu. Just remember that whenever those pages                 touchscreen devices. The Fargo ‘Arrow Pad’ (Outliner >
 will make it much easier      say “Cmd”, (as in the Command key on OS X) what                   Show Arrow Pad) has two buttons, one to collapse or
 to keep stuff you want
 to publish through Fargo      they mean on Linux is the Control key.                            expand parts of the hierarchy, and the other to toggle
 from everything else, and        Now, let’s talk configuration. To access the Fargo             Navigate and Reorg mode. Depending on the mode
 you should already be         configuration tabs, click on your name in the top-right           the four arrow icons in the pad will let you move
 doing it anyway.
                               corner of the browser window and select “Settings”.               headlines around, or navigate from one to another.
                               Besides a multimedia folder here, you can set a                      On devices with real keyboards, you can use
                               password to encrypt all your private outlines, the                shortcuts for almost all menu entries. Tab and
                                                                                                 Shift+Tab, for example, increase and decrease the
                                 Integration with WordPress                                      indentation level of a headline. Remember that in
                                                                                                 Fargo pressing the Enter key does not enter a newline,
                                 Many bloggers simply cannot give up their WordPress             or split the current text in two. It just add one more
                                 accounts for Fargo, because they need some special plugin       empty headline below the current one, regardless of
                                 or, much more simply, they are just (co-)authors, not the
                                                                                                 where the cursor was when you typed.
                                 owners of those blogs. What should they do, if they find the
                                 Fargo authoring interface much better than the WordPress           Once you have acquired familiarity with the
                                 one? Post to WordPress from Fargo, of course (only one          outline-oriented interface of Fargo, you will also be
                                 blog per Fargo account, sorry!). The “Blog” tab of the Fargo    able to use it to build a public, simple blog. The post
                                 settings interface is there just for that purpose: enter the    shown in the image above-left was created in four
                                 URL of your blog, your username and password.
                                                                                                 main steps (the extra, really simple details are all at
                                     If you need to format your blog posts in ways that Fargo
                                 doesn’t support, just check the Markdown box, and all the       http://fargo.io/docs/blogging/firstPost.html):
                                                                                                  1 Create a new outline (File > New).
                                 markup you add in your headlines will automatically be
                                 converted to HTML before sending it to the blog. After this      2 Give it a name (File > Name Outline), let’s say

                                 initial configuration, every time you want to post create a        ‘golinuxvoice’.
                                 new headline for the title, another right below it with the      3 Write some content in the usual way.
                                 content, and click on the WordPress icon in the left sidebar.
                                                                                                  4 When you are done, put the cursor on the top




92                                                                  www.linuxvoice.com
                                                                                                                       FARGO 2 TUTORIAL

  headline, and click the Eye icon in the left bar.
  The last action will create a new subdomain,
golinuxvoice.smallpict.com (Small Pict is the
company that develops Fargo). All visitors of that
domain will be transparently redirected to static HTML
copies, organised like a blog, of all the posts that you
add to that named outline. The documentation also
explain how to add WordPress-like categories or
generate RSS feeds.
  If you plan to use Fargo just for private outlines, but
occasionally want to share one of them with others, in
read-only mode, select File > View In Reader: this will
produce a public URL of your outline that you can
distribute to your friends, students or colleagues.

Desktop integration and automation
What you have learned so far is enough to make most
aspiring authors of outliners and personal blogs
happy, but we Linux users are more demanding than
the average bear.                                              This is where all your raw content, obviously in open formats, ends up in Fargo: inside
    Writing outlines and optionally publishing them            dedicated folders and subfolders of the Fargo app space of your Dropbox account.
online with Fargo is easy and efficient, but could we do
more? For example, would it be possible to reuse               the other, if you want to use Fargo for blogging, your
Fargo content in other publishing systems, with as             online presence will only be as stable as the smallpict.
little manual work as possible?                                com domain name, and the willingness of its owners
    Or what about writing outlines locally (even when          to let you use it for free.                                        PRO TIP
there is no connectivity), and uploading them                     Wouldn’t be great if all the servers Fargo needed            Markdown (http://
automatically when you connect to the internet?                were a Raspberry Pi under your desk, and it could use           daringfireball.net/
                                                                                                                               projects/markdown/) may
    The first activity – re-use – is pretty easy. Set up the   any domain name of your choice?                                 be the most popular, if
Linux client for Dropbox to automatically copy all the            Truth be told, Dave Winer and the other developers           not the most versatile,
raw outlines onto your computer in OPML format,                of Fargo do see all the limitations, and are more than          markup system for
                                                                                                                               plain text available
then play with tools like Pandoc to convert them to            willing to overcome them. In fact, we already have              today. Learning to write
other formats, as in these two examples:                       some alternatives today, and a road ahead to solve              and convert text with
 #> pandoc -f opml -t html outline.opml > outline.html         the problem for good.                                           Markdown, regardless of
                                                                                                                               Fargo, would be a very
 #> pandoc -f opml -t markdown outline.opml > outline.md          The already existing, but radical solution to the            smart move if you want
In other words, it’s easy to avoid being locked into           problem just mentioned is to not use Fargo. If you              to publish lots of text
Fargo as an outline-based editor.                              think about it, a desktop-based outline editor coupled          regularly.
   The reverse path – that is, generating OPML                 with a static blog engine like Mynt or Jekyll already
outlines on your computer and using them in Fargo –            provides most of what you may get from Fargo.
is not possible yet. Not directly, at least. If you put        Especially on Linux, which gives you the ability to
OPML files in your Fargo folder at Dropbox.com                 couple it with the right set of shell scripts.
nothing will happen. The only available workaround so             At the same time, it is hard to beat the ease of use
far seems to be uploading those files somewhere else,          and device independence of Fargo. And the
and then to tell Fargo to include them. This location          companion free software of Fargo called Fargo
can even be another subfolder of your Dropbox                  Publisher (https://github.com/scripting/
account, as long as you share it to get a publicly             fargoPublisher) can already transfer HTML versions
accessible URL usable by Fargo.                                of Fargo outlines to any server of your choice, solving
                                                                                                                                  PRO TIP
                                                               the domain name problem for good. The process is
                                                                                                                               You can transform
Control, and alternatives                                      quite complex, but Chris Dadswell, who is already               your outline in online
All this finally leads us back to the final basic point of     using it, made a great job of documenting all the steps         presentations as
Fargo, the one that we only hinted at in the beginning,        at http://scriven.chrisdadswell.co.uk/articles/                 explained at
                                                                                                                               http://fargo.io/docs/
and to the future developments of this technology.             howtofargoselfpublishingstorageoptions.html and                 presentations.html.
   One of the official announcements of Fargo proudly          http://scriven.chrisdadswell.co.uk/articles/
points out that using it “you have a lot more freedom          howToSelfPublishingFargoBlog.html.
about where you host your website”. In reality, as you            The Dropbox dependency remains, but with any
should have already noticed, things are quite different        luck we’ll also get over it. Stay tuned for another
from that, at least now and for average users.                 tutorial when that day comes!
   On one hand, you have to have a Dropbox account
and let them “see” your private documents, which is             Marco Fioretti is a Free Software and open data campaigner
                                                                who has advocated FOSS all over the world.
not all that comfortable in this post-Snowden era. On



                                                                 www.linuxvoice.com                                                                      93
     TUTORIAL USB CAR



                                  DRIVE IT YOURSELF:
           TUTORIAL
                                  A USB CAR
        VALENTINE                 Ever wondered how device drivers are reverse engineered?
         SINITSYN
                                  We’ll show you with a simple yet complete example.


                                 H
                                            ave you ever been enticed into a Windows          bit of luck to reverse engineer a non-trivial protocol.
 WHY DO THIS?                               versus Linux flame war? If not, you are lucky.    This is legal under most jurisdictions, but as usual,
 • Get to know USB.                         Otherwise, you probably know that Windows         contact a lawyer if in doubt.
 • Earn some geek                 fanboys often talk as though support for peripherals
   points with reverse            in Linux is non-existant. While this argument loses         Get to know USB
   engineering.                   ground every year (the situation is incomparably            Before you start reversing, you’ll need to know what
 • Practice with the PyUSB        better than it was in around 2005), you can still           exactly USB is. First, USB is a host-controlled bus. This
   library.
                                  occasionally come across a device that is not               means that the host (your PC) decides which device
                                  recognised by your favourite distribution. Most of the      sends data over the wire, and when it happens. Even
                                  time, this will be some sort of a USB peripheral.           an asynchronous event (like a user pressing a button
                                     The beauty of free software is that you can fix this     on a USB keyboard) is not sent to the host
                                  situation yourself. The effort required is obviously        immediately. Given that each bus may have up to 127
                                  dependent on how sophisticated the peripheral is, and       USB devices connected (and even more if hubs are
                                  with a shiny new 3D web camera you may be out of            concerned), this design simplifies the management.
                                  luck. However, some USB devices are quite simple,              USB is also a layered set of protocols somewhat
                                  and with Linux, you don’t even need to delve into the       like the internet. Its lowest layer (an Ethernet
                                  kernel and C to write a working driver program for it. In   counterpart) is usually implemented in silicon, and
                                  this tutorial, we’ll show you how it’s done step by step,   you don’t have to think about it. The USB transport
                                  using a high-level interpreted language (Python, you        layer (occupied by TCP and UDP in the internet – see
                                  guessed it) and a toy USB radio controlled car I            page 64 for Dr Brown’s exploration of the UDP
                                  happen to have lying around.                                protocol) is represented by ‘pipes’. There are stream
                                     What we are going to do is a basic variant of a          pipes that convey arbitrary data, and message pipes
                                  process generally known as reverse engineering. You         for well-defined messages used to control USB
                                  start examining the device with common tools (USB is        devices. Each device supports at least one message
                                  quite descriptive itself). Then you capture the data        pipe. At the highest layer there are the application-level
                                  that the device exchanges with its existing (Windows)       (or class-level, in USB terms) protocols, like the
                                  driver, and try to guess what it means. This is the         ubiquitous USB Mass Storage (pen drives) or Human
                                  toughest part, and you’ll need some experience and a        Interface Devices (HID).

                                                                                              Inside a wire
                                                                                              A USB device can be seen as a set of endpoints; or,
                                                                                              simply put, input/output buffers. Each endpoint has
                                                                                              an associated direction (in or out) and a transfer type.
                                                                                              The USB specification defines several transfer types:
                                                                                              interrupt, isochronous, bulk, and control, which differ
                                                                                              in characteristics and purpose.
                                                                                                 Interrupt transfers are for short periodic real-time
                                                                                              data exchanges. Remember that a host, not the USB
                                                                                              device, decides when to send data, so if (say) a user
                                                                                              presses the button, the device must wait until the host
                                                                                              asks: “Were there any buttons pressed?”. You certainly
                                                                                              don’t want the host to keep silent for too long (to
                                                                                              preserve an illusion that the device has notified the
                                                                                              host as soon as you pressed a button), and you don’t
                                                                                              want these events to be lost. Isochronous transfers
                                                                                              are somewhat similar but less strict; they allow for
                                                                                              larger data blocks and are used by web cameras and
                                                                                              similar devices, where delays or even losses of a
Fun to play and also simple: this is the device we will write a driver for.                   single frame are not crucial.



94                                                                    www.linuxvoice.com
                                                                                                                      USB CAR TUTORIAL


  Fixing permissions
  By default, only root is able to work with USB devices in
  Linux. It’s not a good idea to run our example program
  as a superuser, so add a following udev rule to fix the
  permissions:
   SUBSYSTEM==”usb”, ATTRS{idVendor}==”0a81”,
   ATTRS{idProduct}==”0702”, GROUP=”INSERT_HERE”,
   MODE=”0660”
    Just insert the name of a group your user belongs to and
  put this in /lib/udev/rules.d/99-usbcar.rules.



   Bulk transfers are for large amounts of data. Since
they can easily hog the bus, they are not allocated the
bandwidth, but rather given what’s left after other
transfers. Finally, the control transfer type is the only
one that has a standardised request (and response)
format, and is used to manage devices, as we’ll see in
a second. A set of endpoints with associated
                                                                                                                            No, you can’t control this
metadata is also known as an interface.                        tutorial text, but I hope you didn’t get bored. For a
                                                                                                                            car from a PC – it’s a
   Any USB device has at least one endpoint (number            more complete overview of how USB operates, I
                                                                                                                            mouse and misses Output
zero) that is the end for the default pipe and is used         highly recommend O’Reilly’s USB in a Nutshell,               reports.
for control transfers. But how does the host know              available freely at www.beyondlogic.org/usbnutshell.
how many other endpoints the device has, and which             And now, let’s do some real work.
type they are? It uses various descriptors available on
specific requests sent over the default pipe. They can         Under the hood
be standard (and available for all USB devices),               For starters, let’s take a look at how the car looks as a
class-specific (available only for HID, Mass Storage or        USB device. lsusb is a common Linux tool to
other devices), or vendor-specific (read “proprietary”).       enumerate USB devices, and (optionally) decode and
   Descriptors form a hierarchy that you can view with         print their descriptors. It usually comes as part of the
tools like lsusb. On top of it is a Device descriptor,         usbutils package.
which contains information like device Vendor ID (VID)         [val@y550p ~]$ lsusb
and Product ID (PID). This pair of numbers uniquely            Bus 002 Device 036: ID 0a81:0702 Chesen Electronics Corp.
identifies the device, so a system can find and load           Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root
the appropriate driver for it. USB devices are often           hub
rebranded, but a VID:PID pair quickly reveals their            ...
origin. A USB device may have many configurations (a             The car is the Device 036 here (unplug it and run
typical example is a printer, scanner or both for a            lsusb again to be sure). The ID field is a VID:PID pair.
multifunction device), each with several interfaces.           To read the descriptors, run lsusb -v for the device in
However, a single configuration with a single interface        question:
is usually defined. These are represented by                   [val@y550p ~]$ lsusb -vd 0a81:0702
Configuration and Interface descriptors. Each
endpoint also has an Endpoint descriptor that                  Bus 002 Device 036: ID 0a81:0702 Chesen Electronics Corp.
contains its address (a number), direction (in or out),        Device Descriptor:
and a transfer type, among other things.                        ...
   Finally, USB class specifications define their own           idVendor         0x0a81 Chesen Electronics Corp.
descriptor types. For example, the USB HID (human               idProduct        0x0702
interface device) specification, which is implemented           ...
by keyboards, mice and similar devices, expects all             bNumConfigurations 1
data to be exchanged in the form of ‘reports’ that are          Configuration Descriptor:
sent/received to and from the control or interrupt                ...
endpoint. Class-level HID descriptors define the report           Interface Descriptor:
format (such as “1 field 8 bits long”) and the intended             ...
usage (“offset in the X direction”). This way, a HID                bInterfaceClass      3 Human Interface Device
device is self-descriptive, and can be supported by a               ...
generic driver (usbhid on Linux). Without this, we                  iInterface       0
would need a custom driver for each individual USB                    HID Device Descriptor:
mouse we buy.                                                         ...
   It’s not too easy to summarise several hundred                     Report Descriptors:
pages of specifications in a few passages of the                        ** UNAVAILABLE **



                                                                 www.linuxvoice.com                                                                 95
     TUTORIAL USB CAR

The original KeUsbCar
application under Windows
XP.




                               Endpoint Descriptor:                                      Item(Global): Report Count, data= [ 0x01 ] 1
                                ...                                                      Item(Main ): Input, data= [ 0x02 ] 2
                                bEndpointAddress 0x81 EP 1 IN                            ...
                                bmAttributes        3                                    Item(Global): Report Size, data= [ 0x08 ] 8
                                  Transfer Type       Interrupt                          Item(Global): Report Count, data= [ 0x01 ] 1
                                  ...                                                    Item(Main ): Output, data= [ 0x02 ] 2
                               Here you can see a standard descriptors hierarchy;        ...
                            as with the majority of USB devices, the car has only         Here, two reports are defined; one that is read from
                            one configuration and interface. You can also spot a        the device (Input), and the other that can be written
                            single interrupt-in endpoint (besides the default           back to it (Output). Both are one byte long. However,
                            endpoint zero that is always present and thus not           their intended usage is unclear (Usage Page is in the
                            shown). The bInterfaceClass field suggests that the         vendor-specific region), and it is probably why the
                            car is a HID device. This is a good sign, since the HID     usbhid driver can’t do anything useful with the device.
                            communication protocol is open. You might think that        For comparison, this is how a USB mouse Report
                            we just need to read the Report descriptor to               descriptor looks (with some lines removed):
                            understand report format and usage, and we are              Report Descriptor: (length is 75)
                            done. However, this is marked ** UNAVAILABLE **.             Item(Global): Usage Page, data= [ 0x01 ] 1
                            What’s the matter? Since the car is a HID device, the                Generic Desktop Controls
                            usbhid driver has claimed ownership over it (although        Item(Local ): Usage, data= [ 0x02 ] 2
                            it doesn’t know how to handle it). We need to ‘unbind’               Mouse
                            the driver to control the device ourselves.                  Item(Local ): Usage, data= [ 0x01 ] 1
                               First, we need to find a bus address for the device.              Pointer
                            Unplug the car and plug it again, run dmesg | grep           Item(Global): Usage Page, data= [ 0x09 ] 9
                            usb, and look for the last line that starts with usb                 Buttons
                            X-Y.Z:. X, Y and Z are integers that uniquely identify       Item(Local ): Usage Minimum, data= [ 0x01 ] 1
                            USB ports on a host. Then run:                                       Button 1 (Primary)
                            [root@y550p ~]# echo -n X-Y.Z:1.0 > /sys/bus/usb/drivers/    Item(Local ): Usage Maximum, data= [ 0x05 ] 5
                            usbhid/unbind                                                        Button 5
                              1.0 is the configuration and the interface that we         Item(Global): Report Count, data= [ 0x05 ] 5
                            want the usbhid driver to release. To bind the driver        Item(Global): Report Size, data= [ 0x01 ] 1
                            again, simply write the same into /sys/bus/usb/
                            drivers/usbhid/bind.
                                                                                          A bonus value
                              Now, Report descriptor becomes readable:
                            Report Descriptor: (length is 52)                             Most RC toys are quite simple and use stock receivers and
                             Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440          other circuits that operate at the same frequencies. This
                                     (null)                                               means our car driver program can be used to control toys
                             Item(Local ): Usage, data= [ 0x01 ] 1                        other than the car that comes bundled. I’ve just discovered
                                                                                          that I can play with my son’s tractor from my laptop. With
                                     (null)
                                                                                          some background in amateur radio, you’ll certainly find
                             ...                                                          more interesting applications for this.
                             Item(Global): Report Size, data= [ 0x08 ] 8



96                                                              www.linuxvoice.com
                                                                                                                 USB CAR TUTORIAL

 Item(Main ): Input, data= [ 0x02 ] 2
   This is crystal clear both for us and for the OS. With
the car, it’s not the case, and we need to deduce the
meaning of the bits in the reports ourselves by looking
at raw USB traffic.

Detective work
If you were to analyse network traffic, you’d use a
sniffer. Given that USB is somewhat similar, it comes
as no surprise that you can use a sniffer to monitor
USB traffic as well. There are dedicated commercial
USB monitors that may come in handy if you are
doing reverse engineering professionally, but for our
purposes, the venerable Wireshark will do just fine.
   Here’s how to set up USB capture with Wireshark
(you can find more instructions at). First, we’ll need to
enable USB monitoring in the kernel. The usbmon
module is responsible for that, so load it now:
[root@y550p ~]# modprobe usbmon
  Then, mount the special debugfs filesystem, if it’s
not already mounted:
[root@y550p ~]# mount -t debugfs none /sys/kernel/debug
   This will create a /sys/kernel/debug/usb/usbmon
directory that you can already use to capture USB
traffic with nothing more than standard shell tools:
[root@y550p ~]# ls /sys/kernel/debug/usb/usbmon
0s 0u     1s 1t       1u 2s      2t 2u                                                                                    Wireshark captures
   There are some files here with cryptic names. An           transfers, as shown on the screenshot above. The one        Windows driver-originated
integer is the bus number (the first part of the USB          we are interested in is highlighted. The parameters         commands.
bus address); 0 means all buses on the host. s stands         indicate it is a SET_REPORT HID class-specific
for ‘statistics’ t is for ‘transfers’ (ie what’s going over   request (bmRequestType = 0x21, bRequest = 0x09)
the wire) and u means URBs (USB Request Blocks,               conventionally used to set a device status such as
logical entities that represents a USB transaction). So,      keyboard LEDs. According to the Report Descriptor we
to capture all transfers on Bus 2, just run:                  saw earlier, the data length is 1 byte, and the data
[root@y550p ~]# cat /sys/kernel/debug/usb/usbmon/2t           (which is the report itself) is 0x01 (also highlighted).
ffff88007d57cb40 296194404 S Ii:036:01 -115 1 <                  Pressing another button (say, “Right”) results in
ffff88007d57cb40 296195649 C Ii:036:01 0 1 = 05               similar request; however, the report will be 0x02 this
ffff8800446d4840 298081925 S Co:036:00 s 21 09 0200 0000      time. One can easily deduce that the report value
0001 1 = 01                                                   encodes a movement direction. Pressing the
ffff8800446d4840 298082240 C Co:036:00 0 1 >                  remaining buttons in turn, we discover that 0x04 is
ffff880114fd1780 298214432 S Co:036:00 s 21 09 0200 0000      reverse right, 0x08 is reverse, and so on. The rule is
0001 1 = 00                                                   simple: the direction code is a binary 1 shifted left by
Unless you have a trained eye, this feedback is               the button position in KeUsbCar interface (if you count
unreadable. Luckily, Wireshark will decode many               them clockwise).
protocol fields for us.                                          We can also spot periodic interrupt input requests
   Now, we’ll need a Windows instance that runs the           for Endpoint 1 (0x81, 0x80 means it’s an input
original driver for our device. The recommended way           endpoint; 0x01 is its address). What are they for?
is to install everything in VirtualBox (theOracle             Except buttons, KeUsbCar has a battery level indicator,
Extension Pack is required, since we need USB                 so these requests are probably charge level reads.
support). Make sure VirtualBox can use the device, and        However, their values remain the same (0x05) unless
run the Windows program (KeUsbCar) that controls              the car is out of the garage. In this case, there are no
the car. Now, start Wireshark to see what commands            interrupt requests, but they resume if we put the car
the driver sends over the wire. At the intial screen,         back. We can suppose that 0x05 means “charging”
select the ‘usbmonX’ interface, where X is the bus that       (the toy is simple, and no charge level is really
the car is attached to. If you plan to run Wireshark as a     returned, only a flag). If we give the car enough time,
non-root user (which is recommended), make sure               the battery will fully charge, and interrupt reads will
that the /dev/usbmon* device nodes have the                   start to return 0x85 (0x05 with bit 7 set). It looks like
appropriate permissions.                                      the bit 7 is a “charged” flag; however, the exact
   Suppose we pressed a “Forward” button in                   meaning of other two flags (bit 0 and bit 2 that form
KeUsbCar. Wireshark will catch several output control         0x05) remains unclear. Nevertheless, what we have



                                                                www.linuxvoice.com                                                              97
     TUTORIAL USB CAR

                                                                                                  effort. We also use PyGame for the user interface, but
This may not look as good                                                                         won’t discuss this code here – though we’ll briefly visit
as KeUsbCar, but it runs                                                                          it at the end of this section.
under Linux.
                                                                                                     Download the PyUSB sources from https://github.
                                                                                                  com/walac/pyusb, unpack them and install with
                                                                                                  python setup.py install (possibly in a virtualenv). You
                                                                                                  will also need the libusb library, which should be
                                                                                                  available in your package manager. Now, let’s wrap
                                                                                                  the functionality we need to control a car in a class
                                                                                                  imaginatively named USBCar.
                                                                                                  import usb.core
                                                                                                  import usb.util


                                                                                                  class USBCar(object):
                                                                                                    VID = 0x0a81
                                                                                                    PID = 0x0702
                                   figured out so far is already enough to recreate a
                                   functional driver.                                               FORWARD = 1
                                                                                                    RIGHT = 2
                                   Get to code                                                      REVERSE_RIGHT = 4
                                   The program we are going to create is quite similar to           REVERSE = 8
                                   its Windows counterpart, as you can easily see from              REVERSE_LEFT = 16
                                   the screenshot above. It has six arrow buttons and a             LEFT = 32
                                   charge level indicator that bounces when the car is in           STOP = 0
                                   the garage (charging). You can download the code                  We import two main PyUSB modules and define the
                                   from GitHub (https://github.com/vsinitsyn/usbcar.              direction values we’ve deduced from the USB traffic.
                                   py); the steering wheel image comes from                       VID and PID are the car ID taken from the output of
                                   www.openclipart.org.                                           lsusb.
                                      The main question is, how do we work with USB in            def __init__(self):
                                   Linux? It is possible to do it from userspace (subject to        self._had_driver = False
                                   permission checks, of course; see the boxout below),             self._dev = usb.core.find(idVendor=USBCar.VID,
                                   and the libusb library facilates this process. This library    idProduct=USBCar.PID)
                                   is written for use with the C language and requires the          if self._dev is None:
                                   user to have a solid knowledge of USB. A simpler                     raise ValueError(“Device not found”)
                                   alternative would be PyUSB, which is a simpler                    In the constructor, we use the usb.core.find()
                                   alternative: it strives to “guess” sensible defaults to        function to look up the device by ID. If it is not found,
                                   hide the details from you, and it is pure Python, not C.       we raise an error. The usb.core.find() function is very
                                   Internally, PyUSB can use libusb or some other                 powerful and can locate or enumerate USB devices by
                                   backend, but you generally don’t need to think about it.       other properties as well; consult https://github.com/
                                   You could argue that libusb is more capable and                walac/pyusb/blob/master/docs/tutorial.rst for the
                                   flexible, but PyUSB is a good fit for cases like ours,         full details.
                                   when you need a working prototype with minimum                   if self._dev.is_kernel_driver_active(0):
                                                                                                       self._dev.detach_kernel_driver(0)
                                                                                                       self._had_driver = True
  No more toys: writing a real driver (almost)                                                      Next, we detach (unbind) the kernel driver, as we did
                                                                                                  previously for lsusb. Zero is the interface number. We
  Having a custom program to work with a           transmitted available through the /dev/net/
  previously unsupported device is certainly       tun device node. The pytun module makes        should re-attach the driver on program exit (see the
  a step forward, but sometimes you also           working with TUN/TAP devices in Python a       release() method below) if it was active, so we
  need it to integrate with the rest of the        breeze. Performance may suffer in this case,   remember the initial state in self._had_driver.
  system. Generally it implies writing a driver,   but you can rewrite your program in C with       self._dev.set_configuration()
  which requires coding at kernel level (see       libusb and see if this helps.
                                                                                                    Finally, we activate the configuration. This call is
  our tutorial from LV002 at www.linuxvoice.          Other good candidates are USB displays.
  com/be-a-kernel-hacker/) and is probably         Linux comes with the vfb module, which         one of a few nifty shortcuts PyUSB has for us. The
  not what you want. However, with USB the         makes a framebuffer accessible as /dev/fbX     code above is equivalent to the following, however it
  chances are that you can stay in userspace.      device. Then you can use ioctls to redirect    doesn’t require you to know the interface number and
     If you have a USB network card, you           Linux console to that framebuffer, and         the configuration value:
  can use TUN/TAP to hook your PyUSB               continuously pump the contents of /dev/
                                                                                                    self._dev.set_configuration(1)
  program into Linux networking stack. TUN/        fbX into a USB device using the protocol you
  TAP interfaces look like regular network         reversed. This won’t be very speedy either,      usb.util.claim_interface(0)
  interfaces (with names like tun0 or tap1) in     but unless you are going to play 3D shooters
  Linux, but they make all packets received or     over USB, it could be a viable solution.       def release(self):
                                                                                                    usb.util.release_interface(self._dev, 0)



98                                                                    www.linuxvoice.com
                                                                                                                                 USB CAR TUTORIAL

  if self._had_driver:                                                                                                                  With PyUSB we could also
     self._dev.attach_kernel_driver(0)                                                                                                  control this toy digger,
                                                                                                                                        so you may find that the
  This method should be called before the program
                                                                                                                                        drivers you write will
exits. Here, we release the interface we claimed and
                                                                                                                                        have more uses that you
attach the kernel driver back.                                                                                                          imagined.
  Moving the car is also simple:
def move(self, direction):
  ret = self._dev.ctrl_transfer(0x21, 0x09, 0x0200, 0, [direction])
  return ret == 1
The direction is supposed to be one of the values
defined at the beginning of the class. The ctrl_
transfer() method does control transfer, and you can
easily recognise bmRequestType (0x21, a class-
specific out request targeted at the endpoint),
bRequest (0x09, Set_Report() as defined in the USB                    the only possible reason for the exception here. In all
HID specification), report type (0x0200, Output) and                  other cases we report the status as ‘unknown’.
the interface (0) we saw in Wireshark. The data to be                    Another class, creatively named UI, encapsulates the
sent is passed to ctrl_transfer() as a string or a list;              user interface – let’s do a short overview of the most
the method returns the number of bytes written. Since                 important bits. The main loop is encapsulated in the
we expect it to write one byte, we return True in this                UI.main_loop() method. Here, we set up a background
case and False otherwise.                                             (steering wheel image taken from OpenClipart.org),
   The method that determines battery status spans a                  display the battery level indicator if the car is in the
few more lines:                                                       garage, and draw arrow buttons (UI.generate_arrows()
def battery_status(self):                                             is responsible for calculating their vertices’ coordinates).
  try:                                                                Then we wait for the event, and if it is a mouse click,
     ret = self._dev.read(0x81, 1, timeout=self.READ_TIMEOUT)         move the car in the specified direction with the USBCar.
     if ret:                                                          move() method described earlier.
        res = ret.tolist()                                               One tricky part is how we associate directions with
        if res[0] == 0x05:                                            arrow buttons. There is more than one way to do it,
           return ‘charging’                                          but in this program we draw two sets of arrows with
        elif res[0] == 0x85:                                          identical shapes. A first one, with red buttons you see
           return ‘charged’                                           on the screenshot, is shown to the user, while the
     return ‘unknown’                                                 second one is kept off-screen. Each arrow in that
  except usb.core.USBError:                                           hidden set has a different colour, whose R component
     return ‘out of the garage’                                       is set to a direction value. Outside the arrows, the
   At its core is the read() method, which accepts an                 background is filled with 0 (the USBCar.STOP
endpoint address and the number of bytes to read. A                   command). When a user clicks somewhere in the
transfer type is determined by the endpoint and is                    window, we just check the R component of the pixel
stored in its descriptor. We also use a non-default                   underneath the cursor in that hidden canvas, and
(smaller) timeout value to make the application more                  action appropriately.
responsive (you won’t do it in a real program: a                         The complete program with a GUI takes little more
non-blocking call or a separate thread should be used                 than 200 lines. Not bad for the device we didn’t even
instead). Device.read() returns an array (see the ‘array’             had the documentation for!
module) which we convert to list with the tolist()
method. Then we check its first (and the only) byte to                That’s all folks!
determine charge status. Remember that this it is not                 This concludes our short journey into the world of
reported when the car is out of the garage. In this                   reverse engineering and USB protocols. The device for
case, the read() call will run out of time and throw a                which we’ve developed a driver (or more accurately, a
usb.core.USBError exception, as most PyUSB                            support program) was intentionally simple. However,
methods do. We (fondly) assume that the timeout is                    there are many devices similar to this USB car out
                                                                      there, and many of them use a protocol that is close
                                                                      to the one we’ve reversed (USB missile launchers are
  Resources                                                           good example). Reversing a sophisticated device isn’t
                                                                      easy, but now you can already add Linux support for
     USB in a Nutshell: www.beyondlogic.org/usbnutshell
     USB Capture Setup at the Wireshark wiki:                         something like a desktop mail notifier. While it may
     http://wiki.wireshark.org/CaptureSetup/USB                       not seem immediately useful, it’s a lot of fun.
     Tutorial code: https://github.com/vsinitsyn/usbcar.py
     PyUSB homepage: https://github.com/walac/pyusb                    Dr Valentine Sinitsyn edited the Russian edition of O’Reilly’s
     “Programming with PyUSB 1.0” tutorial: https://github.            Understanding the Linux Kernel, has a PhD in physics, and is
     com/walac/pyusb/blob/master/docs/tutorial.rst                     currently doing clever things with Python.




                                                                        www.linuxvoice.com                                                                    99
      CODING BASH



                                BASH: BEYOND THE
          TUTORIAL
                                COMMAND PROMPT
                               Speed up repetitive tasks, get more power out of the command line
       JOHN LANE
                               or just make life easier – welcome to the world of Bash scripting.


                               M
                                          ost Linux users will know Bash as the               program loader to start it. This creates, or forks, a
 WHY DO THIS?                             command line prompt. But it is also a               child process of your shell.
 • Chain commands                         powerful programming language – a lot of               But the script isn’t a binary executable, so the
   together to create
   flexible scripts.           the code that glues the various parts of your system           program loader needs to be told how to execute it.
 • Get more from the           together is written in Bash. You may have looked at            You do this by including a special directive as the first
   command line.               some of it and seen seas of parentheses, braces and            line of your script, which is why most bash scripts
 • Learn a new way of          brackets. This less-than obvious syntax helps make             begin with a line this:
   working.                    other languages, such as Python, more attractive to            #!/bin/bash
                               beginners. But Bash is ubiquitous in the Linux world,             The first two characters, #!, known as a shebang,
                               and it’s worth taking the time to learn how to go              are detected by the program loader as a magic
                               beyond the prompt.                                             number that tells it that the file is a script and that it
                                  A good introduction to Bash programming is to put           should interpret the remainder of the line as the
                               frequently issued command sequences into a file so             executable to load – plus, optionally, any arguments
                               that you can replay them at the command prompt                 to pass to it along with the script itself. The program
                               instead of typing each one. Such a file is called a            loader starts \bin\bash in a new process, and this
                               script, and we often hear “scripting” instead of               runs the script. It needs the absolute path to the
                               “programming”. Bash is nonetheless a language with             executable because the kernel has no concept of a
                               its own syntax, capabilities and limitations.                  search path (that is itself a feature of the shell).
                                                                                                 Scripts that perform specific tasks are usually
                               The basics                                                     executed so they run in a predictable environment.
                               Bash programs, like Python and Ruby, are not                   Every process has an environment that it inherits from
                               compiled into binary executables, but need to be               its parent, and contains so-called environment
                               parsed by an interpreter. For Bash, this is an                 variables that offer its parent a way to pass
                               executable called bash that interprets commands                information into it. A process can alter its own
                               read interactively from its command prompt or from a           environment and prepare that of its children, but it
                               script. If you’re at a Bash prompt, it’ll be provided by a     cannot affect its parent.
                               running bash process, and you can feed a script                   Scripts specifically written to alter the current
                               straight to it:                                                environment (like rc files) are sourced and usually
                               $ source myscript                                              don’t have their execute bit set.
                                  But you may not be at such a prompt (you might
                               use another shell, such as csh or ksh, or you may be at        One line at a time
                               the Run dialog of your desktop). If you set the execute        Bash reads input one line at a time, whether from a
                               bit on your script:                                            command prompt or a script. Comments are
                               $ chmod +x myscript                                            discarded; they start with a hash # character and
                               then you can execute it:                                       continue to the end of the line (bash sees the shebang
                               $ myscript                                                     as a comment). It applies quoting rules and parameter
                               which causes your shell to ask the operating system’s          expansion to what remains and ends up with words
                                                                                              – commands, operators and keywords that make up
                                                                                              the language. Commands are executed and return an
 POSIX                                                                                        exit status, which is stored in a special variable for use
                                                                                              by subsequent commands.
 An IEEE standard for a portable operating      can run in a POSIX-compliant mode. The
 system interface, POSIX is frequently          bash command does this when launched in         Words are separated by metacharacters: a space or
 mentioned in texts about shell scripting. It   this way or if given the --posix command-     one of |, &, ;, (, ), < or >. Operators are character
 means being compatible with something          line option.                                  sequences containing one or more metacharacters.
 called the Shell Command Language, which          In POSIX mode, Bash only supports the        Metacharacters can have their special meaning
 is defined by an IEEE standard and             features defined by the POSIX standard.
                                                                                              removed by quoting. The first form of quoting
 implemented as the shell on all Unix-like      Anything else is commonly called a bashism.
 systems by the /bin/sh command.These days      See http://bit.ly/bashposix for what’s        removes special meaning from all characters
 /bin/sh is usually a symlink to a shell that   different in Bash’s POSIX mode.               enclosed by single quotes. It is not possible to enclose
                                                                                              a single quote within single quotes. Double quotes are



100                                                               www.linuxvoice.com
                                                                                                                                BASH CODING

                                                                case names for your own variables and use upper
  Chain of command                                              case names for constants and environment variables.
                                                                  Parameter expansion happens when a parameter’s
  Bash expects one command per line, but this can be a
  chain: a sequence of commands connected together with         name is preceded by the dollar sign, and it replaces
  one of four special operators. Commands chained with &&       the parameter with its value:
  only execute if the exit status of the preceding one was 0,   echo $1
  indicating success. Conversely, commands chained with         which outputs the script’s first argument. These
  || execute only if the preceding one failed. Commands
                                                                so-called positional parameters are numbered
  chained with a semicolon (;) execute irrespective of how
  the prior command exited. Lastly, the single-ampersand        upwards from 1 and 0 contains the filesystem path to
  & operator chains commands, placing the preceding             the script. Parameter names can be enclosed by { and
  command into the background:                                  } if their names would otherwise be unclear. Consider
  command1 && command2 # perform command2 only if               this:
  command1 succeeded
                                                                $ var=1234
  command1 || command2 # perform command2 only if
  command1 failed                                               $ echo $var5678
  command1 ; command2 # perform command1 and then               $ echo ${var}5678
  command2                                                      12345678
  command1 & command2 # perform command2 after starting           The first echo receives the value of a non-existant
  command1 in the background
                                                                variable var5678 whereas the second gets the value of
    Chains can be combined, giving a succinct if-then-else
  construct:                                                    var, followed by 5678. The other thing to understand
                                                                about parameters is that bash expands them before
                                                                                                                                    PRO TIP
  command1 && command2 || command3
    The exit status of a chain is the exit status of the last   any command receives them as arguments. If this                  You can use a “.” instead
  command to execute.                                                                                                            of “source” to run a
                                                                expansion includes argument separators, then the                 script in the current
                                                                expanded value will become multiple arguments. You’ll            environment.
                                                                encounter this when values contain spaces, and the
similar, except some metacharacters still work, most            solution to this problem is quoting:
notably the Dollar sign, which performs parameter               $ file=’big data’
expansion, and the escape \, which is the third form of         $ touch “$file”
quoting and removes special meaning from the                    $ ls $file
following character only.                                       ls: cannot access big: No such file or directory
   Parameters pass information into the script.                 ls: cannot access data: No such file or directory
Positional parameters contain the script’s argument                 Here, touch creates a file called big data because
list, and special variables provide ways to access them         the file variable is quoted, but ls fails to list it because
en-masse and also provide other information like the            it is unquoted and therefore receives two arguments
script’s filesystem path, its process ID and the last           instead of one.
command’s exit status.                                              For these two reasons, it is common to quote and
   Variables are parameters that you can define by              delimit parameters when expanding them; many
assigning a value to a name. Names can be any string            scripts refer to variables like this:
of alphanumeric characters, plus the underscore (_)             “${myvar}”
but cannot begin with a numeric character, and all                Braces are also required to expand array variables.
values are character strings, even numbers. Variables           These are defined using parentheses and expanded
don’t need to be declared before use, but doing so              with braces:
enables additional attributes to be set such as making          $ myarr=(foo bar baz)
them read-only (effectively a constant) or defining             $ echo “${myarr[@]}” # values
them as an integer or array (they’re still string values        foo bar baz
though!). Assignment is performed with the = operator           $ echo “${!myarr[@]}” # indices
and must be written without spaces between the
name and value. Here are some examples that you                   Special Variables
might see:
                                                                  0      The name of the shell (if interactive) or script.
var1=hello
                                                                  1 .. n The positional parameters numbered from 1 to the
var2=1234                                                                number of arguments n. Braces must be used when
declare -i int=100 # integer                                             expanding arguments greater than 9 (eg ${10}).
declare -r CON=123 # constant                                     *      All the positional parameters. Expanding within
declare -a arr=(foo bar baz) # array                                     quotes gives a single word containing all parameters
                                                                         separated by spaces (eg “$*” is equivalent to “$1 $2
  Variables default to being shell variables; they aren’t                ... $n”).
part of the environment passed to child processes.                @ All the positional parameters. Expanding within
For that to happen, the variable must be exported as                     quotes gives all parameters, each as a separate word
an environment variable:                                                 (eg “$@” is equivalent to “$1 $2 ... $n”).
export $MYVAR                                                     ?      The exit status of the most recent command.
                                                                  $      The process ID of the shell.
  Names can use upper- and lower-case characters                  !      The PID of the last backgrounded command.
and are case-sensitive. It’s good practice to use lower



                                                                  www.linuxvoice.com                                                                     101
      CODING BASH

                             012                                                        used to test and compare parameters, variables and
                             $ echo “${#myarr[@]}” # count                              file types. There are single- and double-bracket
                             3                                                          variants; the single bracket expression is an alias for
                               Arrays are indexed by default and do not need to be      the test command – these are equivalent:
                             declared. You can also create associative arrays if you     “$myvar” == hello
                             have bash version 4, but you need to declare them:         test “$myvar” == hello
                             $ declare -A hash=([key1]=value1 [key2]=value2)              The double bracket expression is a more versatile
                             $ hash[key3]=value3                                        extended test command (see help [[), which is a
                             $ echo ${hash[@]}                                          keyword and part of the language syntax. test is just a
                             value3 value2 value1                                       command that has the opening bracket as an alias
                             $ echo ${!hash[@]}                                         and, when used that way, expects its last argument to
                             key3 key2 key1                                             be a closing bracket. This is an important difference to
                             $ echo ${hash[key1]}                                       understand, because it affects how the expression is
                             value1                                                     expanded. test is expanded like arguments to any
                                Braces are also used for inline expansion, where        other command, whereas an extended test
                             ///:a,b\///1 becomes a1 b1 and ///:1..5\/// becomes        expression is not expanded but parsed in its entirety
                             1 2 3 4 5. Braces also define a command group: a           as an expression with its own syntax, in a way that’s
                             sequence of commands that are treated as one so            more in line with other programming languages.
                             that their input and output can be redirected:               It supports the same constructs as test (see help
                             {date; ls;} > output.log                                   test or man test), performs command substitution
                               A similar construct is the subshell. Commands            and expands parameters. Values don’t need to be
                             written in parentheses are launched in a child process.    quoted, and comparison operators (=, &&, ||, > and <)
                             Expanding them enables us to capture their output:         work as expected, plus the =~ operator compares
                             now=$(date +%T)                                            with a regular expression:
                               Although our example used a child process, the           $ [[ hello =~ ^he ]] && echo match
                             parent blocked; it waited for the child to finish before   match
                             continuing. Child processes can also be used to run          Like any command, both single- and double-bracket
                             tasks in parallel by backgrounding them:                   expressions expand to their exit status and can be
                             (command)&                                                 used in conditionals that use it to choose the path of
                                This enables your script to continue while the          execution:
                             ‘command’ runs in a separate process. You can wait,        if c; then c; fi
                             perhaps later on in your script, for it to finish.         if c; then c; else c; fi
                                Unlike the subshell, the command group does not         if c; then c; elif c; then c; else c; fi
                             fork a child process and, therefore, affects the current   where c is a command. The semicolons can be
                             environment. They cannot be used in a pipeline and         omitted if the following word appears on a new line.
                             they cannot be expanded to capture their output.           Each command can be multiple commands but it is
                             Subshells can do these things and are also useful for      the exit status of the final conditional command that
                             running parallel processes in separate environments.       determines the execution path. Conditionals can be
                                                                                        nested too:
                             Do the maths
                             You’ll also encounter double parentheses; these are
                                                                                           Internal and external commands
                             one way to do integer arithmetic (bash doesn’t have
                             floating-point numbers); let and expr are others:             Some commands are implemented within Bash and are
                             profit=$(($income - $expenses))                               known as builtins. They are more efficient than other
                                                                                           external commands because they don’t have the overhead
                             profit=$((income - expenses))
                                                                                           of forking a child process. Some builtins have equivalent
                             let profit=$income-$expenses                                  external commands that pre-date them being implemented
                             profit=$(expr $income - $expenses)                            within bash. Keywords are similar to builtins but are
                               The double parentheses form allows spaces to be             reserved words that form part of the language syntax. You
                             inserted and the dollar signs to be omitted from the          can use type to see what a word means in bash:
                                                                                           $ type cat
                             expression to aid readability. Also note that the use of
                                                                                           cat is /usr/bin/cat
      PRO TIP                expr is less efficient, because it’s an external              $ type echo
 The Advanced Bash           command. Arithmetic expansion also allows operators           echo is a shell builtin
 Scripting Guide contains    similar to those found in the C programming language,         $ type /usr/bin/echo
 an unofficial style guide                                                                 /usr/bin/echo is /usr/bin/echo
 http://bit.ly/bashstyle.
                             as in this common idiom to increment a variable:
                                                                                           $ type if
                             $ x=4
                                                                                           if is a shell keyword
                             $ let x++                                                        You can get help on builtin commands and keywords:
                             $ echo $x                                                     $ help {
                             5                                                             { ... }: { COMMANDS ; }
                               Finally, we have square brackets, which evaluate               Group commands as a unit.
                             expressions and expand to their exit status. They’re



102                                                               www.linuxvoice.com
                                                                                                                                     BASH CODING


   A question of truth
   A Boolean expression is either true or false. In Bash, true and   if true; then...
   false are shell builtins (you may also find equivalent external   always succeeds. Here true is the command and its exit statis
   commands in /usr/bin) and, like all commands, they return an      is 0, indicating success.
   exit status where zero indicates success and a non-zero value        To confuse things further, arithmetic expansion sees 1
   indicates failure. So, ‘true’ returns 0 and ‘false’ returns 1.    as true and 0 as false, and sees the words “true” and “false”
      You may be tempted to write something like this:               as (potentially undefined) variables rather than the builtins
   var=true                                                          described above.
      This assigns a variable called var with the value of the       $ echo $((true == false))
   four-character string true, and has nothing to do with the true   1
   command. Similarly,                                                  That happens because both true and false are undefined
   if [[ $var == true ]]; then...                                    variables that expand to the same value (nothing) and are
   compares the value of var with the four-character string true,    therefore equal. This makes the expression true which,
   whereas                                                           arithmetically, is 1.


if condition                                                         out=123
then                                                                 f        # 123456789
  if nested-condition                                                echo $out$in1$in2 # 123456                                          PRO TIP
    command                                                             You can be caught out by local variables. Here’s an           test is both a built-in
  else                                                               example: if a function f1 defines a local, then calls            and external command
    command                                                          another function f2, that local is also visible inside f2.       (/usr/bin/test).
  fi                                                                 When a function defines local variables, they are visible
fi                                                                   to any functions that it calls. Also, you can define one
while and until loops are also controlled by exit status:            function inside another but you might not get what
while c; do c; done                                                  you expect. All functions are names and have similar
until c; do c; done                                                  scope. Function definitions are executed – that means
 The for loop is different – it iterates over a series of            that a function defined inside another function will be
words:                                                               redefined every time that function is called.
for i in foo bar baz                                                    Functions return an exit status, which is either the
do                                                                   exit status of the last command to be executed within
 something                                                           the function, or explicitly set with “return”. Exit status is
done                                                                 a number between 0 (meaning success) and 255. You
but you can use brace expansion to simulate a                        can’t return anything more complex than that.
counting loop:                                                          There are, however, tricks that you can use to return
for i in {1..10}                                                     more complex data from a function. Using global
                                                                     variables is a simple solution, but another common
Function definition                                                  one is to pass the name of a varaible as a parameter                PRO TIP
No programming language would be complete                            and use eval to populate it:                                     Try to always use double
without some way to group and reuse code, and bash                   myfunc() {                                                       bracket expressions
has functions. A function is easy to define, either:                   local resultvar=$1                                             unless POSIX compliance
                                                                                                                                      is important.
function myfunc {                                                      local result=’a value’
}                                                                      eval $resultvar=”’$result’”
or (preferably, and POSIX compliant):                                }
myfunc () {                                                          myfunc foo
}                                                                    echo $foo # a value
  Functions have the same naming rules as variables                  eval enables you to build a command in a string and
but it’s conventional to use lower-case words                        then execute it; so, in the example above, the function
separated by underscores. They can be used                           passes in foo and this gets assigned to the local
wherever commands can, and are given arguments in                    resultvar. So, when eval is called, its argument is a
the same way, although the function definition doesn’t               string containing foo=’a value’ that it executes to set
define any (the parentheses must be empty). The                      the variable foo. The single quotes ensure that the
function sees its arguments as positional parameters.                value of result is treated as one word.
  Variables defined outside a function are visible                     These are the main parts of the language, and
inside, and variables defined inside are accessible                  should be sufficient for any Bash script to make sense,
outside, unless declared as local:                                   but there are many nuances and techniques that you
function f() {                                                       can still learn. Your journey beyond the prompt has
  in1=456                                                            just begun…
  local in2=789
  echo $out$in1$in2                                                   John Lane is a technology consultant. He doesn’t know where
                                                                      our jetpacks are, but he does help businesses use Linux.
}



                                                                        www.linuxvoice.com                                                                      103
      CODING NINJA



                             CODE NINJA:
          TUTORIAL
                             PROGRAMMER’S GOLF
                             Sometimes you just have to prove, without a doubt, that you’re
  BEN EVERARD
                             the best programmer in the room.


                             P
                                     eople are naturally competitive. There’s just                 print number
 WHY DO THIS?                        something in human nature that makes us             This is 40 characters. It’s easy to see we’ve wasted
 • Show off your 1337                want to find out who’s the best at something,     quite a bit on the variable name, so we can shrink this
   programming skillz.
                             whether it’s who’s the fastest runner, who can jump       down to 30 characters by simply replacing it with a
 • Push yourself to learn
   more about your           the furthest or who’s the best at kicking balls between   single letter:
   language of choice.       goalposts. Sometimes we geeks like to think we’ve         for i in range(1,7):
 • Save minuscule            transcended this base desire. Perhaps you have, but                    print i
   amounts of disk space.    many of us have just transferred this competitive           If you’re familiar with Python, you might know that
                             instinct from physical exploits to mental ones.           there are two extra characters that we can get rid of
                                Linguists have crosswords, mathematicians have         quite easily.
                             number puzzles, and techies have programmer’s golf.       for i in range(1,7):print i
                             Programmer’s golf in case you’re wondering, is the           It’s clear that we need the print statement, because
                             challenge of taking a particular problem and coding it    there’s no shorter way of outputting text onto the
                             in as small a number of characters as possible.           screen. Of the remaining code, the range call takes up
                                There aren’t any fixed rules for this other than the   8 characters, so it seems like a good place to look for
                             result must be accepted by the interpreter or compiler    further shrinking. We need something that Python can
                             as a valid program, and sometimes there are               iterate over that returns the 1 to 6. It’s important to
                             restrictions on the modules or libraries that can be      realise that in this case, it doesn’t matter if it’s the
The source code to the       used. Beyond that, anything is permissible.               numbers 1 to 6 or the characters 1 to 6, because
main engine of this             A good understanding of the language being used        Python’s print statement can work with either.
simplified game of Tetris
                             is essential, especially as it’s often the language’s
is: function(a,b,c,d,e)
{return d+=c,e=a|b<<d,d<0|
                             more esoteric features that can result in saved space.    How short is a piece of string?
a&b<< d&&(a=e=parseInt          Let’s take a look at a simple example, printing the    Once you’ve realised that it can be the characters 1 to
((a|b<<c).toString(d=32).    numbers 1 to 6 at one per line in Python. Done            6, it’s fairly obvious that we can iterate the for loop
replace(/v/,””),d),b=new     normally, this might look something like this:            over a string instead:
Date%2?1:3),[a,b,d,e]}       for number in range(1,7):                                 for i in ‘123456’:print i
                                                                                         This has managed to claw back another couple of
                                                                                       characters. What’s more, it now uses the string type,
                                                                                       which has quite a few powerful methods that perhaps
                                                                                       we can make use of.
                                                                                         We’re confident that print is the shortest way of
                                                                                       outputting something to the screen, and we think that
                                                                                       the string is the shortest way of encoding the
                                                                                       numbers we need. The only place left to look is the for
                                                                                       loop. Here, we need to think back to what the original
                                                                                       challenge was: print the characters 1 to 6 with each
                                                                                       character on a separate line. So far, we’ve been using
                                                                                       a separate print statement for each line, and this has
                                                                                       required us to use a loop to call the print statements
                                                                                       on each number in turn. However, we could get rid of
                                                                                       the loop if we printed them all with the same print
                                                                                       statement, but put a new line character in-between
                                                                                       each number.
                                                                                       print’\n’.join(‘123456’)
                                                                                           This uses Python’s join method on the string ‘\n’.
                                                                                       This iterates through the argument and outputs every
                                                                                       item in the argument with the original string between
                                                                                       it. Since strings are iterated through on individual
                                                                                       characters, this outputs:



104                                                         www.linuxvoice.com
                                                                                                                                       NINJA CODING


1\n2\n3\n4\n5\n6
Since \n is the new line character, printing this results
in each number being printed on a separate line.
   There is another way of getting the code this short.
In Python, you don’t need to separate bits of text with
spaces if the interpreter can distinguish between
them, so you can remove the space between in and
the start of the string. In other words, with:
for i in’123456’:print i
   Is this as short as it can go? Possibly not. There’s
no way to know for sure that there definitely isn’t a
shorter way of doing something. If you find a way to
remove a few characters, drop me an email at
ben@linuxvoice.com. I’d love to hear it.
   Some people may wonder why bother with this at
all. After all, the resulting code is almost always an
unreadable, unmaintainable mess. Wouldn’t it be
better to focus our competitive instincts on more
useful aspects of programming like readability or
performance? No decent programmer would focus
their efforts on squeezing every last byte out of their
code without a very good reason.
   However, aside from the competitive aspect of the
challenge, there are some skills to be learned in
shrinking file sizes. For one, it forces you to learn more           The code used to create this 3D render is small enough to fit on a business card, and
about your chosen language. For example, it’s                        perhaps more impressively, is 1337 bytes long. For more details see
perfectly possible to program in Python for years, yet               www.fabiensanglard.net/rayTracing_back_of_business_card
never really get to grips with lambda functions.
However, if you’re looking to squeeze a few characters               language, and these can sometimes lead to bugs or
out, they can be a fertile source of reductions. The                 other unexpected behaviour. Learning to exploit these
features you learn may well help you program better                  means learning to understand them, and this means a
in ways other than file size.                                        better understanding of the language.
   Many times, the tricks that you use to remove                       Now, let’s see how good you are with a little
unnecessary bloat are quirks and edge cases of the                   competition. Fore!




                                                           COMPETITION
                                Write ridiculously small code, win an attractive garment!

  This month, the Linux Voice challenge is a game of       number_in = raw_input(“Enter a number: “)                Beyond this, there are
  Python programmer’s golf. Your challenge is to           romannumeral(int(number_in))                          just a few rules:
  write the smallest possible Python program that             This is obviously not optimised for size, so you     The length of the code
  takes a number as input, and prints the value in         shouldn’t have too much trouble stripping some fat      will be the total length of the submitted code in
  Roman numerals. To get you started, here’s a             off it. The question is, how much?                      characters, and the person who submits the
  sample program that does just this:                         There are a couple of things to point out about      shortest code will win an exclusive Linux Voice
  symbols = [(‘M’, 1000), (‘C M’, 900), (‘D’, 500),        this code. It puts a space in between each              winner’s T-shirt.
       (‘C D’, 400), (‘C’, 100), (‘X C’, 90), (‘L’, 50),   character. This is for simplicity, and any spacing      No modules can be imported. That would just
       (‘X L’, 40), (‘X’, 10), (‘I X’, 9), (‘V’, 5),       between characters other than new lines is              make it too easy.
       (‘I V’, 4), (‘I’, 1)]                               acceptable as long as it’s consistent.                  Either Python 2 or 3 is acceptable.
                                                              There is also some contention about what the         Email your entries to ben@linuxvoice.com by the
  def romannumeral(number):                                Roman numerals for certain numbers are. For             end of the day on 15th October 2014.
         while number > 0:                                 example, should 1999 be MIM or MCMXCIX?                 In the event that more than one person has an
                for symbol, value in symbols:              Without wanting to get into a historical argument       entry the same length, they will both be
                      if number - value >= 0:              about how people would have written numbers             considered winners, but the first entry received
                            print symbol,                  thousands of years ago, we’ll simply say that your      will win the T-shirt.
                            number = number - value        program should match the form of Roman numerals         All code must be released under an OSI approved
                            continue                       given by our program.                                   open source licence, and GPL v3 is preferred.




                                                                        www.linuxvoice.com                                                                        105
      CODING KONRAD ZUSE



                                KONRAD ZUSE:
          TUTORIAL
                                (NEARLY) THE GERMAN TURING
                                Try a programming language designed amid the rubble of post-war
    JULIET KEMP
                                Germany before there were any computers on which to run it.


                                I
                                    f you have any interest in computer history, and
 WHY DO THIS?                       possibly even if you haven’t, you’ll have heard of
 • Discover an under-               two of the early computer pioneers: Alan Turing
   appreciated pioneer of
   computer science.            and John von Neumann, who were involved with the
 • Plan your next trip to the   machines being developed during World War II. But
   technical museums of         there’s a fair chance that you haven’t heard of Konrad
   Germany.                     Zuse, in Germany — despite the fact that he was
                                achieving very similar things over four years earlier.
                                   Unlike both Turing and von Neumann, Zuse was
                                working in isolation — he had no similarly able
                                colleagues in Germany, and did not of course have
                                any contact with the leading computer scientists and
                                mathematicians working for the Allies. Nevertheless,
                                in the Z3 he built the world’s first fully operational
                                electromagnetic programmable computer, in 1941;
                                and came up with the theory of stored-program
                                computation in 1937, several years before von
                                Neumann proposed it.

                                Z1 and Z2                                                   Konrad Zuse in 1992 (he died in 1995). Photo: CC-SA,
                                In 1935, a young Zuse was working as a design               Wolfgang Hunscher, Dortmund.
                                engineer at an aircraft factory near Berlin. Much of his
                                time was spent in doing large numbers of calculations       destroyed in an air raid in 1944, although a replica is
                                by hand, and Zuse, understandably, found this               now in the German Museum of Technology in Berlin.
                                massively tedious. He began to wonder whether he               Zuse’s next attempt was the Z2, which he built in
                                could construct a machine to calculate for him.             1939–40. He had been called into military service, and
                                Working in his parents’ flat, he began building the Z1 in   so had a research subsidy, but initially at least was still
                                1936, from bits of metal plate and pins. The Z1 wasn’t      working in his parents’ flat. The Z2 took up several
                                a computer, but a floating-point binary mechanical          rooms of the flat when he presented it to the
                                calculator. It had some programming capacity, and           Deutsche Versuchsanstalt für Luftfahrt (DVL, the
                                read instructions from holes punched in 35mm film.          German Research Institute for Aviation), which rather
                                Zuse filed two patents in 1937, which most                  makes you wonder how big the flat was and how
                                importantly included the idea of stored-program             tolerant Zuse’s parents were! T
                                computation and what has become referred to as                 The Z2 was basically an improved version of the Z1,
                                “von Neumann architecture”, years before von                but using 600 telephone relays rather than the metal
                                Neumann himself proposed it. The Z1 was finished in         plates of the Z1. It had a 64-word mechanical memory,
                                1938, but it never worked particularly well, as its         and electrical relay circuits for the arithmetic and
                                30,000 metal parts were not precise enough. It was          control logic. It weighed 300kg. It worked better than
                                                                                            the Z1, but was still very unreliable — though it worked
                                                                                            well for the presentation to the DVL and impressed
                                                                                            them enough that they coughed up further funding.

                                                                                            Z3
                                                                                            In 1941, with subsidies from the DVL, Zuse was able
                                                                                            to start a company and (finally!) hire a lab to work on
Replica of the Z1 in
the German Museum                                                                           his next machine, the Z3. This was a programmable
of Technology in                                                                            calculator with a memory, which had loops but no
Berlin. Image: CC-SA,                                                                       conditional jumps (so no if/then logic). Like the Z2, it
ComputerGeek.                                                                               was relay-based, using 2,000 relays and 22-bit words,



106                                                             www.linuxvoice.com
                                                                                                                KONRAD ZUSE CODING

but it was far more reliable. Zuse’s co-worker Helmut
Schreyer had suggested vacuum tubes to Zuse, as               Turing-completeness
were used in Colossus in 1943, but he dismissed
                                                              A Turing-complete machine is one that can        proved that it was, by proposing a program
them as a crazy idea. (IBM’s Harvard Mark II, built in
                                                              simulate any single-taped Turing machine.        that instead of branching, would compute
1947, used relays, so they were by no means                   In practice this basically means that it can     both sides of every branch. It would therefore
obsolete.) As with the previous machines, the Z3 used         (in theory and approximately) simulate any       calculate all possibilities, and cancel out the
punched film for code and data input; it also had a           other general-purpose computer; so it can        unnecessary ones. In an abstract theoretical
terminal and lamps for input and output. It was               do anything you expect a “computer” to be        sense, then, the Z3 was Turing-complete.
                                                              able to do. It might, however, take a very       In practice, this doesn’t mean that it was
Turing-complete (see boxout, right), and as such was
                                                              long time!                                       in any real sense the same as a modern
the world’s first fully operational electromechanical             Since the Z3 had no conditional branching    computer, or even a 1940s/50s computer
computer. However, Turing-completeness was not of             (if/then), it is not straightforwardly obvious   with branching capability. However, the Z4
interest to Zuse or his backers the DVL, who were             that it is Turing-complete. In 1998 Raúl Rojas   did have conditional branching.
interested only in automating calculations. (It was a
similar story with the ENIAC in the US, which was
originally intended to calculate artillery firing tables;   went on to build a further 250 computers before being
but the wider possibilities were quickly realised by US     sold to Siemens in 1967.
mathematicians and scientists. ENIAC wasn’t ready              IBM bought an option on his patents in 1946 (Zuse,
until 1945, though, several years after the Z3.)            it seems, might have preferred to work for them
   Like the Atanasoft-Berry Computer in the US (tested      directly, but they weren’t interested).
in 1942, but not programmable, being designed to            The exact influence of this on IBM’s work is unknown,
solve linear equations), but unlike ENIAC and IBM’s         but it is possible that information from Zuse’s binary
early machines (which were decimal), the Z3 was             machines were part of IBM’s move from decimal and
binary. The punched tape system was also ahead of           analog to binary and digital computers.
other early computers — Colossus and ENIAC were
both programmed with plugs and switches. It was an          Simulators
eminently practical machine, for the time, thanks           There’s a really nice Z3 simulator available online (note
undoubtedly to Zuse’s engineering background. His           that the site is in German). It runs there as an
main aim was to automate engineering calculations,          in-browser applet, which I wasn’t able to get running
and the Z3 did this admirably. Its primary use at the       on my Linux browser. (I could run it on Mac, which is
DVL was analysing wing flutter (vibration in certain        usually pickier about Java, so the applet definitely
flying conditions, which can damage or destroy              does work; a different hardware and software setup
aircraft). Zuse did ask for funding to replace the relays   may be all that’s needed.) Alternatively, I was able to
with electronic switches, but this was considered “not      run it on Linux by downloading the file Z3.zip from the
war-important” and denied.                                  simulation overview page, unzipping it, and running
   Meanwhile, Zuse was also working on the S1 and           appletviewer simulation.html from the resulting
S2, which were special-purpose computing machines           folder. I couldn’t initially see the film tape part of the
to calculate corrections to the wings of radio-             main window, but it did reappear after I resized the
controlled flying bombs – the precursors to the             window, choose Programm > Neu, and hit Ende. (And
modern cruise missile.                                      in fact you can program the simulation without seeing
                                                            the film tape, although it’s nice to see your instructions
Z4 and afterwards                                           appear!). If you only have a big purple box in the
The Z3, along with Zuse’s workshop, was destroyed in        middle of the top and no ‘film’ picture, this is the
an air raid in 1943, but the successor Z4 (also             ‘Speicherauswahl’ box referred to below. Enter your
relay-based) was in a different workshop, and was not       memory locations in here and use the right-hand
affected. It was eventually packed up and moved,            buttons for operations just as detailed below.
half-finished, to Berlin in February 1945, then                The Z3 is labelled in German. Some of the labels are
evacuated to Göttingen where it was completed, after        immediately obvious, but here’s a quick translation of
which it was moved again to Bad Hindelang in                some of the others:
Bavaria, near the Austrian border, where it was hidden           German                  English
in a shed to avoid its capture by the Allies.               Vorzeichen              Sign (positive/negative)
   For the next couple of years, Zuse’s priority was        Ziffern                 Numbers
survival — he sold woodcuts to farmers and US               Komma                   Comma
troops to earn money. He began working on the Z4            Wurzel                  Root
again in 1948, but electricity was only intermittently      Einlesen                Read in
available and there was only rarely enough of it to run     Ausgeben                Output
the Z4. A visit from Prof Stiefel from Zurich led to the    Eingabe                 Input
Z4 eventually being delivered to the Swiss Federal          Mantisse                Mantissa (significand)
Institute of Technology in Zurich in July 1950. At the      Speicher                Memory
time, it was the only working computer in continental       Rücksetzen              Reset
Europe. Zuse formed the company Zuse KG, which              Fortsetzen              Resume/continue



                                                              www.linuxvoice.com                                                                           107
      CODING KONRAD ZUSE

                                                                                                        You can also use the ‘film’ to enter a program. When
                                                                                                     you first load the applet, there’s a program provided on
                                                                                                     the film. To run this, go to the applet’s Programm
                                                                                                     menu and choose Start. To enter your own new
                                                                                                     program, go to Programm > Neu (new). You’ll then get
                                                                                                     an extra three buttons: Laden (load/read from
                                                                                                     memory); Speichern (store to memory); and Ende
                                                                                                     (end). You use the purple Speicherauswahl box to
                                                                                                     enter a memory location, and the buttons to enter an
                                                                                                     operation code (such as addition, multiplication, read
                                                                                                     from storage, etc).
                                                                                                        Here’s how to enter a program to add two numbers:
                                                                                                        Enter 0 in the purple Speicherauswahl box, and hit
                                                                                                        Laden. This reads from memory location 0.
                                                                                                        Enter 1 in the Speicherauswahl box, and hit Laden,
                                                                                                        to read from memory location 1.
                                                                                                        Hit Addition. This will add the last two numbers that
                                                                                                        were read in.
                                                                                                        Hit Ausgeben. This will output the result.
                                                                                                        Hit Ende to finish the program.
Replica of the Z3 at
                                     The registers R1 and R2 are the working registers,                 Go to the Speicher window and enter a number in
the German Museum in
Munich. Image: CC-SA,             and the memory (Speicher) has 64 words available.                     the 0 location and in the 1 location.
Venusianer.                       You can set this manually by clicking the circles. I                  Choose Start from the Programm menu. Your
                                  found the mantissa/exponent setup a little confusing                  program will run, and you’ll see the result (the sum
                                  but each line has a decimal translation at the end so                 of your two numbers) at the bottom-left.
                                  you can play around until you have the idea.                          To start again, you’ll need to hit Fortsetzen (Reset).
                                     The mantissa (or significand)/exponent is a way of                 To store the result in a specific memory location,
                                  describing floating point numbers. For example, a                     say location 6, you can replace the Ausgeben
                                  significand of 1234 and an exponent of -1 would                       instruction with
                                  describe the decimal number 123.4.                                 Speicherauswahl 6, Speichern.
                                     You can either enter a calculation directly, using it in        Run this (you’ll have to re-enter the whole thing), and
                                  effect as a desk-top calculator, or enter a program.               keep an eye on the Speicher window. You’ll see your
                                  (Sadly, you can’t save programs.) As with other                    result show up in memory location 6.
                                  computers of a similar age, to run a calculation, you                 Here’s a program to calculate 4! (4*3*2*1):
                                  first enter two numbers. These will be loaded into the                In the Speicher box, enter values 1, 2, 3, 4 in memory
                                  two working registers R1 and R2; the next instruction                 locations 0, 1, 2, 3.
                                  is then applied to those registers, and the output                    In the main window, start a new program.
                                  stored in R1, ready for the next calculation.                         Speicherauswahl 0, Laden.
                                     Here’s an example of manually adding two                           Speicherauswahl 1, Laden.
                                  numbers, 11 and 2:                                                    Multiplikation.
                                     Enter 11 with the top set of buttons (Eingabe).                    Speicherauswahl 2, Laden.
                                     Hit the Einlesen button, and watch the circuitry                   Multiplikation.
                                     change. Notice that the R1 circle on the bottom left               Speicherauswahl 3, Laden.
                                     will now be lit.                                                   Multiplikation.
                                     Enter 2 with the top set of buttons (Eingabe).                     Ausgeben.
                                     Hit the Einlesen button again. Both R1 and R2 are                  Ende.
                                     now lit.                                                           Run the program to get the output 24. Note that
                                     Hit Addition, then Ausgeben. The output, 13.0, will             multiplication steps take a while! You’ll see here the
                                     appear in the very bottom left.                                 advantage of having the output of each calculation
                                                                                                     stored in R1 ready to be used. By rewriting memory
  Zuse and Turing                                                                                    addresses it should be possible to construct a loop;
                                                                                                     have a go and see what you can manage.
  Zuse and Turing may have met briefly after       this meeting is only described in Heinz              If you want more information about the simulation,
  the war, in 1947, at a colloquium in Göttingen   Billing’s memoirs, and no details survive. The    there is an article by Raúl Rojas which discusses the
  which included a few other British and           historical detail is discussed in a paper by      construction of the simulation and includes the
  German researchers. (‘Colloquium’ is a polite    Herbert Bruderer. If Zuse and Turing did meet     instruction set. There are also instructions for using
  way of describing a discussion which has         it is likely, due to the secrecy of the war and
                                                                                                     the simulator (in German, but Google Translate does a
  also been described as “an interrogation”.       post-war period, that neither of them was
  The participation of the German scientists       familiar with the achievements of the other,      reasonable enough job) on the Zuse project webpage.
  was almost certainly not optional.) However,     which seems more than a little sad.                  While building the Z4, Zuse concluded that an
                                                                                                     alternative was needed to programming in machine



108                                                                    www.linuxvoice.com
                                                                                                                KONRAD ZUSE CODING

code, to make programming more straightforward. In
1945/6, when he was living in the rural Allgäu and
couldn’t work on hardware, he designed Plankalkül
(“Plan Calculus”), which was the first high-level
programming language. However, this only existed in
theoretical form during his lifetime; a team finally
implemented a compiler in the year 2000, five years
after his death. Plankalkül has been compared to APL
and relational algebra, but it did not in practice have an
impact on future languages, since it wasn’t
implemented at the time. It is, however, the first
theoretical description of high-level programming.

Programming in Plankalkül
Zuse’s original notation for Plankalkül was two-
dimensional, although a linear notation was devised
when implementing it in the 1990s. The full report
from the Free University of Berlin team is a fascinating
read, but here are a few of the basics:                                                                                    Z4 (the real thing!) on
   There are three basic types of variables:                  universe itself is running on a cellular automaton. (Von     display in the German
   V variables (V0, V1…), read-only, used to pass             Neumann had an interest in cellular automata, too.)          Museum in Munich. Image:
   parameters into programs.                                  There’s no physical evidence against this thesis, and        Clemens Pfeiffer, CC-G.
   Z variables (Z0, Z1…), read/write, used for                other scientists have expanded on it since. After
   intermediate results.                                      retirement, he spent his time painting; he died in 1995.
   R variables (R0, R1…), write-only, used to pass the           Looking at Zuse’s history, it’s hard not to make
   final results of a program.                                comparisons with Turing, von Neumann, or Hopper,
   Loop variables are also used, written i0, i1, i2, etc.     working at the same time in other countries; and to
   Variables have one of the following types:                 wonder what might have happened if Zuse had been
   One bit, written 0.                                        taken more seriously in his own country. Or, more
   n bits, written n.0.                                       cheerfully, if all of them had been truly able to
   Tuples of other types, written (n.0, m.0, ...). So (3.0,   collaborate in a peaceful world across international
4.0) would be a tuple with two members, one 3-bit             boundaries. What would programming languages
variable and one 4-bit variable. Tuples can have two or       look like today if Plankalkül had been implemented
more elements.                                                before COBOL? Would things have moved faster if the
   Vectors of a single type: so m.n.0 is a vector (or         Z3 hadn’t been destroyed (or if Colossus, in the UK,
array) with m members each of which has n bits.               had been an open project)? Or, on the other hand, did
Vectors are used for arrays of the same type, tuples          the war drive developments that would otherwise
for arrays of different types.                                have been much slower? The ethics on all sides are
   Here’s a quick example that adds two numbers:              difficult, too; all the pioneers of this time were working
P1 (V0[:8.0], V1[:8.0]) => R0[:8.0]                           on war projects. Zuse, while he was working for the
  V0[:8.0] + V1[:8.0] => R0[:8.0]                             Nazi regime, was never a member of the Nazi Party
END                                                           (unlike many other German scientists of the time). In
Note that the report would have R(V0[:8.0]...) in that        later life he suggested that scientists and engineers
first line, but the online compiler at the Zuse Project       usually have to choose between working for
website doesn’t like that.                                    questionable interests (commercial or military), or not
   After Zuse KG was bought, Zuse wrote the book              working at all.
Calculating Space, in which he suggested that the                What is clear is that Zuse was working at the very
                                                              top of his field, even if he wasn’t able to work
                                                              alongside the others doing the same. His machines
                                                              were at least two–three years ahead of the teams in
                                                              the UK and US. Although the Z4, his ‘final’ version, was
                                                              finished at roughly the same time as ENIAC and a little
                                                              after Colossus, it was more programmable than both
                                                              and genuinely general-purpose. Zuse was an
                                                              immensely talented scientist whose contribution to
                                                              computing has gone unfairly unnoticed.


                                                               Juliet Kemp is a programming polyglot, and the author of
The Z3 window and memory window, in the middle of
                                                               O’Reilly’s Linux System Administration Recipes.
entering a program.



                                                                www.linuxvoice.com                                                             109
      MASTERCLASS SAMBA




                               MASTERCLASS
                                 Work with Windows users, using the Samba and the Samba
  BEN EVERARD                    Web Administration Tool.


SAMBA: SHARE WINDOWS FILES
Set up file sharing and co-exist in harmony with Windows users.


                                 E
                                          ven the most die-hard Linux fan will at some               You’ll need to be logged in as root to use mount like
                                          point find themselves on a network alongside             that, or you can add an entry to /etc/fstab to mount
                                          users of other operating systems and will want           automatically upon boot:
                                 to share files with them.                                         //myserver/myshare /mnt cifs username=myuser,password=myp
       JOHN LANE                    Samba is an open-source implementation of the file             ass,users 0 0
                                 and print sharing protocol that Windows computers                    We use the username and password options to
                                 use. It was originally part of the networking suite that          specify the credentials needed to connect to the
                                 Microsoft implemented before they adopted TCP/IP,                 remote share. You can omit these if you’re connecting
                                 the networking standard that we all use today, and                to a publicly-accessible guest share. The users option
                                 this legacy brings a certain quirkiness to the                    allows members of the users group to mount and
                                 interaction between Linux and Windows, one of which               unmount the share without needing root privileges.
                                 is having to deal with two name resolution services.
                                    There are two ways that you can exchange files                 smbclient
                                 with a Windows system. You can, as a client, connect              While you may prefer to mount shares that you
                                 to another resource on the network to access files or             frequently use, there is another way to access them
                                 you can set up a server to allow others to connect to             that may suit for occasional use or in situations where
                                 you. You’ll hear network-accessible filesystems being             you aren’t permitted to mount. This is the smbclient
                                 called shares and, in the Linux world, Samba shares.              tool, and you’ll need to install it from your repository:
                                    Connecting to one of these as a client is very easy            $ apt-get install smbclient
                                 these days, because the drivers that you need are now                It works a bit like an FTP client; you connect to a
      PRO TIP
                                 part of the Linux kernel, but you may still need to               host and then use put and get to send and receive
 Apple’s OS X uses the
                                 install the command-line tools:                                   files. You can give the help command to see the list of
 same Samba as Linux and
 can therefore interoperate      $ apt-get install cifs-utils                                      commands available. Here’s an example session
 in the same way.                CIFS is the Common Internet File System, and is what              $ smbclient //myhost/public
                                 Microsoft calls Samba. It was originally called Server            Enter john’s password:
                                 Message Block, or SMB, which led to the Linux                     Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.4]
                                 implementation being called Samba.                                smb: \>ls
                                   So, if all you want to do is connect to a Windows               testfile N 6 Wed May 15 19:32:07 2013
                                 server to read and write files, it’s a simple mount:              smb: \> get testfile
                                 $ mount -t cifs -o username=myuser,password=mypass //             getting file \testfile of size 6 as testfile (0.1 KiloBytes/sec)
                                 myserver/myshare /mnt                                             (average 0.1 KiloBytes/sec)
                                                                                                   smb: \> quit
                                                                                                      With these methods you can read and write files
 The ‘guest’ user
                                                                                                   shared by others, but to share yourself, you need a
 When you connect to a Samba share, you do           A quirk of the protocol requires recognised   server – and that’s where Samba comes in. There are
 so as a specific user that, unless you specify    users to authenticate even when accessing       two versions in popular use: the 3.6 series and the
 otherwise, will be the same as your local         shares that are accessible to guests without
 username. The server can be configured, like      doing so. You can get around this by
                                                                                                   newer 4.x series. The major difference is that version
 our example is, to provide a guest user and       mounting with the guest option:                 4 can work as an Active Directory Domain Controller,
 to map unrecognised users to it. This allows      $ mount -t cifs -o guest //myserver/public_     but that’s overkill if all you want to do is share some
 access to permitted shares without                share /mnt                                      files. Either version is fine for that purpose and one of
 authenticating. Shares are accessible to            Our example configuration sets the            them will be easily installable from your distribution’s
 guests when their configuration includes:         ownership of files written by guests to the
 guest ok = yes                                    nobody user and nogroup group.
                                                                                                   repositories:
                                                                                                   $ sudo apt-get install samba



110                                                                     www.linuxvoice.com
                                                                                                             SAMBA MASTERCLASS


   You configure Samba by editing its configuration
file, usually /etc/samba/smb.conf. It is formatted           What is NetBIOS ?
similarly to the .ini found on Windows systems, so           When Microsoft implemented Windows, it          and configure your systems /etc/nsswitch.
any text editor will do. Here is an example that             used a networking API called NetBIOS            conf to use it by adding wins to its hosts
provides a public share:                                     (Network basic Input/Output System) that        entry:
global                                                       ran over various protocols, but TCP/IP wasn’t   hosts: files wins dns
                                                             used until Windows 95 and, with Windows             Samba implements the SMB/CIFS
    server string = Samba Server Version %v
                                                             2000, Active Directory began to lessen the      protocol over TCP/IP, either with (on port
    # Treat unknown users as a guest (where permitted)       requirement for NetBIOS, although the My        139) or without NetBIOS (port 445). The
    security = user                                          Network Places browser still uses it and it     nmbd daemon provides the NetBIOS services
    map to guest = Bad User                                  allows older versions of Windows to co-exist    including WINS server.
                                                             on the same network.                                The Samba suite gained full Active
                                                                NetBIOS includes several parallels to TCP/   Directory compatibility in version 4, including
           # For Windows network browsing
                                                             IP networking, such as the Windows              the ability to be a domain controller, but it is
           workgroup = LVSAMBA                               Internetworking Name Server (WINS) that         unnecessary for simple file- and print-
           netbios name = MYSERVER                           provides name resolution services to            sharing.
           name resolve order = wins bcast                   NetBIOS clients in a similar way to DNS. If         Samba allows NetBIOS to be disabled, but
                                                             you want to be able to resolve NetBIOS          doing so is only practical if Active Directory
                                                             names when mounting shares, you’ll need to      is implemented instead. Our examples keep
tempfiles
                                                             install winbind                                 NetBIOS, because this configuration is more
   path = /tmp                                               $ sudo apt-get install winbind                  likely to suit home or other small networks.
   read only = No
   browsable = Yes
   guest ok = Yes                                          using Samba’s testparm command:
          force user = nobody                              $ testparm
          force group = nogroup                            Load smb config files from /etc/samba/smb.conf
   create mask = 0755                                      rlimit_max: increasing rlimit_max (1024) to minimum Windows
   directory mask = 0755                                   limit (16384)
                                                           Processing section “[tempfiles]”
homes                                                      Loaded services file OK.
   comment = %U home directory                             Server role: ROLE_STANDALONE
   read only = No                                             Samba runs two daemons, called smbd and nbmd.
   browsable = No                                          The former provides the sharing services and the
                                                           latter provides the NetBIOS name services necessary
Inside the Samba config file                               for your Samba server to appear in My Network
The global section is for system-wide settings. Its        Places. Start the Samba daemons with:
server string is a description that is displayed to        $ service smbd start
clients browsing the network for shares. The               $ service nmbd start
“security = user” and “map to guest” settings cause          You should then be able to browse for the new                           PRO TIP
any unknown users to be treated as a guest. Finally, it    share from a Windows machine (remember to use                         You can ask Samba to
configures the NetBIOS Workgroup. This is where the        backslashes: \\myserver\tmp). Or, from a Linux (or                    reload its configuration
Samba server should appear in the Windows network          other Unix-like) machine, you can use findsmb to list                 without restarting. Use
                                                                                                                                 smbcontrol all reload-
browser (My Network Places) on Windows clients.            servers on the network and smbclient to view their                    config.
   The tempfiles section describes a share called          shares.
tempfiles, which gives access to the local /tmp            $ findsmb
directory. The attributes we’ve used in the example are    IP ADDR       NETBIOS NAME WORKGROUP/OS/VERSION
self-explanatory; they are a few of the many available      - - - - - - - - - - - - - - - - - --
and are documented at http://bit.ly/smbconf. You           10.0.2.6      MYSERVER +[LVSAMBA] [Unix] [Samba 3.6.9]
create sections like this for each local directory that    $ smbclient -L MYSERVER
you want to share.                                         Domain=[LVSAMBA] OS=[Unix] Server=[Samba 3.6.9]
   The homes section in our configuration is special                   Sharename      Type Comment
because it shares users’ home directories when they                     - - -    --     - --
authenticate using their username and password. For                    IPC$       IPC     IPC Service (Samba Server
a user to be recognised by Samba, it needs to be           Version 3.6.9)
created with smbpasswd:                                                tempfiles    Disk
$ smbpasswd -a myuser                                         We’ve covered what is necessary to access shares
   Note that this sets up a separate password to that      and provide your own. But Samba enables you to do
stored used by passwd. You can then use home               much more, including auto-configuring home
directories                                                directories and sharing printers. With version 4 you
$ mount -t cifs -o username=myuser,password=mypass //      can participate fully in an Active Directory network,
myserver/myuser /mnt                                       and this is something that we will cover in a tutorial in
  It’s a good idea to test your configuration for errors   the near future.



                                                             www.linuxvoice.com                                                                             111
      MASTERCLASS SAMBA



THE GUI WAY TO SAMBA
Can configure and use Samba without the command prompt.


                              I
                                  f you prefer to use a graphical configuration tool        http://myserver:901 to see Swat’s main page. You will
       JOHN LANE                  instead of manually editing files, there are various      need to have a login on the Samba server and use
                                  tools available that enable you to administer             those credentials to log in to Swat (Samba credentials
                              Samba and access remote shares without opening up             created with smbpasswd are not used).
                              a terminal window or text editor.                               The options available to you after logging in will
                                 The first of these that we will look at is called Swat,    depend on your ability to write to the Samba
                              or the Samba Web Administration Tool. It’s part of the        configuration file. The usual way to gain this right is to
    PRO TIP                   Samba suite but your distribution may package it              be a member of the admin group and for that group to
 if you log in to Swat as     separately from the Samba server suite. To install it         have write access to the file. This will need to be
 root, its status page will   on Ubuntu:                                                    preconfigured by a user with root privileges:
 give you buttons to start
 and stop the Samba           $ apt-get install swat                                        $ sudo usermod -a -G admin myuser
 daemons.                        Before using Swat, bear in mind that it will rewrite       $ sudo chgrp admin /etc/samba/smb.conf
                              Samba’s configuration file /etc/samba/smb.conf. So,           $ sudo chmod g+w /etc/samba/smb.conf
                              if you have carefully crafted a nicely laid out and             A user without write access can browse the Samba
                              well-commented configuration file that you don’t want         documentation, see server status, view the server
                              to be overwritten, make a backup before using Swat.           configuration and change the Samba password for
                              Another thing to note is that, although it is still part of   any user that they know the current password for.
                              the Samba suite, Swat isn’t actively maintained any           They can do this on remote Samba servers as well as
                              more and there have been discussions about                    the local one where Swat is running.
Swat allows limited access    dropping it completely. That said, it remains a popular
to users without write
                              choice for Samba administrators because it is useful          The Swat wizard
privileges. They can view
the server status and its     as a learning tool and as a reminder of what the              Users with write privileges also get access to the
configuration, browse         available options are and their default values.               options used to configure Samba. There are screens
documentation and                Swat runs as a web service on port 901 of the              to edit the global configuration, shares and printers.
change Samba passwords.       Samba server. Point your web browser at, for example,         There is also a wizard to build configuration for you.
                                                                                               Aimed at “the Microsoft-knowledgeable network
                                                                                            administrator”, the wizard has two options: the first,
                                                                                            ‘Rewrite smb.conf file’, rewrites smb.conf with the
                                                                                            existing settings, ignoring any changes made but not
                                                                                            written; the rewritten file will lack any comments or
                                                                                            settings that were already Samba defaults. The
                                                                                            documentation calls this a ‘fully optimised format’.
                                                                                            What this means is that it removes all unnecessary
                                                                                            comments and any settings that are unnecessary
                                                                                            because they are the defaults values anyway.
                                                                                               The other option that the wizard offers allows you
                                                                                            to configure a new server, either standalone or as a
                                                                                            domain member or controller (Swat doesn’t offer
                                                                                            options for the new Active Directory functionality
                                                                                            introduced with version 4). You can select a WINS
                                                                                            configuration and choose whether you would like to
                                                                                            create per-user home directory shares. After selecting
                                                                                            your desired options, click the commit button to write
                                                                                            a new smb.conf file.
                                                                                               Using Swat can help you become familiar with the
                                                                                            many available Samba configuration options because
                                                                                            its pages display many of them along with their
                                                                                            current or default values as well as hyperlinks that
                                                                                            take you directly to the relevant part of the
                                                                                            documentation. A button on each setting allows
                                                                                            resetting to its default. Settings with their default
                                                                                            values don’t get written to the configuration file.
                                                                                               Because Swat exposes many of Samba’s
                                                                                            configuration options, it can be more overwhelming



112                                                            www.linuxvoice.com
                                                                                                         SAMBA MASTERCLASS


for those with little knowledge of them. For basic
configuration tasks, other tools may be more
appropriate and one such tool is system-config-samba.
   This is a Python GUI application from Red Hat that
enables you to manage shares and users. It has some
integrated help pages. You may find it in your
distribution’s repositories, or you can obtain the
source from Red Hat (http://bit.ly/sysconfsamba).
$ apt-get install system-config-samba
   If system-config-samba is too basic, another option
is gadmin-samba, part of the GAdminTools project.
It needs to be run as root and also overwrites the
smb.conf file, but it does warn about this when it
starts. It contains lots of options and overwrites any
existing configuration with a more comprehensive
one that contains lots of settings, the reasons for
which may not be clear if Samba configuration is new
to you. You may find the resulting configuration is
                                                            The Swat Wizard provides some basic options that can
more complicated than you require (which may not be
                                                            get you up and running quickly.
an issue if you only view it through a GUI application!).

File access                                                    There are also GUI tools that can help if you have a
Once Samba is configured, your main interaction with        large number of shares to manage. These often
it will be for accessing files shared on the network by     support multiple protocols, smb:// being one of them.
remote servers. Samba integrates well into desktop          Two examples of these
environments and allows shares to be browsed as             kind of tools are Gigolo
easily as local filesystems.                                and PyNeighborhood,       “Most desktop environments
   Popular file managers like Nautilus, Thunar and          available in many         can browse Samba shares
PCManFM support virtual filesystems that can directly       distros’ repositories.
open remote Samba shares without the need for a                They offer a network   through their file managers.”
separate step to mount them. They use a URI syntax          browser to locate,
to represent shares, and opening a share is as easy as      select and mount shares. Alternatively, they allow
using its URI, for example:                                 remote server, user and share details to be specified
smb://myserver/myshare                                      manually. Gigolo supports multiple filesystem types,
   What makes this possible are the virtual filesystem      whereas PyNeighborhood specialises in SMB/CIFS
libraries like the Gnome Virtual Filesystem (GVFS) and      browsing.                                                     PRO TIP
the KIO library on KDE. Each file manager also allows          Most modern desktop environments have the               After changing the
you to create shortcuts to frequently used paths, for       integrated capability to browse Samba/Windows              configuration, Samba
                                                                                                                       must reload it: the
example by dragging them from the location bar into         shares through their file managers and may include         smbcontrol all reload-
Places or adding bookmarks.                                 graphical administration tools as well.                    config command
                                                                                                                       performs this task.




                                                                                                                      System-config-samba has
                                                                                                                      the basic tools to manage
                                                                                                                      shares and users.


                                                              www.linuxvoice.com                                                                113
      /DEV/RANDOM/




Final thoughts, musings and reflections
                           Nick Veitch
                           was the original editor
                           of Linux Format, a              Beloved x220 sitting
                           role he played until he         on a docking station                                   Main monitor, only
                                                                                                                  used for doing mails
                           got bored and went
                           to work at Canonical
                           instead. Splitter!




E
         veryone really is out to get you. Well, a
         statistically significant number of people
         are anyhow.
   Many many years ago, when i set up my first                                               Spare laptop
Wi-Fi network and went out down the road, trying                                             charger, in case I                    N10 tablet used
                                                           Nexus 4 I use for                 want to step out                      for compilation
to see how far I could get and retain a                    development and                   for a coffee                          purposes mostly
connection, I also managed to spy two other                testing purposes
networks. One which belonged to a local
business and one whose owners (still to be

                                                       My Linux setup Thomas Voß
identified) seem to be Star Wars geeks (SSID:
Dantooine). Now I can see 14 networks without
leaving the front door. A tempting target.
   Since those early days, I have always carved        The chief architect of the Mir display manager (see p40)
off a bit of network as open access. Anyone can        shows us where he does his coding.
log in and take advantage of some meagre
bandwidth (I have benefited from individuals                 What version of Linux are you             switched to Debian and then Ubuntu.
opening their access in the past, most notably in            using at the moment?
Cornwall, where it used to be harder to get a                Ubuntu 14.10.                                    What Free Software/open source
decent signal than to find a dry patch of grass).                                                             can’t you live without?
But last week, someone tried to break in.                                                                     Linux, Unity, GCC and Clang, cmake,
   Fortunately, they never actually managed to               Which desktop do you prefer,                     the usual set of command line tools,
actually achieve anything, so far as I can see, just         and why?                                  and Chromium. XChat is part of my daily
used the open access to point a bot at the router            Unity – it’s nice and easy, and does      workflow, too. As for editors: I’m
for 10 minutes or so, trying a dictionary attack.            not get in my way.                        pragmatic, I use both Emacs and Vim. For
My router is a bit, erm, non-standard, so I am                                                         some of my coding work, Qt Creator is my
guessing that helped; I don’t know what they                  What was the first Linux setup           tool of choice.
would have found if they even HAD got access to               you ever used?
the main network. I guess they could have                     Some SUSE version installed from a              What do other people love but
printed me out a note on the LaserJet. But my                 CD that was supplied with a                     you can’t get on with?
guess is that it wasn’t industrial espionage trying    computer magazine. I have no idea about                Some people seem to love
to find out what my next feature for Linux Voice       the exact version, but I remember that I               flamewars/trolling, but I personally
was, but some l33t idiots on their summer break        used FVWM2 back in the day. The                 could very well live without them. The
looking for mischief.                                  installation was far from flawless, and the     other thing is playing computer games!
   Anyhow, the moral is that you don’t have to be      package manager (I think Yast) was              I’m totally into the technology driving
in charge of the Iranian nuclear programme to be       horrible to use, but still: I spent days        those games, and I can spend hours and
the target for “cybercrime”. With drive-bys like       setting up the system to my own liking,         days reading the code of game engines.
this, and the modern equivalent of kidnapping          fiddling around with configuration files…       However, I hardly ever play a computer
(http://goo.gl/zDBNn3) already in play, it pays to     and really enjoyed the experience! I stayed     game in my free time and I stopped
lock the doors.                                        with SUSE for some time, but finally            considering consoles after the SNES.



114                                                           www.linuxvoice.com
CC-BY 2.0 Sacha Chua http://sachachua.com