DOKK Library

Linux Voice [Issue 22]

Authors Linux Voice

License CC-BY-SA-3.0

Plaintext
        WIN £4,250 OF HACKER SWAG: DETAILS INSIDE
                                                                       XMAS BONANZA!
                                                                               Our festive
                                                                            gift guide for
                                                                           the discerning
January 2016                                     www.linuxvoice.com                  geek


 HACK A
 BLUETOOTH                                                                     WHEN
 MONITOR p76             Try more                   Get a prettier          DEVELOPERS
                       Linux distros                  desktop                FALL OUT!
                                                                                p28



                             USE
                            LINUX                                      Serve your
                           SMARTER
        Keep tabs on
        your system                                                   own website



                                                           Streamline the
                        Keep on top                        way you work
                        of updates
       MODEL
     THE GLOBAL
      ECONOMY
         p84
                                                                32 PAGES OF TUTORIALS
 GIANUGO RABELLINO                     QUIZMASTER
 MR MICROSOFT                          RASPBERRY PI
                                                                              Januar y 2016 £5.99 Printe d in the UK




 The senior director                   Build your own
 of open source                        Python-powered
 communities at MS                     touchscreen
 on the importance                     quiz machine for
 of being open                         glorious learning



MYSQL › FEDORA › UBUNTU › PYTHON & MORE!
The only Linux magazine available
   as DRM-free PDFs and ePub




shop.linuxvoice.com
                                                                                                  ISSUE 22 WELCOME



VOICE OF THE MASSES
The January issue                                                                        What’s hot in LV#022
                                                                                                  ANDREW GREGORY
                                                                                                  We haven’t put a number on it,
                                                                                                  but our collection of tips is
                                                                                                  numerous and diverse, with
                                                                                                  people like Matthew Garrett and
                                                                                                  Matthias Kirschner contributing
                                                                                                  their all-time favourites.
                                            GRAHAM MORRISON                                       p14
                                            A free software advocate
                                            and writer since the late                             BEN EVERARD
                                            1990s, Graham is a lapsed                             Valentine’s in-depth look at how
                                            KDE contributor and author                            Linux works is becoming
                                            of the Meeq MIDI step                                 compulsive reading. This month,
                                            sequencer.                                            he deconstructs and reconstructs




O
                                                                                                  the humble executable, which is
         n our podcast (which is seven years old in February!), there’s                           something we use every day.
         a section called ‘Voice of the Masses’. This is where we ask                             p94
         our listeners a question. This question often starts off
innocuous but the answers always surprise us with their insight and                               MIKE SAUNDERS
positivity. One of the best examples of this happened recently, when                              We’ve not run a competition
we asked, “Who is your Linux or Free Software hero?”                                              before, but we can’t help being
  What surprised us most was that out of the 60 people proposed in                                excited about the pirate booty
the replies, there was only one mention of Linus Torvalds, and only                               we’ve got from Pimoroni. All
three or four of Richard Stallman. The majority were for the unsung                               you’ve got to do is find 10
heroes behind much of the software we all use every day: Fabrice                                  penguins!
                                                                                                  p26
Bellard,for his work on Qemu and FFmpeg; Martin Gräßlin for
speaking calmly in a KDE storm; and even Mark Shuttleworth for
bringing Linux to the masses. But to even highlight these few is to
miss the point – the best thing about Linux? It’s built by all of us.

Graham Morrison
Editor, Linux Voice
                                            Linux Voice is different.
  THE LINUX VOICE TEAM
                                            Linux Voice is special.                        SUBSCRIBE
  Editor Graham Morrison
  graham@linuxvoice.com                     Here’s why…                                    ON PAGE 56
  Deputy editor Andrew Gregory
                                             1 At the end of each financial year we’ll
  andrew@linuxvoice.com
                                            give 50% of our profits to a selection of
  Technical editor Ben Everard              organisations that support free
  ben@linuxvoice.com                        software, decided by a vote among our
  Editor at large Mike Saunders             readers (that’s you).
  mike@linuxvoice.com
  Games editor Michel Loubet-Jambert         2 No later than nine months after first

  michel@linuxvoice.com                     publication, we will relicense all of our
  Creative director Stacey Black            content under the Creative Commons
  stacey@linuxvoice.com                     CC-BY-SA licence, so that old content
                                            can still be useful, and can live on even
  Malign puppetmaster Nick Veitch
                                            after the magazine has come off the
  nick@linuxvoice.com
                                            shelves
  Editorial contributors:
  Mark Crutch, Andrew Conway, Juliet         3 We’re a small company, so we don’t
  Kemp, John Lane, Vincent Mealing,         have a board of directors or a bunch of
  Simon Phipps, Les Pounder, Mayank         shareholders in the City of London to
  Sharma, Valentine Sinitsyn.               keep happy. The only people that matter
                                            to us are the readers.



                                                                www.linuxvoice.com                                                   3
     CONTENTS ISSUE 22 JANUARY 2016




                          Contents
                            Welcome to Linux Voice, the magazine that gives back to the community


    Regulars                                        Cover Feature
News                                      06
Big money moves in the world of Free
Software, a huge government contract for                                                                                                           14
LibreOffice, and Raspberry Pis head to the
International Space Station.

Distrohopper                             08
Taste 57 varieties of Ubuntu and whet your
appetite for your next rainy weekend of
installing new distros.

Speak your brains                          10
Why a free internet is essential (and like
Linux), and the final word on that awful/
loveable penguin.

Subscribe!                           12/56
Save money, get the magazine delivered to
your door and get access to 22 issues of
Linux Voice in lovely DRM-free PDFs.

FOSSPicks                                     58
                                                   Make yourself a better Linux user with our mélange of tips, tricks and
Software that’s as Free as the migratory           software discoveries, and get more out of Free Software.
birds that flock to Britain at this time of the
year, driven by the cold Siberian winds that
scourge northern Europe.                            Interview                                       Feature
Core Tech                                94

                                                                                                     GEEK GADGET
The intrepid Dr Valentine Sinitsyn goes
inside a Linux executable to discover what’s                                            34                                                         24
                                                                                                     GIFT GUIDE
really going on when you optimise code at
compile time.

Geek Desktop                              98
Inside the geek den (including oscilloscope!)
of Jon Williamson, provider of goodies at
top swag suppliers Pimoroni.



                                                   Gianugo Rabellino                               Consume!
         SUBSCRIBE                                 After years of FUD, Microsoft loves Linux –     Remember the real meaning of Christmas: to spend money
         ON PAGE 56                                and it’s due in large part to this man.         on gadgets. Here are some of the best for your list.


                                                    FAQ                                  Group Test                            WIN
                                                                                                                              STUFF
                                                   Software Defined Networking 32       Window managers                  50   WORTH
                                                   The tech that’s going to make
                                                   networking a lot more flexible,
                                                                                        Your desktop isn’t just about eye
                                                                                        candy – it’s a reflection of the
                                                                                                                              £4,250!
                                                   scalable and adaptable.              way you work. So work better!

                                                                                                      TURN TO PAGE 26!
4                                                                    www.linuxvoice.com
                                                                                          ISSUE 22 JANUARY 2016 CONTENTS


 Feature                                                                                                          Tutorials


                                                                                                      28




                                                                                                                 Shower                                 66
                                                                                                                 Give presentations anywhere with HTML.
                                                                                                                 Death to PowerPoint! Long live Shower!




Codes of conflict
When developers fall out, the community feels the shockwaves. But why can’t they just get along?                 Bash                                    68
                                                                                                                 Save time by entering commands without
                                                                                                                 typing them. No, this is not telepathy…
 Reviews
                                                                                                                 Raspberry Pi                              72
                                                                                                                 Build a quiz machine with Python 3, a

                                                                                                      42         touchscreen and a cardboard box.

                                                                                                                 Hardware                               76

Fedora 23
                                                                                                                 Avoid withdrawal anxiety by monitoring
                                                                                                                 your machine over Bluetooth.
Try the Linux of tomorrow, today, with
                                                                                                                 Database 101                             80
the most advanced Linux distro known
                                                                                                                 Enter information into a database with a
to man. We’ve tried it, and we think it’s
                                                                                                                 fancy web-based interface.
pretty jolly good.

                                                                                                                  Coding
Ubuntu 15.10                      43   OwnCloud Server 8.2            44   TeamViewer 10                   45
Want to get into Linux? Try            Love the convenience of Google      Now it’s even easier to share a
Ubuntu 15.10, the latest version       services but hate being spied on?   screen remotely and provide tech
of this beginner-friendly distro.      Here’s the solution.                support for the family…




                                                                                                                 Minsky                              84
                                                                                                                 Model complex mathematical formulae
                                                                                                                 without having to learn maths.

                                                                                                                 Code Ninja                                 88
                                                                                                                 Build a (very small, but perfectly formed)
                                                                                                                 filesytem in userspace with FUSE.
Gaming on Linux                                 46       Books                                              48
Dark graphics, moody plots and acute social              Books: still the best way to read lots of words about   Haskell                                90
commentary – gaming on Linux is a far cry from the       subjects you need to concentrate on, including          Programming the functional way, with a
days of SuperTuxKart.                                    cryptocoins and programming.                            language that was almost called Curry.



                                                                   www.linuxvoice.com                                                                       5
     NEWS ANALYSIS




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


The flood of foundations
Some companies like impartial supervisory bodies so much, they’re creating their own!

                           Simon Phipps             the most important freedoms – to use the           of corporations has transformed into a
                           is ex-president of the   software for any purpose, study and improve        medium for them to express their
                           Open Source Initiative
                                                    it and share with anyone – are secured by          competitive goals and especially to chill new
                           and a board member
                           of the Open Rights       using an OSI-approved open source licence.         entrants to their markets.
                           Group and of Open        Any project that doesn’t clearly point to the
                           Source for America.      source code and identify how it’s licensed is      Corporate interests
                                                    definitely a problem. But with that taken as       Trade associations in open source are
                                                    read, a Foundation offers:                         evolving in a similar way. While open source
                                                       An “Asset Lock”, guaranteeing that              projects were originally grass-roots
                                                       community assets can only be used in            collaborations between individual experts,



O
         f late, there seem to have been a             ways the community approves (including          their disruptive force has led the corporate
         tidal wave of new “open source                trademarks and copyrights).                     targets of that disruption to invest not just in
         foundations” appearing in the                 A “bank”, handling donations, paying staff      technology but in the politics surrounding it.
technology industry – there’s the Node.js              and fulfilling tax-reporting obligations.       The new giant open source “Foundations”
Foundation, Cloud Foundry Foundation,                  An impartiality guarantor, anchoring the        are high-stakes political venues with big
Cloud Native Computing Foundation and the              representation of its community and             entry tickets. Individuals still have a role in
OpenStack Foundation to name but a few.                ensuring decisions are made in the way          the technical work, but the overall strategy is
What is going on?                                      that the community wants independently          a thing of smoke-filled rooms. Open source
   The first thing to observe is that there are        of any one participant.                         trade associations provide the ideal vector
two different kinds of entities that call              An infrastructure provider, hosting code,       for the equivalent of regulatory capture in
themselves “open source Foundations”.                  mailing lists, forums and bug trackers and      open source.
Some – like the Apache Software                        also hosting events.                               That’s not to say they are all bad. A
Foundation or the Document Foundation –                So why do companies prefer trade                well-designed one (the Eclipse Foundation
are public benefit organisations, with a            associations as the vehicle for this, rather       for example) keeps a strong separation
mission and bylaws that drive them to act in        than public benefit charities? I liken it to the   between the fiduciary responsibilities and
the interests of the public at large. The other     way technology companies responded to              the technical work, and only allows the
kind – like all the examples I gave above, as       open standards in the 80s. Originally              members to buy in to the former, as well as
well as better-known bodies like the Linux          introduced as a way to stem the control of         expecting those requesting higher status to
Foundation and the Eclipse Foundation –             monopolistic mainframe companies over              commit to investing developers in the
are actually trade associations, with a             their markets, standards organisations             technical work. That’s not to say all public
mission and bylaws that expect them to act          increasingly became the domain of                  benefit open source charities are perfect.
in the interests of their members rather than       corporate politicians. Even nominally              Even the best designed one – the Apache
of the general public. Almost all of the            national standards bodies like BSI or              Software Foundation – has been
proliferation is in this latter category.           international ones like ISO are actually           conspicuously gamed by corporate forces
   What is the value of a Foundation? In both       occupied by career technology politicians          on multiple occasions.
the public benefit and trade association            employed by the largest corporations. The             So take care to disambiguate the term
cases, there are clear benefits when a              result has been regulatory capture – the           “Foundation”, and encourage your employer
project has a large, diverse community. All         mechanism invented to regulate the power           not to start another one if that’s what they
                                                                                                       are thinking. Join an existing Foundation –
    A well designed foundation keeps a                                                                 there are several of both flavours that accept
                                                                                                       new projects – or if they really must make a
    strong separation between the fiduciary                                                            new one, seek specialist advice and focus

    responsibilities and the technical work                                                            first on software freedom. Remember,
                                                                                                       “Simon says ... no new Foundations!”



6                                                               www.linuxvoice.com
                                                                                                      ANALYSIS NEWS



        LibreOffice • Kubuntu • Red Hat + Ansible • ZFS • Pis in Space • KDevelop



CATCHUP                                                        Summarised: the biggest news
                                                               stories from the last month

          New LibreOffice respin                         Kubuntu head honcho Jon                    Red Hat buys Ansible
   1      wins government support                 2      Riddell stands down                 3      Enterprise Linux giant Red
           The flagship open source                       Jonathan Riddell founded                  Hat has snapped up Ansible,
office suite keeps going from strength         Kubuntu back in 2005, and has grafted      makers of the eponymously named IT
to strength. Collabora Ltd has created         away over the last decade to establish     automation software. Red Hat’s goal
a version called GovOffice with extra          it as one of the forefront desktop Linux   with Ansible is to create “frictionless IT”:
migration tools, deployment features           distros. But in recent years he has        http://tinyurl.com/qjrr8dh
and long term support, and the UK              expressed dissatisfaction with Ubuntu
government has said it will “provide           parent company Canonical for its
public sector organisations with savings       handling of IP policies – to the point
on open source office software”. If ODF        that the Ubuntu Community Council
file formats become the norm in the            wanted to boot him out. With the
government, we’d be happy pandas.              release of Kubuntu 15.10, Riddell has
www.collaboraoffice.com/collabora-             left the project, deriding Ubuntu as a
govoffice.php                                  project that “won’t obey its own rules”.




          ZFS to be included in                          DRM coming to JPEGs?                       First beta release of
   4      Ubuntu as standard                      5       Officially “Digital Rights         6      KDevelop 5 available
           Originally developed by Sun                    Management”, but more                     It’s been over a year in the
for its Solaris operating system, the ZFS      commonly referred to in the FOSS world     making, and KDevelop 5.0 is inching
filesystem and logical volume manager          as “Digital Restrictions Management”,      ever closer to release with the first beta.
has since seen widespread usage in             DRM aims to stop people sharing            The code base has been ported to Qt
other Unix flavours, most notably              information. Now the JPEG Privacy and      5 and KDE Frameworks 5, while the
FreeBSD. It features support for huge          Security group is investigating ways to    old C++ parser has been replaced by
volume and file sizes, data corruption         add DRM to JPEG images – stopping          a much more powerful one from the
protection, snaphots and other snazzy          you from copying or saving images you      LLVM/Clang project. Semantic language
features. Until now it hasn’t been             see on the web. We think DRM is simply     support for QML and JavaScript has
included as standard in many distros,          ineffective and a waste of time, and the   been rolled in, and we may even see
but Canonical boss Mark Shuttleworth           Electronic Frontier Foundation has         KDevelop releases on Windows and Mac
has said it will be available for all to try   already started campaigning against it:    OS X at some point.
in upcoming Ubuntu releases.                   http://tinyurl.com/op4lzdw                 www.kdevelop.org




          Raspberry Pis heading to                                                                  Element14 to build
   7      the Space Station                                                                  8      custom Raspberry Pis
           As if the Pi wasn’t already                                                              In other Pi news, distributor
popular enough here on Earth, two units                                                   Element14 has created a new
are now jumping onto a rocket for a                                                       Customisation Service for the dinky
stay on board the International Space                                                     single-board computer. If you’re willing
Station. The Raspberry Pi Foundation                                                      to order at least 3,000 units of your
recently ran Astro Pi, a competition to                                                   custom design, you can reconfigure the
give UK school students the opportunity                                                   board layout, add components such
to develop experiments to run on Pis                                                      as Wi-Fi or extra I/O pins, and even add
aboard the ISS. Seven experiments                                                         onboard flash memory. Element14 will
have been selected and will be carried                                                    guide you through the process and
up to the ISS with ESA astronaut Tim                                                      show you what’s doable (and what’s
Peake on a shiny Soyuz 45S.                                                               not). See here for more details:
http://tinyurl.com/pisinspace                                                             www.element14.com/custompi




                                                        www.linuxvoice.com                                                               7
     DISTROHOPPER LINUX DISTROS




DISTROHOPPER
What’s hot and happening in the world of Linux distros (and BSD!).


(K/X/L)ubuntu 15.10
News from the spin-offs.


Y
         es, it’s that time of year again: a new
         Ubuntu release is here. Ben’s review
         over on page 43 focuses on the
main distribution, but here we’ll explore the
spin-offs. Kubuntu 15.10 features a snazzy
KDE Plasma 5.4 desktop along with KDE
Applications 15.08, while LibreOffice 5.0 and
Firefox 41 make up the major non-KDE
software components. It’s available as a
1.3GB DVD ISO download and system
requirements are a minimum of 1GB RAM
and 10GB hard drive space (although we’d
say double the RAM is much more sensible).
   Meanwhile, Xubuntu 15.10 arrived at the
same time and has also cranked up its
memory requirements (1GB recommended)              Here’s Ubuntu Mate 15.10 on a Raspberry Pi 2. Don’t expect stellar performance, but it is usable.
by dropping the lightweight AbiWord and
Gnumeric applications in favour of                    Over in Lubuntu land, the new distro            15.10, the spin-off that uses the Mate
LibreOffice. Xubuntu has always presented          release is an evolutionary affair as the team      desktop, a continuation of the Gnome 2.x
itself as a RAM-friendlier alternative to (K)      prepares to move to the LXQt desktop in            codebase. This release includes a version
Ubuntu, but LibreOffice is getting snappier        16.04. Some LXDE components have been              optimised for the Raspberry Pi 2. The team
and lighter. Xubuntu 15.10 also includes           updated and artwork has been improved, but         has put in a lot of work to make the distro run
Xfce Panel Switch, making it easier to back        otherwise there’s not a lot to write home          smoothly on the Pi, so you can even use the
up and restore panel layouts.                      about. Oh, and let’s not forget Ubuntu Mate        dinky device as a general-purpose desktop.




CentOS goes 32-bit
No, this isn’t a step backwards – it actually makes a lot of sense.


C
        entOS, the community-supported             useful to have modern, mature and stable
        respin of Red Hat Enterprise Linux,        distros such as CentOS to run on them.
        went 64-bit only with version 7. This      32-bit CPUs are more than capable enough
made sense for most use cases, as 64-bit           for most tasks, especially if you don’t need
CPUs from AMD and Intel have been the              access to more than 4GB of RAM.
norm for many years now. But there have               And then there’s more: supporting a wider
been calls from some CentOS users for a            range of CPUs can often make it easier to
32-bit version that’s more suitable for older      finds bugs and security holes, as the
machines. But it’s not just about decade-old       OpenBSD project has found. The 32-bit
hardware. 32-bit processors are still doing        CentOS 7 release is the work of the project’s
the rounds, such as the Intel Quark system-        AltArch Special Interest Group, and you can
on-a-chip. We can expect to see more of            find out more information, including               CentOS 7’s 32-bit port is a boon for users of
these CPUs in everyday life thanks to the          potential bugs, over at https://wiki.centos.       SoC development boards, and could help to
much-hyped “Internet of Things”, so it’s           org/SpecialInterestGroup/AltArch/i386.             identify tricky bugs too.



8                                                              www.linuxvoice.com
                                                                                                      LINUX DISTROS DISTROHOPPER



News from the *BSD camps
What’s going on in the world of FreeBSD, NetBSD and OpenBSD.


O
         penBSD 5.8 arrived in the middle of
         October, sporting an impressive
         range of updates all over the
system. Along with the usual set of new
hardware drivers and performance tweaks,
there have also been many improvements to
the miniature httpd web server that replaced
Nginx in the base system. It now supports
pattern matching and redirections via Lua,
along with HTTPS HTTP Strict Transport
Security. A new doas utility replaces sudo
and provides enhanced security by being
much simpler, while OpenSSH is included in
this release and has a new default cipher.
   Over in the FreeBSD camp, the team has
produced its latest quarterly status report –
and the longest one ever written, reflecting
the overall good health of the project. Bhyve,
the FreeBSD hypervisor, has seen a lot of
work including support for external firmware,
which allows it to run Illumos (a fork of
OpenSolaris) and Windows in headless
mode. The LLVM/Clang toolchain has been                  Got an old Psion in the loft doing nothing? Get NetBSD 7.0 running on it!
updated to version 3.7.0, while a handful of             (Image credit: http://tinyurl.com/nojmnpy)
developers have grafted away on support
for the Acer C720 Chromebook. Almost                     this final release has been slow, with RC1             EPOC PDAs. (Yes, NetBSD will run on almost
everything works in FreeBSD now, making                  arriving back in June, but 7.0 brings a stack          anything containing a CPU, or someone is
the machine an ideal little laptop for hacking           of new goodies including ARM                           working on porting it.) Most notably for us
on the go. See http://tinyurl.com/pdo35u5                multiprocessor support, accelerated                    Linux users, NetBSD 7.0 now runs on the
for the full report. Finally, we should give a           graphics on x86 boxes using Intel and                  Raspberry Pi, providing an alternative Unix
mention to NetBSD 7.0. Progress towards                  Radeon chips, and a new port for Psion                 flavour to our familiar Raspbian.


  Linux From Scratch 7.8

  If you really want to understand how Linux works – and more specifically,
  how a distribution is put together – you should spend some time with
  Linux From Scratch. As its name suggests, it’s all about creating a Linux
  installation from the bare components, with no fancy graphical installers
  or setup scripts to help you on your way. Linux From Scratch (LFS) isn’t a
  piece of software but rather a book that explains the process step-by-step.
      And it’s a fascinating process to follow. You start off by using an
  existing Linux installation to create a new LFS partition, into which you
  download some low-level toolchain components (such as a C compiler)
  and build them. From here you add system tools and libraries to the point
  of having a workable – albeit very rudimentary – Linux installation. It
  teaches you an enormous amount about how a Linux system boots, what
  all of the low-level components do, and of course it provides you with
  ample opportunity to tweak settings and customise the result. Expect to
  spend many hours working through the various steps, but it’s worth it.
      Linux From Scratch 7.8 was released in early October and includes
  updates to 30 packages including GCC, Glibc and Binutils. In addition,
  there’s a spin-off of the book using Systemd as the init system, although
  the main book still currently focuses on Sysvinit. You can read the book
  online at www.linuxfromscratch.org or download a bzipped archive for
  offline reading. Once you’ve built an LFS system, try some of the other              LFS explains exactly what each component does, how much time it
  books on the website, such as BLFS (Beyond Linux From Scratch).                      takes to compile, and how to build it.




                                                                        www.linuxvoice.com                                                               9
     MAIL YOUR LETTERS




YOUR LETTERS
Got an idea for the magazine? Or a great discovery? Email us: letters@linuxvoice.com


             ANTI-SEX LEAGUE
             The simplest test of a search engine’s openness is a
             search for ‘sex’. I don’t say it as a prurient interest, just as a
             search engines willingness to allow you to find what you’re
STAR         looking for unfiltered, unchaperoned if you will.
LETTER          Much like the differences between Linux and other
             operating systems in its willingness to allow you to
             change aspects of the OS to suit your needs or interests.
             The more adaptable an OS is, the better suited it may be             Oh, and those dastardly Europeans are interfering with our
             to one’s specific needs and interests.                               sovereignty again by outlawing default internet content
                Here in America, you go into the library and ask the              filtering. Perfidious Brussels!
             reference librarian a question, you get an answer. You do
             not get, “Why do you want to know?” or “I’m sorry we don’t           Andrew says: Well, quite. I’m open to the idea that
             provide that information.” or “Could you be more specific?”.         consenting adults can put pictures of themselves
             Maybe search engines are good for the lion’s share of                on the internet in various states of undress,
             searches. When it comes to making moral (or market)                  but I don’t want to see it when I haven’t had my
             choices about what constitutes acceptable, there’s a lot to          breakfast, so some degree of insulation is probably
             be desired. And if they are making moral (or market)                 OK – Google’s safe search is a good idea for most
             choices, their accuracy as well as usability is in question.         people, most of time. But who’s to say what’s
                Granted, the morals of the Middle East, Korea, China              Google’s idea of not safe? Or David Cameron? Or the
             and elsewhere around the world (including the US) are as             Chinese government?
             different as night and day. A search engine that attempts              I bought a book a few years ago called How to
             to please ALL in return for market share ultimately winds            Build an Atomic Bomb and Other Weapons of
             up not really pleasing anyone.                                       Mass Destruction. It’s not beyond the realms of
                I’m an adult. I’m not telling you how to live your life. I        possibility that some people, in certain states,
             don’t want a search engine that tries to tell me how to live         would have a search for this term filtered, or
             mine. If I’m not breaking any laws, I should be able to use          monitored, or brusquely investigated by men in
             a search engine to the fullest extent possible –                     uniform 5 in the morning. Thankfully I paid cash,
             unrestricted. Much the same as the Linux philosophy. Roll            so there’s no way the UK security services know I
             your own.                                                            have it in my possession. It’s very good, but I have
             Mike Moore, USA                                                      yet to use it to build anything.



             IT’S THAT BIRD AGAIN
             This is the second issue of LV where the subject of the              the penguin community for survival. They are also
             penguin logo has come up. I would like to try and                    unafraid of humans. Does not the mighty penguin
             put this to rest and so I respond to Maurice                                resemble what Linux is all about? Happy, content,
             George (LV019).                                                                  relying on each other for support… there’s no
               I have been hacking Linux since                                                   boss or leader but a very close knit
             1992 when Linux was only a green                                                       community helping each other. Finally,
             cursor blob on the computer                                                             should not Linus Torvald be the one to
             screen. Now I am only going by                                                           decide if the logo should be changed?
             memory but I believe that Linus                                                           Eugene Wong
             Torvalds chose the penguin
             because they are the only                                                                 Graham says: Right, that’s enough
             creatures that do not have a                                                              of this penguin stuff. Please let’s
             leader but rely on each other and                                                        just move on as a society.



10
                                                                                                           YOUR LETTERS MAIL


DOCUMENTATION                                                                                                                Qt is the gold
                                                                                                                             standard, the
                                                                                                                             Rolls Royce,
I was a little disappointed when I came to the end of your
                                                                                                                             the Duisenberg
article on Syncthing as it did not include the idiots’ guide to                                                              of Linux
setting up on a headless computer/server, however the                                                                        documentation.
Syncthing documentation and forum answers are really
good and, I think, worthy of note.
   I wondered if a documentation rating would be a useful
addition to the magazine. Would it prompt some others to
improve their documentation for the benefit of as aspirant
nerds? Also, I would be grateful for the occasional sidebar
of explanation with some of the more advanced articles             if you like, and it’s one reason we’ve never done
and; and what about a small glossary to your interviews            a tutorial on developing with Qt Creator, for
with really clever buggers?                                        example: the documentation is already excellent,
   Don’t want much then?                                           and, crucially, it’s easy to find a definitive guide.
   Thanks for the intro to Syncthing, should have it running       Likewise Syncthing.
this weekend once I have sorted Bug #720.                             Some sort of comparison of documentation
Paul, Farnham                                                      would be a worthwhile feature, if we did it right
                                                                   – most Free Software developers provide their
Andrew says: I’ve always considered it part of                     work free of charge, and it’s wrong to stamp our
our job to compensate for the often rubbish state                  tiny feet when the docs aren’t very good. We need
of documentation in Free Software by providing                     to remember that, and be constructive. Regarding
documentation ourselves. It’s a gap in the market,                 glossaries in interviews: I like it. Thanks!



WELCOME, COMRADE
I was a bright-eyed Linux newbie when picking up your              evaluated this decision. Is there a more appropriate
magazine from #1. Since then I’m now confident enough              distribution for me? How would I go about deciding what
to say that “I kinda know what I’m doing on a GNU/Linux            is the most suitable distribution for my application?
box”, so thanks. I read the Distrohopper section each              noisyboiler
month with interest and wonder how I can possibly figure
out the best distribution for my application – because             Andrew says: If you’re happy with it, then Ubuntu is
there are so many out there!                                       the right platform for you. It’s not for everyone, but
   My stack is Python 2, RabbitMQ, MySQL and SOLR, and             it’s used as a server platform by loads of massive
I pay a cloud solution for the pleasure of this. This is on a      companies, so you’re in good company. Keep the
GNU/Linux server and I have grabbed the most accessible            faith (but you might as well try Mint, and Mageia,
distro out there for a newbie (Ubuntu) but have never really       and Fedora, and Arch…)




                                                                  www.linuxvoice.com                                                      11
     SUBSCRIBE




Subscribe
shop.linuxvoice.com

                                                                        Get your regular dose
                                                                        of Linux Voice, the
                                                                        magazine that:
                                                                          Gives 50% of its profits
                                                                        back to Free Software
                                                                          Licenses its content
           SUBSCRIBE TO                                                 CC-BY-SA within 9 months
                                                                          US/Canada subs prices
           TODAY!                                                         1-year print & digital: £95
                                                                          12-month digital only: £38


        Get many 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.

12                                                         www.linuxvoice.com
                                                                       SUBSCRIBE


                                All subscribers get access to every
                                single digital back issue –
                                that’s about 1,000,000 words of
                                tutorials, reviews and free software
                                hackery at your fingertips




Overseas subs prices
12-month print & digital:
Europe: £85
US/Canada: £95
Rest of world: £99                               DIGITAL
                                                 SUBSCRIPTION*
                                                 ONLY
                                                  *
                                                      £38
                                                     WHEREVER IN THE WORLD YOU
                                                   ARE – IT’S DIGITAL, SO THERE ARE
                                                          NO POSTAGE COSTS


                            www.linuxvoice.com                                        13
     FEATURE USE LINUX SMARTER




             Whether you’re a Linux beginner or a certified expert, we’ve put
             together a collection of the finest tips known to Gnumankind.


         L
                  earning Linux is a lot like learning how to solve   solution, as with achieving Linux enlightenment, is to
                  the Rubik’s Cube. In the beginning, It can look     build on layers. When you’ve nailed your first
                  inaccessible and complicated. Even knowing          solution, go back to refine your reflexes, strengthen
          where to start is a challenge. But after installing your    your finger muscles and commit new algorithms to
          first distribution and moving on to your second, it         memory. Which is exactly what we’re going to do
          gets easier. It’s the equivalent to the classic             here – sending nuggets of speed, efficiency, wisdom
          beginner’s strategy to the Rubik’s Cube – solving           and knowledge back to our former selves, enabling
          one side of the cube followed by another. But the           anyone to level-up their Linux skills.



14                                                       www.linuxvoice.com
                                                                                                      USE LINUX SMARTER FEATURE


                                                                                                                   Give Home a permanent home
                                                                                                                           The one thing all of us like to do
                                                                                                                           is install more than one Linux
                                                                                                                   distribution, whether that’s by running two
                                                                                                                   instances of Linux at once, or replacing one
                                                                                                                   with another release. To make this as hassle-
                                                                                                                   free as possible, we’d recommend creating
                                                                                                                   a separate Home partition when you install
                                                                                                                   your first distribution. Home is where all your
                                                                                                                   personal data lives, as well as your various
                                                                                                                   configuration files, caches and libraries, and
                                                                                                                   putting it on its own partition means you
                                                                                                                   can share this data across multiple installed
                                                                                                                   distributions, and keep your data safe when
                                                                                                                   you install a new distribution or upgrade an
                                                                                                                   old one.
                                                                                                                      The process for creating and selecting
                                                                                                                   a Home partition is different for each
                                                                                                                   distribution, but in all of the, you’ll need
                                                                                                                   to select a custom partitioning scheme
                                                                                                                   from the installer. In Ubuntu, for instance,
                                                                                                                   select ‘Something Else’ . Add at least a root
                                                                                                                   partition with a / mount point, followed by
                                                                                                                   a /home partition/mount point, and a swap
                                                                                                                   partition. We’d recommend making swap
                                                                                                                   the same as your RAM, root between
                                                                                                                   10–100GB (depending on your usage)
                                                                                                                   and more for home.

Put back missing features in your desktop
     Both Ubuntu and Gnome are well known for
     removing options, but you can get back a lot
more control by installing their associated Tweak
Tools. For example, Ubuntu’s will enable you to
disable Amazon searches, switch the window                                                                         Don’t forget: disable the ‘format’ option
                                                                                                                   when selecting an old Home partition.
control buttons to the right or adjust the size and
transparency of the launcher.
 Install/enable SSH                    Use keyboard shortcuts               Our favourite shortcuts




                                                                                                                 To enable automatic update in Ubuntu,
         The one essential daemon              There’s a good reason                After a quick office poll,   open the Software & Updates panel.
         that needs to be running on           Ubuntu displays common               here are four of our most
 any machine, whether it’s brewing     shortcuts when you first get         commonly used shortcuts:             Update everything automatically
 beer, a Raspberry Pi or a remote      to the desktop – using them             Ctrl+C/X/V Everyone knows                You only stop being vulnerable to
 server, is SSH server. The package    will transform your experience.      these – cut, copy and paste.
                                                                                                                        a security flaw after you’ve
 will often need to be installed       Learning just a few shortcuts for       Alt+Left Click With Alt held
 separately, as with Ubuntu.           your desktop, your browser and       down, drag any window without        updated your system. Unless you want
     With the SSH daemon/server        the command line will make you       clicking on the title bar.           to keep abreast of every threat, it’s
 enabled, you can fix almost any       faster and more efficient. More         Ctrl+wheel Zoom in/Zoom out.      easier to turn on automatic updates.
 problem remotely without              importantly, you’ll look awesome.    Works almost everywhere, from        Ubuntu can download and install
 re-installing, or connecting          All desktops enable you to change    icon sizes in the file manager to
                                                                                                                 them automatically, for instance, and
 screens and keyboard, or even         the defaults, so it’s also worth     LibreOffice and web pages.
 fixing PCs when the video or          making your shortcuts map to the        Ctrl+W/Q. Close windows and       unlike Windows 8, you’ll always
 display is messed up.                 same keys across all applications.   tabs with W; quit apps with Q.       be notified before an upgrade.




                                                                     www.linuxvoice.com                                                                       15
     FEATURE USE LINUX SMARTER


                                                                                               Gnome Do everything
                                                                                                         Gnome Do is one of those little-known
                                                                                                         utilities you’ll wonder how you ever
                                                                                               lived without. It’s a shortcut to launching
                                                                                               applications, searching your desktop and
                                                                                               the web, playing music, updating social
                                                                                               networks, sending email, and doing almost
                                                                                               anything else as long as there’s a plugin
                                                                                               for it. It does all this from a super simple
                                                                                               keyboard shortcut, which is Super+Space by
                                                                                               default (the Super key is usually the one with
                                                                                               the Windows symbol on it).
                                                                                                   Perhaps the reason Gnome Do isn’t more
                                                                                               widely used is that it’s not obvious how it
                                                                                               works. After launch, Gnome Do appears as
                                                                                               two large squares. The first will hold the
                                                                                               result of what you start searching for, while
                                                                                               the second holds the action. Search for a
                                                                                               file, for example, and the action will default
                                                                                               to ‘open’. You can page through the list of
                                                                                               results by cursoring down, and you can
                                                                                               change actions by tabbing across to the
                                                                                               other square and using the cursor
                                                                                               keys again. It’s quick, powerful and can
                                                                                               replace your launcher and speed up the way
                                                                                               you work.
Install a different theme/font/icon/colour scheme
      We know that appearances are only skin
      deep, but giving your desktop a new look is
like putting a fresh lick of paint on your shed: it
gives you a new perspective, and makes you feel
like getting out/in there and making the most of it.
In particular, we love the new Google-inspired
                                                                                                Gnome Do works brilliantly with the
‘Paper’ theme for GTK/Gnome/Unity and ‘Papirus’                                                 Conky desktop application launcher.

for the KDE desktop.
                                          7 Incredible KRunner Shortcuts
Matthew Garrett                                  Like Gnome Do, KRunner is a
Freedom advocate and security engineer.          command-driven launcher,
                                          opened from KDE by pressing Alt+F2.
                                          Here are some of our favourite features:
                                            Web shortcutsType wp: to search
                                          Wikipedia and open the results in your
                                          default web browser.
                                            Calculator Precede a calculation with
                                          = to see the answer, eg =3*sin(90).
                                            Pervasive search Type the beginning
                                          of an application or file to open it.      Dynamic backgrounds
                                            File manager Typing file:Downloads
                                          opens a file manager for the
                                                                                            In Unity, select images in
                                          Downloads folder.                                 Shotwell and select
                                            Messaging Type the name of a                    ‘Desktop Slideshow’ from
       Forgot to type sudo before a       contact to initiate an IM conversation.
       command? sudo !! will re-run         Amarok remote Control playback           the File menu. The desktop will
the previous command under sudo.
But not just sudo: it can be used to
                                          with Play, Pause and Next.                 cycle through the slideshow, and
                                            Desktop control Type desktop 1 to
precede the previous command with
whatever comes before the !!.             switch desktops, or try logout and
                                                                                     the panel and window colours will
                                          shutdown.                                  also change.

16                                                        www.linuxvoice.com
                                                              USE LINUX SMARTER FEATURE

Use a clipboard manager
       Copy and paste is fundamental
       to the way we use computers.
Linux is already ahead of the game in
the way you can select text with your
mouse and paste it with a simple click
of the middle mouse button, but you
can do so much more.
   Install a clipboard manager like
Glipper or KDE’s Clipboard and you can
access any of your previous cuttings,
reselect them, and paste as usual.
But you can also do clever things like
perform an action when you copy
something specific, or use a regular
expression to modify the data
for pasting.




                                                                    Vimerise Firefox shortcuts
                                                                            There are many addons for
                                                                            Firefox, but the first we install is
                                                                    VimFx. This will default all Firefox
                                                                    keyboard shortcuts to keys familiar to
                                                                    any Vim user, such as O for opening, X
                                                                    to close, GG/Shift+G for top/bottom
                                                                    and ‘/’ for searching. Press F and every
                                                                    link is overlayed with a new shortcut for
                                                                    easy navigation – mouse free!



                                                                      Ben Nuttall
                                                                      Education advocate at Raspberry Pi.

Manage your audio levels with Pavucontrol
      Nearly every Linux distribution now
      defaults to PulseAudio for audio duties, but
they provide little control over how volumes and
devices are configured. If you need to see what’s
going on, and give yourself more control, install
the sparse but powerful Pavucontrol tool. It lists
every application generating sound and enables                                 On the command line, Alt + . (Alt
you to change the audio device or output used by                               and full stop) places the last
                                                                      argument of the previous command into
each one, as well as visualising the levels and                       your current position. For example, if
                                                                      you’ve just entered mkdir bob, type cd and
giving you control over the volume. You can also                      hit Alt + . and your command will now be
                                                                      cd bob. It’s got history too, so keep hitting
set application-specific default devices.                             “.” to get the one before.


                                         www.linuxvoice.com                                                       17
      FEATURE USE LINUX SMARTER


Pro Tip: Graham Morrison
Magazine editor and amateur musician




        If you’ve ever been in the dire
        situation of losing your partition
table, perhaps after a wayward dd command,
the testdisk utility is the best way I’ve found
                                                   Use your desktop’s best feature: Virtual Desktops
to recover your data. Run it from a live CD/
USB drive and choose the Analyse option.
                                                        Every operating system seems to have
With a bit of luck it will find and restore your
precious data.
                                                        virtual desktops now, but that’s because
                                                        they’re awesome, and Linux still has the
                                                   most powerful implementations. You can, for
                                                   example, configure your setup so that emails
                                                   always launch on desktop 3, or use a tiling window
                                                   manager to organise each desktop by task – say,
                                                   accounts in one desktop, personal in another
                                                   desktop, and real work in another. Save yourself
Get a password manager                             from a having to buy a second screen and work
        Passwords have never been
        more important, which is why               from anywhere.
they should all be random and unique.
But that obviously makes them                       Dual and triple displays              Learn Vim, finally                    Essential Bash shortcuts
impossible to remember. This is what a
password manager is for – it’s a single
repository locked by a strong
memorable password (or two-factor
authentication), which then gives you
access to your other passwords.
   All the main desktops integrate their
own, but your passwords are non-                             Linux now mostly works               Linux users do a lot of               Here our three essential
transferable, not available on other                         with second and third                text editing, and while GUI           tips to getting the most out
computers, and not on your phone. The               displays thanks to the X extension    editors are great, nothing beats      of the command line:
solution is to use a portable password              for multiple displays configuring     Vim for being able to edit files        Ctrl+R. <command>. Search
                                                    itself correctly. However, we’ve      direct from the command line,         command history and auto-
manager or a remote password store.
                                                    found nothing to beat the             whether that’s on a server, your      expand the same command.
KeePass is our favourite, because you               flexibility and performance of        desktop or a Raspberry Pi.               Ctrl+A, E Respectively, these
can keep it on a USB drive and there are            Nvidia’s proprietary drivers and         Vim is one of the most powerful    go to the beginning and end of a
open source Linux and Android clients.              their ‘TwinView’ implementation.      editors ever created, but it uses     command. Meta B and F will also
You only need a copy of the database                Use the nvidia-settings tool that     lots of keyboard shortcuts. To        move between words.
                                                    comes with these drivers to enable    make learning easier and fun,            Ctrl+U, P The first will cut from
to access your passwords. But we also
                                                    TwinView and edit the settings for    we highly recommend a website         text before the cursor (great for
really like the pass tool, as it simply             both connected monitors and the       called Vim Adventures. It makes       mistyped passwords); the latter
uses GnuPG encruption and the Linux                 dual display without restarting the   you play a game to learn Vim’s        will paste this buffer before the
filesystem to do a similar job.                     desktop session.                      various intricacies!                  cursor.



18                                                                   www.linuxvoice.com
                                                                                            USE LINUX SMARTER FEATURE


                                                                                                       Grab extra software
                                                                                                               Most distros come with plenty of
                                                                                                               software in their repositories, but
                                                                                                       if you find yourself needing something
                                                                                                       that’s not already available (or a newer
                                                                                                       version of a piece of software), most distros
                                                                                                       have alternative community-maintained
                                                                                                       repositories.
                                                                                                           Arch has the Arch User Repository (AUR),
                                                                                                       which has a frankly mindblowing array of
                                                                                                       software. Red Hat and Centos have the
                                                                                                       Extra Packages for Enterprise Linux (EPEL)
                                                                                                       repositories, which contain mostly server
                                                                                                       software that isn’t supported by Red Hat.
                                                                                                       Ubuntu has Personal Package Archives
                                                                                                       (PPAs) hosted on Launchpad, which are
                                                                                                       basically mini repositories that you can add
                                                                                                       for each piece of software.



Run Windows software on Linux                      that has pre-set configuration files for
       There’s a great range of software           loads of common programs that make them             Save time with aliases
       available on Linux, but every once in a     really easy to install and run. It was originally            You may find that there are certain
while we find ourselves needing something          designed for games (hence the name), but                     commands you end up running very
                                                                                                       frequently. You can use aliases to save
that will only run on Windows. For this scenario   now it includes a range of programs,
                                                                                                       shorted versions of these commands to
there’s Wine, a compatibility layer that enables   including office software and development           make them easier to access. The format for
Windows executable files to run on Linux, but it   tools. Thanks to an intuitive interface,            this is:
can be difficult to set up. Fortunately, there’s   getting this software on Linux takes just           alias <newcmd>=”<cmd to run>”
also Play on Linux. This is a wrapper for Wine     a few clicks.                                       So, if you constantly find yourself wanting
                                                                                                       to view the full details of all the files in a
                                                                                                       directory (ls -la), you can use:
                                                                                                       alias la=”ls -la”
                                                                                                       Now, whenever you type la, Bash will run
                                                                                                       ls -la. If you want this to stay every time
                                                                                                       you restart Bash, you need to add the alias
                                                                                                       command to the end of your ~/.bashrc file.




                                                                                                       Pro Tip: Alan Pope
                                                                                                       Ace community manager at Canonical




Relax your mind                                                                                                 Often I’ve wanted to look at the
                                                                                                                source code for something installed
     Humble Bundles are pay-what-you-want                                                              on my Ubuntu system, but don’t want to
                                                                                                       have to go looking for it online in Launchpad,
     collections of DRM-free indie games for                                                           Bitbucket, GitHub or Sourceforge. With
                                                                                                       Debian-based systems you can get the
Linux, Windows and Mac OS X. They’re a great                                                           source package that was used to build
                                                                                                       the binary of whatever is on your system,
value source of entertainment                                                                          including patches, like this: apt-get source
                                                                                                       firefox. Reading and understanding the
(www.humblebundle.com).                                                                                source is of course another matter…



                                                             www.linuxvoice.com                                                                     19
      FEATURE USE LINUX SMARTER


REISUB
        Shhh, don’t tell the Windows and Mac
        users, but sometime Linux crashes,
and sometimes it crashes hard. Not very
often, but once in a while the screen will lock
up, and nothing you can do with keyboard or
mouse seems to do anything.
   The last-ditch option is the magic SysRq
key combination. If you hold down Alt and
Print Screen (also known as SysRq) then
press R,E,I,S,U then B, your system will
restart a little safer than just powering down
(which can corrupt data). These key presses
correspond to (in order):
  Switch keyboard to raw mode.
  Ask all processes except init to finish.
  Kill all unfinished processes except init.
  Sync all mounted filesystems.
  Remount all filesystems as read-only.
  Reboot.
   If you’re having trouble remembering this,
some people find the mnemonic ‘Reboot
Even If System Utterly Broken’.                   Join the web
                                                        If you’ve got a spare Linux machine, you can
                                                        use it to host a website. Most distros include
                                                  a web server (such as Apache) that can easily host
                                                  pages, and with a dynamic DNS system you can
                                                  get a domain name to point to your home internet
                                                  connection. Using these, you can become your
If you need a more whimsical way to
remember the REISUB sequence, try: ‘Raising       own web master and share your passion with the
Elephants Is So Utterly Boring”.
                                                  world, make your fortune by starting the next
                                                  Google, or make some of your data available when
                                                  you’re away from home.
Pro Tip: Mike Saunders
Creator of the famous MikeOS                      Monitor your system
                                                         The top command is well known
                                                         for providing a real-time overview
                                                  of which software is using the CPU and
                                                  memory. As well as providing a broad
                                                  overview, it gives detailed statistics for
                                                  each process. This style has inspired
                                                  other commands to monitor
                                                  performance . Our four favourite are:
                                                    iftop displays detailed information
                                                    about how much data is going
                                                    through your network port.                 Report bugs
                                                    ptop and mtop help you monitor your
                                                    PostgreSQL and MySQL databases.                 When you find a bug
                                                                                                    in open source
       You can turn any machine with SSH
                                                    virt-top supplies all the latest
       access into an instant web proxy
                                                    information on how your virtual
                                                                                               software, don’t ignore it.
server with this command:
ssh -N -D 0.0.0.0:8888 user@hostname                machines are performing.
                                                    apachetop provides detailed
                                                                                               Report it to the developers
In your browser, go to connection settings
(eg Advanced > Network > Settings in                information about how your Apache
                                                                                               and help them make the
Firefox) and use 127.0.0.1 (your local IP)
                                                    web server is performing.
as the SOCKS host, and 8888 for the port.
                                                    iotop keeps an eye on your disk
                                                                                               software even better.
Browsing will now be via the SSH machine.
                                                    performance.



20                                                                 www.linuxvoice.com
                                                                    USE LINUX SMARTER FEATURE


                                                                            Pro Tip:Nick Veitch
                                                                            Publishing legend




                                                                                    Virtual machines are your friends!
                                                                                    The overheads to using them are
                                                                            practically non-existent these days and mean
                                                                            you can easily separate your home desktop
                                                                            with all the things which you critically need
                                                                            to work from dangerous nonsense – strange
                                                                            network services, experimental kernel
                                                                            options, different distros, silly software
Listen to podcasts                                                          which requires at least half a dozen unstable
                                                                            versions of libraries to run and anything that
      Podcasts are a great way of learning more                             Mike had a hand in.

      about Linux, providing as they do the facility
to pipe information and entertainment directly
into your ears as you commute, or do your weekly
shop. There are loads of options, from the
confrontational Bad Voltage, to the melodic
Ubuntu UK Podcast, to the joyfully stuck-in-the-
mud Linux Luddites – and don’t forget the
fortnightly Linux Voice podcast, which the team                           Find the missing manual
somehow find time to record when they’re not                                     Almost every piece of command
                                                                                 line software comes with a
making this magazine.                                                     manual that’s full of information (know
                                                                          as the man page). You can get the man
Virtualise new distros                                                    pages with the command:
        There are hundreds of different                                   man <command>
        distros out there, so how do you                                  There’s a particular style and format for
know which one is right for you? The                                      man pages, which can take a little
best option is to try a few out, this can                                 getting used to, so it’s a good idea to
be time consuming.                                                        become familiar with the manual before
   Fortunately there’s a quicker way:                                     you need it. One of the best features of
virtualisation. Using a tool like VirtualBox                              the manual is that it doesn’t rely on the
or KVM you can create virtual machines                                    network, so you can always get the help
that enable you to boot a distro from                                     you need – great for then you’re stuck
within your currently running machine.                                    with a knotty problem and can’t get
The downside of this is that the system                                   access to the internet.
you’re testing won’t be as snappy as it                                     How do you learn how to use man?
would if it were running natively, but                                    Why with the man page of course!
sidestepping the need to push the file                                    Get started in your journey to manual
onto a USB stick and reboot makes it                                      mastery with:
much faster to try new distros.                                           man man



                                               www.linuxvoice.com                                                     21
      FEATURE USE LINUX SMARTER


Edit images with commands
        If you have a lot of photographs,
        making edits to them can be time
consuming: resizing them to save space,
correcting for a problem with the camera
or rotating them. It all takes time. Rather
than go through each photo individually in
graphical editing software such as Gimp,
you can so everything from the command
line using the ImageMagick tools. The most
useful of these is the convert program, which
takes a file, edits it and creates a new image.
   There are a huge array of options (far
too many for us to cover here), but a simple
example of creating a numbered thumbnail
from every PNG file in a directory is:
convert ‘*.png’ -resize 120x120
thumbnail%03d.png


Dmesg reporting
        If you’re having trouble with hardware,
        the most useful source of information     Use a BSD                                            Linux. By using both Linux and a BSD, you can
is the kernel message buffer, which is
                                                         This might sound like an odd tip to help      get a better feel for the decisions Linux distros
displayed with the command dmesg (you
can pipe it into less to enable you to scroll           you become a better Linux user, but it         make, and decide for yourself if you think
through, or grep to search for a particular       can be a useful point of comparison. If you’ve       they’re good or bad.
word). The kernel message buffer includes         only used Windows, OS X and Linux, then                PC-BSD and GhostBSD are great options
all the messages from kernel drivers that         you’ve missed a whole genre of free software         for your first try, as they’re both built with
are controlling the hardware, so if there’s
                                                  OSes to help you understand computing.               desktop users in mind. FreeBSD is also worth
anything awry in this area, you should see
evidence of it in the output from dmesg.          BSDs, as the other major open source                 considering if you’re planning on using your
    Dmesg is also useful for debugging the        Unix-alike, provide a really useful counterfoil to   BSD machine as a server.
boot sequence. All those messages that
appear on the screen as your distro starts
(when you press Esc to hide the splash
screen) are safely stored here, so you can
find out what happened when you started
your machine.




Pro Tip: Ben Everard
Author of the best Raspberry Pi book.




                                                  Calibre newsfeeds
                                                        You can create ebooks automatically from
       When picking your Linux setup,
       remember that cutting-edge distros               web pages or RSS feeds. Just point the
force you to update a lot, while stable
distros can have older software. Decide what      Calibre application at the sites you’re interested in
balance between the two aspects is right
for your needs and find a distro that makes       and it will grab content for you to enjoy offline on
the same compromise. Despite what some
zealots might say, there is no perfect choice.    your eReader or smartphone.

22                                                                 www.linuxvoice.com
                                                                                                         USE LINUX SMARTER FEATURE


                                                                                                                       Pro Tip: Matthias Kirschner
                                                                                                                       President, FSF Europe.




                                                                                                                               I write as much text as possible in
                                                                                                                               my preferred editor. I use the same
                                                                                                                       editor – in my case “the editor of the beast”
                                                                                                                       (Vim) – for emails, personal notes, press
                                                                                                                       releases, FSFE briefings/statements, blog
                                                                                                                       entries, etc; There was a time when this was
                                                                                                                       impossible to do with with text fields in the
                                                                                                                       web browser, like editing wiki pages, writing
                                                                                                                       online comments, or some blog systems.
Meet fellow Linux users                                                                                                The Firefox/Iceweasel extension ItsAllText
                                                                                                                       solved this problem: it adds a button on text
      We don’t know of a better way to                                                                                 fields in your browser. When you click on it, it
                                                                                                                       opens your preferred text editor, and you can
      experience the Free Software community                                                                           edit the text with your beloved shortcutsand
                                                                                                                       no need to copy and paste.
than by meeting fellow geeks. There are Linux
User Groups (LUGs), events and meetups around
the world where people come together to chat
Linux and maybe have a beer or two – a couple of
our favourites are OGGCamp in the UK and
FOSDEM in Belgium.
 Recover deleted files                  The clipboard in the CLI              Commandlinefu
                                                                                                                     Remote access
                                                                                                                             As Linux users, we spend quite a
                                                                                                                             lot of our time remotely accessing
                                                                                                                     other Linux machines. Here are our top
                                                                                                                     five tips for remote access.
                                                                                                                        Transfer files using rsync with the
                                                                                                                        --partial flag and you can resume
          We’ve all had that horrible          Copy and paste are two                  Want more command                failed transfers.
          sensation of a slipped               invaluable commands in                  line tips? The website           The MObile SHell (Mosh) is a wrapper
 finger on the mouse, or an             graphical applications, and they      www.commandlinefu.com has a               for SSH that’s designed for unstable
 accidental command, and all            can be useful at the command line     list of user-submitted tricks for         internet connections such as via a
 of a sudden you’ve deleted an          as well. The command xsel can be      your perusal and enjoyment.
                                                                                                                        cell phone.
 important file. All is not lost,       used to pipe data in and out of the       There are lots of useful tricks,
 however, and with a little luck you    clipboard. As a quick example, you    as well as some frankly odd               The terminal multiplexer (Tmux) has
 may be able to get the deleted         can copy a list of the files in the   options. Ever wanted to watch             many tricks up its sleeve for
 files back.                            current directory with:               Star Wars in the terminal? Or how         maintaining terminal sessions even
     First, make sure you don’t write   ls | xsel --clipboard --input         about querying Wikipedia via              when you end a connection and
 anything else to disk. Shut down          You can Ctrl+V the list into a     DNS? If you have, then you’re in
                                                                                                                        re-establish it.
 the machine and reboot with a live     graphical application, or send        luck. Whether you’re a terminal
 distro if possible, then try either    data the other way by using the       newbie or a greybeard, you’ll find        Passwords are insecure, and it’s
 extundelete or photorec to recover     --output flag.                        some new and interesting tricks to        far safer to use certificate-based
 the lost files.                                                              improve your skills.                      SSH logins.



                                                                        www.linuxvoice.com                                                                         23
     FEATURE GEEK’S CHRISTMAS




GEEK GADGET                                                                                                 You can never have
                                                                                                            enough gadgets. Nor



GIFT GUIDE
                                                                                                            can your friends – and
                                                                                                            we’re here to help you
                                                                                                            all decide what to get
                                                                                                            for each other.


T
         here are certain times of the
         year (maybe one is close?),
         when a convenient list of                          01                                                                     03
lovely things for any Linux or
open source geek comes in
handy. And as we’ve looked at
rather a lot of this stuff over the
last 22 issues, now is the perfect
excuse to revisit and revise some
of those items, as well as look at a
few new things, for anyone
looking for inspiration. If
you’re not looking for
inspiration, but would like to
inspire someone else, why
not circle a couple and leave
these two pages open
somewhere prominent?




                            02



              01
                              Google Cardboard              recommending spending a few meagre              and probably a case. And for a chance
                              (from £4)                     pounds more on a proper comfortable             to win one, turn the page.
                              If you’ve already got an      plastic enclosure.                              https://www.raspberrypi.org
               Android phone, this low-cost virtual



                                                            02                                              03
               reality headset is an absolute blast. It                  Raspberry Pi 2 Model B                         Ubuntu Phone (from £125)
               relies on your phone for everything                       (£30)                                          Despite Canonical’s
               – from the gyroscopes, which are used                     We’re sure you’ve already                      touch-based portable
               for head tracking, to the screen, which      heard about this serious upgrade to the         operating system not quite hitting the
               is split into two and focused onto your      all-conquering Raspberry Pi, but we’re          mark, and facing an uphill adoption
               retinas through a couple of cheap            even more enamoured by its                      struggle, we can’t help but admire the
               plastic lenses.                              capabilities after a few months of using        company’s young pretender to the
                  For something so hackneyed, the           it in our own projects. In particular, it’s a   smartphone throne. The OS itself is
               experience is fantastic. Just install any    brilliant media player, especially with         doing great things, with the long-
               ‘Cardboard’ apps via Google Play and         XBMC/Kodi. For lots of content, you still       awaited convergence mode making an
               you’ll find yourself fully immersed in the   need the hardware MPEG-2 decoding               appearance, and it’s more open than
               Tuscan countryside, standing on              unlocked (this costs a couple of pounds         Android. We’d suggest an Ubuntu
               mountaintops, shooting along a roller        via raspberrypi.org), but this revision         Phone is ideal of you want an open
               coaster or exploring an Egyptian tomb.       can easily stream HD material without           source device for tinkering, and we’d
               Google’s original origami cardboard          hitting the CPU, making it much cooler          recommend a more
               hurts your nose and doesn’t hold the         and more stable. As always, you’ll also         powerful device for this reason.
               phone adequately, so we’d                    need a quality power supply, USB hub            www.ubuntu.com/phone



24                                                            www.linuxvoice.com
                                                                                             GEEK’S CHRISTMAS FEATURE
                                           04
                                                                                          05




04
             BitScope (from £94)
             Oscilloscopes are very cool.
             They visualise the
intricacies of varying voltages passing
through a circuit, turning what’s
theoretical into something you can see.
They’re also incredibly useful for
synthesizer technicians and musicians,
as those audio voltages will also reveal
the constituent waveforms within an             06                                                                                  07
audio path. BitScope’s headless designs
feature Linux support, using your
desktop or even your Raspberry Pi as
the screen. They’re also excellent logic
analysers – visualising the binary            works brilliantly with Valve’s own
signals sent from integrated circuits.        games but takes some getting used to
For oscilloscopes with this kind of           for others. Either way, it’s the cheapest
power, they’re excellent value for money.     way to join the Linux games revolution.
www.bitscope.com                              http://store.steampowered.com/
                                              hardware



05
              Kobo Aura H20 (£140)



                                              07
              We love electronic readers.                   LibreBoot X200 (from
              We read dozens of books                       £290)
via their silky backlit e-ink screens every                 This is the most expensive

                                                                                           08
year and we put a lot of love into our        item we’re looking at here and, as such,
own ePub editions specifically for that       won’t be an impulse purchase. But if
purpose. And while it’s a shame we            you care about Free Software, it’s
know of no open source reader, the            still great value.
Kobo Aura H20 supports all DRM-free              The X200 is a reconditioned
formats, works with Linux and has a           Thinkpad overhauled with a
screen to rival the latest Kindle – plus,     software stack endorsed by the Free
you can read it in the bath. Dare we also     Software Foundation. This includes
mention it’s the perfect accompaniment        LibreBoot as a BIOS/UEFI firmware
to a new Linux Voice subscription?            replacement, and Trisquel GNU/Linux
http://kobo.com                               as the operating system. Technically,
                                              the machine is more than adequate



06
              Steam Controller (£40)          with perhaps just the screen falling        into a spare USB port, requires no
              We’ve not had a chance to       below modern HiDPI standards (it’s a        external power and no special drivers.
              play with one of Valve’s        12.1″ 1280×800 TFT LCD display). Even       Since our review in issue 9, the price
official boxes yet, although we’ve been       more impressively, profits from sales       has been lowere, making it even better
running our own Steam Box since the           will fund the LibreBoot project.            value against its competition, and it’s
launch of SteamOS. We still can’t quite       http://minifree.org                         the only quality DAC we’ve found that’s
believe it lets us play AAA games,                                                        completely open source. Admittedly,



                                              08
natively, on Linux, and the situation is                   Henry Audio DAC (approx.       you’ll need some serious DSP
only going to get rosier now you can                       £160)                          programming skills to make this
buy officially endorsed Steam PCs. A                       If you love music, and         relevant, but there’s already a huge
central part of this strategy is Valve’s      listen predominately from CDs or Flacs,     community built around the SDR-
new controller, which uses two circular       this high-quality digital-audio-converter   Widget, which is exactly what the USB
touchpads to emulate the                      (DAC) is a great upgrade over your          DAC 128 Mk II is built around.
responsiveness of mouse control. This         computer’s inbuilt audio output. It plugs   www.henryaudio.com



                                                               www.linuxvoice.com                                                   25
     COMPETITION WIN LOADS OF COOL STUFF




     Win!
                                                                            BOOTY
                                                                            WORTH
                                                                            £4,250!
        We’ve got together with the great folks
        at Pimoroni to give away lots of lovely stuff.
        We’re good friends with Pimoroni (it stands for        from its home in Sheffield. Its Picade, the brilliant
        Pirate, Monkey, Robot, Ninja). We spoke to them for    Pi-based table top arcade machine, was the UK’s
        one of our first interviews in 2014, and since then    first Kickstarter project, and the company now
        they’ve moved to new premisies and continued           makes lots of other ingenious ‘HATs’ for Raspberry
        to be hugely successful. Pimironi’s success has        Pi, augmenting Pis with everything from piano
        mirrored that of the Raspberry Pi – the company has    keyboards to migraine-inducing flashing lights.
        sold over 150,000 of its Pibow Raspberry Pi cases,     Which is why we’ve partnered with them to give
        and now sells more than 1,000 different products       away dozens of their best gadgets!




           5 x Raspberry Pi 2 + Pibow
           Coupe, Picade (including
           8-inch screen)
           5 x Raspberry Pi 2 + Pibow
           Coupe, Picade Console
           5 x Raspberry Pi 2 Starter
           Kit, Piano HAT, Display-O-
           Tron HAT, Unicorn HAT and
           Explorer HAT Pro + Parts Kit



           Pimoroni’s lovely cases
           accomdate their HATs, such
           as the Piano HAT and the                                                                                    Use the Display-
           Unicorn HAT (both right)                                                                                    O-Tron to parse
                                                                                                                       updates from
                                                                                                                       linuxvoice.com.




26                                                    www.linuxvoice.com
                                                                                    WIN LOADS OF COOL STUFF COMPETITION



                                                                                        HOW TO ENTER
                                                                                        We’ve hidden ten penguins
                                                                                        throughout this issue of the
                                                                                        magazine. After you’ve found them,
                                                                                        email their page numbers, with
                                                                                        your name and postal address to:
                                                                                        picomp@linuxvoice.com
                                                                                        (only one entry per person please)




      We’re giving away five
      complete Picade kits, five
      console kits and five starter
      kits, including everything you
      need for Pi-based fun.




           MORE SWAG!
        We’ve got more Pimoroni
             swag to give away
        throughout November and
         December. Follow us on
         Twitter @linuxvoice and
          listen to our podcast for
                more details.




TERMS & CONDITIONS
Competition runs from 9 November 2015 until 11.59pm 31 December 2015. Only one entry per person. No purchase or payment necessary. Winners wil be chosen at
random from entries with the correct page numbers. No cash alternatives. We’ll announce the winners on http://linuxvoice.com and email the winners directly. Prizes
unclaimed after 31 January 2016 will be re-assigned. We reserve the right to modify this promotion and replace items with others of equivalent value. The prize value
is current as of 29 October 2015. We respect your privacy and will only retain your details for the purpose of running this competition.
                                                                      www.linuxvoice.com                                                                          27
     FEATURE CONFLICT IN THE COMMUNITY




         (SHE)BANG
         OUT OF ORDER
          Flamewars and insults on mailing lists are driving
          developers apart. Mike Saunders asks: can
          Codes of Conduct/Conflict save the day?


         I
               magine you’ve spent weeks working on a project
               in your free time – some code for a popular Free
               Software application. You’ve devoted hours to
          your work, refined your code, tested it for bugs and
          written some documentation. Full of confidence and
          optimism, you submit your patch to the program’s
          mailing list, hoping that it will be accepted into the
          next release – or at least you’ll get some constructive
          feedback. But no. Your efforts are instantly
          dismissed with these words: “Your code is crap, you
          suck, and you should never have been born.”
             Sounds extreme, doesn’t it? Fortunately, such
          behaviour is rare in the Free Software world. We’ve
          observed interaction in all manner of FOSS projects
          over the last couple of decades, via mailing lists, IRC
          channels and real-life meetups, and most people are
          friendly and patient. But as Linux and FOSS grows,
          the amount of hostility, abuse and threats on mailing
          lists and forums is expanding at an alarming rate
          too. Most recently, Sarah Sharp, one of the relatively
          few female kernel hackers, said she no longer wants
          to contribute due to the “toxic” environment around
          the kernel community. She had previously criticised
          Linus Torvalds for his acerbic rants and flowery
          language on the mailing list.
             Meanwhile, Systemd head-honcho Lennart
          Poettering has described the FOSS world as “quite
          a sick place to be” after receiving an onslaught of
          abuse and even death threats. Because of all this,
          many projects are now putting into place Codes of
          Conduct (or Conflict): documents listing rules to
          which the community should adhere, and guidelines
          for dealing with disagreements. But will they work?
          Is it sad that we need these guidelines in the first
          place? And why is the internet so angry?
             The answers are complex as we’ll see, and reflect
          a history, culture and mindset that goes far beyond
          lines of source code. We spend 90% of our time
          thinking about technology at Linux Voice, but the
          people behind it – with their own sets of views,
          problems and quirks – are fascinating as well.



28                                                     www.linuxvoice.com
                                                                                  CONFLICT IN THE COMMUNITY FEATURE

   It might seem easy to pinpoint the crux of the
problem: Free Software developers are 99% antisocial
male nerds who live in their parents’ basements and
don’t understand anything about human interaction,
right? Well, this argument might have held some
water back in the early 1990s, but even then, it wasn’t
all about reclusive shut-ins. Even when GNU, Linux
and FOSS was largely the domain of hobbyists, many
contributors were university students, retired Unix
admins with families, and other “normal” developers.

Does a fish rot from the head down?
Fast forward to today: a large chunk of development
work – even the majority in some projects like the
Linux kernel – comes from full-time developers
working 9–5 jobs in offices around the globe. Even
for those hackers who work from home, the vast
number of conferences, meetups and hackathons
mean that developers meet up in person very
regularly. Writing FOSS code is a respectable, social                                                                        Lennart Poettering
job, so we can’t simply ascribe negative behaviour              Torvalds: Hi Dev. Thanks again, but it still doesn’t fit     is no stranger to online
to the FOSS world being a load of socially inept                into the way we do things in the kernel. etc. etc.           abuse, but says he looks
übergeeks who never see the light of day.                          This back-and-forth exchange of emails and patches        beyond it and focuses on
   Lennart Poettering has remarked that on the Linux            could drag on for months. Contrast it with this:             code.
kernel mailing list, “the fish rots from the head down”.        Dev: Hi Linus. Here’s a patch that adds feature X to
In other words: Linus Torvalds has set the standard             the kernel. What do you think?
for communication, and it only gets worse from there.           Torvalds: This is completely broken and entirely
Long-time kernel developers are used to Linus’s epic            unsuitable for the kernel. Throw it away.
rants, in which he thoroughly lambasts other hackers               This response is more brash – and arguably
for their failures, mincing no words when he wants to           impolite – but it gets the message across much more
get his point made.                                             quickly. The developer in question may feel hurt that
   One argument in favour of the Torvalds-style                 Torvalds doesn’t like his/her code. but at least he/she
response is that it saves time in the long run. Take            won’t spend weeks or months trying to ‘fix’ something
these two scenarios:                                            that will never be accepted any way.
Dev: Hi Linus. Here’s a patch that adds feature X to
the kernel. What do you think?                                  Who’s your daddy?
Torvalds: Hi there Dev. Thanks for sending the patch.           However, the problem runs deeper. Many developers
Well, kudos for giving it a try, but I’m not really sure it’s   have said they don’t object to this level of directness,
the right approach. Maybe you could try it slightly             but the insults go too far. In one of Torvalds’s famous
differently?                                                    tirades, he said that developers who write code in a
(Two weeks later) Dev: Hi Linus. I’ve reworked the              certain way “should just be retroactively aborted”.




‘‘
patch and made it slightly different…                           Some would argue that such statements are so
                                                                clearly over the top that they’re not meant to be taken
                                                                literally – Torvalds doesn’t actually want to kill people.
                                                                And others have noted that Torvalds’s quips always
                                                                focus on a person’s abilities as a coder, and not
                                                                personal aspects.
                                                                   The big issue here is: Torvalds is a role model for
      Linus Torvalds is a                                       many younger and less experienced hackers. We
     role model .We may                                         may accept the odd hyperbolic rant when he’s deeply
                                                                disappointed in another (senior) developer, but what
   accept the odd rant, but                                     happens when others try to emulate his ways?
                                                                Some greenhorn developers may assume that it’s
    what happens when
    others try to emulate
          his ways?
                                                 ‘‘             perfectly normal to post abuse to the mailing list –
                                                                and the more abuse, the more they’ll be seen like
                                                                their hero. They don’t understand how Torvalds
                                                                thinks, how such outbursts are extremely
                                                                rare, and how they’re about code. No, they
                                                                think it’s cool and trendy to hurl around
                                                                obscenities and abuse.



                                                                  www.linuxvoice.com                                                                29
     FEATURE CONFLICT IN THE COMMUNITY

                                                                                     ‘‘
‘‘CODES OF CONFLICT
  The solution may lie in carefully crafted guidelines...

                             In early March 2015, 60 kernel developers signed off a
                             patch that could remedy the situation. The ‘Code of
                             Conflict’ – a short 223-word text file – was created by
                             long-time kernel hacker Greg Kroah-Hartman and
                                                                                             This isn’t a silver bullet solution, but it provides
                                                                                          something that never existed before: an official way
                                                                                          to report and register bad behaviour. If you’re on the
                                                                                          receiving end of personal abuse, no longer do you
                             accepted into the mainline source tree by Linus              have to suck it up or simply quit kernel development,
                             Torvalds. For such an important project like the Linux       but you actually have an avenue to (hopefully) get the
                             kernel, you might expect this document to be very            situation resolved. The Code of Conflict also signs off
                             specific in its demands and expectations of the              with this positive thought:
                             community, but it’s actually rather vague. For starters,        “We are all humans, and frustrations can be high on
                             it alludes to the fact that you need a thick skin as a       both sides of the process… keep in mind the immortal
                               kernel developer:                                          words of Bill and Ted, ‘Be excellent to each other.’”
                                  “Your code and ideas behind it will be carefully           So there are very few specifics in the document that
                             reviewed, often resulting in critique and criticism. [...]   actually define what abuse is or what the acceptable
                             This development process has been proven to create           level of communication should be. Some may find the
                             the most robust operating system kernel ever, and            Code of Conflict deeply lacking in that respect, but we
                             we do not want to do anything to cause the quality of        think it’s a good start. By and large, the Linux kernel
                             submission and eventual result to ever decrease.”            has been an enormous success, so let’s try to fix the
                                So in other words: you won’t be handled with kid          problem with a general solution, rather than requiring
                             gloves, we will be harsh if your code is bad, and the        everyone to read a 5,000-word document and sign it
                             system has worked so far. But this doesn’t sound like        off before contributing – like some kind of tiresome
                             much progress, does it? If we can carry on as before,        End User Licence Agreement.
                             what’s the point of having a Code of Conflict in the
                             first place? Well, the second section deals with that:       The LLVM approach
Theo de Raadt founded
                                “If however, anyone feels personally abused,              Since the Linux kernel got its own Code of Conflict,
OpenBSD after being
expelled from NetBSD for     threatened, or otherwise uncomfortable due to this           some other notable FOSS projects have adopted one
abusive behaviour, and       process, that is not acceptable. If so, please contact       as well. LLVM, the development toolchain providing
has since gone on to run a   the Linux Foundation’s Technical Advisory Board.”            some healthy competition to GCC, took a different
successful project.                                                                       approach to the kernel’s document with a whopping
                                                                                          1,361-word file (http://tinyurl.com/llvmcoc) that goes
                                                                                          into many more specifics. It describes in depth how
                                                                                          mailing list posters should be patient, welcoming and
                                                                                          respectful, and gives concrete examples of behaviour
                                                                                          that should be avoided, including: violent threats;
                                                                                          discriminatory jokes; personal insults; unwanted




                                                                                    ‘‘
                                                                                          sexual attention; and personal information (“dox”).




                                                                                                  LLVM’s Code of
                                                                                                   Conflict gives
                                                                                               concrete examples of
                                                                                               behaviour that should
                                                                                               be avoided, including
                                                                                                violent threats and
                                                                                                 unwanted sexual
                                                                                                     attention
                                                                                                                                      ‘‘
30                                                            www.linuxvoice.com
                                                                                 CONFLICT IN THE COMMUNITY FEATURE

                                                                        former. Trusting developers to use their
                                                                        intuition and know what’s right or wrong
                                                                        seems more fitting to the open and
                                                                        diverse community around FOSS – but
                                                                       maybe some people will simply still not
                                                                      get it, and a more precise set of guidelines
                                                                     will be necessary in the future.

                                                                It’s not all bad…
                                                                One of the most famous forks in Free Software
                                                                history is OpenBSD, the operating system that
                                                                forked from NetBSD back in 1995. A year
                                                                earlier, the NetBSD Core Team had expressed
                                                                concerns that one of its most prominent developers,
                                                                Theo de Raadt, was being abusive to other hackers
LLVM has adopted a detailed Code of Conflict, whereas           on the mailing list and dissuading others from
the Linux kernel’s essentially says “just try to be nice”.      contributing to the project. The problem was
                                                                described to de Raadt in private:
   Similarly, the LLVM guide provides a much more                  “Your abusive actions have seriously impaired the
detailed set of steps for reporting bad behaviour and           success of the NetBSD project in several ways. Your
how it will be resolved. The LLVM Advisory Committee            actions have driven away developers or potential
will get together and review the incident, suggesting           developers, and have alienated many users. They
possible resolutions: the misbehaving developer could           have also squandered much of the good will that
be given a private reprimand if the incident is minor, or       various people have directed at the project.”
asked to make a public apology. If it’s a more serious             Meanwhile, on the public netbsd-users mailing list,
case of threats or personal abuse, that developer               the Core Team expressed their decision with regret:
could be asked to take a week off to cool down, or be              “On December 20, Theo de Raadt was asked to
permanently expelled from the project (with a chance            resign from the NetBSD Project by the remaining
to appeal the decision).                                        members of ‘core’. This was a very difficult decision
   So we have two types of Code of Conflict: the Linux          to make, and resulted from Theo’s long history of
kernel’s short-and-vague approach, and LLVM’s very              rudeness towards and abuse of users and developers
detailed document. Which one will be more effective             of NetBSD. We believe that there is no place for that
in the long run remains to be seen, but we prefer the           type of behaviour from representatives of the NetBSD
                                                                Project, and that, overall, it has been damaging to the
                                                                project. This decision was difficult to make because
  Saving face
                                                                Theo has a long history of positive contributions.”
  Those of us who’ve grown up in the western world get             What followed was an epic series of mailing list
  used to a certain amount of ‘banter’: jokes, jibes and
                                                                posts and private mails, all of which de Raadt has
  even the odd spate of personal insults here and there.
  We don’t want to hurt anyone’s feelings, but we also          archived at www.theos.com/deraadt/coremail.html.
  don’t get deeply offended by such natter at the pub or        The file contains over 52,000 words – so not some
  between friends. Consequently, we carry a lot of this over    light bedtime reading – but we spent a few days going
  to our communications online – often with liberal use of      through it all. In summary: de Raadt had behaved
  emoticons to make it clear that we don’t mean anything
                                                                extremely inappropriately, using personal abuse and
  truly offensive.
     But for many cultures – especially in the Far East – the   sexual references to other developers.
  concept of ‘face’ plays a much bigger role. People carry         In the end, de Raadt left NetBSD, forked it into
  a sense of dignity based on their position in a social        OpenBSD, and now has a more popular project today
  group, and if that sense is scuffed or damaged by abusive     (with a different focus: full-on security rather than
  criticism, the effects can run deep. Imagine a Chinese or
                                                                portability). Despite his abrasive personality, de Raadt
  Japanese kernel hacker being told on the mailing list that
  they are utterly rubbish, their work is worthless, and they   took many NetBSD developers with him and runs
  should turn off the computer forever.                         a successful project today – arguably for the same
     Many of us would find such remarks unpleasant, but not     reasons that makes the Linux kernel a success under
  care what that person thinks and carry on with our work.      Torvalds. (And de Raadt himself has said that he’s
  We’ll then joke about that person at the pub. Whereas the
                                                                “not as angry” as he was 20 years ago.)
  Chinese or Japanese developer may feel deep shame in
  being humiliated in public, and lose face among colleagues       Of course, the OpenBSD community is tiny in
  or friends who also happen to be on the list. Of course,      comparison to Linux, so there aren’t as many eyeballs
  some of this is a stereotype and there are developers in      watching how developers interact. Maybe one day
  every country who respond differently. But if we want         OpenBSD will expand enough that the developer base
  to bring talent from around the world to Free Software
                                                                is diverse enough to require a Code of Conflict. And
  development, we need to be aware of cultural differences,
  ‘saving face’, and craft our criticism correspondingly.       who knows – maybe someone will fork OpenBSD into
                                                                another project, and the cycle will continue forever…



                                                                  www.linuxvoice.com                                       31
     FAQ SOFTWARE DEFINED NETWORKING




Software Defined Networking
        Redefine your infrastructure on the fly with the latest network technologies.

                                                   What, so instead of one router,         hardware manufacturer do it
BEN EVERARD                                        I’d have to have a hardware             differently?
                                            router and a server to run the                        The most popular way of
                                            control software? What’s the point in                 controlling data layer hardware is
      Networking’s all about                adding that complexity?                        with the OpenFlow protocol. This works
      hardware. Cables, routers,                   Well, if you’re just running a single   in exactly the way we’ve just described.
interfaces, that sort of thing. Where              router, there’s not much point in       There’s an OpenFlow controller that
does the software come into it?             SDN. However, if you run more than one         handles the control layer, and hardware
      Things like routers and firewalls     router or switch then a single machine         that handles the data layer. Using this,
      have networking hardware, but         can be the control layer for all of them.      you can combine hardware from any
they also all have software that controls   This means that rather than managing           manufacturer and any controller
the hardware. This software does            a single piece of hardware, the control        provided they all support OpenFlow.
things such as decide where packets         software can handle all of the hardware        This is known as the southbound
should be sent (if indeed they should be    at the same time. As well as being able        protocol.
sent at all).                               to manage multiple pieces of hardware,            The SDN controller should also
                                            the control software will also be able to      enable software to run on it from above.
      Ah, I think I’ve seen that. At        see the whole network, so will be able         This software is know as the
      home, I’ve got a Wi-Fi router         to make more intelligent decisions             applications layer, and the idea is that
with a HTML control panel that              about how the network should be                the setup will enable standard software
enables me to block ports, forward          configured.                                    in the control layer to run software in
data and that sort of thing.                   The end goal of SDN is a network            the application layer to run on any
      That’s exactly the sort of thing      that can quickly and easily adapt as the       physical hardware in the data layer.
      we’re dealing with. In Software       uses of the network change. This goes             The software running in the
Defined Networking (SDN), we talk           hand-in-hand with things like                  application layer can then take
about the control layer (which is the       virtualisation technology, which enables       advantage of the controller’s power to
software that manages the hardware),        you to quickly and easily change the           configure the network in different ways.
and the data layer (which is the actual     software stack running on hardware.            This could include, for example, a web
networking hardware itself).                SDN isn’t a silver bullet to solve all a       app to handle levels of Quality of
  On most current networking                businesses IT problems, but a more             Service (QoS) across all nodes on the
equipment both of these things run on       flexible IT setup should enable a              network or an algorithm for
the same device, so in the case of your     business to be more flexible in its            automatically balancing the load on the
home Wi-Fi router there’s one box that      operations.                                    network. The connection between this
has both the networking hardware and                                                       higher-level software and the controller
the software that provides you with the           That makes sense. I guess this           is known as the northbound protocol.
configuration options. In an SDN setup,           means that you need a way for            There isn’t yet a standard for
these two aspects are separated, so the     the control layer to communicate               northbound protocols, and different
control layer runs on a separate            with the data layer. Is there a                SDN controllers allow different software
machine to the data layer.                  standard for this, or does each                to run on them.


     The end goal of Software Defined Networking is                                              Northbound? Southbound?
                                                                                                 What’s any of this got to do
     a network that can quickly and easily adapt as                                        with a compass?
                                                                                                 Some of the terminology can be
     the uses of the network change                                                              a bit confusing. Typically,



32                                            www.linuxvoice.com
                                                                              SOFTWARE DEFINED NETWORKING FAQ

whenever someone draws a diagram,
SDN infrastructure has the data layer at
the bottom of the page, the control
layer in the middle and the applications
layer at the top. The protocols are all in
relation to the control layer, so the
protocols going downwards from the
control layer are called southbound, and
the protocols going upwards are called
northbound.

       This SDN thing sounds useful.
       Are most corporate networks
run on SDN now?
       The concept of SDN has been
       around since the late 90s, but it’s
only been a practical solution to
enterprise tech needs since around
2013. Since it requires new hardware,
SDN is only slowly catching on.
However, many are suggesting that it
will become a serious player in the
technology scene in 2016 and 2017.
Industry analysts IDC, for example,
expect the worldwide SDN industry to
be worth $8 billion by 2018. If you’re an    The Open Networking Foundation sets the standards for SDN, including OpenFlow, and its members
early adopter, or like to get ahead of the   include Google, Facebook, HP, Intel and almost anyone else who’s anyone in the tech world.
tech curve, you need to start
investigating SDN now.                       clearly: there’s no point in using SDN if                 which understands the OpenFlow
                                             you only have one or two pieces of                        protocol.
       What’s all this SDN stuff got to      network hardware (eg routers or
       do with Linux anyway?                 switches). The chances of you having a                           Isn’t there a less heavy-duty
       There’s nothing inherently Linuxy     home network that would actually                                 way of giving it a go?
       about SDN; however, given the         benefit from SDN is pretty small. Of                             An alternative approach is to
prevalence of Linux in the data centres      course, just because there’s no                                  build some networking hardware
where many of these SDNs are running,        technical benefit in something, that                      using a Linux-based machine. You’ll
and the flexibility of the Linux stack, it   doesn’t mean you shouldn’t dive in and                    need a computer to build it on, which
should come as no surprise to learn          do it anyway for the geeky fun of                         could be more or less any machine that
that a lot of the SDN hardware runs          learning something new! SDN is both                       can run Linux (including a small ARM
Linux. This includes things like             an interesting area and a rapidly                         device such as a Raspberry Pi or an
OpenvSwitch and Microsoft’s Azure            growing aspect of system                                  Odroid). You’ll need to add more than
Cloud Switch (ACS).                          administration.                                           one network interface, which is easily
                                                Assuming you don’t want to go out                      and cheaply done using USB Ethernet
       Hang on just one second. Did          and buy expensive enterprise-level                        interfaces, and then you’ll need some
       you just say that Microsoft           networking hardware, you’ve got                           form of SDN driver running on it, such
runs its SDN on Linux?                       basically two options if you want to                      as LINC (https://github.com/
       Yep! We were equally surprised.       experiment with SDN. The simplest                         FlowForwarding/LINC-Switch).
       Microsoft’s ACS is used in its        option is to use virtual machines. Using                     Either of these methods (and indeed,
Azure cloud data centre to control the       visualisation software such as KVM or                     both simultaneously) can be used to
hosted environment. If that’s not a          VirtualBox, you can start machines with                   create the data layer of an SDN. On top
ringing endorsement for Linux as the         virtual network interfaces.                               of this, you’ll need to create a control
base platform for SDN, then we really           These interfaces connect to virtual                    layer. There are a few open options here
don’t know what is.                          networks. Usually, the visualisation                      including Pox (www.noxrepo.org),
                                             tools you’re using will connect them                      Floodlight (www.projectfloodlight.org/
      If all these SDN systems are           together in a fairly straightforward                      floodlight), or Maestro (http://
      built on Linux, does that mean         manner, but you don’t have to use the                     zhengcai.github.io/maestro-platform).
I can build my own SDN setup on my           technology that comes out-of-the-box.                        The process of setting up an SDN
Linux box?                                   Instead, you can use more powerful                        isn’t completely straightforward, but if
      First off, we’ll just repeat what we   virtual networking software such as                       you go through it, you’ll end up learning
      said at the start, slowly and          OpenvSwitch (http://openvswitch.org),                     a lot about this emerging technology.



                                                              www.linuxvoice.com                                                              33
     INTERVIEW GIANUGO RABELLINO




GIANUGO RABELLINO
MICROSOFT’S GNU WHISPERER
Graham Morrison simply walks into Mordor to discuss open source strategy with
Microsoft’s senior director of open source communities. But is all as it seems?


S
      aved from a career in law by a career    and a partner in five initiatives with the        version of Office running on Android, and
      at Microsoft, Gianugo Rabellino has      Linux Foundation. Thanks to customer              has even been working on its own internal
      played a huge role in Microsoft’s        demand and the prevalence of Linux in             Linux distribution – both things that were
burgeoning interest in open source.            everything from phones to the cloud, along        completely unimaginable 10 years ago. But
Microsoft is now a significant contributor     with the wiser stewardship of its new CEO,        how real is this change? We find out what’s
to many projects, including the Linux kernel   Satya Nadella, Microsoft has released a           going on at the heart of Microsoft.



       Why did you take on the job at      GR: No, I missed the Amiga stuff and         utterly broke. And I got into the BBS
       Microsoft?                          that’s one of my regrets, but what can       world. And at the centre point, I wanted
Gianugo Rabellino: This October is         you do?                                      to run my own BBS but I could only
my fifth anniversary at Microsoft. I                                                    have one computer. And that was quite
joined in 2010, coming all the way from          PCs are probably a much wiser          a luxury. I saved and bought a 386
Europe. I had an open source services            choice anyway.                         because I heard that those things could
company, and before that, and after        GR: In a number of ways, yes. So I           run more than a program at a time, so I
that of course at Microsoft, I spent all   found myself thinking that I almost got      could run my BBS and use the
my life in open source.                    this degree in law but I don’t want to be    computer at the same time, and lo and
   I’m a member of the Apache              a lawyer, what am I going to do? I didn’t    behold Windows 3.1 didn’t do that. So I
Software Foundation, contributed to        have the time or the money to pursue         got into [IBM’s] OS/2. I loved everything
various projects, founded the first        another degree and then I found myself       about it.
official Linux organisation in Italy in    back in computing, stumbled into open
1994, so I go back to Linux 0.99 and a     source, fell in love with it. Luckily that         Yeah, it had multitasking.
big pile of floppies. I had a C64 when I   was when the internet had started.                 GR: Yes, exactly. And then they
turned 14. My parents had a company                                                     did OS/2 3.0 and it was like OK, no that
and they had one of the first PCs.               What was it that you liked             was a mistake. Friends brought a pile of
                                                 about open source? You could           floppies with Linux and it was like, oh
     So from a C64 to a PC, so not         have had Windows on your PC?                 wow, look at that – that’s interesting!
     through the Amiga then?               GR: I could have except that I was           And then I thought, you know what,




                                                                                                Like a lot of the high-rollers we
                                                                                                 speak to, Gianugo got his first
                                                                                                 taste of Linux using a stack of
                                                                                                        Slackware floppy disks.



34                                                          www.linuxvoice.com
                                       GIANUGO RABELLINO INTERVIEW




“The only way to achieve
interoperability is by building
open protocols, open formats, open
standards – and that gets coupled
more and more with open source”
                  www.linuxvoice.com                                 35
     INTERVIEW GIANUGO RABELLINO

                                                                                                 You mean in a general IT
                                                                                                 sense, nothing to do with open
                                                                                          source?
                                                                                          GR: It was the attitude towards
                                                                                          Microsoft. I really thought that they
                                                                                          deserved more credit, and were genuine
                                                                                          in their efforts to do more open stuff.

                                                                                                When was this?
                                                                                                GR: We’re talking 2008, which is
                                                                                          when I started (Sourcesense). Then
                                                                                          when I decided for other reasons to
                                                                                          leave Sourcesense and take a
                                                                                          sabbatical, I sent an email to my
                                                                                          contacts at Microsoft saying I’m leaving
                                                                                          the company, going somewhere else, it
                                                                                          was fun working with you, and they said
                                                                                          hey do you want to come have an
                                                                                          interview. So that’s how I joined.

  Gianugo talks a good game,                                                                     So Redmond has realised it
  but the proof of the pudding is
                                                                                                 needed some help because its
  in the eating (and he was part
                                                                                          open source work was very isolated?
  of the team that open sourced
  .NET, so that’s a tasty pudding).                                                       GR: They were doing some bits of open
                                                                                          source here and there. They were
                                                                                          dipping their toes. But then it came to a
instead of running a BBS, I really want      Vienna, and I was like I’m in a small        point that there was clearly an
to spread the word about this Linux          town in Italy and now my stuff is            executive mandate to do more, to
stuff, so I’m just going to open up          getting to Vienna. And then this guy told    explore. So I joined in 2010 and had 23
access. Dial up a number, get a login        me, yeah but this is actually Vienna         interviews to get the job, and I asked for
prompt, no password, you’re in and you       USA, it’s not Vienna Austria. My mind        those because I really wanted to talk to
can play around.                             was blown, and I realised I could just       as many people as I could before
  And I would be on another terminal         use IRC, back in those days where you        making a big decision such as moving
doing stuff while other people were          could just use IRC.                          a family of four, including a two-month-
absolutely tearing my machine to                                                          old, to the USA and also taking a career
shreds. And one day, just by accident, I          We still put our magazine               that was built on open source, on my
get a talk request. Do you remember?              together through IRC.

       Ah, the days of FidoNet.
                                             GR: So then I came on IRC and I found
                                             people from HP, people from IBM,
                                                                                             I owe everything to open
       GR: Exactly. And it turned out to     people from Sun and I understood that I         source software. That’s the
be a professor at a university who was       had another shot at a career. I could
looking for help to set up a lab, and he     actually learn because there’s so many          beginning and the end of it
said it looks like you know Unix why         resources that I could use. And I started
don’t you come and help me out. I still      hacking and I never looked back.             open source reputation, and joining
had to prepare for my final exam, but a                                                   Microsoft. But at the time I signed up, I
few months later I was pretty much a               That’s really good.                    was positive that there was a genuine
teacher’s assistant of Computer                    GR: Yeah. I owe everything to          willingness to turn this company
Science managing a lab in my small           open source software. This is the            around and make it become more
town. And that’s what got me into it,        beginning and the end of it.                 open. And it wasn’t just… lip service,
and it was a combination of “hey I got          Microsoft were doing their first forays   they wanted to change the company.
this operating system for free, wow          into open source and back then they          So that was a challenge that was really
that’s awesome”, and then I was lucky        were actually involved in OpenXML,           exciting for me.
enough that I could actually dial into the   which you might recall was quite
university and I had the internet, which     controversial at that time. And my                 Can you say who at Microsoft
is something you couldn’t afford back        impression as an open source person                wanted that change to happen?
then. There was no web, those were the       was that Microsoft was not getting           GR: I have to give a lot of credit to my
days of Gopher [a protocol that              credit for what they were trying to do.      hiring manager, Jean Paoli, whom I’ve
pre-dated HTTP]. And I remember              Everyone was second guessing that            worked with for the last five years. He
sending my first traceroute and being        Microsoft was coming from the angle          clearly had that vision, but he was also
amazed that my first traceroute went to      that these guys were not right.              backed by a lot of executives at



36                                                            www.linuxvoice.com
                                                                                     GIANUGO RABELLINO INTERVIEW

             Microsoft, including for a number of        important as this Microsoft changes, is      there where it’s really hard to say
             years Satya Nadella, the current CEO.       that open source changed as well. The        whether they are a standard or an open
             He was the one who approved of our          Microsoft of floppy drives and the open      source project. What is the new
             first big plan to build open source for     source of floppy drives had become           container initiative? It’s based on
             Azure. There was a lot of executive         the Microsoft and the open source of         Docker. They have these four
             backing behind this effort.                 the internet era, where everything is        components that I care about: open
                                                         connected, products are shipped to           source, open standards, interoperability
                    Did everybody understand the         the cloud. The software that runs your       and community development, because
                    advantages and why it was            phone is coupled with your device.           that’s the other part.
             important internally? All we saw was        Those are new things and so openness            What we learn about over the years is
             the outside image presented by              has become a more nuanced concept.           that open source is stuff that you throw
             people like Steve Ballmer.                      Today, I don’t like just talking about   at the wall. I mean, it’s nothing. You’re
             GR: Steve Ballmer was 2001 and floppy       open source. It’s important – it’s           building the ‘whole of the garden’ code.
             drives. So fast forward a few years and     absolutely crucial – but if you talk about   It doesn’t matter. Code by itself rocks.
             what we got was probably the tail end       open source alone, you don’t bring open      But I’m an Apache guy, to me it’s
             of that phase when Microsoft was very       standards into the picture. If you don’t     community over code always.
             reluctant towards open source. The ‘no      bring interoperability into the picture,
             way’ phase. And then, pretty much           I mean, we need to see the same                     Have you built a community
             when I joined or shortly thereafter, we     webpage and access the same email.                  within Microsoft so that those
             started a phase of genuine, open and        It looks like magic, but there’s a lot of    open projects will remain open?
             honest asking of ourselves why. I mean,     technology behind it.                        GR: Absolutely, yes. And again, that
             I’m open to the view of using open                                                       maps to something that changed in the
             source, but give me a good reason. And            Wouldn’t you say that                  market. Gone are the days of five years
             of course there’s a spectrum. It went             Microsoft wasn’t too worried           until the next version of Windows or the
             from people who were highly sceptical       about interoperability and open              next version of Office. The turnaround
             to people who were very open, but I         standards up until 2005–2006?                needs to be faster: Azure updates every
             never met anyone at Microsoft who           GR: I think it’s interesting to see how      day. Your Windows devices update
             was under the idea that we are not          Microsoft got interested in                  nearly every day or on a weekly basis.
             doing it just because it was open           interoperability and, subsequently, went     We need that fast turnaround. And we
             source. I never saw that in my five years   into open source – into openness in          need to make sure our products and
             at Microsoft.                               general. Because the only way to             technologies can embrace that model.
                Recently, I think we squarely entered    achieve interoperability is by building
             the age of ‘why not’, so give me a good     open protocols, open formats, open                When you say open source, is
             reason not to. We’re going to default       standards – and that gets coupled                 it more important for the
             to openness. At the same time, what         more and more with open source. Right        source to be open and readable with
             I think happened, and I think it’s as       now there are so many projects out           more of an emphasis on permissive,




Linux is no longer a cancer that
attaches itself to everything
it touches (cf Ballmer, 2001).
Rejoice, oh my brothers!



                                                           www.linuxvoice.com                                                               37
     INTERVIEW GIANUGO RABELLINO

or is it that it becomes more of a            was very little advantage in building our      and always focused on ‘the code talks’.
community project?                            own licences, but back when Microsoft          It’s a useless conversation about the
GR: An open source license gives you          did that, I wasn’t at the company then.        specific open source project or
all of that. So I can read it, I can modify   It kind of made sense. That was the            technology without showing code,
it, I can redistribute my modification.       time when everybody was doing their            that’s the whole idea. We have been
But the real value comes when those           own licences. And then it became a             consistently pushing on the same
modifications get merged back in.             problem and we understood at                   strategy for five years and little by little
When I talk about open sourcing               Microsoft that we need to go where the         we made this stuff change.
products or technologies at Microsoft, I      community is and the community                     When I interview people who want to
always say if you don’t intend to accept      wants to coalesce and consolidate on a         work at Microsoft, want to work in my
contributions there’s little point in what    handful of licences. We don’t need so          team, I always tell them you cannot be
you’re doing.                                 many, we just need a few. And that is          successful in changing a big company
                                              why today we have five or six licences         if you take a speedboat approach.
     But initially Microsoft had              and everything else is really in the long      You’re not on a lake in a speedboat
     quite specific Microsoft open            tail. We just follow that trend.               doing zig zags. You’re actually the tug
source licences. Thankfully, these                                                           boat that needs to steer the container
seem to be fewer.                                    What would you say has                  ship. And the only way you can do it is
GR: Yes, absolutely, they’re gone now.               changed the most at Microsoft           by using a lot of torque. And little by
We haven’t been using them for years.         since you joined in its attitude to            little, slowly but surely – it looks like
                                              open source, and also how does the             you’re not making progress – but then
      Coming from the Apache side             wider world of computing outside of            you look back and you see that the ship
      of things, did you have                 Microsoft feel about the company?              is turning.
anything to do Microsoft’s new                GR: When I look back at these five
licensing regime?                             years, my impression is that we did                   So you’re able to look back and
GR: Marginally, but by the time I joined      everything organically and that’s                     see the difference between
there was already very very little use of     probably one of the reasons why we             people at Microsoft five years ago
MS-PL [the Microsoft licences]. If            were successful at changing the                and people now?
anything, I nudged towards Apache 2.0,        company so much. We didn’t jerk, we            GR: It’s consistent. It just took this
being an Apache guy, and recently             took it little by little. Small steps with a   much time. It was a journey. We had to
we’ve switched more and more to the           bit of a bottom-up, grassroots approach        demonstrate business value. We had to
MIT Licence. But we realised that there       with executive coverage from the top,          validate. So when I joined there was a
                                                                                             hypothesis that we need to change, we
                                                                                             need to become more open because it’s
                                                                                             good for us, it’s good for our customers,
                                                                                             it’s good for the company.

                                                                                                    Was there any pressure from
                                                                                                    outside Microsoft?
                                                                                             GR: Oh there was tons of pressure. We
                                                                                             always listen to customers, that’s one
                                                                                             of the main reasons why. And it was a
                                                                                             changed landscape. Imagine how the
                                                                                             world has changed since, as an
                                                                                             example, the inception of XML. XML
                                                                                             meant that all of a sudden you could
                                                                                             have a heterogeneous data centre in a
                                                                                             number of technologies and still have
                                                                                             those machines communicate with one
                                                                                             another. And that brought our
                                                                                             customers to say, you know what, we
                                                                                             love your technology but we also love
                                                                                             this other technology now and they can
                                                                                             talk together and we want to keep it
                                                                                             that way, we want to use both. So that
                                                                                             was the pressure that started it all off.
  The Microsoft Open Source Programs
  Office has a small team of four
                                                                                                  Was there a change in attitude
  people – if you fancy working to help
                                                                                                  at Microsoft?
  Microsoft use more Free Software
  open source, why not apply for a job?                                                      GR: There was a big shift in the market.
                                                                                             The market went from a single-vendor



38                                                              www.linuxvoice.com
                                                                                      GIANUGO RABELLINO INTERVIEW




“Right now, we are at a point from
an executive trajectory point of
view, we are where we want to be:
the era of the ‘why not?’. We need
to default to being open.”


            market, where you are married to your        source to the next level, realising that      we still have to deliver a consistent
            customer for a decade because of             open source is across the company.            experience. So the fact that we can do
            lock-in, to a much more dynamic                                                            it, thanks to the work the Microsoft and
            market where customers could mix and               Were you involved in the open           many others did at places like the W3C,
            match. They told Microsoft and they                sourcing of .NET?                       just thoroughly amazes me.
            told all the other companies, “hey this is   GR: I absolutely was. I actually sit on
            the way we want to operate going             the board of the .NET foundation.                  So what’s next?
            forward. We’re going to have a                                                                  GR: Right now the mission of the
                                                                 It’s probably one of the biggest      Open Source Programs Office is to

Being more open is good                                          and most positive things
                                                         Microsoft has done for open source
                                                                                                       enable, simplify and promote open
                                                                                                       source across the company. We
for our customers, and                                   in that it’s genuinely useful.                managed to turn the ship around and
                                                         GR: And a few months after we                 now we need to sail it.
it’s good for the company                                announced open sourcing .NET, we
                                                         announced Visual Studio Code. It’s about              Where are you sailing to?
            heterogeneous set of technologies that       meeting developers where they are. It’s               GR: We’re sailing to where the
            can interact with each other, and we’re      the ultimate evolution of the mixed IP        market wants us to sail. We know that
            going to keep you accountable for that”.     idea. We went from “I want to have a          there’s going to be a lot of openness
            So we have an interoperability executive     little bit of everything in my data centre”   down the road, so we’re heading in that
            council, which is part of what my team       to “I will need to have a little bit of       direction. Now it’s about taking all those
            has been doing for the past few years        everything because I’m in the cloud and       little stumbling blocks that are still
            and we have large companies and              that’s what I’m running today”; it may        there, making sure the process is
            startups coming to us and telling us to      not be what I’m running tomorrow, it          smooth. Making sure that when you
            fix this, you ought to fix this.             may not be what I’m running next              ingest an open source package, you do
                                                         month. It may not be with this particular     your own due diligence, you make sure
                   How far have you got in your          provider, it may be with somebody else.       it’s an appropriate thing to do and we
                   mission at Microsoft?                 And I also have my private cloud and I        need to make sure that the process
            GR: From this standpoint in turning the      need to connect everything. So                doesn’t take much [effort].
            ship around, I think we’ve done it, we’re    interoperability is supremely important.          Right now my major concern is
            done. To me, there were two major                Don’t get me started with devices,        making sure that we will need to create
            milestones: open sourcing of .NET –          with the idea that, hey I build apps or       a process to manage resources
            open sourcing of one’s crown jewels if       web sites. Take a random room of five         internally and I want that process to be
            you like – and the second major              or six people and you will find a mix of      as frictionless as it can possibly be
            milestone for me was folding MS Open         probably twelve different operating           because we are doing these things to
            Tech back, which meant taking open           systems, devices, screen sizes etc. And       speed us up.



                                                           www.linuxvoice.com                                                                 39
        LISTEN TO THE PODCAST



         WWW.LINUXVOICE.COM




BUY           MUGS AND T-SHIRTS!




      shop.linuxvoice.com
                                                                                                                             INTRO REVIEWS




REVIEWS
The latest software and hardware, rigorously bashed against a wall by our crack team.

                                                  On test this issue . . .
                                                                                                                        42
                                                                                                                                   Fedora
                                                                                                                                   23
                                                                                                                                   Behind the scenes, Fedora
                                                                                                                                   is just about the most
                                                                                                                                   technologically advanced
                                                                                                                                   Linux distribution there
                                                                                                                                   is. Combine that with an
                                                                                                                                   attractive desktop and a
Andrew Gregory                                                                                                                     solid community you’ve got
Is building a scale model of Harlech castle out                                                                                    a great system.
of abandoned laptops.




B
        y the time you read this
        magazine, the world will have
        forgotten about the TalkTalk
data leak/hack, in which a telecoms
company in the UK mislaid a load of its
customers’ data (including bank
details). That’s a shame, because there           Ubuntu 15.10                    43    OwnCloud Server 8.2            44    TeamViewer 10                 45
are lessons to be learned.                        Beware the moon! The beginner-        All the convenience of Google        Pay money for a proprietary
  The most important of these is that             friendly distro is so simple even     Docs/Mail/Calendar, with none of     remote desktop? When it’s as
you always need someone to blame.                 werewolves can use it.                the privacy issues. Excellent.       good as this, you just might.
TalkTalk’s share price fell from the day
the hack was announced, a slide that
was only arrested when police arrested
a 15-year old from County Antrim in
                                                  Group test and books
connection with the attack.

Always blame someone else
Are you keeping your customers’ data
unencrypted? Fine, carry on. Do you
know of a breach, but doing nothing,
hoping it’ll go away? Also fine. But find
someone to blame, pronto.
  No doubt once this child has been
prosecuted the CEO will leave for
another gold-plated salary and they’ll all
pat themselves on the back for riding
out the storm. But really, if a 15-year-old       Group test – window managers                        50   Books                                             48
can hack your network, it’s not the               For more control, more power, or more speed – if         Exercise for programmers, inside the tech of Bitcoin
15-year old that should be arrested.              you like to tinker with your setup, give one of these    and evaluating your code as if it were a crime scene.
andrew@linuxvoice.com                             window managers a try today.                             That’s some esoteric reading right there.



                                                                    www.linuxvoice.com                                                                      41
     REVIEWS GNU/LINUX DISTRO




Fedora 23
Slightly later than expected, Fedora 23 is here to delight Mike Saunders.


                               F
Web www.fedoraproject.org              edora 23 was due to be released a few days           layout randomisation), the OS can make security
Developer Red Hat and
Fedora Project                         before we went to press, but some last-minute        holes less damaging, as crackers can’t assume that
Platforms IA32, x86-64, PPC,           spanners in the works meant that it was held         certain bits of code are at specific points in RAM.
ARM                            back by one week. That’s fair enough, we feel – time-
                               based releases are a great way to ensure that                Waiting for Wayland
                               software gets shipped at some point and doesn’t              Desktop-wise, Fedora 23 ships with Gnome 3.18,
                               languish in development hell, but it’s worth being a bit     and while many improvements have been made to
                               flexible to ensure the final release is of decent quality.   Wayland, the X Window System still provides the
                                  As with the last few releases, Fedora 23 is available     default graphical layer. LibreOffice 5.0 made it into the
                               in multiple flavours: Workstation (for typical desktops      release just in time as well. In the Server flavour of the
                               and office environments), Server and Cloud. One              distro, there’s a new role to set up Fedora as a cache
                               major change that affects all versions is package            server for web applications (using memecached),
                               hardening: where possible, binary executables are built      while the Cockpit administration interface now
                               as PIC (position independent code), which means they         supports SSH key authentication and can work with
                               can be placed anywhere in the operating system’s             Kubernetes to manage clusters of Linux containers.
                               memory address space. Using ASLR (address space                 Other changes include Docker 1.8 in the Cloud
                                                                                            flavour, a migration from Mono 2.10 to 4.0, and
                                                                                            Unicode 8.0 support. Along with the standard Gnome
                                                                                            version of the Workstation release, there are “spins”
                                                                                            featuring other desktops such as KDE, Xfce, LXDE,
                                                                                            Mate and Cinnamon. On the whole it’s a worthy
                                                                                            upgrade: the switch to PIC binaries should have a
                                                                                            positive impact on the distro’s security in the long run,
Gnome 3.18, the default                                                                     and easy access to the latest Gnome and LibreOffice
desktop in Fedora 23,
                                                                                            releases make it a no brainer.
sports two new programs
(Calendar and Characters)
                                                                                            A shiny new desktop, updates to LibreOffice and
and Google Drive                                                                            more security – there’s plenty to like here.
integration – see p43 of
last issue for our review.


42                                                             www.linuxvoice.com
                                                                                                           UBUNTU 15.10 REVIEWS




Ubuntu 15.10 (aka Wiley Werewolf) Desktop and Server
Ben Everard’s purple werewolf costume left some people confused at Halloween.


F
        ire up Ubuntu 15.10 desktop and you could be                                                                  Web www.ubuntu.com
                                                                                                                      Developer Canonical
        forgiven for thinking you’re running 15.04, or                                                                Licence Various free
        14.10. Not much has changed in quite some                                                                     software licences
time. There’s a purple-ish geometric background, a set
of blocky icons on the left-hand side and the same
Unity experience that you’ll either love or hate. As
you’d expect, Werewolf comes with the latest
upstream software, but otherwise, there’s no reason
to upgrade.
                                                                                                                      Ubuntu still includes online
   Let’s now move swiftly on to the Server edition                                                                    results in local searches,
of Ubuntu 15.10, where there are some pretty big                                                                      but it’s easy to disable if
changes afoot. The biggest of which is the new                                                                        you want to increase your
OpenStack installer (Autopilot). It’s a little bit of a                                                               privacy.
shame that in 2015 an easy installer for software can
be considered a feature. However, OpenStack isn’t         network packets far more quickly than with traditional
an easy system to set up, and having a simple path        kernel drivers.
to running a private cloud will make Ubuntu a much           Like all regular versions of Ubuntu, 15.10 will
more attractive option for people taking their first      only be supported for nine months, which isn’t long
foray into this system.                                   enough for many organisations. However, these new
   LXD, Canonical’s container management tool, is         technologies are a show of strength from Canonical
now shipped by default. This isn’t a huge change,         six months before the release of the next LTS version
since LXD has already been available for some time,       (which will be supported for five years). If the new
but by pushing it into every installation, Canonical      technologies prove to be stable, it will pave the way for
is trying to get people into its own tool rather than     the next release (16.04) to further cement Ubuntu’s
alternatives such as Docker.                              position as the leading OS for modern data centres.
   Users with heavy network loads may be interested
to see the inclusion of the Data Plane Development Kit    Not much new on the desktop, but a strong sign
                                                          of things to come in Ubuntu server.
(DPDK) in the latest version of Ubuntu. This set
of drivers and libraries enables users to handle



                                                            www.linuxvoice.com                                                                43
     REVIEWS FILE SHARING




OwnCloud Server 8.2
Thanks to this great update, Graham Morrison has [almost] managed to drop Google.


                             W
Web https://owncloud.org/                 e use OwnCloud every day to put this           folders in previous versions. Clicking on the Details
Developer OwnCloud Inc.
Licence AGPLv3                            magazine together. It’s a fantastic piece of   menu item also opens a new panel on the right
                                          software that turns anything capable of        where you can easily see the sharing status of your
                             being a server into the closest open source gets to         selection, along with a preview of its contents – and
                             Dropbox or some of Google’s cloud-bases services.           brilliantly, access to each version if the file has been
                             It’s also rapidly evolving, and 8.2 is the second major     modified. We love the way you no longer have to save
                             update since 8.0 was released in February 2015. After       a text file when you edit it, as all changes are saved
                             manually updating our old 7.x servers, we’ve been able      automatically. But our favourite visual upgrade is to
                             to use the automatic internal update feature for both       the Gallery view, replacing the old Pictures mode.
                             8.1 and 8.2, making the upgrades effortless.                You can sort your images by creation date, and
                                 Many changes for this release are visual. There’s a     the update time for us was much faster than with
                             small new menu adjacent to each file that provides          previous versions. You can also zoom and pan around
                             download, delete and rename duties, for instance,           your photos, making this the first time we’ve felt
                             while upload and file creation moves to a new ‘+’           comfortable sharing a folder link with someone rather
                             menu at the top. These replace the slightly clunky          than using another online photo repository.
                             icons that appeared when you hovered over files and            Administrators get a lot more control from the
                                                                                         command line, including the ability to modify the
                                                                                         number of versions and the amount of trash kept by
                                                                                         the system, and the ability to encrypt and decrypt
                                                                                         everything. And while it’s not specifically part of the
                                                                                         server package, we have to mention that the recent
                                                                                         upgrades to the Linux desktop standalone client
                                                                                         are brilliant. It no longer sucks CPU cycles and can
                                                                                         connect to multiple servers at once. OwnCloud is a
The best thing about the
                                                                                         project that just keeps getting stronger.
new desktop client is that
you can use it with more
                                                                                         Nothing touches OwnCloud for its feature set, or
than one account and                                                                     for its development speed.
OwnCloud server at the
same time.


44                                                           www.linuxvoice.com
                                                                                                         TEAMVIEWER 10 REVIEWS




TeamViewer 10
Ben Everard may be about to become the technical support team for his social circle.


L
        inux has a surfeit of remote access tools, from                                                                Web www.teamviewer.com
                                                                                                                       Developer TeamViewer
        the command line SSH to the graphical VNC.                                                                     Licence Free for personal use
        Many video chat tools also have screen-                                                                        or from £449
sharing capabilities. With all this, is there really a need
for a proprietary option?
    To answer that question, we have to look into the
two things that TeamViewer does. First, as you may
expect, it shares a computer’s screen with a remote
computer. The remote user can then take over the
mouse and keyboard and use this as they wish. The
most common usage for this is fixing problems.                                                                         You can try if you like, but
TeamViewer performs this task perfectly well, but so                                                                   these login details won’t
do other tools. TeamViewer’s real advantage comes in                                                                   let you take over the Linux
the second task it performs: managing these remote                                                                     Voice network.
connections simply without needing an inbound TCP
connection to the machine being controlled.                   to their machine and can fix their problem for them.
    That all sounds a little technical, so let’s go back      That alone is worth the full five stars from us. There
for a minute. Imagine your friend calls you up and            are only two problems we can see: it’s closed source;
says they’re having a problem with their computer.            and if you make it too easy for people to come to
How do you connect to it? With SSH or VNC, you need           you with their problems, they may never fix anything
an IP address to contact. This is fine for a server;          themselves again. We’ll leave it up to you to decide
it’s probably even possible over a home internet              how serious these problems are.
connection, but it won’t be easy to set up.                     As well as Linux, TeamViewer works on Windows,
    With TeamViewer, they’ll just get a few numbers           Mac, Android, Windows Phone and Blackberry, so you
displayed on their screen which you need to enter             can help people of any computer denomination.
into your machine, and you have access to their
desktop. It’s simple enough for you to be able to talk        The easiest way of fixing other people’s
                                                              problems on just about any computer.
a technically inept person through the installation
and setup in a few minutes; then you’ll have access



                                                                www.linuxvoice.com                                                                 45
     REVIEWS GAMING




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


 DEAR SAINT NICHOLAS…
                                           Soma
                                           Atmospheric sci-fi horror from the makers of Amnesia: The Dark Descent.


                                           P
                                                    enumbra and Amnesia are often
                                                    considered to be among the scariest
                                                    games of all time, but Soma focuses
                                           more on story than horror. It’s far more mature
                                           than its predecessors, using philosophy as an
                                           theme to its sci-fi exploration-focused story.
                                              The game’s predecessors were considered
 Michel Loubet-Jambert is our Games
 Editor. He hasn’t had a decent night’s    terrifying due to the lack of self defence abilities,
 sleep since Steam came out on Linux.      but also for their atmosphere and excellent
                                           sound design. Soma does these things well,              Soma’s mysterious underwater facility feels very


 T
          he first Steam Controllers –     though by this point the formula has been               much alive and is full of decay.
          on which much of the viability   imitated to the extent where it has almost
          of Linux as a mainstream
                                           become a genre of its own.                              experience and constant second-guessing as
 gaming platform hangs – have been
 shipped, and those lucky enough to           As a sci-fi story-focused game, Soma is hugely       to the goings-on really pull the player into the
 have pre-ordered have given their         successful, though the horror aspects can be            game’s world, and in effect also serve to bolster
 thoughts online. At the same time,        half-baked. At times, it feels as if more could         the horror aspects, which Soma does more
 Valve has pushed back the official        have been achieved if the game stopped doing            effectively. It is these aspects that make the
 release closer to Christmas to iron
                                           what was expected of it and concentrated on             game undoubtedly better than its predecessors.
 out some of the kinks.
    Responses have been positive,          the excellent plot. That said, the atmosphere              We recommend Soma – it’s one of those
 though the unusual double trackpad        achieved through the traditional means of horror        games that create conversations between
 design has been reported to work          really adds to the experience.                          people who have played it, albeit in this case far
 better on some types of games than           The story deals with some intriguing themes          more about the story and the issues it raises
 others, and it’s expected that later
                                           such as human consciousness and unfolds                 than the jumpscares.
 versions will attempt to do more to
 make it a more viable option for FPS      at an excellent pace as the mysteries of the
                                           underwater facility and its former occupants              Website http://store.steampowered.com/
 games. The controllers also had
                                                                                                     app/282140 Price £29.99
 issues with running out of the box on     are steadily revealed. The loneliness of the
 some major Linux distros, though this
 has now been patched up.
    Meanwhile, contracts have been
 secured in the UK, US and Australia
 to bring the Linux-powered consoles
 and their controllers to the biggest
 bricks-and-mortar game retailers in
 those countries, bringing PC gaming
 back to store shelves alongside
 consoles after a long absence. The
 sheer variety of hardware and pricing
 will be a challenge for vendors.
    Having gotten a chance to try out
 SteamOS on a home made Steam
 machine, it’s certainly impressive. As
 a gaming distribution, it takes
 plug-and-play to a whole new level,
                                             The story takes place after waking
 without having to wrestle with pesky
                                             up in an abandoned facility under
 graphics drivers or fine-tune things
 after installation. There is no doubt       mysterious circumstances.
 as to the ease of use to potential
 Linux newcomers, though its
 acceptance by the gaming                     The atmosphere achieved through the traditional
 community will remain to be seen.
                                              means of horror really adds to the experience.

46                                                               www.linuxvoice.com
                                                                                                             GAMING REVIEWS


Sword Coast Legends                                                                            ALSO RELEASED…
A well polished RPG set in the Forgotten Realms universe.


T
          here have been many successful       not true to the rulesets and have criticised
          attempts at reinvigorating the RPG   it pretty extensively. Not knowing the
          genre and Sword Coast Legends        least bit about D&D, I can only speak for
pulls it off exceptionally well. Rather than   the campaign, which has high production
lazily relying on the success of Icewind       values, a solid story and excellent voice
Dale and Baldur’s Gate and drowning in         acting. That said, the combat and skill
a sea of nostalgia, the game delivers 3D       trees are somewhat superficial, which
visuals that look great even when zoomed       need not be a bad thing in order to attract     Wasteland 2: Director’s Cut
incredibly close to the characters.            a new generation of players, but seasoned       Just over a year after the critically acclaimed
    There’s still plenty of standard fantasy   RPG fans may be somewhat disappointed           Wasteland 2 was released, it has received a
tropes of bustling towns and huge caves        in this regard.                                 complete graphical overhaul and a few very
                                                                                               welcome additions. Among the additions to
filled with monsters and bandits alike.                                                        this Fallout-esque RPG are controller support,
Many of the Dungeons & Dragons crowd             Website http://store.steampowered.com/        extra voice acting and more character
                                                 app/325600 Price £32.99
claim that the game’s multiplayer mode is                                                      customisability. Needless to say, the Director’s
                                                                                               Cut is a huge improvement on a game that was
                                                                                               already extremely impressive.
                                                                                               http://store.steampowered.com/app/240760




                                                                 The move away from 2D
                                                                                               The Beginner’s Guide
                                                        backgrounds has helped bring the       From the makers of The Stanley Parable comes
                                                         RPG genre into the 21st century.      another equally fascinating experience, which
                                                                                               diverges from the traditional mechanics of
                                                                                               video games. The player explores the
                                                                                               numerous creations of a game developer,

Grand Ages: Medieval                                                                           taking them on an emotional journey that
                                                                                               touches upon aspects of the human condition.
                                                                                               The story is mostly driven by the narrator, who
A pleasant trading simulator which could have been far more.                                   is also the creator of the levels, and it lasts a



W
                                                                                               couple of hours at most.
              hen Grand Ages was                                                               http://store.steampowered.com/app/303210
              announced, it looked to be
              an exciting combination of
the best aspects of 4X strategy games
like Civilization, with the complex empire-
building aspects of a grand strategy
game. However, it turned out to be a
somewhat superficial trade simulator with
limited combat and building mechanics,         Grand Ages clearly has an impressive engine
and no political mechanics whatsoever.         and a good base for a solid franchise.
    Nonetheless, Grand Ages is by no means
                                                                                               Skyhill
a bad game. It is fun and satisfying, while    challenge. However, a number of patches         This fun roguelike/adventure/survival game
providing many hours of gameplay – even        have already addressed some of these            meshes together some seemingly different
if it does feel like a missed opportunity at   issues, and progression feels pretty solid      genres, with the player getting to enjoy the
times. The campaign is well put together,      most of the time. The game would suit           best of each. The challenge here is making
with a story that takes place in the latter    fans of the Patrician series and other trade-   your way down the 100 floors of a hotel by
                                                                                               scavenging for food, crafting items and
days of the Byzantine empire.                  oriented games the most, while grand            battling mutants to get through to the exit.
    The gameplay often lacks balance,          strategy fans may also enjoy it.                There’s also good narrative thrown in to add
ranging from it being near impossible                                                          intrigue and remove repetition.
to turn a profit, to being incredibly            Website http://store.steampowered.com/        http://store.steampowered.com/app/382140
                                                 app/310470 Price £29.99
overpowered and there being little



                                                              www.linuxvoice.com                                                                   47
     REVIEWS BOOKS



Exercises for Programmers
Ben Everard changes out of his Lycra – these are different exercises.
Author Brian P Hogan
Publisher Pragmatic Bookshelf
Price £15.99
ISBN 978-1680501223




H
           ow long does it take to learn a      need to come up with any novel algorithms
           new language? The answer to this     or tricks to get through this book. The result
           question really depends on what      is a slightly pedestrian set of exercises
you mean by learn a language. A decent          which didn’t really excite us.
programmer can probably pick up the                Exercises for Programmers takes you
syntax and basic usage of a new language        through everything from creating user
in a weekend. After a month, they should        interfaces to using web services for the
be fairly comfortable. However, it can take     purpose of getting data, all to force you to
a long time to really get you head around all   search through all the features, libraries and
the little bits that you need to know.          modules of your chosen language. These
   Exercises for Programmers is a set of        exercises should work with any language
challenges that are designed to cover every     regardless of paradigm.
area of a language so that when you’ve
                                                A useful, but slightly dull, workout to help
covered them, you’ll be able to program         you make sure you have a complete grasp
comfortably in that language. The tasks are     of a new language.                               Musicians practise scales, so perhaps
there to test your knowledge of a language,                                                      programmers should practise the routine parts
not your skill as a programmer, so you won’t                                                     of their craft as well.




You Code as a Crime Scene
Ben Everard’s code always looks like a crime scene.
Author Adam Tornhill
Publisher Pragmatic Bookshelf
Price £23.99
ISBN 978-1680500387




I
     t doesn’t matter how good your code        knowledge to inform your development
     is, there are bugs in it, and one of the   practices (should this code be re-factored?)
     challenges of programmers is finding       and human resources (should more people
where they’re hiding. In Your Code as a Crime   know how this code works?). In small
Scene, Adam Tornhill introduces the idea        projects, developers can easily keep track
of using forensic techniques to work out        of the whole codebase, and so identifying
where they’re most likely to be. The process    hotspots isn’t very useful, but as projects
is based on geographic offender profiling,      get larger, it becomes more useful to know
which attempts to locate the likely location    where problems may arise. Adam Tornhill
of a criminal based on the pattern of their     takes the reader through a series of real
crimes. Tornhill uses tools and techniques      open source projects to demonstrate the
that attempt to locate likely places for bugs   techniques. This isn’t a failsafe approach
based on the location of complexity in and      guaranteed to leave your software spotless,
changes to the code base. This spatial          but could be a useful weapon in the endless
mapping produces visualisations that            battle for software quality.
highlight a series of ‘hotspots’ where bugs
are likely to occur.                            A novel approach to software analysis that
                                                                                                 The deerstalker and pipe aren’t essential
                                                could prove useful for managing large
   By identifying these hotspots, you can       projects.                                        accessories to this book, but we highly
focus your bug squashing activities in                                                           recommend them.
the most fruitful places, and also use this



48                                                            www.linuxvoice.com
                                                                                                               BOOKS REVIEWS



Blockchain
Graham Morrison finds the first example of currency gentrification                    Also released…
Author Melanie Swan
Publisher O’Reilly
                                                                                      December 2015
Price £15.54
ISBN 978-1491920497

                                                                                      Learning Virtual Reality
T
          his is a book that covers
          classic O’Reilly territory:                                                 We know the current craze
                                                                                      for virtual reality is likely
          it takes a technically
                                                                                      to go the same way as 3D
challenging new area that could lead                                                  movies, and be little more
to a revolution, and explains why that                                                than a footnote in a
technology is important. O’Reilly has                                                 couple of years, but we’re
done this in the past with both social                                                genuinely excited by its
                                                                                      revival (we loved playing
networking and the smartphone
                                                                                      the Virtuality arcade
economy, and Bitcoin is ripe for                                                      machines of the 1990s).
similarly skilled divination, especially                                              This book is an
as we’ve yet to see a practical analysis                                              introduction to developing
of the algorithms and the potential        Let’s hope the future of Bitcoin doesn’t   for VR, featuring Oculus,
                                                                                      WebVR and the ultra-          We can’t wait for Super
outside of digital currency. However,      include the NSA running its own mines.
                                                                                      cheap Google Cardboard.       Tuxcart in virtual reality.
this isn’t the book we’re looking for.
It’s going to appeal to readers who        place, even expanding into the future
want a more academic exploration           with Blockchain 3.0, and what different
of how blockchains (the indivisible        kinds of blockchains might lead to.
list of all transactions behind crypto-    This is where the book succeeds, and       Learning to Love Data Science
currencies like Bitcoin) are likely to     where potential readers will get the       Data science is becoming
operate outside of the darknet.This        most.                                      mainstream, and is being
isn’t surprising when you look at the                                                 used everywhere from
author’s background: Melanie Swan          Open University                            manufacturing to
                                                                                      journalism. This book is a
is the Founder of the Institute for        But for us, it reads like a pre-peer       sobering appraisal of its
Blockchain Studies and is currently        reviewed research paper for potential      potential, complete with a
studying for a Contemporary                investors, even finishing with scholarly   few case studies. It’s
Philosophy MA.                             sections on challenges, limitations        likely a good read for
    But everyone already knows             and the classic ‘Conclusion’. It’s not     anyone in the position to
                                                                                      try and do clever things
about Bitcoin. The ongoing drama           what we were expecting, and we             with big data, which in the
surrounding the bankruptcy of              think says something about who             age of citizen journalism
the Mt. Gox Bitcoin exchange is            the book is targeted at. Certainly not     and open data, means          We thought all science
still making headlines, even in the        people interested in the specifics of      almost anyone.                was based on data.
general press, and the alleged theft       the algorithm and how it could be
of Bitcoins by a US secret service         subverted into different roles.
agent while investigating the Solk             A description of the algorithms
Road black market portal is even more      does appear in the first appendix,         Lego Power Functions
newsworthy, as is the plight of Silk       titled ‘Cryptocurrency Basics’. It
                                                                                      We love the idea of this
Road’s creator, Ross Ulbricht, who was     could be that Bitcoin makes sense          book. It’s full of small
given a life sentence for his crimes.      without these technical foundations,       projects that showcase
    With these kind of magnetic back       but not for us. And we also found          Lego’s various Technic
stories, it’s surprising that this book    the complete lack of any diagrams          moving elements in
does very little to pull in casual         disappointing, especially when             modular re-usable forms.
                                                                                      It’s exactly what Lego is
readers who have discovered Bitcoin        blockchain transactions can be visual      good at, and the reason
through this coverage. After a lengthy     in a way that dramatically helps with      why we all still enjoy
preface, the book wastes no time           comprehension. It left us mostly with a    messing around with the
on technicality by diving into second      feeling of missed potential for anyone     stuff. That the functions
guessing what the algorithms behind        but a Bitcoin student.                     in the book have value in
                                                                                      the real world of
Bitcoin might lead to – the reinvention                                               construction is an added      Build anything with Lego.
of financial services, for example, or     An academically written and dry look at
                                           the potential of blockchains.              bonus. We promise.            Except political works.
self-signing contracts. It does a good
job of putting all predictions into one



                                                                www.linuxvoice.com                                                                49
     GROUP TEST WINDOW MANAGERS




GROUP TEST
Speed up your Linux box by switching away from a heavy desktop to a
lightweight window manager. Mike Saunders weighs up your options.



 On test                                                  Window managers
                                                          C
                                                                   hanging just one                   some power-users’ features that
 FVWM                                                              component in your Linux            can save a huge amount of time in
            URL www.fvwm.org                                       installation can have a            the long run.
            Licence GPL                                   massive impact on your                         We’re going to look at six of the
            Latest release 2.6.5                          productivity. Just think about how          most useful alternative lightweight
            It’s almost as old as the Linux kernel,       much time you spend managing                window managers (WMs).
            and it’s insanely configurable.
                                                          windows: moving them around,                Compared to the likes of Gnome
                                                          maximising and minimising them,             and KDE, they provide relatively
 IceWM                                                    and placing them side-by-side to            few features – just the ability
            URL www.icewm.org                             work on two tasks at the same               to manage windows and start
            Licence GPL + LGPL                            time. Perhaps you also use virtual          programs. You can add the other
            Latest release 1.3.8                          desktops, keyboard shortcuts and            features of a desktop environment
            Like the traditional Windows 9x layout?       other features for managing your            (such as a file manager) via your
            This dinky WM will float your boat.           activities. Dealing with these things       distro’s package manager, with
                                                          may only seem like a small part of          the end result being something
 Window Maker                                             your daily work, but it all adds up
                                                          over the months and years.
                                                                                                      that uses much less RAM, runs
                                                                                                      at a blistering pace, and offers
            URL www.windowmaker.org
                                                             Even if you’ve gotten used to            customisation and features way
            Licence GPL
            Latest Release 0.95.7                         your regular desktop environment            beyond the big-name desktops.
            This takes a more novel approach and          – be it Gnome, KDE, Xfce, Mate,                The six WMs we’re testing here
            apes the design of Next/OpenSTEP.             Cinnamon or something else – you            all offer their own unique sets
                                                          could be working much smarter               of features and are available in
                                                          and faster. We have nothing against         pretty much every distro, so you
 i3                                                       those desktops, but they have their         can try them today. We’ll help you
            URL www.i3wm.org                              downsides. They’re generally heavy          to explore them, point out their
            Licence BSD                                   on the RAM banks, they often tend           benefits, and show you some tricks
            Latest release 4.11
                                                          to limit customisation, and they lack       to get the most out of them.
            A tiling window manager designed to
            maximise screen real estate usage.
                                                            The window managers we’re testing
 Fluxbox                                                    here all offer speed, features, and the
            URL www.fluxbox.org
            Licence MIT                                     potential for customisation.
            Latest release 1.3.7
            Very small, very fast, and – with the
            right themes – very good-looking too.          The agony of choice
                                                           There are hundreds of window managers         And if you don’t find a WM to scratch

 Awesome                                                   out there on the internet, most of which
                                                           aren’t in active development any more
                                                                                                      your itch, and fancy getting started with
                                                                                                      a new project, why not write your own?
            URL http://awesome.naquadah.org                or were simply forks of other window       There’s a lot to learn, but it’s not as
            Licence GPL                                    managers with a few tweaks made. The       difficult as you might think. Getting the
            Latest release 3.5.6                           Arch Linux wiki is a great resource for    basics done requires just a small amount
            For maximum productivity, you want to          information on other WMs, so take a look   of code, and Chuan Ji has written an
                                                           at https://wiki.archlinux.org/index.php/   excellent introduction with concepts and
            keep your hands on the keyboard.
                                                           Window_manager to explore further.         code at http://tinyurl.com/njlkhkp.




50                                                    www.linuxvoice.com
                                                                                       WINDOW MANAGERS GROUP TEST



Layers upon layers
The modularity of the graphical stack on Linux/Unix can be confusing.


F
       or new Linux users who’ve come over        a rudimentary API (application programming          to other platforms, such as Windows,
       from Windows or Mac OS X, the              interface) so that programs can say “draw a         much easier. The next layer is the window
       different layers that make up the          line” or “turn these pixels a different colour”.    manager, which talks to the X server and
end-user environment in Linux can be                 Very few programs interact directly with         provides mechanisms for moving windows
bamboozling. But it’s this modularity that        X, however. Most software uses a graphical          around, resizing windows and closing them.
makes our operating system so flexible. At        toolkit that does the hard work of talking          It’s possible to run programs without a
the lowest level we have the X Window             to the X software (the X server), such as           window manager, but they’ll be fixed in size
System, which talks to graphics hardware          Qt or GTK. These toolkits provide a layer           and position, making it impossible to work
and renders pixels to the screen. It provides     of abstraction and make porting software            with multiple apps at once.




FVWM
As old as the hills.

B
          ack in the early 90s, as the Linux
          kernel was paired with GNU software
          and we had a fully Free Software OS,
FVWM was the window manager of choice.
Actually, there wasn’t a huge amount of
choice back then, with most people running
this or its predecessor, TWM. GNU/Linux
was very much the domain of übergeeks
back then, so FVWM didn’t have much in the
way of fancy wizards or step-by-step setup
tools – no, you were expected to spend a
few days working through a configuration
file, exploring hundreds of options to craft
your desktop to perfection.
    To try it out, install it from your package
manager, log out of your current session,         For a prettier and more user-friendly introduction to FVWM, try its shiny FVWM-Crystal spin-off.
and choose FVWM from the list of desktops
or window managers when logging back in.             As mentioned, FVWM is insanely                   than the vanilla FVWM package. It works in
(Unfortunately the location of this list varies   configurable – just look at the manual page         very much the same way – left-click on the
with all the login screen setups out there, so    (man fvwm). It’s a mind-boggling 58,000             desktop to bring up a menu – but with
you’ll just have to click around until you find   words long. If you look at your configuration       attractive program launchers, workspace
it. Time for some standards, we think!)           file in ~/.fvwm/.fvwm2rc you’ll find plenty of      switchers and taskbars out of the box.
    Once you’re logged in you’ll see a            options to play around with, so you can edit           FVWM is a fascinating project rich with
grand total of nothing. Left-click on the         this file in a text editor, save and restart to     history, but we can only recommend it if
desktop, however, and a small menu will           view your changes. To get some inspiration          you’re willing to put in the hours poring
pop up; click on Setup Form to bring up           for what’s possible, try doing a web                through the manual page and configuration
a dialog box that can be used to create a         search for “fvwmrc” – many people have              file. If you’ve never been satisfied with
more sane configuration. Select ‘Create a         uploaded their configurations (with plenty of       any other window manager or desktop,
starting .fvwm2rc’ file and the buttons for       comments) so you can nab ideas and create           maybe you can finally create your dream
FvwmWinList, FvwmButtons, FvwmPager,              a setup perfect for your liking.                    environment with FVWM. Plus, of course, it’s
FvwmIconBox and FvwmTaskBar, then                                                                     a very mature project, so once you’ve built
click the F2 button at the bottom followed        TOO MUCH CHOICE!                                    up your ideal .fvwm2rc file, you know it will
by F3. Now you’ll have a more usable setup        It’s quite tough to make FVWM look pretty,          work long into the future.
with various components including a virtual       but one spin-off called FVWM-Crystal
desktop manager and window list at the            (http://fvwm-crystal.sf.net) does a decent           VERDICT
bottom. Also, when you now left-click on a        job here, and is available in a separate             Has virtually every
                                                                                                       customisation option you
blank part of the desktop, you’ll see a more      package in many distros. This is then                can imagine, but requires
detailed menu from which you can launch           presented as another option in the login             a lot of patience to set up.
software.                                         screen, and provides more sensible defaults



                                                              www.linuxvoice.com                                                                     51
     GROUP TEST WINDOW MANAGERS


IceWM
Harking back to the glory days of Windows 9x.


W
              ell, when we say glory days       Click the IceWM button in the
              we mean that in jest of       bottom-left to open a program menu
              course – Windows 95 was a     – and note especially the Settings
big improvement over 3.11, but it was       submenu where you can change the
still a horribly unstable stack of          theme. But here you’ll encounter a
software trying desperately to cover up     problem: IceWM isn’t very clever at
its DOS roots. Nonetheless, for all its     picking up what software is installed on
faults (and we were clinging on to our      the system. So in the program menus
Amigas back when it came out), its          you’ll see launchers for programs that
interface had a certain amount of           you probably don’t have installed.
charm. The Start menu and taskbar               To fix this, you’ll need to run a
combo worked well enough that it has        separate utility and feed the results
been copied endlessly over the years.       to IceWM’s configuration file. One         IceWM is supplied with themes emulating Windows and
   IceWM is one of the older window         such option can be found at https://       OS/2, along with some unique ones, such as Infadel2.
managers here, and has been in              github.com/gapan/xdgmenumaker.
development since the late 90s.             It’s annoying that this extra step is                    usage are tiny in comparison to
Consequently it has a rather retro          required, but on the upside IceWM’s                      desktop environments. It’s fast, and it’s
appearance, although a handful of           system requirements and memory                           ridiculously stable – this author used it
fresher themes are included. Once                                                                    for five years without any crashes.
you’ve installed it and logged in, you’ll      You’ll see a familiar
see a familiar taskbar and Start menu                                                                  VERDICT
panel along the bottom. It also contains       taskbar and Start menu                                  Screamingly fast but
                                                                                                       requires some fiddling to
a clock and system tray on the right,
along with workspace switcher buttons.
                                               panel along the bottom                                  get the menus set up.




Fluxbox
Dark and moody, this WM does its best to get out of your way.


F
        luxbox is a fork of an older        Alt+Tab. Fluxbox is very minimal and
        window manager called               low on effects – so there are no pretty
        Blackbox, and dates back to         transition effects when you switch
2001. It was hugely popular for a while     between desktops.
among power users, before tiling               Right-click on the desktop to bring
window managers really reached their        up the main menu. Unlike with IceWM,
prime, although it’s still in development   this is automatically populated with
and has an army of hardcore fans.           software on the system, and it also
Fluxbox boasts extremely low                provides a great deal of configurability
requirements and RAM usage thanks to        without the need to poke around inside
its minimal dependencies – it uses the      text files. Try searching in particular
X Window System’s own libraries for         inside the Styles and Configuration
rendering and therefore doesn’t need        submenus. If you look at the Window        Fluxbox has a lot in common with IceWM, but with a more
external toolkits hogging up RAM.           Manager submenu, you’ll see that           imaginative design and working menus out of the box.
   When you first start it, you’ll notice   you can switch to another WM from
a thin panel along the bottom with          Fluxbox without having to return to the                  who need the basics but with no extra
various elements contained therein.         login screen – a handy bonus if you’re                   fluff. As it uses little screen space, it’s
From left to right these are: a virtual     trying various WMs.                                      ideal for reviving an old netbook with a
desktop (workspace) switcher, taskbar          Fluxbox has a few extra features                      fresher distro.
and system tray area. Buttons are           such as tabbed grouping of windows
provided to switch between desktops         (drag titlebars with the middle mouse                      VERDICT
                                                                                                       A joy to use if you want to
and windows, but you can do the             button together to join them), but                         save RAM and don’t need
former with Ctrl+Alt and the left/right     by and large it’s a simple, sleek and                      tiling facilities.
arrow keys, and the latter with good old    attractive window manager for those



52                                                          www.linuxvoice.com
                                                                                        WINDOW MANAGERS GROUP TEST


Window Maker
                                                                                                Beefing up your WM
NeXT/OpenSTEP comes back to life.
                                                                                                Useful apps and tools to add.


                                                                                                O
                                                                                                           nce you’ve settled down with your new
                                                                                                           choice of window manager, you may
                                                                                                           find your setup a bit lacking in
                                                                                                comparison to a desktop environment. After
                                                                                                all, the likes of Gnome and KDE provide
                                                                                                integrated file managers, text editors and other
                                                                                                tools – whereas your window manager serves
                                                                                                primarily as a launcher for anything you
                                                                                                happen to have installed. So you’ll first want to
                                                                                                install a good file manager, and for this
                                                                                                purpose we can recommend PCManFM
                                                                                                (http://wiki.lxde.org/en/PCManFM). It’s used
                                                                                                in the lightweight LXDE desktop, and does a
                                                                                                great all-round job. Another alternative is XFE
                                                                                                (http://roland65.free.fr/xfe), based on the FOX
                                                                                                toolkit, which has fewer features but runs at
                                                                                                light speed.
Note that you can tear off menus and keep them separately on the screen by clicking their top      Another tool worth adding – especially if
bars, as we’ve done with Themes here.                                                           you care about eye-candy – is a compositing
                                                                                                manager. This lets you add effects like drop-



S
         teve Jobs isn’t the most popular          Try launching a program and you’ll           shadows and animations to windows, and
         figure in the Free Software world,     notice that its icon appears in the bottom-     the one we recommend is Compton (https://
         but there’s no denying that he had a   left corner of your screen. If you drag         github.com/chjj/compton). It’s available
massive impact on computing history.            this icon onto the Dock – ie next to the        in almost every major distro, and once you
After being kicked out of Apple – the           Terminal icon – you’ll see that you can         have it installed, run it from a terminal with
company he co-founded – back in 1985,           add it to the Dock permanently. In this way     compton -c to get pretty shadows underneath
Jobs created Next, which developed a            you can quickly build up a set of launchers     windows and menus. See the manual page
high-end (and extremely expensive at            for your most commonly-used tools.              (man compton) to get an overview of all the
$10,000) computer. This machine ran the                                                         available options.
NextStep operating system, which later          Add usefulness                                     For some WMs you may want to add a dock
morphed into OpenStep and became part           The button in the top-left is the Clip. This    for your most commonly used applications.
of Mac OS X when Jobs returned to Apple         lets you switch between workspaces              Cairo Dock (http://glx-dock.org) is a superb
in 1997.                                        (virtual desktops), of which by default there   choice here, and while it’s clearly heavily
   Window Maker is an open source               is only one, so right-click on the desktop      inspired by Mac OS X, it has plenty of features
window manager that recreates much of           and go to Workspace > Workspaces > Add          in its own right. To learn more about using
the classic look and feel of NextStep, while    New To Add More. You can add launcher           these extra tools, and piecing them all together
still providing the ability to run modern       icons to the Clip for specific workspaces,      to create your own desktop environment, see
FOSS programs. Unlike the other window          so you can use the Dock for general apps        our tutorial at www.linuxvoice.com/create-
managers on test here, Window Maker             and the Clip for apps you only want to          your-own-desktop-environment.
is a slightly larger project incorporating a    launch on certain workspaces.
widget set and extra libraries.                    Window Maker includes a
   To get it running, install it via your       comprehensive setup tool (double-
distro’s package manager, log out of your       click the uppermost icon in the Dock)
current session and choose it from the          and various themes (See WorkSpace
list of desktops at the login screen. The       > Appearance > Styles in the desktop
first thing you’ll see is a pair of icons in    menu). It’s a mature, reliable and attractive
the top-right corner – this is the Dock,        desktop with a unique way of working, and
and it contains program launchers. You          we’ve spent many months hapily using it
can start a program by double-clicking its      as our daily driver in the past.
launcher, so try it with the default Terminal
icon. Next, right-click on an empty part of       VERDICT
                                                  Well tested, refined and a
                                                                                                Here’s Window Maker again, but with lurvely drop
the desktop to bring up the applications          refreshing alternative to                     shadows around windows and menus thanks to
menu, which provides access to the                the typical approach.                         the Compton compositor.
software installed in your distro.



                                                                   www.linuxvoice.com                                                         53
     GROUP TEST WINDOW MANAGERS


i3 vs Awesome
Tiling WMs go head-to-head.


T
          iling WMs are becoming
          increasingly popular, especially
          among power users running
large displays, and they can help you to
work much more efficiently. But what is
a tiling WM?
   The best way to explain is by
demonstrating. Install i3 from your
distro’s package manager and then
select it at your login screen. You’ll see
two things when the WM starts up:
a thin panel along the bottom of the
screen (called the i3bar) and a “first
configuration” box asking you if you
want an automatically generated config
file – hit Enter here and choose Alt as
the default modifier when prompted.
   And you’re ready to go. Alt+Enter and
a terminal window will appear, filling the
whole screen. Now hit the same key
combination again to spawn another            A typical i3 session, with vertical and horizontal splits in use. To exit the WM use Alt+Shift+E.
terminal – and you’ll see that they’ve
automatically been placed side-by-side        ; keys for left, down, up and right                             completely. i3 is capable of much
(or one above the other, depending on         respectively (a bit like in the Vi editor).                     more, so see https://i3wm.org/docs/
your display ratio).                          To switch between horizontal and                                userguide.html for the complete guide.
                                              vertical splitting, use Alt+E. And to close                        Awesome, meanwhile, shares
Save space with tiling                        a window, use Alt+Shift+Q. To resize                            many of the same features as i3: it’s
This is the tiling aspect of i3; it           a window, hit Alt+R and then use the                            a tiling window manager designed
automatically places and resizes              arrow keys followed by Enter when                               to maximise screen space usage
windows to make the best use of your          you’re done – or use the mouse to grab                          and make you less dependent on the
screen space. To switch between               the handle between windows if you                               mouse. Unlike i3, however, it’s a bit
windows, use Alt with the J, K, L and         don’t want to say goodbye to the rodent                         more friendly to mouse users out of the
                                                                                                              box, as you’ll see if you right-click on the
                                                                                                              desktop (a program menu appears). To
                                                                                                              open a terminal, use Mod4 (usually the
                                                                                                              Windows key) and Enter – by default
                                                                                                              windows are in floating mode, so use
                                                                                                              Mod4+Space to switch to tiled mode,
                                                                                                              like i3. A full list of keybindings can be
                                                                                                              found at http://awesome.naquadah.
                                                                                                              org/doc/manpages/awesome.1.html.
                                                                                                                 Awesome is a hugely configurable
                                                                                                              WM with support for Lua extensions
                                                                                                              to add tabs, popup menus and even a
                                                                                                              Space Invaders game. Once you’ve spent
                                                                                                              a few days learning the keybindings
                                                                                                              for Awesome or i3, you’ll never want to
                                                                                                              waste your life shoving windows around
                                                                                                              on your desktop ever again.

                                                                                                                VERDICT
                                                                                                                I3 Simple, clean and      AWESOME More
                                                                                                                effective – the perfect   complex than i3 but
                                                                                                                introduction to tiling    more versatile thanks
                                                                                                                window managers.          to Lua extensions.

Awesome has a lot in common with i3, and is also extensible thanks to Lua scripting support.



54                                                              www.linuxvoice.com
                                                                                             WINDOW MANAGERS GROUP TEST



  OUR VERDICT
Window managers
E
        veryone has their own way             rodent (or trackpad), Window Maker
        of working, so we can’t say           is well worth getting to grips with.
        which one of the six window           Its use of the Dock and Clip creates
managers here is perfect for you –            an alternative workflow to the usual
but hopefully you’ve found a few              taskbar-and-system-tray setup, and
that have whetted your appetite to            the ability to dock menus around
try out for a couple of days or               the screen can be highly useful as         Everyone should try a tiling window manager at least once in their
weeks. Just a few small changes in            well. Plus, some of the in-built styles    lives, we reckon – you have nothing to fear but fear itself!
your working habits can have a                look great – they can be rather dark
huge effect on your productivity as           and stony, but look far better than
time goes by.                                 the extreme flatness that’s being           1st i3
   From our perspective, i3 and               adopted elsewhere these days.
Window Maker come out at the                     So while we recommend that               Killer feature: Tiling heaven
top of the bunch. i3 just makes so            everyone gives i3 and Window                www.i3wm.org
much sense for the type of work               Maker a go, there’s still plenty            If you have a big monitor, you absolutely must try this – don’t be
that many of us Linux geeks do,               worth investigating in the others.          put off by the learning curve.
and while it takes a while to master,         We’d choose IceWM if we were
the learning curve is worth it. If you        upgrading someone’s old Windows             2nd Window Maker
have plenty of screen space and               XP machine, in that it provides a
want to neatly divide your display            familiar layout and runs like the           Killer feature: NextStep goodness
into sections so that you can work            clappers even on dated hardware.            www.windowmaker.org
on multiple projects side-by-side             Fluxbox’s conservative use of               A great alternative to taskbar-based window managers, with
– or just keep tabs on an htop                screen real estate makes it ideal for       some lush themes included.
session on a remote machine –                 old netbooks, while Awesome has
then i3 is bliss. You’ll wonder why           plenty to sing about as well.               3rd Awesome
you ever wasted so much time                     And if you want to create the WM
manually shuffling windows around             of your dreams without hacking
                                                                                          Killer feature: Lua extensions
with the mouse.                               away on code, just spend a few              http://awesome.naquadah.org
   Of course, constant keyboard               months meticulously crafting an             More tiling fun, with the ability to customise and add heaps of
usage isn’t for everyone, and if you          FVWM configuration file and live            extra functionality via extensions.
have a good relationship with your            forever in peace.
                                                                                          4th IceWM
   i3 makes so much sense for geeks
   – while it takes a while to master,                                                    Killer feature: Familiarity for Windows 9x users
                                                                                          www.icewm.org
   the learning curve is worth it.                                                        Blazingly fast and providing a comfortable environment for those
                                                                                          used to old-style Windows releases.


  Tmux: a window manager for your terminal                                                5th Fluxbox
  Yes, WMs even exist for command line        in the same terminal window next to
  programs. Tmux (https://tmux.github.        each other. Even better, Tmux lets you      Killer feature: Perfect minimalism
  io) is the best example, and is included    detach from sessions to reconnect           www.fluxbox.org
  by default in many major distros. Simply    to them later. If you’re SSHed into a       Keeps out of your way but still provides just enough to make you
  enter tmux to start it, and you’ll see a    system and running some programs            feel at home.
  green bar along the bottom. Hit Ctrl+B      inside Tmux, hit Ctrl+B followed by D to
  followed by C to create a new (full         detach and return to the Bash prompt.
  screen) window, and Ctrl+B followed by      You can now close the terminal window       6th FVWM
  N or P to switch between windows. In the    – the programs running on the remote
  panel at the bottom, you’ll see the names   server will continue. SSH back in to the
  of programs running in each window.         server and run tmux a to reconnect, and     Killer feature: Taking up your life
     Tmux provides a tiling option so you     everything will show up as it was when      www.fvwm.org
  can have multiple programs running          you detached.                               It provides pretty much every customisation option you could
                                                                                          imagine – if you’re willing to read the giant man page.



                                                                     www.linuxvoice.com                                                                     55
     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 100 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.


56                                                         www.linuxvoice.com
                                                                                                                                         NEXT MONTH



                           NEXT MONTH IN



ON SALE                                                                                   EVEN MORE AWESOME!
 THURSDAY
                                                                                                                                            Bradley Kuhn
17 DECEMBER                                                                                                                                 There are forces out
                                                                                                                                            there that want to
                                                                                                                                            take control of your
                                                                                                                                            computer away from
                                                                                                                                            you. Don’t worry
                                                                                                                                            though: Bradley
                                                                                                                                            Kuhn has got your
                                                                                                                                            back. Cheers Bradley!

                                                                                                                                            Automate RSS
                                                                                                                                            The old technologies
                                                                                                                                            from the dawn of
                                                                                                                                            Web 2.0 are not
                                                                                                                                            dead; they are only
                                                                                                                                            resting. Reanimate
                                                                                                                                            RSS, and get your
                                                                                                                                            websites to talk to
                                                                                                                                            each other.

                                                                                                                                            Documentation
                                                                                                                                            The good, the bad


THE INTERNET OF THINGS
                                                                                                                                            and the ugly of Linux
                                                                                                                                            documentation
                                                                                                                                            – and what you can
Frankly, we were unimpressed with the                                                                                                       do to make Free

Internet of Things buzzphrase – until we                                                                                                    Software better and
                                                                                                                                            more accessible for
realised that we could hack everything!                                                                                                     everyone.




       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, 2nd      Anything in this magazine may not be
andrew@linuxvoice.com            All code printed in this magazine is licensed   Floor, 5 Churchill Place, Canary Wharf,       reproduced without permission of the editor,
Technical editor Ben Everard     under the GNU GPLv3                             London, E14 5HU                               until July 2016 when all content (including
ben@linuxvoice.com                                                               Tel: +44 (0) 20 3148 3300                     our images) is re-licensed CC-BY-SA.
Editor at large Mike Saunders    Printed in the UK by                                                                          ©Linux Voice Ltd 2015
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                                                                                  57
     FOSSPICKS




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

              Out benevolent editorial overlord Graham Morrison tears himself away
              from updating Arch Linux to search for the best new free software.
Simple file transfer


Zget
H
         ow many times have you          automatically negotiate a
         been sitting with your          connection across your network,
         laptop and needed to            so you don’t need to worry about IP
quickly and instantly transfer a file    addresses or how your clients
to another computer? If you’re           connect with one another. After
anything like us, you’ve lost count.     installing the tool through Pip, the
The answer is typically to find a        Python package manager, and a bit
USB thumbdrive, or use web-based         of configuration, transferring files is
email, or even a quick installation of   as simple as typing zget filename
SSH so that SFTP works. But              on one machine, and zget filename
thanks to a tip from @nlswrnr,           on the other. The two clients should
we’ve got a solution which we’ve         find one another and instigate the
found to be far simpler to use and       transfer without any further user
particularly well suited for when        interference.
someone else is using your
computer. Zget uses the magic of          PROJECT WEBSITE                          Use Zget to quickly transfer files from one machine on a network
                                          https://github.com/nils-werner/zget
zero-configuration networking to                                                   to another.


Cloud music player


Nuvola Player 3 (beta)
P
        lease forgive us. We’ve          providers you want to use. Nuvola
        become smitten by online         currently supports 15 different
        music services, mostly           streaming services, including
because they’re so convenient and        Spotify, Google Play Music,
using them means you don’t have          Amazon, Deezer, Rdio, Plex, Tunin
to worry about taking your files with    and even Logitech’s Media Server,
you, or synchronising your music         which could be useful for accessing
before making a trip. Nuvola Player      your own local collection.
specialises in being a single portal
to several of these cloud-based          Simple sounds
services, encapsulating their web        With the plugins installed and the
interfaces into a single window on       app running, you select one of the
                                                                                   You can upload 50,000
your desktop. We’ve used the old         services to get started. The                                         cross-referencing, where a playlist
                                                                                   of your own music files
2.x version before, especially on        experience is exactly like using a        to Google Play for free,   can be created from different
Ubuntu, and there’s a major new          web browser, because that’s               and access them from       sources, but Nuvola keeps things
update on the horizon, with the          essentially what’s running within         anywhere.                  simple. And there’s a lot to like
betas of version 3 now considered        the application window. Desktop                                      about that.
relatively stable.                       integration includes notifications,
   You’ll need the player and            Scrobbling, and lyrics. We’d love to                                  PROJECT WEBSITE
                                                                                                               https://tiliado.eu/nuvolaplayer
additional plugins for whichever         see some of Banshee’s collection



58                                                              www.linuxvoice.com
                                                                                                                             FOSSPICKS


Terminal emulator


Terminology 0.9
T
        he multiple promises of          those physical attributes is quite
        future computing interfaces,     good fun, especially when they
        as seen in films like Minority   don’t impede on function, and this
Report, or perhaps the positronic        is where Terminology comes in.
brains of Asimov’s robots, seem to          Terminology is a smooth,
make an anachronism of the               feature-packed terminal emulator
manual command line. And yet it’s        that takes the emulator part
2015, and many of us use it daily.       seriously. By default, its simple
   But the command interpreter is        X-Term startup configuration glows
only one part of the interface, with     from the strip lighting of your virtual
                                                                                   Terminology is part of
the other part being the host for the    1981-era computing laboratory.                                       on files, URLs, email addresses and
                                                                                   Enlightenment, but
terminal session. Unless you still       Right-click, and smooth scrolling         works brilliantly on any   music just like a desktop would.
access Bash through a late 1970s         menus let you change everything           desktop.                   There’s even a visual virtual
video terminal, these host               about its appearance. Behind the                                     ‘session’ mode. But the best thing
applications are called terminal         scenes it can work with the latest                                   about Terminology is that it remains
emulators, mostly because they           technology, such as OpenGL or                                        quick and responsive, turning what
emulate the function of those late       Wayland, and some of the oldest,                                     could have been a rudimentary
1970s video terminals.These all          like the framebuffer, and it can act                                 Bash session into a modern
provide a similar feature set, and                                                                            terminal session with some neat
integrate well with your chosen
environments. But one thing they
                                            Terminology is a smooth,                                          references to the past.

don’t do is emulate the physical            feature-packed terminal                                            PROJECT WEBSITE
characteristics of those early                                                                                 https://www.enlightenment.org/

terminals. But experiencing a few of        emulator for Linux                                                 about-terminology




Development environment


KDevelop 4.7.2
K
         DE has just celebrated its      but Qt’s recent emphasis on touch,
         19th birthday and for many      mobile and proprietary modules
         of those years, it was its      has meant KDevelop is just as
integrated development                   important as ever. Thankfully, with
environment, KDevelop, that made         over five years since the first
KDE as accessible as possible to         re-written 4.0 release, KDevelop has
new developers. Like KDE itself,         come successfully through its dark
KDevelop lost its way when a major       period, with this latest release being
update was quickly followed by a         another strong revision to the major
long-promised code overhaul that         4.7.0 update that appeared in 2014.
eventually led to a complete rewrite.
   At the same time, the Qt project      KDE made easy(er)
                                                                                   KDevelop is just like a
– used heavily by all KDE                Help integration, code completion,                                   you can have multiple sessions
                                                                                   version of KDE’s
developers – released its own            huge performance improvements,            excellent Kate text        open, which is useful if you’re using
much more functional development         PHP support and a powerful plugin         editor augmented for       one project to learn from while
environment, the wonderful Qt            system make it a must-try for KDE         developers, which is       coding into another, but the best
Creator. Qt Creator benefited from a     developers, and even other                exactly what an IDE        thing about KDevelop is that it’s
full-time team and the official          programmers looking for a modern          should be.                 remained relatively lightweight and
backing of the Qt project, quickly       IDE. There’s Gnome and wxWidgets                                     straightforward, unlike its previous
making it slick, stable and just as      support, for example, along with                                     incarnation.
capable as the older KDevelop.           support for languages like Python,
   Qt Creator is still a great open      Perl, Ada, Java and Ruby alongside                                    PROJECT WEBSITE
                                                                                                               https://www.kdevelop.org
source development environment,          the perennial C++. We like the way



                                                               www.linuxvoice.com                                                               59
     FOSSPICKS


Interior design


Sweet Home 3D 5.1
H
          ell has indeed frozen over.   Maslow’s hierarchy of needs. You
          Not only has Microsoft        start by creating the floor plan,
          created its own Linux         dragging the mouse to generate
distribution, but we‘re now covering    walls with satisfying angles. You
interior design software in the         can even add skirting boards and
pages of a Linux and open source        vary the thickness of your
magazine! But fear not. Thanks to       partitions, perfect for the slanted
open source, we’re already ahead of     walls of a gym or swimming pool.
the game. We can reveal, for                The background grid snapping
instance, that we’ve reached peak       and the distance/angle annotations
Château Grey and French Linen for       make it easy to recreate a real
colouring, and that next season’s       environment – you’ll just need to
                                                                                Bring a riot of colour to
hues will be more vibrant, with         take a few measurements. You                                        but it does include both the RAL
                                                                                your garden room in
yellow-based neutrals and velvet        then drag and drop doors and            complete and immersive      and Creative Commons colour
flocked paper coming back into          windows into your scene, before         3D.                         matching lists, and dialling in your
style. We know this because we’ve       moving on to the huge variety of                                    isn’t a problem. When you’re
experimented with our own               furniture and fittings listed in the                                finished, you can stroll around the
palettes, textures, layouts and         hierarchical list.                                                  real-time 3D view using WASD keys,
furniture, transforming our                 When you’re happy with the                                      or by dragging a symbol around the
bedroom offices without spilling a      layout, you get to play with colours                                plan, and you can even render a
drop of paint. And we’ve done this      and textures, and every surface can                                 ‘photo’ within the application, with a
thanks to Sweet Home 3D.                be modified and adapted according                                   surprisingly photo-realistic quality
                                        to your creative whimsy. We were a                                  (although it takes a long time), or
Sweet Home panorama                     little disappointed that the palette                                output the entire scene as an object
Despite initially sounding like an      selection tool didn’t include the                                   file for Blender. We found the entire
add-on for the popular life             latest collection from Farrow & Ball,                               process hugely enjoyable, and that’s
alternative, The Sims, Sweet Home                                                                           without any kind of motivation to
3D is a serious design tool that
combines draughtsmanship, 3D
                                           Sweet Home 3D combines                                           tidy-up the place or get on
                                                                                                            makeover TV.
modelling, texture mapping and             3D modelling, texture
rendering with a sense of homely                                                                             PROJECT WEBSITE

belonging taken directly from              mapping and rendering                                             www.sweethome3d.com




How it works: Build your perfect home




 1
   Use the ‘Create walls’ and ‘Create rooms’      2
                                                    Add the doors, windows, furniture and           3
                                                                                                      The final output can be rendered within
modes to drag your layout into existence,        furnishings. Import external models if            the application, or exported as an object file
using either your imagination or real-word       required. All colours, textures and materials     that can be processed or raytraced in a 3D
coordinates from your own property.              can be changed according to taste.                application like Blender.



60                                                           www.linuxvoice.com
                                                                                                                             FOSSPICKS


Minimal browser


Dillo 3.0.5
A
         lthough all of us on the       at Dillo, which has recently been
         team still love Firefox, and   upgraded to version 3.
         consider it one of the most       Dillo is lightning fast, which is the
important open source projects out      first thing you notice after launching
there, there are murmurings of          its 725k binary. Its page loading
disillusioned after recent              speed takes you back to a time
developments. In particular, Firefox    before the irony of responsive web
is no longer a lightweight web          design, before JavaScript and even
browser, requiring significant          before image maps.
amounts of RAM and CPU if you              But so too does its rendering,
open more than a dozen tabs at          which is sparse, often appearing
once. This has left us eager to find    broken and the opposite of what
an alternative, at least for the        many modern browsers would
                                                                                   Even Dillo’s cache is
majority of browsing we do, which       expect. However, as it should                                         compromises are all made for
                                                                                   cleared when you quit
is searching for our own names and      always be, the words are always            the browser, helping       speed. We really enjoy using Dillo,
keeping abreast of                      legible and navigation remains             both speed and your        and while it’s slightly too minimal
/r/ToasterRights.                       clear. Like a Formula 1 racing car         privacy.                   for day-to-day use, it’s brilliant on
   This is one of the reasons we        that’s unsuitable for roads, Dillo’s                                  devices like the Raspberry Pi, or on
found Qutebrowser so effective –                                                                              an older machine that rarely needs
the combination of low resource
usage, good rendering and Vim-like
                                           Dillo is lightning fast, which                                     to render a web page.

shortcuts revolutionised our               is the first thing you notice                                       PROJECT WEBSITE
browsing behaviour. And it’s also
another reason we’re taking a look         on launching its 725k binary                                        www.dillo.org/screenshots/index.html




Secure messaging


Cutegram 2.7.0
W
            e’ve covered quite a few    has become the go-to application
            secure instant              for many. This is the other side of
            messaging platforms in      the Faustian pact in secure
the past, but Cutegram has become       messaging. You need to use a client
one of our favourites. As its name      the other person is using too.
implies, this is a Telegram client
built atop the Qt framework             Always compromises
(pronounced ‘cute’ by developers).      Ignoring the almost-impossible-to-
   Telegram is a well established       certify security, Telegram is still a
platform for messaging securely         great platform, and there are
                                                                                   Telegram’s encryption
and privately. There are official       several features specific to                                          with your contacts, theoretically
                                                                                   reportedly uses
clients for nearly every device –       Cutegram that make it our favourite.       Diffie-Hellman key         making it very difficult for a
including another Qt-based offering     The QML design is lightweight and          exchange – we hope         third-party to crack the data.
for Linux, and even a client that can   fast, fitting in well with almost any      this has been updated in      We all now send many messages
be driven from the command line.        desktop. Transitions are smooth            teh wake of the NSA’s      today, and it’s very likely that all the
They’re all open source, but the        and give a very modern style to the        supposed learning how      protocols you use are insecure (look
server software that binds clients      user-interface, and you can send           to crack this method.      at SMS, for instance). Telegram isn’t
together is closed – however, many      and receive messages from more                                        perfect, but it is a great application
users trust Telegram enough to          than one account too, even with                                       that’s more open than most.
make it their default                   ‘emoticons’, whatever they are.
communications tool, and with a         Telegram’s best privacy/security                                       PROJECT WEBSITE
reported 60 million users sending       feature is also easily accessible,                                     http://aseman.co/en/products/
                                                                                                               cutegram
12 billion messages every day, it       providing end-to-end encryption



                                                              www.linuxvoice.com                                                                  61
     FOSSPICKS


Software synthesizer


Oxe 1.3.3
A
          t the very beginning of Tom          timbres, and they’re quite different                                        the mid-90s, for example, as a
          Cruise’s classic 1980s               from the classic subtractive sounds                                         single chip of an FM synthesizer
          movie, Top Gun, Harold               of older synths.                                                            was nearly always bolted on to
Faltermeyer’s soundtrack begins                                                                                            every soundcard and console.
with a very distinctive low chiming            Oxe grinding                                                                   As you’d imagine from one of the
sound, and it’s a sound that can be            The second reason the DX7 was                                               first digital synthesizers, there have
heard across many other                        revolutionary was because it was
recordings of the era. This sound is           digital. Yamaha cannily bought the                    Oxe FM is a VST synth
a preset from the most                         rights to the algorithms in the
revolutionary synthesizer of the               1970s, and by the 1980s, advances                     plugin that replicates the
time, Yamaha’s DX7, and the sound
was called ‘TUB BELLS’ in reference
                                               in integrated circuits meant it could
                                               finally implement in software what
                                                                                                     sound of the DX7 synth
to the instrument made famous by               other synths were doing in                                                  been many recreations in software.
Mike Oldfield over a decade before.            hardware. They built a synthesizer                                          But good ones are rare, which is
   The DX7 was revolutionary for               that was technically superior while                                         why when one of the best Windows
two reasons. Firstly, its sound                costing considerably less than the                                          FM synths became open source
generator was driven by frequency              competition. The DX7 was cheap,                                             and then started bundling a Linux
modulation. This is where a simple             robust, duo-timbral and polyphonic,                                         version, we had to take notice.
‘carrier’ waveform has its frequency           unlike almost any other synth. This                                            Oxe FM is a VST synth plugin that
modulated by another waveform                  is why the sound of Yamaha’s FM                                             recreates the sound of the DX7.
operating within the audio range,              synthesis is all over the 80s. While                                        There’s even an optional skin to
creating almost infinite complexity.           early FM sounded fresh and                                                  make it look like one. To install it,
The sounds it generates are                    modern, its ubiquity soon left it                                           you’ll need a VST-compatible host
incredibly distinctive, especially for         feeling cheap. You’ll have heard                                            such as QTractor or Ardour. You
brass, bass, string and bell-like              them in almost every game from                                              then place the pre-compiled .so
                                                                                                                           binary into a location that you add
                                                                                                                           to the plugin path of your host. The
                                                                                                                           plugin should then appear just like
                1                                                                                                          any other. FM synthesis is still
                                                                                                       3
                                                   2                                                                       complicated, and this makes the
                                                                                                                           Oxe GUI look more intimidating than
                                                                                                                           you might expect. There are six
                                                                                                                           operators, just like the original DX7,
                                                                                                                           plus a noise generator and a filter.
                                                                                                                           These are all mixed together in a
                                    4                                                                                      huge bank of knobs known as a
                                                                                                                           modulation matrix. This cleverly
                                                                                            7
                                                                                                                           allows you to mix the input from
                                                                                                                           one source into another, as well as
                                                                                                                           the final output. But you don’t need
                                                                                                                           to understand anything about FM
                                                                                                                           to use the synth. It comes with a
                                                                                                                           couple of banks of excellent
                                                                                                                           presets, revealing the 1980s in all
                                                                                                 8                         their Day-Glo glory, and you can
                                                                                                                           obviously change and adapt these
                                                                                                                           sounds to suit your own purposes.
                    5                                      6                                                               We think it sounds fabulous, and
                                                                                                                           with FM making a retro-comeback,
1 Display For parameter feedback and preset names 2 Presets Switch between the 2 banks of 127 presets
                                                                                                                           there’s never been a better time to
3 Effects Add excellent delay and reverb effects 4 Operators These generate sound from a preselected waveform              get re-acquainted with the DX7.
5 Noise/Envelopes Each operator has control of amplitude over time, plus pitch, except this noise generator

6 Filter Mix outputs from the other operators into a simple filter 7 Mod Matrix Set modulation levels for each operator,    PROJECT WEBSITE
and mix values for filter, noise and outputs 8 LFO Add repeating modulation and change mix levels.                          www.oxesoft.com




62                                                                     www.linuxvoice.com
                                                                                                                               FOSSPICKS


  FOSSPICKS Brain Relaxers
https://launchpad.net/pybik/
 Strategy game


 Tanks of Freedom 0.3-7 beta
 I
      f you read our tutorial in issue     skirmish, and battle against other
      20 on the Godot games                humans. There’s even a map
      creation engine and were             editing mode for creating your own
 intrigued by what kind of results         scenarios, which is great fun in
 might be possible, Tanks of               itself. Despite the game’s beta
 Freedom is a perfect example. It’s        status, we found performance was
 a excellent old-school turn-based         excellent, with the game already
 strategy game, where you move             playable and addictive enough to
 and upgrade units to take best            keep you playing.
 advantage of your resources. Its             Without packages for our
 design is gorgeous and soaked in          distribution (Arch) we needed to
                                                                                    We love the original
 nostalgia thanks to its isometric         first grab the Godot games engine,                                  can make your own contribution,
                                                                                    soundtrack that comes
 pixel art, fabulous chip-tune             which needed to be built, and then       with the game, complete    or just dive in to see how it works.
 music and artefact-laden speech           download the latest Tanks of             with speech synthesized      Overall, this is a well thought
 synthesis. The 16-bit pixel art of        Freedom files from the code              title screen effects.      out and designed game that
 older versions has been updated           repository. These totalled only                                     genuinely brings that old-school
 to 32-bit, but its isometric layout       12MB and included the game logic,                                   RTS feeling to your Linux desktop,
 and the movement of the units             artwork and sound. All we then                                      and definitely worth a look if
 very much feels like an old game.         needed to do was add the                                            you’ve got some time to fill.
 The gameplay will feel familiar to        configuration file as a new project
 anyone who’s played Westwood’s            within Godot, pressing Play to the                                   PROJECT WEBSITE
 old Dune II game, and you can             launch the game. Launching from                                      http://w84death.itch.io/tanks-of-
                                                                                                                freedom
 play a campaign, or a one-off             the Godot engine also means you




 Platformer


 Sol 1.2
 S
        ol is a brilliant platformer       also borrowed from perennial
        that’s a little different to the   classics like Mario. The game is
        games we usually feature           bright, colourful and challenging.
 in this section. That’s because it’s      The visual style is primitive, but the
 being sold for $14.99. But what’s         level design is absolutely top-notch.
 especially impressive is that the            The toughness of the levels is
 game really is open source, and           countered by unlimited lives, which
 you can still download, copy and          seems like an unusual choice for a
 build your own version from the           game like this. It means you spend
 GPLv3-licensed source code.               more time experimenting and
 However, as the website says,             simply enjoying the levels, but it
                                                                                    Sol is a game you can
 “We trust you to support us.” is          removes much of the tension and                                     platformers (especially ones with
                                                                                    buy and download; but
 also what we do here at Linux             stress that goes with a platform         you can also download      properly thought-through story
 Voice, so we’d highly recommend           game, especially a game with             the GPLv3 licensed         arcs) are difficult to find, and Sol
 downloading the demo, playing             aspirations for 1980s nostalgia.         source code and build it   is a great example. We’d love to
 the first three levels and buying         However, properly designed               yourself.                  see the game become successful
 the game if you like it.                                                                                      enough that the developers write
    The game itself is 18 levels of
 tough platform action.
                                              The visual style is primitive,                                   another, and release that as open
                                                                                                               source too.
 Graphically it reminds us of Alex            but the level design in Sol is
 Kidd, an arcade game from the                                                                                  PROJECT WEBSITE

 80s, but game mechanics are                  absolutely top notch                                              http://sol.azurasun.com




                                                                www.linuxvoice.com                                                                  63
                                                                                                                    INTRO TUTORIALS




TUTORIALS
Warning: excessive Linux knowledge may lead to fun and more efficient computing.

                                                In this issue . . .
                                                                                            66                                                   68




Ben Everard
Makes mistakes, but tries to learn from them.
You should too.
                                                Give presentations                                    Type without touching
                                                anywhere with HTML                                    the keyboard.


I
                                                HTML is the one universal language, so                John Lane is too lazy to type commands. Join him
      ’ve been battling hand pain for a         Valentine Sinitsyn uses it for presentations and      as he delves deep inside his terminal to automate
      little over a year now, and I finally     doesn’t get caught out by software mismatches.        the process of entering text.
      feel like I’ve found the right
combination of exercises, computer
peripherals and medication to work
comfortably again. It’s not been a fun
experience. You should learn from my
mistakes: don’t ignore twinges; don’t
put off going to the doctor because you
feel you’re too busy and don’t wait until
it’s too late to make changes to your
work setup.                                     Build a quiz machine          72    Monitor over Bluetooth         76   Database 101                 80
    We should consider using a                  Motors, cardboard and glue are      Ben Everard never likes to be       Find out how web apps work
computer to be a dangerous activity             the only things Les Pounder         away from his computer, so he       with part two of Mike Saunders’
because, well, it is. There’s a good            needs to start a game show.         stays in touch with Bluetooth.      database series.
chance that sitting at a desk for work
will, at some point, leave you in pain.
    This isn’t something you can
abdicate to your employer’s health and
                                                Coding
safety team, because you’ll suffer a lot
more than them if anything goes
wrong. Take a little time now to
research the best posture and
ergonomics. Be prepared to spend a
little on a decent keyboard and mouse.
Think very carefully before committing
to using a laptop long term. They may
be convenient, but do they enable you           Economic modelling           84     Build a filesystem             88   Functional programming         90
to sit in a safe position? Don’t wait until     Andrew Conway models                Writing to files is for wimps.      Juliet Kemp enters the world of
it becomes a problem: take action now.          mathematical equations with his     Ben Everard builds an entire        Haskell with only functions to
    ben@linuxvoice.com                          drag-and-dropping finger.           filesystem to save his data.        guide her.



                                                                  www.linuxvoice.com                                                                 65
         TUTORIAL SHOWER




    SHOWER: BUILD HTML-
    BASED PRESENTATIONS
    Making a presentation should be no harder than writing a blog post.


                                    W
VALENTINE SINITSYN                                  hatever job you do, you're likely to do
                                                    presentations from time to time. A de-facto
                                                    standard slide maker is Microsoft
    WHY DO THIS?                       PowerPoint. It's certainly powerful (perhaps too much
    • HTML is a standard               for an occasional presenter), but non-free, and
      that renders the same
      everywhere                       provides no support for Linux to date. LibreOffice
    • Focus on content, and let        Impress is a close free alternative, and it can even
      the system handle styling        handle PowerPoint documents, up to a point.
    • Easily publish your slides          The trouble is that quite often PowerPoint
      online or export them            documents are rendered differently on different
      to PDF
                                       machines. You know what we mean: fonts could                   Simply toggle the browser window to full-screen, and
                                       be different shapes and sizes, equations missing or            press F5 to begin the presentation.
                                       garbage and so on. Impress can always export your
                                       slides to PDF: this way, you gain fidelity but lose much       Shower recognises several hotkeys: Space/➝/
                                       of the interactivity. Modern web browsers are quite            moves to the next slide, Shift+Space/➝/ / brings
                                       powerful and flexible, too – so, why not use a browser         you back, and F5 toggles presentation mode, as in
                                       as a presenter tool?                                           Impress. For that reason, you can't use F5 to reload
                                          Shower is a JavaScript library that makes it easy           a page. If this bothers you, use browser add-ons, like
                                       to create presentations with plain HTML and CSS.               Auto Reload for Firefox.
                                                      There's no visual editor as in PowerPoint/
                                                      Impress, but if you already use HTML            Laying out slides
    PRO TIP
                                                      or Markdown for your blog, everything           Shower treats everything with a slide class as a slide.
    When you copy-paste a slide, remember
    to change its ID, otherwise Shower may            should go smoothly.                             Usually, it's <section/>, and the slide body goes
    behave oddly.                                        To start a presentation, download            wrapped in a <div> inside it. You can use any HTML
                                                      http://shwr.me/shower.zip and unzip it.         markup you like, but as usual, avoid being too noisy.
                                                      Now, open your favourite text editor and        Better stick to lists, paragraphs, headings and images.
    Your slides may include            start making   changes.   The archive already contains            For starters, give your presentation a title. Simply
    not only images, but also          many   "lorem  ipsum"  slides  of varying layouts you can      edit the contents of <title/> in the page head, and
    equations, thanks to the           use  as templates   or for reference.  Usually, this is more   <header/> in the body. Now, proceed to slides. Text
    MathJax library.                   effective  than starting from   scratch.                       goes in <p>, and headings use <h2>. Bullet (<ul>)
                                          After you finish a slide or two, save your work and         and ordered (<ul>) lists, hyperlinks (<a>), quotations
                                       preview the presentation (index.html) in a browser.            (<blockquote>) and even tables are readily supported
                                                                                                      and styled appropriately. Each slide has an ID (either
                                                                                                      explicitly assigned or an automatically generated
                                                                                                      ordinal: 1, 2, 3...), so you can create cross-references
                                                                                                      via <a href="#id"/>. Sometimes, a slide may carry just
                                                                                                      a few words, like "Questions?". In these cases, use the
                                                                                                      shout class to style it. Non-default Shower themes
                                                                                                      may define additional classes.
                                                                                                         The <footer> tag is somewhat special. Its contents
                                                                                                      are hidden in presentation mode, but shown on a
                                                                                                      mouseover in the slides view, which is convenient for
                                                                                                      leaving notes to self:
                                                                                                      <section class="slide"><div>
                                                                                                       <footer>Remember the milk</footer>
                                                                                                      </div></section>



    66                                                                  www.linuxvoice.com
                                                                                                                          SHOWER TUTORIAL


  You can also define your own custom styles with                                                                                  Shower even makes your
<style/>. Usually you do it straight in a slide's body.                                                                            tables look stylish.
Styles are reusable across slides, and they come
handy to position images, for example:
<section class="slide centred"><div>
 <img src="images/chart.svg">
 <style>
  .centred img {
       width: 60%;
       margin-left: 20%;
       margin-right: 20%
  }                                                                 <body>
 </style>                                                            ...
</div></section>                                                     <script src="prismjs/prism.js"></script>
   This works best for scalable image formats, like                 </body>
SVG. Alternatively, the cover class stretches an inner                 That's it! Now, wrap your code snippet like this:
image across the slide like background.                             <pre><code class="language-python">print('Hi')</code></
   Shower doesn't sport funky animations like Impress               pre>
or PowerPoint, but it does provide some interactivity.              and it should render highlighted. Don't forget to
If you add the next class to any slide fragment, it will            escape HTML special characters like <, > or &. Also,
remain hidden until you advance to it with Space or                 Shower's slides aren't big, so be picky and show
another shortcut. This way, you can reveal contents                 relevant lines of code only.
as you proceed with your speech.                                       If you're making a scientific report, it's equally easy
                                                                    to embed beautifully looking formulas. The MathJax
Going further                                                       library renders Tex, MathML or even ASCII math
As you can see, Shower's feature set is rather basic.               straight inside a browser. Grab it from www.mathjax.
Still, your presentation is just a web page, so there are           org, but this time it'd be a big download: the library
many ways to enrich it.                                             spans more than 30,000 files counting towards 150
  Say you want to show a code snippet. Shower can                   megabytes when unpacked. This can make syncing
do it out of the box, but that doesn't look particularly            your slides to Dropbox or unzipping them rather slow.
impressive. There are more capable JavaScript syntax                   Two solutions are possible. First, you can use
highlighters available, and I usually choose Prism for              MathJax CDN, and I'd opt for this unless you are
simplicity and language support.                                    unsure about internet availability. Or, you can trim
  Start with downloading minified JavaScript and                    MathJax locally, either with Grunt or a Python script
CSS files from www.prismjs.com. Use a configurator                  (https://github.com/yuexue/small_mathjax). The
to select the theme and languages you need, then                    former is an official option, but it relies on particular
put the files, say, under the prismjs folder next to the            web developer tools. If you don't have them installed,
presentation's index.html.                                          the latter would probably be simpler.
  Now, include Prism's CSS in <head> and JS – in the
bottom of <body>:                                                   Final touches
<head>                                                              So far, we've covered all aspects of a typical
 ...                                                                presentation. But before you start a show, there are
 <link rel="stylesheet" href="prismjs/prism.css">                   some minor issues to address. You may not like a
</head>                                                             progress bar going along the bottom of a slide, or you
                                                                    may not want the "Fork me on GitHub" ribbon, if your
                                                                    slides aren't really on GitHub.
   Jekyller                                                            Both are easy to remove. To get rid of the
   You may not like or know HTML, but in a blogging era             progress bar, delete <div class="progress"/>. <p
   you are almost certain to use some other markup, like            class="badge"/> renders the ribbon, and you can
   Markdown. If so, you can still run Shower thanks to Jekyller.
   As the name suggests, it's based on Jekyll (www.jekyllrb.        remove it as well.
   com), a free static website generator written in Ruby.              Finally, you may want a PDF version of your slides
      Jekyller is especially handy if you have a GitHub account.    for 100% fidelity, or for hand-outs. Shower handles this
   Just fork it from https://github.com/shower/jekyller,
                                                                    easily: just open your presentation in list mode and
   make changes as needed, commit them, and push back to
   GitHub. In a minute, your slides will be translated to GitHub    use the "Save as PDF" option available in Chromium-
   Pages and made available at http://your_name_here.               based browsers. Alternatively, you can do it from the
   github.io/jekyller for free! You don't even need to carry your   command line with the wkhtmltopdf tool.
   presentation around on a USB stick anymore. Still, if you
   want to, you can convert your Markdown presentation to            Dr Valentine Sinitsyn teaches physics, develops high-loaded
   plain HTML locally with the jekyll command.                       services and does other clever things with Python.




                                                                       www.linuxvoice.com                                                               67
      TUTORIAL FAKING INPUT




FAKING INPUT – TYPE
WITHOUT A KEYBOARD
Fed up with typing? Write a script to inject keystrokes into any terminal.

       JOHN LANE
                               I
                                   magine a really complicated command – one                know as the standard input, output and error. But
                                   that's far too complicated to type and one that          they're actually the same thing. See this:
                                   differs every time it's used. One that even              $ ls -l /dev/fd/
WHY DO THIS?                   keyboard-junkies would baulk at. One that you still          lrwx - - 1 john users 64 Jul 9 09:33 0 -> /dev/pts/22

• Learn how terminals work     need to edit and use interactively. A lot.                   lrwx - - 1 john users 64 Jul 9 09:33 1 -> /dev/pts/22
• Automate keyboard input         You think to yourself "I know, I'll write a script to     lrwx - - 1 john users 64 Jul 9 09:33 2 -> /dev/pts/22
                               generate the command line for me and write it at the            These files (technically they're "file descriptors"
                               prompt ready for me to edit before pressing Enter to         rather than real files) are for standard input (0), output
                               run it".                                                     (1) and error (2) but they're all just symbolic links to
                                  Fantastic! It should be easy, right? You get writing      the same thing: a file representing the terminal that
                               and suddenly realise that your echo and printf output,       you're using. This is most likely a terminal window on
                               although looking pretty good, isn't showing at the           your desktop (a pseudo-terminal, or pts, implemented
                               prompt. Then the penny drops: standard output is the         in software) rather than being a real one. If you
                                                                                            aren't running a graphical environment then you'll
                                                                                            see something like /dev/tty1, which is the terminal
     One of the defining features of Unix is                                                implemented in the Linux kernel that displays text on
     that everything is a file, and files can be                                            your monitor and accepts input from your keyboard.
                                                                                               It's also possible, although less likely these days,
     read from and written to                                                               that your terminal is separate hardware connected to
                                                                                            your computer via a serial line (this remains a popular
                               wrong place. What about writing to standard input ?          way to connect to embedded or ARM-based small-
                                  But how? Surely there must be a way? Well there is,       board computers). Whatever kind of terminal you're
                               kind-of. In fact there are a few ways, and this month,       using, you can see its file:
                               we'll share them with you.                                   $ tty
The route from terminal           One of the defining features of Unix is that              /dev/pts/22
to process always goes         "everything is a file" and files can be read and written.       What you type on your keyboard can be read from
through the kernel.            Every process gets three of them by default that we          this file and anything written to it will be output. You


                      VGA
                     Driver                                                                                                       tty
                                                                                                                                  pts
  Display
                                                  Terminal
                                                                                                      TTY
                                                  Emulator
                                                                                                     Driver
                                                                                                                                             Shell
                                                                                  Line                                                  (or other process)
                                                                               Discipline
  Keyboard

                    Keyboard                                                                                                                Terminal
                     Driver                                                                               PTY Master                         (xterm, etc)




 Physical                                                  Linux Kernel Space                                                        User Space



68                                                             www.linuxvoice.com
                                                                                                                    FAKING INPUT TUTORIAL


                                                                   command sets this up:
  Other ways to inject keystrokes                                  $ bind '"\e[0n": "ls"'
  If your environment meets certain prerequisites then you           Now, whenever the terminal sends an OK status,
  may have other methods available that you can use to             the shell will output ls instead. It will appear at the
  inject input.                                                    prompt and you can hit Enter to execute it. We just
      If you're in a desktop environment, xdotool is an X.Org
                                                                   need to request a device status from the terminal:
  utility that simulates mouse and keyboard activity, but your
  distro may not include it by default. You can try:               $ echo -e '\e[5n'
  $ xdotool type "ls"                                                 You'll see ls appear after the prompt with the cursor
     If you use tmux, the terminal multiplexer, you can do this:   after it, just as if you'd typed it.
  $ tmux send-key -t session:pane ls
                                                                      There are limitations to this approach, not least that
  where -t selects which session and pane to inject. GNU
                                                                   the shell needs to support key binding. It won't work
  screen has a similar capability with its stuff command:
  $ screen -S session -p pane -X stuff ls                          in sub-processes, which means that it won't work in
    If your distro includes the console-tools package then         scripts unless they are sourced instead of executed.
  you may have a writevt command that uses ioctl like our          It may suffice for some applications and relies solely
  examples. Most distros have, however, deprecated this            on Bash internals and a terminal that plays along
  package in favour of kbd, which lacks this feature.
                                                                   (practically all do). But there's a better way…

                                                                   Tap the pipe
can try this: open another terminal and type                       Let's go back to the pipe. It leaves the
$ echo -e "ls\n" > /dev/pts/22                                     terminal at its master end and ends up
                                                                                                                         PRO TIP
   The command will appear in the other terminal                   with its slave end in the shell. The route it
                                                                                                                         The origin of tty, which is an abbreviation
but it won't be executed. Why? What you've done is                 takes to get there goes through the
                                                                                                                         of teletype, can be traced back to the
effectively the same as writing to standard output:                kernel, as the diagram illustrates,                   invention of the stock ticker in the 19th
what gets written to the terminal gets displayed on                passing the Line Discipline, which                    century.
the terminal. Think of that file as one end of a pipe.             implements device semantics such as
What you put in comes out the other end and you can                control characters (interrupt, kill, etc),
only take out what's been put in at the other end. The             and the TTY Driver.
other end is the terminal: if it's a pts then it's a desktop          The TTY driver is a kernel device driver and, like
application such as Gnome Terminal, Konsole or maybe               all device drivers, has a control interface that is
just Xterm. If it's a tty then we're talking about code            accessible via the kernel ioctl system call – a generic
inside the kernel. Remember that a shell like Bash is              function for sending commands to device drivers.
a separate process to the terminal. It's connected to              The commands supported by the TTY driver are
the end of the pipe represented by the pts file; the "s"           documented on the tty_ioctl man page and one of
means "slave" and the "master" is the terminal's end.              them is of interest to us.
   To send data to the shell we need to put it in the                 The TIOCSTI (Terminal ioctl Send-Terminal-Input)
master end of the pipe that's inside the terminal. Can             command is used to inject characters into the input
we get the terminal to send something that didn't                  stream – they go straight into the pipe and come out
come from its keyboard?                                            in the userspace process when it reads its standard
                                                                   input. When the shell does this it displays the received
Escape sequence initiated…                                         characters at its prompt.
Since the days when most terminals were devices                       There is no command built into the shell for this;
connected to serial ports, they have supported escape              doing so requires an external command. There
sequences. These are sequences of one or more                      isn't such a command in the typical GNU/Linux
characters that can be sent to the terminal that aren't            distribution, but it isn't difficult to achieve with a little
displayed but are instead interpreted as commands.                 programming. Here's a shell function that uses Perl:
They were originally used to configure connection                  function inject() {
parameters but now have many purposes such as                          perl -e 'ioctl(STDIN, 0x5412, $_) for split "", join " ", @
cursor positioning and colour. Try this:                           ARGV' "$@"
$ echo -e "\e[31mThis is RED"                                      }
   The \e is interpreted as the escape character (Esc,                  You can then do:
ASCII code 27). You should see some text displayed                 $ inject ls -l
in red. What's interesting about this is that there are            which prints ls -l after the prompt and followed by the
some escape sequences that cause the terminal to                   cursor, ready to be executed when the user hits Enter.
return other escape sequences – characters that                      You may prefer to create standalone scripts in your
didn't come from the keyboard! We can send a device                favourite language. Here's one in Perl (inject.pl):
status request and the terminal will respond that it's             #!/usr/bin/perl
OK by sending four characters: <ESC>[0n.                           ioctl(STDIN, 0x5412, $_) for split "", join " ", @ARGV
   We can then use a feature built in to Bash that                   0x5412 is the value of the TIOCSTI constant
replaces input characters with others. The bind                    defined in the standard C header file. You can



                                                                        www.linuxvoice.com                                                                        69
     TUTORIAL FAKING INPUT


                                                                                            terminal file and use its file descriptor instead:
                                                                                             fd = open(f, O_WRONLY|O_NONBLOCK);
                                                                                            where f is the required file (eg /dev/pts/25), and then
                                                                                             ioctl(fd, TIOCSTI, &c);
                                                                                               It defaults to the current terminal but accepts a
                                                                                            command line argument to specify another one. It
                                                                                            also sends a newline by default but, similar to echo, it
                                                                                            provides an option to suppress it. The GNU ArgParse
                                                                                            library is used to process the command line options.
                                                                                               Compile it with gcc -o inject inject.c. Prefix the text
                                                                                            to inject with -- if it contains any hyphens to prevent
                                                                                            the argument parser misinterpreting command-line
                                                                                            options. See ./inject --help for an explanation of the
                                                                                            command line options and use it like this:
                                                                                            $ inject --tty /dev/pts/25 -- ls
                                                                                            or to inject the current terminal:
                                                                                            $ inject -- ls
With the right permissions
                             generate the equivalent Perl header, sys/ioctl.ph and            We mentioned that injecting into another terminal
it's possible to control
another terminal.            then use TIOCSTI instead of using the numeric value:           requires an administrative privilege and this can be
                             $ (cd /usr/include; sudo h2ph -a -l sys/ioctl.h)               obtained by:
                                  Now the script can be written a little more legibly:        Running the command as root,
                             #!/usr/bin/perl                                                  With sudo,
                             require "sys/ioctl.ph";                                          giving it the CAP_SYS_ADMIN capability or
                             ioctl(STDIN, &TIOCSTI, $_) for split "", join " ", @ARGV         setting its setuid bit.
                                If you don't like Perl, perhaps Python is your thing          To assign CAP_SYS_ADMIN:
                             (inject.py):                                                   $ sudo setcap cap_sys_admin+ep inject
                             #!/usr/bin/python                                                To assign "setuid":
                             import fcntl, sys, termios                                     $ sudo chown root:root inject
                             del sys.argv[0]                                                $ sudo chmod u+s inject
                             for c in ' '.join(sys.argv):
                                 fcntl.ioctl(sys.stdin, termios.TIOCSTI, c)                 Keep it clean
                             or, perhaps Ruby (inject.rb):                                  You may have noticed that injected text appears
                             #!/usr/bin/ruby                                                ahead of the prompt as if it were typed before the
                             ARGV.join(' ').split('').each { |c| $stdin.ioctl(0x5412,c) }   prompt appeared (which, in effect, it was) but it then
                             or even C (inject.c):                                          appears again after the prompt.
                             #include <sys/ioctl.h>                                           One way to hide the text that appears ahead of
                             int main(int argc, char *argv[])                               the prompt is to prepend the prompt with a carriage
                             {                                                              return (\r, not line-feed) and clear the current line
                                 int a,c;                                                   (<ESC>[M):
                                 for (a=1, c=0; a< argc; c=0 )                              $ PS1="\r\e[M$PS1"
                                  {                                                           However, this will only clear the line on which the
                                      while (argv[a][c])                                    prompt appears. If the injected text includes newlines
                                       ioctl(0, TIOCSTI, &argv[a][c++]);                    then this won't work as intended. Another solution
                                      if (++a < argc) ioctl(0, TIOCSTI," ");                disables echoing of injected characters. A wrapper
                                  }                                                         uses stty, a tool that uses ioctl, to do this:
                                 return 0;                                                  saved_settings=$(stty -g)
                             }                                                              stty -echo -icanon min 1 time 0
                                  Compile the C code to a binary                            inject echo line one
                             $ gcc -o inject inject.c                                       inject echo line two
                                                                                            until read -t0; do
                             Control other terminals                                         sleep 0.02
                             Using ioctl to do this works in subshells. It is also          done
                             possible to inject characters into another terminal,           stty "$saved_settings"
                             subject to having the appropriate permissions.                   where inject is one of the solutions described
                             Normally this means being "root" but we'll explain             above, or replaced by printf '\e[5n" if you're using the
                             some other ways too. The only difference is that the           escape sequence method instead of TIOCSTI.
                             relevant terminal file needs to be used. So, instead of
                             using file descriptor zero (our own standard input)             John Lane types a lot but he has a script that takes over
                                                                                             when he's tired.
                             when calling ioctl, we need to open the relevant



70                                                                     www.linuxvoice.com
                                      FAKING INPUT TUTORIAL




Email andrew@linuxvoice.com to advertise here


                 www.linuxvoice.com                           15
                                                              71
     TUTORIAL EDUCATION




PYTHON 3:
BUILD A QUIZ MACHINE
Programming logic meets cardboard and sellotape in our latest Python/Pi project.

   LES POUNDER
                              L
                                      earning to code is a great experience but how
                                      can we make it more fun? In the past coding
                                      has been a rewarding, if daunting experience
WHY DO THIS?                  that comes with many successes and failures. With
• Learn how to control a      the rise of the Raspberry Pi we see a new era of
  stepper motor               physical computing, merging software with
• Learn Python 3              homebrew hardware, which is a great method to
• Control hardware using      teach children as there are many physical outputs to
  the GPIO                    keep interest high and reward learning. But what if we
• Interface a touch screen    could build a machine that could test the knowledge
• Learn logic                 of our children and be a great source of fun and
                              tinkering? Well we have: it's called the Vend-A-Python.
                                 For this project we shall be using the latest
                              Raspbian image from the Raspberry Pi website.
TOOLS REQUIRED
                              Jessie, the latest release, now comes with a new
• A Raspberry Pi
                              method to access the GPIO pins. Previously only the
• A touchscreen
                              root user or a user using sudo was able to access the
• Speaker
                              GPIO, but with Jessie any user can access the GPIO
• Stepper motor http://bit.
  ly/LV22-Stepper-Motor       and hack hardware. Raspbian Jessie also comes with
• Arts and crafts materials   four of the five Python libraries that we shall be using,
                              these are RPi.GPIO, Time, Random and Pygame, and
                              we'll need to install one more, which is Easygui. In a
                              terminal type the following, then press Enter.
                              sudo pip-3.2 install easygui
                                                                                          Our finished project combines motors, buttons, screens
                                                                                          and crafting into one project. This project could also ask
     With the rise of the Raspberry Pi we see                                             questions from other subjects.
     a new era of physical computing, which                                                 Stepper           GPIO
     is a great way to teach children                                                       IN1               17
                                                                                            IN2               10
                                Easygui, as its name suggests, is an easy library to        IN3               9
                              create menu and interfaces with Python, but more on           IN4               11
                              that later.                                                    We're using the Broadcom (BCM) pin mapping for
                                                                                          the GPIO pins, which is the standard supported by the
                              Setting up the hardware                                     Raspberry Pi Foundation in all of its resources. For
                              We'll start by setting up our stepper motor, which is a     further reference please see http://pi.gadgetoid.com/
                              motor with a high degree of precision (512 steps,           pinout.
                              which control a full revolution). Using these steps we         Also present are two pins labelled 5–12v. These
                              can precisely control the position of the motor, and        two pins are + and -, and are power (+) for the motor
                              later in our code we shall divide the faces of our wheel    and Ground (GND, -). From the GPIO of your Raspberry
                              into four sections, effectively creating four zones each    Pi connect 5V to the + and GND (Ground) to -. If you
                              with 128 steps.                                             wish you can also connect these pins to an external
                                 Our stepper comes with a controller board with four      power source. Next let's connect a button to the GPIO.
                              pins labelled IN1–IN4. Using female-to-female jumper        The button is used to trigger the process and is easy
                              cables, connect these as follows to the GPIO.               to connect. We used an arcade button, as we had it



72                                                            www.linuxvoice.com
                                                                                                        EDUCATION TUTORIAL


lying around, a simple micro switch can be used in
its place. Connect one side of the button to pin 23,
remember we are using the BCM numbering, and the
other to GND. Refer to the diagram, below, for details.




  For the touchscreen we used the Adafruit 5-inch
HDMI backpack, which required an extra step to
                                                                                                                       Our stepper motor came
configure the touchscreen for use. However, we'd           the time and random libraries. We import easygui and
                                                                                                                       from eBay and cost less
recommend picking up the new official Raspberry Pi         rename it to eg before finally importing the pygame         than £2. It provides a
display screen as the touchscreen and display work         library.                                                    handy controller board that
out of the box with Raspbian Jessie. Assemble the          import RPi.GPIO as GPIO                                     can be easily interface with
screen and mount it as you see fit.                        import time, random                                         a Raspberry Pi, Arduino
  Connect your speaker to the 3.5mm port on your Pi;       import easygui as eg                                        or other single-board
you can change the output method by right-clicking         import pygame                                               computers.
on the speaker icon in the top-right of the screen.           Now we setup the GPIO pins. We instruct the Pi
                                                           that we shall be referring to them using the Broadcom
Coding!                                                    layout (GPIO.BCM) we also instruct the Pi to turn off
Before we commit any code, let's step back and look        any warning messages.
at the logic that will control our project.                GPIO.setmode(GPIO.BCM)
   The project starts waiting for the user to press        GPIO.setwarnings(False)
the push button. Once it is pressed, music is played          In this project we use variables to contain
while the stepper motor rotates around the wheel,          references to the GPIO pins and to control the delay
which is split into four areas, with each area covering    used for our stepper motor. Here we can see the
a particular Python topic. How far it travels is handled   pins IN1–IN4 referenced on the stepper motor board
via a function that uses a randomly generated number       and the pin used for the push button. We use their
between 1 and 512. Once the stepper returns to the         reference to store the GPIO pin used on the Pi.
top of the wheel, the user is asked a Python question      IN1 = 17
based upon the topic where the stepper motor               IN2 = 10
stopped on the wheel. The topic of the question is         IN3 = 9
chosen by using the randomly generated number              IN4 = 11
and a series of conditional statements that check the      button = 23
value against hard-coded values. The user answers          delay = 0.01
the question by pressing the correct answer on the            We store the values of the variables IN1–IN4 in a
touchscreen, which triggers another conditional            list and then use a for loop to iterate through each of
statement to check their answer. If correct, the player    the values stored in the list, the pins of the GPIO used
is rewarded, if incorrect the player is chastised. The     for the stepper motor, and configure each of them to
project then resets and is ready to play again.            be an output. This means that current will flow from
   For this project we shall be using Python 3 via the     the GPIO to the pins on the stepper motor controller
Idle editor. As we're using Jessie we do not have to       board.
invoke Idle via the terminal using sudo, but can open it   outputs = \[IN1,IN2,IN3,IN4\]
from the Programming menu.                                 for pin in outputs:
   With Idle open click on File > New Window to open a      GPIO.setup(pin, GPIO.OUT)
new blank document, and save it as Vend-A-Python.             We now set up the push button to be an input and
py before proceeding.                                      set the GPIO pin to be turned on. So when the button
   As always we start coding our project by importing      is pressed it will momentarily connect the pin, pulled
a few libraries. First we import the RPi.GPIO library      high, to the Ground pin. This will cause the state of the
and rename it to GPIO for easier use. Next we import       GPIO pin to be pulled low, which will form the trigger



                                                             www.linuxvoice.com                                                                73
     TUTORIAL EDUCATION

                                                                                               GPIO.output(IN2, True)
                                                                                               GPIO.output(IN3, False)
                                                                                               GPIO.output(IN4, False)
                                                                                               time.sleep(delay)
                                                                                               GPIO.output(IN1, False)
                                                                                               GPIO.output(IN2, False)
                                                                                               GPIO.output(IN3, True)
                                                                                               GPIO.output(IN4, False)
                                                                                               time.sleep(delay)
                                                                                               GPIO.output(IN1, False)
                                                                                               GPIO.output(IN1, False)
                                                                                               GPIO.output(IN1, False)
                                                                                               GPIO.output(IN1, True)
                                                                                               time.sleep(delay)
                                                                                             time.sleep(5)
                                                                                             ccw(steps,delay)
                                                                                            For the next function, ccw (short for counter
                                                                                            clockwise) we reuse the same structure as cw(), but
                                                                                            change the pin sequence so that the stepper moves
The official Raspberry Pi
                               used to start this project.                                  in reverse.
screen can easily hold
a Raspberry Pi upon its        GPIO.setup(button, GPIO.IN, GPIO.PUD\_UP)                       This ends the functions, and now we move to the
back. It also offers a power      We now move on to the functions that will be used         main body of code. We now start using Easygui to
passthrough, reducing the      to contain more complex aspects of the project.              greet the player using a messagebox dialog. This
number of power supplies       Our first function is used to play audio. We define          function has three arguments: the title of the dialog
required.                      the name and then give the function an argument,             box; an image to decorate the dialog; and finally the
                               denoted by the word in the brackets. In this case, the       message to the user.
                               argument is the file name of the audio file to play. We      eg.msgbox(title="Welcome to the Python Quiz",image="./
                               then write the code that is to be run when the function      python.gif",msg="So you think you know Python? Press
                               is called. First we initialise the audio mixer. Next, we     the Green button to start")
                               create a variable called sound to contain loading the           We use a while True loop to constantly check via
                               audio file into the mixer. Finally we trigger the mixer to   an if conditional statement that the push button has
                               play the music once.                                         been pressed. When the button is pressed its state
                               def audio(file):                                             changes from high to low, True to False. So when the
                                pygame.mixer.init()                                         pin reports False we call the audio function with the
                                sound = pygame.mixer.music.load(file)                       name of an audio file to play. When calling the audio
                                pygame.mixer.music.play(1)                                  file it is important to provide the path to the file as a
                                  Our next function, called cw (short for clockwise),       string – simply wrap the file path in "". We can use
                               is used to control the stepper motor so that it moves        an absolute file path which will precisely show the
                               in a clockwise direction. This function takes two            location of the file, or we can use a relative file path
                               arguments: the number of steps to move; and the              that will show the location of the file in relation to
                               delay between each part of the step. Inside the              where our project code is.
                               function we use the number of steps to create a for             Next we create a variable called steps and in there
                               loop that will repeat for that number of steps. In the       we use the random integer function from the Random
                               for loop we turn on each of the stepper pins, IN1 to         library to pick an integer between 1 and 512, 512
                               IN4 in order, by using True to turn the pin on and False     being one full rotation of the stepper motor. Finally we
                               to turn it off. So for IN1 we turn it on, and the others     call the cw() function and pass it the arguments steps
                               are turned off. The code waits for the delay of 0.01         and delay to control how far to rotate the stepper and
                               seconds, before turning the next pin on and turning
                               the others off. This repeats for all of the pins IN1 to
                               IN4 and causes the motor to spin once. Once the
                               number of steps has been reached the code will wait
                               for 5 seconds before calling another function.
                               def cw(steps,delay):
                                for i in range(steps):
                                  GPIO.output(IN1, True)
                                  GPIO.output(IN2, False)
                                  GPIO.output(IN3, False)
                                  GPIO.output(IN4, False)
                                  time.sleep(delay)                                         Installing Easygui via the terminal is easy. Just remember
                                  GPIO.output(IN1, False)                                   to connect to the internet before trying to install…



74                                                              www.linuxvoice.com
                                                                                                                EDUCATION TUTORIAL

how quickly to do so.
while True:
 if GPIO.input(button) == False:
   audio("./tilburg.mp3")
   steps = random.randint(1,512)
   cw(steps,delay)
   Next we create an if conditional statement, which
is used to compare a condition against a value. In
this case we compare the value stored in the variable
steps with two hard-coded values. For the if condition
we check to see if steps is greater than 0 and less
than 128, effectively covering the first quarter of the
wheel similar to a clock face 12 to 3.
if steps \>0 and steps < 128:
   If this condition is true, and the stepper stops
between 0 and 128, we ask the user a question
based upon the subject area, which in this case is all
about variables. To ask the question we first create
                                                                                                                               The EasyGUI library
a variable called answer and we use that to store the           eg.msgbox(title="CORRECT",image="./tick.
                                                                                                                               enables use of a simple
answer to the question posed via EasyGUI's choice              gif",msg="RIGHT ANSWER")                                        GUI creation system that
dialog. We use the choicebox function and give it                If the player chooses a wrong answer a different              can be integrated into
three arguments: the title of the dialog; the message          audio clip is played and the text for the message               any Python project. It is
to the user; and the choices that can be made. When            dialog box is changed to reflect their status.                  compatible with Python 2.x
the user makes a choice it is stored in the variable for       else:                                                           and 3.x.
later use.                                                      audio("./wrong.mp3")
answer = eg.choicebox(title="Question",msg="Which               eg.msgbox(title="INCORRECT",image="./cross.
variable is storing a string?",choices=("a='Hello World'","b   gif",msg="WRONG ANSWER")
= 5","c = 2.0"))                                                  This process repeats using a series of elif, else if
  Next we compare the answer given to the correct              conditions to compare the position of the stepper
answer, and if it is correct we reward the player with a       motor for the other sections of the wheel. With all of
pleasant piece of audio and use a message dialog box           the elif conditions complete we now break from this
to inform the player of the achievement.                       conditional statement and return to the main if...else
if answer == "a='Hello World'":                                conditional statement, which handles waiting for the
 audio("./correct.mp3")                                        button to be pressed. While it waits for input it simply
                                                               prints "Waiting" to the Python shell before sleeping
                                                               for 0.1 seconds, then repeating the process until the
                                                               button is pressed.
                                                                  This ends the code for this project. Remember to
                                                               save your work and when ready click on Run > Run
                                                               Module to run the code via Idle. The Python shell will
                                                               now print "Waiting" to the shell. Press the push button
                                                               and the stepper motor will come to life and start the
                                                               quiz. At present this project only has one question
                                                               per topic but it can be easily extended to add further
                                                               questions, which can be chosen at random using the
                                                               random.choice function from the random library. Use
                                                               this tutorial as a platform to craft your own version of
                                                               the project.
                                                                  By completing this project we have learnt more
                                                               about stepper motors, how connect a push button to
                                                               the GPIO and the flow of the project has introduced
                                                               loops, conditional logic and multimedia.
                                                                  All of the code for this project can be found via our
                                                               GitHub repository at http://bit.ly/LV22Code, or you
                                                               can download a Zip file containing all of the project
                                                               files from http://bit.ly/LV22CodeZIP.

                                                                Les Pounder divides his time between tinkering with
                                                                hardware and travelling the United Kingdom training teachers
                                                                in the new IT curriculum.
We used an old cardboard box to house our project.



                                                                 www.linuxvoice.com                                                                   75
     TUTORIAL HARDWARE




KEEPS TABS ON YOUR PC
WITH BLUETOOTH
Monitor your computer when away from your desk with a wireless link to your phone.

   BEN EVERARD
                               A
                                          lmost all smartphones, most laptops and             which is available via F-Droid at https://f-droid.org/
                                          quite a lot of desktops have Bluetooth              repository/browse/?fdid=ru.sash0k.bluetooth_
                                          hardware, yet it's rarely used beyond sending       terminal. If you would rather install via the Google Play
WHY DO THIS?                   audio to wireless speakers. This is a shame, because           store, BlueTerm by pymasde.es also works.
• Gain an extra mini screen    it's powerful enough to send any data you want
• Keep an eye on processes     between devices, and gives you endless opportunities           Install the software
  when you're away from        for hacking together new features.                             You'll also need some software on your machine,
  your desk                        In this tutorial, we're going to take a look how to use    which your distro may have installed by default. This
• Learn to use serial ports    standard Linux tools to stream real-time data about            will include some software to handle the initial
  for easy communication
                               our PC to our phone to give us an extra, portable              connection between the phone and the computer, and
                               screen to use to monitor our computer. We'll do this           some software to set up a serial connection. To
                               by using Bluetooth to create a serial port between our         handle the initial connection between the two
                               phone and our Linux machine. Serial ports fit very well        machines (known in Bluetooth terminology as
                               with the Unix mantra that 'everything is a file', because      pairing), you should find some graphical software on
                                                                                              your desktop. In Gnome, this is Gnome Bluetooth

     We're going to use standard Linux tools                                                  Manager; in KDE this is Blue Devil; and in Unity this is
                                                                                              the Bluetooth option in the Ubuntu Settings Manager.
     to stream real-time data to our phone, to                                                The process for all these is roughly the same.
                                                                                                  First you need to make sure that Bluetooth is turned
     create an extra, portable screen                                                         on in your phone's settings and that the phone is
                                                                                              discoverable. This is done by going to the Bluetooth
                               they're created as files in the /dev folder and you can        page in the settings app (you need to keep this page
                               write data to them (to send) and read data from them           open to make the phone discoverable). Once this is
                               (to receive). Using this, we can communicate with just         open and turned on, open your Bluetooth manager on
                               the standard command line tools.                               your Linux machine and make sure that Bluetooth is
                                  Before we get to this, though, we have to set up the        turned on, then select the option to add a new device.
                               software. First, you'll need a Bluetooth terminal app on       This should scan and find your phone. Follow the
                               your Android phone. There are a few options for this.          settings on the Bluetooth manager, and it should set
                               The best open source option is Bluetooth Terminal,             up everything you need.
                                                                                                  The pairing process sets up a general connection
                                                                                              between the two device that can be used to create
                                                                                              specific connections to share audio, send files or
                                                                                              stream serial data. In order to send the data we want,
                                                                                              we need to create a serial connection. This is a two-
                                                                                              stage process where we first set up a Bluetooth serial
                                                                                              port on the computer, and then connect the phone to
                                                                                              it. You'll need the rfcomm tool, which you may have
                                                                                              already installed – if not you'll need to get it from your
                                                                                              package manager (in Debian-based systems, this is in
                                                                                              the bluez package).
                                                                                                  Due to an outstanding bug, the rfcomm software
                                                                                              only runs if the user is root, so you'll notice that we
                                                                                              have to run a lot of commands as root. The command
                                                                                              to create a new Bluetooth serial port is:
Pairing in Bluetooth is the process of setting up two devices in anticipation of creating a   sudo rfcomm listen 0
connection. It only needs to be done once for each combination of devices.                    Now your PC is listening, you just need to point your



76                                                               www.linuxvoice.com
                                                                                                               HARDWARE TUTORIAL



  Turn your PC into a Bluetooth speaker
  Ok, so using a PC as a Bluetooth speaker isn't exactly a
  great way to save money, but there are some occasions
  where it can be useful. Perhaps you have a home theatre
  PC set up already and you want to use it to play music off
  your phone as well. Perhaps you just need a way to play
  music on your PCs speakers for a one-off event. Whatever
  the reason, the method is straight forward. Firstly, you need
  to pair the phone and the PC in the way described in the
  main text. Once this is done, you need to tell the PC to treat
  the connection as an audio source. Using the Blueman-
  manager graphical Bluetooth management software, this
  is done by right-clicking on the connection and selecting
  Audio Source. After this, and audio from the phone will go
  through the PC rather than the phone.



phone at the appropriate Bluetooth connection (which
should already be set up since the devices are paired).
This is just a case of opening the Bluetooth terminal
app on your phone and in the connection options,
select the PC. This will create the file /dev/rfcomm0
                                                                                                                             Blueman is a little more
on your PC (you can create more than one Bluetooth                 serial connection). This command is a little more
                                                                                                                             capable than Unity's
serial port at a time by increasing the number on the              complicated than a regular sudo command, because          Bluetooth settings, so can
rfcomm command to create /dev/rfcomm1, 2, etc).                    we need the output redirect to run as root. If we'd run   be useful for Ubuntu users
   Anything you write to this file is sent to the                  the command with just sudo as follows, it wouldn't        looking to set up audio or
Bluetooth terminal on the phone, so a simple test that             have worked.                                              file transfers.
everything's working is:                                           sudo echo “hello world” > /dev/rfcomm0
sudo bash -c 'echo “hello world” > /dev/rfcomm0'                     In this case, the echo command is run as root,
  The echo command outputs the text “hello world”,                 however, the output ( > /dev/rfcomm0) runs as the
and the 'greater than' sign tells the shell to send                normal user. Instead, we need to use sudo to start
that text to the /dev/rfcomm0 file (which is our                   a new Bash session running as root, and run the full




                                                                                                                             A few lines of Bash script
                                                                                                                             is all you need to send
                                                                                                                             diagnostic information to
                                                                                                                             your phone.



                                                                     www.linuxvoice.com                                                              77
     TUTORIAL HARDWARE

Some Bluetooth serial                                                                     phone, you'll see that you have the ability to send lines
terminal phone apps                                                                       of text; however, because of the way we've used the
expect Windows-style line                                                                 connection so far (with commands that only write
endings and can behave                                                                    data out and not read data in), anything you send this
a little odd with the newer                                                               way will be lost.
Linux line endings. This                                                                    The simplest way to read the data you send is with
doesn't affect the content
                                                                                          the tail command. This just outputs the end of a file,
though.
                                                                                          and if you use the -f (follow) flag, it will continually
                                                                                          monitor the file and output anything that gets written
                                                                                          to the end of it. Usually, this is used to monitor log files
                                                                                          as new data comes in, but it's also useful here. Since
                                                                                          we want to show the whole file, not just the end, we
                                                                                          also have to use the -n +1 argument, which tells tail
                                                                                          to show the lines starting with the first. The command
                                                                                          to output the text sent from the phone to the
                                                                                          computer is:
                                                                                          sudo tail -fn +1 /dev/rfcomm0
                                                                                             This in isn't itself very useful, because all it enables
                                                                                          us to do is send text from the phone to the computer.
                                                                                          In principal, you could create a very rudimentary chat
                                                                                          system by using echo to send data one way and tail
                                                                                          to receive it the other way, but this is fairly pointless.

                                                                                          Pipes are useful
                                                                                          Fortunately, we don't have to limit ourselves to just
                                                                                          spitting text out onto a screen. Instead, we can pipe
                              echo and redirect in this root session. We did this in      this data into other commands. A simple way to use
                              the first command by running bash -c.                       this is to read the data from /dev/rfcomm0, evaluate
                                There is a simpler option: tee. This command takes        it in Bash, and then pass the output back to the serial
                              standard input and does two things. Firstly, it writes      port. This can be done with the following script:
                              the input to a file and secondly it passes the input        while read -r line < /dev/rfcomm0; do
                              onwards to standard output. Since the file is written                   $line > /dev/rfcomm0
                              by the command itself, we can just run that as sudo.        done
                              The above command can then be run as:                         This uses the read command to step through
                              echo “hello world” | sudo tee /dev/rfcomm0                  the data that comes in the serial port. The first line
                                                                                          starts a while loop that will continue to operate until
                              Getting interactive
                              Since tee sends the input to both the output and
                                                                                            ObexFTP: Send files back and forth
                              the file, you will see 'hello world' appear on both the
                              Linux terminal and the phone's Bluetooth terminal.            The easiest way to send files over Bluetooth is using the
                              This is the first way we'll use our phone to monitor          ObexFTP protocol. You may find that you need to install
                                                                                            additional software for this to work. On your phone, you'll
                              our machine. It's particularly useful if you want to set
                                                                                            need an app that understands the protocol, and there are
                              a long command running, and want to leave your                quite a few options in the Google Play store. We used
                              machine unattended until it finishes. Pipe the output         Bluetooth File Transfer, but others should work. On your
                              to sudo tee /dev/rfcomm0, and you can leave your              Linux machine, you'll also need software to handle the
                              machine alone, and make sure that it's still running by       communication.
                                                                                                Most graphical Bluetooth tools have some options for
                              checking the Bluetooth terminal on your phone.
                                                                                            sending files, but it's often useful to be able to incorporate
                                  There is a slight problem with this approach – if the     file transfer into scripts. For example, you could create a
                              command doesn't give any output, you don't know               script that runs at a certain point every day (when you'll be
                              when it's finished. You can solve this by running two         at your desk) and backs up the data on your phone.
                              commands one after the other, which is done using                 There's a command line tool called ObexFTP, which is in
                                                                                            most distro's repositories. You can use it to get a list of all
                              the semicolon. For example, the following will update
                                                                                            the files on your phone from your PC with:
                              a Debian system (sending the output to both the               obexftp -b -l
                              terminal and the phone), and then end with the word              The result comes in a slightly awkward XML file, but you
                              'finished':                                                   should be able to see what's going on. The general format
                              sudo apt-get upgrade | sudo tee /dev/rfcomm0 ; echo           for getting files is:
                                                                                            obexftp -c <directory> -g <file>
                              “finished” | sudo tee /dev/rfcomm0
                                                                                              There's some code and examples of how to do more
                                 So far, we've used our Bluetooth serial port as a sink     complex things with ObexFTP at the tool's website: http://
                              into which we've poured data, but haven't gotten              dev.zuckschwerdt.org/openobex/wiki/ObexFtp.
                              anything back from it. If you look at the app on your



78                                                            www.linuxvoice.com
                                                                                                                    HARDWARE TUTORIAL


  A very brief history of Bluetooth
  Bluetooth is a set of specifications created by the Bluetooth
  Special Interest Group (SIG). The SIG came into being on
  20 May 1998, and since then has continued to develop
  the standard as the technology has improved, and as
  the technology landscape changes to require different
  features. The latest incarnation (Bluetooth 4) includes a
  new specification for low-power devices that run off small
  batteries, and is designed with the internet of things in
  mind. There's also a version of the protocol designed for
  devices where data transfer rates are more important than
  power usage (Bluetooth High Speed), which can send data
  at up to 24Mb/s. These new technologies are helping to
  make sure that the wireless protocol is still relevant today
  despite being over 15 years old.



it reaches the end of the file, and since serial port files
don't have an end (that is, they never return an end
of file, they just don't always have data to return), this                                                                      Most popular langages,
loop will keep going until the serial port is closed. The         sort (the -g flag uses numeric sorting), and then             including Python, have
second line just evaluates the contents of the line in            into head to get the line with the highest processor          libraries for dealing with
the shell, and passes the output of this back to the              utilisation.                                                  serial connections if you
serial port. If you save this as a file called serialterm.           There is a little difference between the figures           need more control over the
sh, you can launch it with:                                       returned by the two commands. Mpstat will calculate           data sent.
sudo bash -c "bash serialterm.sh 2> /dev/rfcomm0"                 the CPU utilisation over a short period (in this case,
   The last part of the command (2> /dev/rfcomm0)                 two seconds), while ps will calculate the average
is needed to redirect any errors that occur in the                processor utilisation over the life of the process.
execution of the script on to the serial port. Discretion            To run the data from this to your phone, just pipe
is advised here as this will create a root terminal on            the data through like we have done before. If you save
your phone (though only when within Bluetooth range               the script as serialtop.sh, this is done with:
of your machine).                                                 sudo bash -c "bash serialtop.sh > /dev/rfcomm0"
                                                                     After this, everything should be piped through to
Top dog                                                           your phone and you can keep an eye on your CPU
One particularly useful thing to do with our serial               usage even when the main screen is taken over by
Bluetooth connection is monitor how much load there               other programs.
is on the CPU when we can't see the screen. This                     These, of course, are just a few examples of what
could be, for example, when using full-screen                     you can do with Bluetooth serial connections between
graphical applications. You could just pipe the output            your phone and your computer. If you want to take
of the top command straight to the phone, but the                 things further, you can make a serial connection
different layout of the screen on the phone makes it a
little awkward to read the data. Instead, we're going to
create a stripped-down version of top that just                      You could easily take the output from
outputs the CPU usage and the process that's using
most of the CPU.
                                                                     our final monitoring script and visualise
    We'll use the mpstat command to get the processor                it as something like a speedometer
utilisation and ps to get the CPU utilisation per
process. The full script is:                                      from inside a custom-written application on your
while true; do                                                    phone, which can take a particular format of data
  echo -n "% cpu: "                                               and process it in any way you wish. For example, you
  bc <<< "100 - $(mpstat 2 1 | grep 'Average:' | cut -c 92-)"     could easily take the output from our final monitoring
  echo "top process: "                                            script and visualise it, perhaps as something like a
  ps -eo pcpu,args | sort -g -k 1 -r | head -1                    speedometer to show you how fast the computer is
done                                                              running at a particular time. Serial connections are
   In the third line, we use grep to select just the line         almost endlessly flexible to allow a huge range of
of the mpstat output that contains the average data,              uses, but at the same time, as you have seen, they can
then cut to return just the characters that contain the           be very easy to use.
percentage of time the CPU is idle. The bc command
is a calculator, so we just send the input of 100 – the            In an unusual twist, Ben Everard is also monitoring GCHQ's
idle time to get the CPU utilisation.                              machines from his Android phone.
   The per-process utilisation from ps is piped into



                                                                    www.linuxvoice.com                                                                 79
     TUTORIAL DATABASES




SERVER 101: BRUSH UP
YOUR DATABASE SKILLS
Part 2: Learn how to interact with a database using PHP, and build the killer web
apps/tax dodging walled gardens of tomorrow.

MIKE SAUNDERS
                            L
                                     ast issue we looked at the basics of databases:    use lvtest;
                                     why they're important, how they work, and how      show tables;
                                     to set up one from scratch. We also explored a        In the previous tutorial we used select * to retrieve
WHY DO THIS?                handful of vital SQL commands to manipulate data            all fields of a database entry, but it's important to note
• Discover how web apps     and search for results. (If you're missing issue 21, grab   that we can narrow them down like so:
  work under the hood       it from http://shop.linuxvoice.com – or take out a          select ID, Name from login_dates;
• Explore data stored by    subscription and get free access to every single one        This just shows the ID and Name columns, and omits
  WordPress, OwnCloud
                            of our digital back issues!)                                anything else. We can restrict the results further:
  and co.
                                In this second part of the tutorial we'll delve         select ID, Name from login_dates where ID > 1;
• Learn SQL to perform
  powerful search queries   further into SQL with commands to modify data,                 To change the data inside an existing row in a table,
                            perform more advanced searches, and link search             we use the update command, providing the name
                            results across multiple tables. We'll then move on to       of the column we wish to change, its new value, and
                            accessing databases with the PHP programming                a reference to the specific row. For instance, if we
                            language, providing you with the building blocks to         want to modify the third row in our table, and change
                            make websites. By the end you'll have the skills to         Graham to Ben, we would use this:
                            poke around inside web apps such as OwnCloud,               update login_dates set Name = 'Ben' where ID = 3;
                            PhpBB, and many others that are written in PHP and            Here are some other commands worth knowing.
                            make extensive use of databases.                            The first deletes a row from a table, while the second
                                                                                        and third add and remove columns respectively.
                            Advanced SQL                                                Remember that MySQL and MariaDB don't hold your
                            Let's continue with the database and table we set up        hand when you're working – they'll happily delete vast
Screenshot 1: Here's
                            last issue. Log in to MariaDB like so:                      amounts of data with just a few keystrokes! You get
the results of our 'join'
operation, combining the    mysql -ulvuser -p                                           no chance to confirm, so when you're working with
Name column from one          Enter pass123 when prompted for the password.             real-world data, tread carefully...
table with the Command      Switch to the lvtest database and list the tables it        delete from login_dates where ID = 3;
column from another.        contains:                                                   alter table login_dates add Shell varchar(20) after Name;
                                                                                        alter table login_dates drop column Shell;
                                                                                          In the first alter command here, we add a column
                                                                                        called Shell, which contains a string of up to 20
                                                                                        characters, and place it after the Name column. (If
                                                                                        we omitted the after part, the column would simply
                                                                                        be added on to the end of the table.) The second alter
                                                                                        command removes this column and any data that it
                                                                                        may contain.

                                                                                        Turning the tables
                                                                                        When we explored the concepts behind relational
                                                                                        databases last issue, we used an example of a second
                                                                                        table to go alongside the one we've set up, containing
                                                                                        a command that was executed and its exit code.
                                                                                        These tables both use the ID columns as primary
                                                                                        keys, so we can cross-reference data between them.
                                                                                        Let's create and populate this second table:
                                                                                        create table commands(ID int auto_increment primary
                                                                                        key, Command varchar(255), ExitCode int);



80                                                          www.linuxvoice.com
                                                                                                               DATABASES TUTORIAL


insert into commands values(0, 'df -h', 0);
insert into commands values(0, 'crontab -e', 1);
insert into commands values(0, 'shutdown', 1);
  If you now enter select * from commands; you'll
see the data we've just inputted. And if you look at
each table separately, you can work out that for ID 2,
Ben logged in at 2015-04-25 and ran the command
crontab -e, which exited with code 1 (failure). But how
do we pull this data together with SQL? What happens
when we want some columns from one table, another
set of columns from another table, but everything
together in a single set of results?
  This is where the mightily useful join command in
SQL comes into play. Let's say we want to generate
results showing the ID column, the name from
the login_dates table, and the command that was
executed from the commands table:
select login_dates.ID, login_dates.Name, commands.
Command from login_dates join commands on login_
dates.ID = commands.ID;
   Phew – that was a mouthful! Let's go through it
                                                                                                                            Screenshot 2: It only takes
bit-by-bit. We start off by saying we want to generate            Got that? See screenshot 1 for the results. SQL
                                                                                                                            a few lines of PHP to
results in three columns: ID and Name from the login_           syntax – and especially join instructions – can get         extract information from a
dates table, and Command from the commands                      very complicated, which is why some admins use              database and render it as
table. We use join to insert data from the commands             uppercase for commands, as noted last issue, to             HTML.
table into the results, and want results where the ID           distinguish them from table and column names.
column matches in both tables.                                  When you're working with large data sets across
                                                                multiple tables, join operations are immensely useful
                                                                for narrowing down the information that you need.
  NoSQL: databases done differently
  Relational databases power the web. MySQL/MariaDB,            Onto the web
  PostgreSQL, Oracle, Microsoft SQL Server and others chew      Interacting with your data via the command line is
  through vast amounts of data every day, and they'll be with
  us for decades to come. But a new breed of databases that
                                                                rather tedious and completely unsuitable in the long
  eschew the familiar table and relational models are coming    run, so what are some alternatives? You could build a
  up – and receiving a lot of attention. NoSQL is the moniker   native application that talks to a database – eg to
  given to database software that takes a different approach.   make a collection manager, human resources system
     MongoDB (www.mongodb.org) is one of the most famous        or similar program. But a quicker (and more cross-
  NoSQL databases, and stores its information inside JSON
  (JavaScript Object Notation) documents rather than tables.
  JSON uses attribute-value pairs, and is somewhat like XML
  but designed to be easier to parse in JavaScript. Here's an
                                                                   MySQL and MariaDB will happily delete
  example:
  {
                                                                   vast amounts of data with just a few
      "ID": 1,
      "Name": "Graham",
                                                                   keystrokes, so tread carefully…
      "Commands": ["crontab -e", "shutdown"]
      "ExitCodes": [0, 1]                                       platform) approach is to make a website that hooks
  }                                                             up to a database. Thanks to the PHP programming
     This shows a login entry with ID 1 for Graham, and in      language, this is rather easy, and involves just a
  the Commands and ExitCodes fields you can see arrays
  denoted by square brackets. Potential benefits of the
                                                                smattering of HTML and coding knowledge.
  NoSQL approach include simpler database designs and             To get started, you'll need to install the Apache web
  better performance when scaling up to large clusters of       server, the PHP language and a module that links both
  computers, and many startup websites are going the NoSQL      together. In Debian and Ubuntu-based distros you can
  route. (Note that despite the name, some NoSQL databases      grab the packages with:
  still let you interact with data using SQL-like commands,
                                                                sudo apt-get install apache2 php5 libapache2-mod-php5
  making the transition easier.)
                                                                php5-mysql
                                                                   (If you're using a different family of distros, search
                                                                through your package manager to find packages of
                                                                the same or similar names.) Once the software is
                                                                installed, visit http://localhost (or http://127.0.0.1)
                                                                in your web browser to view Apache running on the



                                                                  www.linuxvoice.com                                                                81
     TUTORIAL DATABASES

                                                                                                    language was installed correctly, you'll see the "PHP
                                                                                                    works" message. We're ready to go!
                                                                                                      To work with the database, first we need to initiate
                                                                                                    a connection and associate that connection with an
                                                                                                    object. If the connection fails, we need to quit out (die)
                                                                                                    before doing anything else; otherwise we perform
                                                                                                    a query on the connection and store its results in a
                                                                                                    variable. Then we go through the results, parsing out
                                                                                                    the individual fields from the database. So let's use
                                                                                                    PHP to grab the data from our login_dates table and
                                                                                                    display it – save this again as test.php:
                                                                                                    <?php
                                                                                                         $conn = mysqli_connect("localhost", "lvuser",
                                                                                                    "pass123", "lvtest");


                                                                                                         if(!$conn)
                                                                                                                die("Couldn't connect");


                                                                                                         $result = $conn->query("select * from login_dates");

Screenshot 3: The command line is fiddly, so we've provided a method for adding data
                                                                                                         while($row = $result->fetch_assoc())
via a HTML form. You can tart this up with a spot of CSS.
                                                                                                                echo $row['ID'] . ", " . $row['Name'] . ", " .
                                                                                                    $row['Login'] . "<br />";
                              local machine. All being well, you'll see an "It works"               ?>
                              message, so you can start using PHP.                                    Most of this should be self-explanatory. The mysqli_
                                 Switch into the /var/www/html directory and create                 connect() function is provided by the php5-mysql
                              a file called test.php with the following contents:                   package that we installed earlier, and we pass four
                              <?php                                                                 parameters to it: the hostname or IP address of the
                                            echo "PHP works!";                                      server to which we want to connect, a username, the
                              ?>                                                                    password for that username, and then the database
                                   If you've never used PHP before, it has a C-like                 that we want to use. This function returns an object,
                                                                                                    which we store in $conn. We then check to see if
     Now you have all the skills required to                                                        $conn contains anything – if not, it means that the
                                                                                                    connection failed for some reason (such as invalid
     create interactive websites that use                                                           login details, or the database isn't running), in which

     databases as back-ends                                                                         case we quit with an error message.
                                                                                                      If everything works, we then perform an SQL query,
                                                                                                    just like we would at the command line, passing the
                              syntax and all code must be supplied between <?php                    results back into the newly created $result variable.
                              and ?> tags, to differentiate it from HTML. So, open                  The last two lines may faze you a bit: essentially, after
                              http://localhost/test.php in your browser, and if the                 doing the database query, $result contains a number
                                                                                                    of rows. So in the while loop we go through each row
                                                                                                    and extract its contents into an associative array – in
                                   Back up your data!
                                                                                                    other words, an array where each element has its
                                   When you start to build up a lot of data, you'll want to make    own name. In our case, these element names are the
                                   regular backups. MariaDB is a pretty robust database, but it     columns from our table, so we have ID, Name and
                                   can't save your hide if you suffer a major hardware failure
                                                                                                    Login.
                                   or your hard drive throws in the towel. While MariaDB stores
                                   its data in rather complicated binary files, you can generate      Using PHP's echo command we spit this out as
                                   text versions for backup purposes using the mysqldump            text, joining the three elements together with commas
                                   utility (at the command line) like so:                           and spaces, and tacking a <br /> tag onto the end to
                                   mysqldump -ulvuser -p lvtest > backup.sql                        make the results more readable. The end result will
                                       If you now look at backup.sql in a text editor, you'll see
                                                                                                    be like in screenshot 2 – a (very rudimentary) HTML
                                   all of the SQL commands required to recreate and populate
                                   the tables inside the lvtest database, so you can gzip this      version of our login_dates table!
                                   up and store it somewhere as a backup. Later on, if you            Of course, if you're a dab hand with HTML and CSS,
                                   need to recreate the tables you use the regular mysql tool       you could now improve the output by using proper
                                   with the database name and filename:                             tables, divs and other fluff to make everything look
                                   mysql -ulvuser -p lvtest < backup.sql
                                                                                                    nice. We're not going to focus on that here, as we have
                                      You could, of course, automate the backup step by
                                   placing it inside a Cron job and running it every day (or        other things to do, but now you know how websites
                                   multiple times a day, if you have enough disk space).            connect to and extract information from databases.
                                                                                                      So that's displaying data – but what about feeding



82                                                                         www.linuxvoice.com
                                                                                                              DATABASES TUTORIAL

new data back into the database? What's the best
way to go about this? There are a few options, but
the simplest is to use a HTML form and some PHP to
handle the results. At the end of test.php, after the ?>
(which terminates the PHP code), add this HTML:
<hr />
<form action="test.php">
Name: <input type="text" name="Name" /><br />
Login: <input type="text" name="Login" /><br />
<input type="submit" />
</form>
   This is a simple HTML form that calls back to
the same file (test.php) when the Submit button is
clicked, and it has two text fields: Name and Login,
as per our login_dates table. So this HTML table now
appears under the information we extract from the
database. In order to process the information when
we submit the form, however, we need to do some
work in the PHP section at the top. Underneath the
                                                               The Vim editor has syntax highlighting for almost everything under the sun, including
"die" line, add these two lines:
                                                               SQL (useful if you're rummaging around in backups).
if($_GET['Name'])
  $result = $conn->query("insert into login_dates
values(0, '$_GET[Name]', '$_GET[Login]')");                    you're using a website with forms and data, you'll have
   By default, when a HTML form is submitted its form          a pretty good idea of how the website works and what
fields are passed to the "action" file (in our case, the       it takes to store and retrieve such information.
same test.php file) in an array called $_GET. This also            PHP, databases and related topics are all huge
means that the fields are supplied as part of the URL,         beasts themselves, so if you'd like us to dedicate
as you'll see when you submit the form.                        some pages to one of them, just drop
   So we first check to see if anything was entered            us a line. In particularly, if you'd like
into the Name field – ie if it's not blank – and then          to explore other databases such as               PRO TIP
we perform an SQL query, inserting the data as we've           PostgreSQL, or try interacting with              You may have come across the term
explained previously. Note that this is an extremely           databases using other programming                'LAMP' before: this refers to a stack
                                                                                                                of software typically used to serve up
quick and simple way to perform the SQL query; in              languages, let us know.                          websites. The letters stand for Linux,
a real-world scenario, you'd want to perform many                  In the meantime, here are a few tasks        Apache, MySQL/MariaDB and PHP –
more validation and security checks against the data           you can try with your new skills – if you        although the latter can be replaced by
                                                                                                                Perl or even Python in some instances.
to make sure someone isn't craftily trying to submit           get stuck, someone should be able to             Similarly, some sites have moved
executable PHP via the form! That's worth a whole              help at http://forums.linuxvoice.com:            away from Apache and are using more
other tutorial though...                                                                                           lightweight alternatives like Nginx.
   So test.php now does three things: it shows the             1
                                                                   Use tables or divs to make the
contents of the login_dates table, it provides a form              login_dates HTML look much better
for adding new data, and it processes the data and                 – maybe spruce it up with some CSS too.
adds it to the database if the form is filled out. Give it a   2
                                                                   Check that the user has filled in the Login field as
try – enter some text in the Name box and a suitably               well as Name in the form. You can combine multiple
formatted date (eg 2015-10-04), click the Submit                   tests together into the same if operation.
button, and you'll see the new row in the database             3
                                                                   Provide a way for a user to delete an item. For
when the page reloads as in screenshot 3.                          instance, you could achieve this using a drop-down
                                                                   list, performing a separate SQL query if a number is
And that's all the weather!                                        selected in the list.
So now you have the basic skills required to create            4
                                                                   Check that the dates in the Login field are of a valid
interactive websites that use databases as back-ends.              format. This is where PHP's string handling facilities
And more importantly, you understand exactly how it                come into play.
works, down to the raw SQL instructions. There are
countless web frameworks and abstraction layers out              Some of these may require more PHP knowledge
there that do all the hard work for you, and completely        than we've gone over here, so have a look at the
separate you from the gritty job of talking to the             excellent tutorials at www.w3schools.com/php for
database – and they're hugely useful if you're making          ideas. Happy hacking!
the next big Web 3.0 (or are we at 4.0 now?) website.
   But as with assembly language or the build-it-
yourself Linux From Scratch project, nothing beats              Mike Saunders is working on his own database, MikeSQL,
                                                                written entirely in 16-bit x86 assembly language.
knowing what's going on under the hood. Next time



                                                                   www.linuxvoice.com                                                                     83
     CODING MINSKY




MINSKY: DYNAMIC
SYSTEMS MODELLING
Get stuck into some complex maths, without having to learn complex maths.

ANDREW CONWAY
                             I
                                  n many disciplines – science, engineering,
                                  medicine and economics – models are used to
                                  predict behaviour to save on costly, dangerous or
WHY DO THIS?                 impossible real-world experiments. Computers are
• Do mathematics without     used to run numerical models that describe
  equations                  everything from fish populations to the behaviour of
• Program without coding     the Universe in its first moments.
• Hack the economy!             Building these models requires skills in
                             mathematics and programming in addition to an
                             understanding of the particular subject involved.
                             For some disciplines that are already very reliant on
                             mathematics, such as physics, this sits well, but for
                             others a different approach is needed.                      Here's a sine wave plotted in Minsky.
                                This is where Minsky comes in – it's a FOSS tool
                             than enables you to construct complex dynamic               sudo apt-get update
                             numerical models using a graphical interface. Rather        sudo apt-get install minsky
                             than formulate equations, then writing code, you               We're using version 1.D037, which was available
                             drag and drop icons to see the results in a graph. Not      from the OpenSUSE build service, but there's a more
                             only can you share this with mathematically minded          recent beta if you don't mind building it yourself.
                             friends, but you'll probably find yourself learning a lot      All the screenshots produced for this article have
                             about mathematics in an agreeably intuitive fashion.        a corresponding .mky you can load up for yourself,
                                Minsky is released under GNU GPL v3, so you              though we recommend you try to wire up at least the
                             can build it from the source code available from            most basic models. You can grab the .mky files from
                             sourceforge.net/projects/minsky, but be warned:             https://github.com/mcnalu/linuxvoice-minsky and
                             it does have a few fiddly dependencies. It probably         load them using the Open item under the File menu.
                             won't be available in your distro's package manager,
                             but it can be found in the OpenSUSE build service.          Simple building blocks
                             Check for specific instructions provided for your           Minsky's interface is straightforward. There's a menu
                             distro, but on Xubuntu 15.04 the installation involved      bar, controls for playing, stopping and adjusting
                             the following commands:                                     simulation speed, a palette of components, and the
                             sudo sh -c "echo 'deb http://download.opensuse.org/         main canvas.
                             repositories/home:/hpcoder1/xUbuntu_15.04/ /' >> /etc/         Let's start with something simple: plotting a straight
                             apt/sources.list.d/minsky.list"                             line. See the boxout for detailed instructions, but in
                                                                                         short we create a time component and wire it to the
                                                                                         graph, then start the simulation.
                                                                                            Now let's plot the sine function. Right-click on the
                                                                                         wire connecting t to the graph and select Delete Wire
                                                                                         from the context menu. Now click on the icon with sin
                                                                                         inside it and place it between t and the graph. Connect
                                                                                         a wire from t to sin and from sin to the black port on
                                                                                         the graph. Run the simulation and you'll see the sine
                                                                                         function being plotted. If you don't see the sine wave
                                                                                         shown in the screenshot, hit the square Stop button to
Plot sin against cos and                                                                 reset the simulation and try again.
you end up with a circle –                                                                  You can speed up or slow down the simulation
odd, but true.                                                                           using the slider at the top of the screen, or move it



84                                                             www.linuxvoice.com
                                                                                                                             MINSKY CODING


forward just one step at a time using the button to the
left of the slider. You can zoom in and out using the
mouse wheel and resize a graph by right-clicking on it
and selecting Resize.
   Let's now plot a second curve on the same graph.
Drag the cos component and place it beneath the
sin one, and wire it to the t component and to the red
arrow on the graph. Run the simulation and you'll see
that cosine has the same shape as the sine function,
but shifted to the left.

Going in circles
Now delete the wire from cos to the graph and move
it underneath the graph, then connect the cos
component to the black arrow at the bottom of the
graph, as shown in the image above.
   Before this example we didn't connect anything to
the horizontal axis of the graph, so Minsky assumed
                                                                                                                                    Add a constant to our
we wanted to plot our function against time. But now               -1 to 1, but -2 to 2. We now have an ellipse that's
                                                                                                                                    graph of sin aganst cos
we're telling Minsky to plot sin against cos. In other             4 units in width and 2 units high. If you're keen to             and you get an ellipse
words, at each time step t, the y co-ordinate of the               see something on the graph that's less round, feel               (really, it is, look closely at
graph will be sin(t) and x co-ordinate will be cos(t). As          free to experiment. For example, move the 2 and                  the axes!).
you can see, the result is that we've made a circle.               multiplication constants before cos so that it receives
   Let's now combine components. Delete the wire                   two times t as its input.
from the cos component to the graph. Next, place
the multiplication (&times;) component to the right                Making equations
of cos. Then place the component labelled const                    In the screenshot for the ellipse we've
above cos. This represents a constant. Set its value               placed two red components containing              PRO TIP
to 2 in the window that appears, or you can do so via              x and y. These are variables that we              There is some innate complexity in
                                                                                                                     modelling dynamic systems that no GUI
the Edit item in the context menu by right-clicking                placed using the var item in the                  can hide away. Also, as an evolving FOSS
afterwards. Now drag wires from the constant, which                component palette. These appear to be             project that's grown from grants and a
will be labelled 2, and from cos, to the left-hand side of         handy labels, but there's more to them            Kickstarter crowdfunding, Minsky is not
                                                                                                                     complete nor is it bug-free. But despite the
the multiplication symbol. Then join its tip to the black          than that: we can use them to output              odd glitch and its rather basic appearance,
port at the bottom of the graph.                                   some equations like the ones shown.               Minsky's core functionality has been well
   When you run the simulation you'll see a circle                    Go to the File menu, select Output             established and we found it surprisingly
                                                                                                                     intuitive to use.
again, but notice that the horizontal scale is no longer           LaTeX and enter a filename which, by
                                                                   convention, should end in .tex. Let's call
                                                                   it ellipse.tex.
  Simple line
                                                                      Now outside Minsky, either on the command line or
    Click once on the graph icon, then click anywhere on the       using your favourite text editor, open up ellipse.tex.
    canvas to place it.                                            Inside are LaTeX commands for formatting equations.
    Click on the triangular icon with a t inside it and place it
    to the left of the graph on the canvas.
                                                                   To see the equations themselves you'll need to
    Drag from the tip of t's triangle to the port (black arrow)    process them within LaTeX. Open up a terminal, cd to
    on the left-hand side of the graph – this wires it to the      the appropriate directory and on the command line
    graph.                                                         type:
    Click on the square Stop button to reset the simulation.       latex ellipse.tex
    Click the Play button underneath the menu bar.
                                                                      If the latex command isn't recognised then you'll
                                                                   need to install LaTeX. On Ubuntu you can do so as
                                                                   follows:
                                                                   sudo apt-get install texlive-latex-base
                                                                      The first time we ran the latex command we got
                                                                   an error about breqn.sty not being found. To work
                                                                   around this bug we had to go into the Options-
                                                                   >Preferences menu in Minsky and check and then
                                                                   uncheck the 'Wrap Long Equations In LaTeX Export'
                                                                   option and then perform the export again.
                                                                      The latex command will produce a file called
                                                                   ellipse.dvi, which should open if you click on it in your
                                                                   file manager – both Evince and Okular will open a DVI



                                                                     www.linuxvoice.com                                                                         85
     CODING MINSKY

                                                                                                     If you run the simulation you will find that it
                                                                                                  produces the same graph as before. This is not
                                                                                                  an accident. What we have demonstrated is that
                                                                                                  integrating the function t (black line) gives you
                                                                                                  t<sup>2</sup>/2 (red curve), and differentiating
                                                                                                  that gives you t. In other words, differentiation is the
                                                                                                  reverse of the integration process.
                                                                                                     Integration and differentiation are the basic tools
                                                                                                  of calculus, much like addition and subtraction are
                                                                                                  the basic operators in arithmetic. They are needed
                                                                                                  in almost any situation in which we want to build a
                                                                                                  model of something changing over time (or space).

                                                                                                  Constants and variables
                                                                                                  We've already met constants: they are values that do
                                                                                                  not change during the run of a simulation, unless you
Integration: about all we
                                file. If you'd like to turn it into a PDF file, do this:          want to intervene and alter them. Load up the ellipse
remember from A-level
maths.                          dvips ellipse.dvi                                                 simulation, then right-click on the 2 and choose Edit
                                                                                                  from the context menu. Set its value to 1 and the
                                Area under the graph                                              Slider Bounds to have Max 1 and Min 0. Next, right
                                    Let's go back to our first graph – the very exciting one      click, choose Slider and you will see a little slider
                                    that plotted time against time. Click the component           appear above the constant. Start the simulation and
                                    that's to the right of const, the one that's got a strange    reduce the value slightly with the slider and you'll see
                                    flattened S symbol with dt next to it. If you hover the       that the ellipse's width decreases. Sliders are handy
                                    tool tip over it you'll notice it's called integrate. We'll   for changing constant values on the fly.
                                    explain why in a bit. Place the integrate component              We saw above that variables can be used to
                                                    between t and the red port on the             output LaTeX equations, but they have a much
                                                    left-hand side of the graph and connect       more important use. Again, starting with the ellipse
PRO TIP                                             up the wires.                                 simulation, place a new graph below the existing one.
Minsky is named after economist Hyman                  When you run the simulation you'll         Right click on x and choose Copy and you'll be able to
Minsky and its creation was motivated by
a desire by economist Prof. Steve Keen              see  the black straight line and a new red    place a copy of x. Put it to the left of the new graph.
and the code's main author, Prof. Russell           curve.  Pause the simulation (press the P     Do the same for y and put it below the copy of x. Now
Standish, to open up the field of economic          button again) after it has just passed 4      place a plus symbol to their right and wire it up so that
modelling.
                                                    units of time. You may want to slow the       x+y is sent to the black port on the left-hand side of
                                                    simulation down. Now right-click on the       the graph. When you run the simulation you'll see that
                                    graph and choose Expand and a window will appear              this new graph displays something like the sin or cos
                                    with a clearer version of the graph with a finer grid.        graphs we saw earlier.
                                       The value of the red curve at any value of t is the           Delete the wires from x and y to the plus
                                    area under the black line up to that value of t. Let's        component. Now create another x and another y
                                    check this. At t=4 the black line has value 4 on the          and use times components to make x squared and y
                                    vertical axis, and area under the graph is half of the        squared. Then wire them to the plus component as
                                    square with corners at (0,0) and (4,4), ie half of 4 x 4 (=   before. You should end up with what is shown in the
                                    16), which is 8. And the value of the red curve at t=4 is     screenshot below. Notice that we could have done
                                    indeed 8.                                                     this without variables by running four wires (two from
                                       To integrate a function just means to calculate
                                    the area under the curve of the function plotted on a
                                    graph. It has many uses in practice, for example, if the
                                    black line were the speed of an accelerating car, then
                                    the red curve tells you the distance travelled since t=0.
                                    Alternatively, if the black line is the amount of money
                                    saved into a bank account each day, then the red
                                    curve would be the total amount saved.

                                Derivatives
                                Let's now use Minsky to take the derivative, a process
                                known as differentiation. In this example we multiply t
                                by itself to make t squared, then divide by 2 and plot
                                the result of that as the red curve. But we also take the
                                result and pass it through the differentiate                      Constants and variables, shows the variation of x squared
                                component to produce the black line.                              plus y squared in the bottom graph.


86                                                                   www.linuxvoice.com
                                                                                                                              MINSKY CODING


  What is the Lorenz Attractor?
  In the 1960s Edward Lorenz was using numerical models
  to describe motions of air in the atmosphere, but he soon
  realised they exhibited some surprising behaviour. This
  prompted a swell of interest from mathematicians to work
  on what is now known as chaos theory. Lorenz was the
  person who coined the term 'butterfly effect', referring to
  the fact that a small change in a chaotic system can lead
  to dramatic consequences in how it evolves: a butterfly
  flapping its wings (so the theory goes) could cause a
  hurricane at the other side of the world.
     The state of the Lorenz system is described by three
  variables (x, y and z) and how it evolves from one time step
  to the next is determined by three equations, represented
  by the three main blocks in Minsky that end in x, y and z.
  These equations have three parameters represented by
  Greek letters: ρ, σ and β. Many values exhibit chaos, though
  the "classic" ones originally used by Lorenz are ρ=28, σ=10
  and β=8/3. The Lorenz attractor is the shape shown on the
  x-y plot. This is actually a 2D projection of it (or shadow),
  because the attractor is a 3D object (x, y and z).              The Lorenz Attractor was originally dreamed up to model convection.


sin, two from cos) down to the times components,                  the simulation it will soon settle down into an orbit on
but that would be messy and hard to read. Instead we              the x-y plot, but notice that it's not periodic – it's not
define the x and y variables as outputs from cos and              repeating the orbit exactly. You can see this also in
sin respectively, and use them when constructing an               the graph of all three parameters at the bottom. After
input to the bottom graph.                                        some time the system will break out of the first orbit
   Now use the slider to put the constant back to a               to the lower left and enter another orbit that's above
value of 1 and run the simulation. It may not seem                and to the right. These two orbits gives the Lorenz
tremendously exciting, but the graph will show a                  attractor its distinctive figure-of-eight shape as shown
constant value of 1. If you slow the simulation down              in the image.
and watch the moving dot on the first graph you                      A parameter that determines chaotic behaviour is
should be able to tell what's going on. The second                ρ (Rho) and if you reset the simulation and change
graph is showing the distance of the current point on             its value to 10 then you'll see the system is no longer
the first graph from the centre (0,0). For a circle this          chaotic but spirals into the centre of the lower-left
distance is equal to the radius, which in this case is
1. For an ellipse the distance to the centre varies with             We've used Minsky to illustrate a
time. Try varying the slider as the simulation runs to
verify this.                                                         mathematical theorem originally stated
   What we've shown here is that the distance of
a point from the origin (0,0) is x squared plus y
                                                                     by the Greek chap Pythagoras
squared. In fact, we've used Minsky to illustrate a
mathematical theorem originally stated by the Greek               orbit. If you set ρ to 350, you'll find that the system
chap Pythagoras. We've also proved what's called a                starts out appearing chaotic but eventually settles
trigonometric identity: the square of cos(t) plus the             down into what appears to be periodic behaviour, ie
square of sin(t) is equal to 1 for any value of t.                repeating the same orbit.
   Let's bring this incidental tour of fundamental
mathematics to an end for now and turn to generating              And there's more
some chaos.                                                       We've covered the basics of Minsky but haven't yet
                                                                  touched on its raison d'être – economic modelling.
The Lorenz Attractor                                              We'll get stuck into this in part 2, but in the meantime
The Lorenz Attractor may sound like a long lost                   you can learn more about Minsky at
episode of Star Trek, but it's actually a feature of a            www.debtdeflation.com/blogs/minsky and we
famous chaotic system first described by Edward                   recommend Prof. Steve Keen's video tutorials that
Lorenz. To produce it only involves the components                you'll find there. The later ones do involve a bit of
we introduced above, but as it's a little more complex            economic theory, but the first few will nicely
you might want to load up the file lv8_lorenz.mky via             complement what we've described in this article and
the GitHub link above.                                            show you a few more tips and tricks.
  If you load up the lv8_lorenz.mky file, the system
has the "classic" parameter values mentioned in the                Andrew Conway watches the solar system, but also keeps a
                                                                   keen eye on Free Software and global macroeconomics.
boxout and starts with x=1 and y=z=0. When you run



                                                                    www.linuxvoice.com                                                        87
      CODING NINJA




CODE NINJA: MAKE A
FILESYSTEM WITH FUSE
Combine Python and Fuse to build a new directory structure into your distro.

   BEN EVERARD
                               M
                                            ost of the time, filesystems are data
                                            structures stored on some physical storage
                                            (such as a hard disk) that enable us to save
WHY DO THIS?                   and read data. That's actually not the whole story
• Understand the Fuse          though, since files and directories are just a way for
  method for building          our computers to organise information for us to use.
  filesystems                  As well as the sort of disk filesystems we're used to,
• Integrate your data with     we can create filesystems that return any type of data
  your operating system at
  a fundamental level          to us.
• Add another string to your      Traditionally, filesystems were created by the kernel,
  Python bow                   but now we can use Filesystems in USErspace (Fuse)            Our very own filesystem running and displaying the date.
                               to write programs that can create filesystems from
                               outside the kernel. In this tutorial, we're going to create     listxattr = None
                               a filesystem in Python. Our really simple filesystem            open = None
                               will just include just one file, called date, and the           opendir = None
                               contents of this file will be the current date.                 release = None
                                  First, make sure you have Fuse installed. In Ubuntu,         releasedir = None
                               this is done with:                                              statfs = None
                               sudo apt-get install fuse                                        As you can see, there are 12 operations that users
                                 Then you'll need to install the Python module we'll         could perform on the filesystem, although only three
                               be using to create our filesystem:                            are relevant to our simple program. We've assigned
                               sudo pip install fusepy                                       all the others a value of None to avoid any problems if
                                 Now that we have everything we need, we can write           they're called by the user. The three operations we're
                               the code. The majority of our code is taken up by a           interested in are get attributes, read file and read
                                                                                             directory. Each of these methods will need fleshing
     Our really simple filesystem will include                                               out to return the right results when they're called.

     just one file, and the contents of this file                                            Our attributes
                                                                                             First, let's take a look at getattr. The operating system
     will be the current date                                                                will call this function when it needs the attributes of
                                                                                             a file. It'll pass two pieces of information; the path
                               class that defines our filesystem. The outline for this       and the file handle (we only use the path). The OS will
                               class is:                                                     expect this function to return a dictionary containing
                               class Context(LoggingMixIn, Operations):                      all the relevant attributes for the file. Our simple
                                 def getattr(self, path, fh=None):                           filesystem will only have two different paths: /, which
                                   #code                                                     is the root of the filesystem, and /date, which is the
                                                                                             file containing the current date. Our code to process
                                 def read(self, path, size, offset, fh):                     these is:
                                   #code                                                       def getattr(self, path, fh=None):
                                                                                                 if path == '/':
                                 def readdir(self, path, fh):                                         attr = dict(st_mode=(S_IFDIR | 0755), st_nlink=2)
                                   #code                                                         elif path == '/date':
                                                                                                      attr = dict(st_mode=(S_IFREG | 0444), st_size=30)
                                 access = None
                                 flush = None                                                    attr['st_ctime'] = attr['st_mtime'] = attr['st_atime'] =
                                 getxattr = None                                             time()



88                                                                 www.linuxvoice.com
                                                                                                                                  NINJA CODING


    return attr
   Since / is a directory and /data is a file, they
require slightly different attributes. They both need
to have a mode which is calculated using the flags
imported from the stat module and the number that
corresponds to the Linux permissions for the file. They
both also have a created time, modified time and an
access time. For our filesystem, these aren't really
relevant, so we've just set them to the current time.
   The directory also needs an attribute with the
number of hardlinks pointing to the directory. This, for
a directory with no subdirectories, is 2. The file also
needs a size. We've cheated a bit on this one and just
hard coded in a size of 30, but it could vary depending
on the actual date.
   The second method we need is read. This will be
called whenever the OS wants the content of a file.
In our case, there's only one possible file, so we only
need to check that that's the file being read and then
return a string with the current date:
  def read(self, path, size, offset, fh):
                                                                                                                                   The fusepy documentation
    if path == '/date':
                                                                                                                                   is a little lacklustre, so if
       return datetime.datetime.now().strftime("%B %d,             fuse = FUSE(Context(), argv[1], foreground=True,                you need more information
%Y") + '\n'                                                      ro=True)                                                          about what a particular
   The final method is called whenever the OS wants                 The first block imports all the modules we need.               operation does, check out
the content of a directory. Again, we only have one              The line if __name == '__main__:' looks a little odd, but         the documentation for
directory, so all we do is return a list of the contents of      is a useful Python snippet for any code that can both             the main version of Fuse:
a directory:                                                     be run from the command line and called from other                fuse.sourceforge.net.
  def readdir(self, path, fh):                                   pieces of code. The expression evaluates to True if
    return ['.', '..', 'date']                                   the file is the main program being run. In our case, we
  That's our main class complete. Now we just need               use it to launch the Fuse filesystem if we're running
the rest of the program to wrap this class up and                this as a program, but also enables our Python file to
launch the new filesystem.                                       be included as a module in other programs. The final
from stat import S_IFDIR, S_IFREG                                line uses the imported FUSE function to launch the
from sys import argv, exit                                       filesystem. The first two arguments are our new class
from time import time                                            and the location to mount the filesystem (this is taken
from fuse import FUSE, Operations, LoggingMixIn                  from the argument passed across on the command
import datetime                                                  line when the filesystem is launched. The others just
class Context(LoggingMixIn, Operations):                         set the standard filesystem parameters.
  #code from above                                                  With all this code in place, you can launch the
if __name__ == '__main__':                                       filesystem from the command line. The permissions
  if len(argv) != 2:                                             needed to launch a filesystem vary from distro
    print('usage: %s <mountpoint>' % argv[0])                    to distro. For testing purposes, it's easiest to run
    exit(1)                                                      everything as root. You'll need two terminal sessions.
                                                                 In the first terminal session, get everything ready with:
                                                                 mkdir fuse-test
  Fuse filesystems
                                                                 sudo python fusedate.py fuse-test
  Fuse isn't just for creating toy filesystems. It can also be     In the second session, you can then navigate the
  really useful as it lowers the barrier to entry and makes it   new filesystem and read the current date:
  possible for non-kernel hackers to create new filesystems.
                                                                 sudo bash
  This also makes it easier to distribute new filesystems
  as they don't require the user to compile them as kernel       cd fuse-test
  modules. Here are a few of our favourite:                      cat date
    SSHFS Mount remote filesystems using just SSH with              That's all there is to creating filesystems. Obviously
    no other software required on the remote server.             ours is very limited, but the basic techniques are
    EncFS Create encrypted filesystems to keep your
    data safe.
                                                                 exactly the same regardless of how many files or
    Archivemount Use compressed archives such as                 directories there are.
    tarballs as though they were normal directories without
    unzipping them.                                               Ben Everard is the best-selling co-author of the best-selling
                                                                  Learning Python With Raspberry Pi.




                                                                   www.linuxvoice.com                                                                       89
     CODING HASKELL




HASKELL: PROGRAMMING
BACKWARDS
Rock-like reliability, a solid safety record in embedded systems, and a cool name.

     JULIET KEMP
                         H
                                   askell wasn't the first functional language,        minimise the need for brackets and avoid statement
                                   but it was the one that consolidated                terminators (as in Python). Lists and tuples were
                                   functional programming, and if you're looking       important to Miranda, something else that made its
                         for a pure functional language today, it's your best          way into Haskell.
                         choice. Haskell has also become a bit more popular               The original plan for the Haskell committee was
                         lately as functional ideas come into wider usage. It's        to use Miranda as a jumping-off point for the new
                         quite different from imperative or OO languages, and,         language, but Turner politely declined the request,
                         as with some of the other languages we've looked at,          preferring to maintain Miranda as a single-dialect
                         wrapping your head round it can be a challenge. (It           language. Haskell still owed a great deal to Miranda,
                         doesn't, for example, have a for loop.) But it's fun to try   but having to start from a blank page, while meaning
                         out, and the excellent interactive interpreter makes it       a great deal more work, did give them more scope to
                         easy to experiment with.                                      make some potentially more radical decisions.
                                                                                          The first meetings of the committee, including the
                         History                                                       one where the name was decided upon (it is named
                         Lambda calculus, developed by Alonzo Church long              after the logician Haskell Curry, but Haskell was felt to
                         before modern computers existed, is basically a way           be a better and less pun-inducing name than Curry),
                         of thinking about functions and computability (we             were face-to-face, but after that the work was all
                         looked at Lambda functions in LV008's Code Ninja).            done over email. Haskell 1.0 was defined in 1990, and
                         Unsurprisingly, it was a major part of thinking about         improvements were made over the next seven years,
                         computer languages in the 1950s and 1960s. Lisp               finally producing Haskell 98 in the form of The Haskell
                         development owed quite a bit to lambda calculus, and          98 Report (all 150 + 89 pages of it). This consisted
                         Robin Milner used the same ideas when developing              of a minimal core language and a standard library.
                         the functional language ML in the early 1970s.                Haskell is intended to be easy to extend and vary.
                            There was quite a bit of interest in functional               More recently, the borrowing of functional ideas into
                         languages and lazy evaluation (evaluating an                  languages like Python and Ruby has made Haskell
                         expression when it is needed and not before, which            a more popular language outside of academia,
                         has the potential to massively reduce running time)           and there's now an active coder community.
                         at the time, but the first commercial lazy and purely         Further improvements have also been made to the
                         functional language was Miranda, produced by David            specification, with the most recent release, Haskell
                         Turner at Research Software Ltd in 1985. Miranda              2010, including bindings to other languages (the
                         programs consisted of a set of equations, defining            foreign function interface), and various extensions.
                         functions and data types. As with Haskell, the order          There's an open-source library repository, Hackage,
                         of the set was irrelevant, and indentation was used to        maintained by the community, and a useful wiki is
                                                                                       also available from the Haskell webpage.

                                                                                       Getting started
                                                                                       Several distros offer packaged versions of the
                                                                                       Glasgow Haskell Compiler (GHC) and the interactive
                                                                                       interpreter. For Debian/Ubuntu, install ghc, and for
                                                                                       other distros check out the Haskell website.
                                                                                          Once you've started ghci, the interactive interpreter,
                                                                                       try a few expressions:
                                                                                       Prelude> "Hello world"
                                                                                       "Hello world"
Experimenting with the                                                                 Prelude> 6 + 3
interpreter ghci.                                                                      9



90                                                        www.linuxvoice.com
                                                                                                                                   HASKELL CODING


   Prelude is a standard module that's imported by
default. It includes various functions including string
functions, list functions, and basic I/O operations.
   You can test a lot of expressions in the interpreter,
and it's good for experimenting, but what if you want
to write an actual function? You can't write functions
directly in the interpreter; instead you need to create a
source code file and load it in. Create a file hello.hs:
helloworld = print "Hello World"
  Load and run it in GHCI:
Prelude> :load hello.hs
[1 of 1] Compiling Main ( hello.hs, interpreted ) Ok,
modules loaded: Main.
*Main> helloworld
"Hello World"
  So, you can define a function with just an equals
sign, just like a variable. Just remember, once an
assignment is made, you can't change it. Try this:
                                                                                                                                            The Haskell Working
helloworld = print "Hello World"                                     printSquare input =
                                                                                                                                            Group, Oxford, 1992.
helloworld = print "Hello World!"                                                putStr (" " ++ input ++ "")
  Load and run that, and you'll get an error:                        outputLine lineList = do
Prelude> :load hello.hs                                                          mapM_ printSquare lineList
[1 of 1] Compiling Main           ( hello.hs, interpreted )            putStrLn " "
hello.hs:2:1:                                                        outputWholeThing list = do
  Multiple declarations of `helloworld'                                          let (topOfSquare, restOfSquare) = splitAt 3 list
  Declared at: hello.hs:1:1                                                      let (middleOfSquare, bottomOfSquare) =
          hello.hs:2:1                                               splitAt 3 restOfSquare
Failed, modules loaded: none.                                                    outputLine topOfSquare
  This applies to variables as well as functions (in                             outputLine middleOfSquare
fact, variables and functions are basically the same                             outputLine bottomOfSquare
type of thing); see the boxout for more on code purity               main = do
and functionality.                                                     outputWholeThing numberedSquareList
                                                                        numberedSquareList will be used to give a
Tic Tac Toe                                                             number to each of the 9 squares in a standard
Let's try writing a tic-tac-toe program. This will be a                 tic-tac-toe board. The main function just outputs
very basic text-based input/output, rather than                         numberedSquareList as a three-by-three square,
anything graphical, but it will show some aspects of                    which is set up by the rest of the functions.
Haskell. The first part will set up a list of the numbers               printSquare takes a single input. It's possible to
of the squares, and output them tidily:                                 specify the type signature of a function, and we'll do
numberedSquareList = ["0", "1", "2", "3", "4", "5", "6", "7",           this for a function later, but as a rule Haskell can
"8"]                                                                    guess it from your code. Here, the input is a string,


  Haskell: functional and pure
  In an imperative language, you give the computer a      Impure code (which includes system commands,              another, as well as sticking them together. The
  sequence of actions to perform in a specific order.     modification of global variables, and I/O) may have       map function is an example: it takes a function
  In a functional language, like Haskell, you give it     side effects or alter state.                              and a list as parameters, and applies the function
  instead a collection of expressions, so it knows           A corollary of all of this is that within pure code,   to every element of the list. Haskell functions can
  what to compute, but not how or when to do it.          variables mustn't vary, but remain the same once          also return functions, as well as having them as
     In order for this to work, it's important that       set. Otherwise the result of a function that refers to    parameters. These ideas all arise from lambda
  functions should have no side-effects. That means       the variable foo might differ depending on whether        calculus, and will be familiar if you know any Lisp.
  that a functional expression must not change            or not foo changed at another point in the program.       Functional programming can be a bit of a challenge
  any part of the program state, and the result of a         Given no side effects and no changes to                if you're familiar with imperative programming,
  function must depend only on its input, and not on      variables, the expressions in a program can be            but it has some real advantages for certain sorts
  anything else happening elsewhere in the program.       evaluated in any order. This supports Haskell's           of project. It entirely avoids a certain class of
     This makes life a bit difficult if you want to do    "lazy" approach: Haskell will evaluate an expression      bugs, those which are due to unanticipated side
  any input/output: I/O actions necessarily have side     when and only when its result is needed. This             effects; and makes testing easier. It also makes it
  effects, as they interact with the outside world and    doesn't matter, because the program has no moving         possible to automatically parallelise the pure parts
  can alter system or program state. To deal with         parts; whenever you evaluate the expression, the          of your code (recent versions of ghc will do this for
  this, Haskell divides code into 'pure' and 'IO'. Pure   result will be the same. Functional languages             you), as side effects are one of the big issues with
  code has no side effects, and never alters state.       also make it easy to pass functions into one              parallelised code.




                                                                       www.linuxvoice.com                                                                               91
     CODING HASKELL

                                                                                            translate it into an Int. (Note that read doesn't do any
                                                                                            error-checking; you could look into using reads.)
                                                                                               saveMove uses a couple of useful list functions.
                                                                                            splitAt does what you'd expect: it splits the given list
                                                                                            at the given index (with that index starting the second
                                                                                            list). We then stick the two lists back together, adding
                                                                                            the player value (which will be X or O, in tic-tac-toe)
                                                                                            between them, and dropping the first value of the
                                                                                            second list. (The function tail list returns all but the
                                                                                            first value of a list.) Since we split the list at the index
                                                                                            point, this effectively creates a list that has the new
                                                                                            move in the place where the index number used to
                                                                                            be. So if player X chose square 6, the list now has X
                                                                                            instead of 6. We then output the whole thing to show
                                                                                            the player what the board now looks like. At this stage,
                                                                                            we're only getting player X to play, and only once.
                                                                                               You might notice that sometimes we use let x =
                                                                                            y, and sometimes we use x <- y. The former is used
                                                                                            for 'pure' code, and the latter for I/O (or other impure)
It's a draw, as tic-tac-toe
                                and the function outputs it to the screen with a            code. If in doubt, experiment, and the compiler will tell
tends to be when both
players know what they're       space on each side.                                         you if you've got it wrong.
doing.                          outputLine takes a list, and applies printSquare to            This all looks good, but if you run it, you'll find that
                                each member of the list. mapM_ and mapM are the             the final output no longer has the x in the 'saved'
                                functions that handle applying functions to lists, and      position. This is because Haskell is a pure language;
                                they're really useful. The syntax, as shown here, is        you can't reassign variables once they've been
                                mapM function list                                          assigned. In saveMove, you're not actually replacing
                                mapM also collects and outputs the return value of          numberedSquareList. You're creating a new local
                                the function as it is repeatedly applied. Here, we're       variable, also called numberedSquareList, which only
                                not really interested in the return value, so we use        exists for the lifetime of that particular function. Once
                                mapM_, which discards the return value. mapM and            we return to main, the local variable disappears, and
                                mapM_ deal with monads, whereas map does not;               the original numberedSquareList hasn't changed.
                                see the boxout for more on monads.                             One way to get around this is to get saveMove to
                                outputWholeThing takes a list and outputs it three          return a value, and keep creating new lists:
                                elements at a time. The splitAt function does what          saveMove :: [String] -> Int -> [String] -> IO [String]
                                you might expect: it splits a list at the given element     saveMove player square oldList = do
                                (note that lists in Haskell are indexed from zero). So        let (listA, listB) = splitAt square oldList
                                first we split the list into the first three elements and     let newList = listA ++ player ++ (tail listB)
                                the rest of the list, then we split the rest of the list      outputWholeThing newList
                                again into the first three elements and the                   return newList
                                remainder. (This doesn't check for errors, like a list      main = do
                                that is the wrong size; it just assumes that we're            outputWholeThing numberedSquareList
                                getting in a 9-element list.) Then outputLine outputs         (a, b) <- getMove "x"
                                each section of the list, creating our tic-tac-toe grid.      list1 <- saveMove [a] b numberedSquareList
                                Now let's try to get a player's move, and then save it:       (a, b) <- getMove "o"
                              getMove player = do                                             list2 <- saveMove [a] b list1
                               putStrLn ("Enter square to move for player " ++ player)        (a, b) <- getMove "x"
                               square <- getLine                                              list3 <- saveMove [a] b list2
                               return (player, read square :: Int)                            (a, b) <- getMove "o"
                              saveMove player square = do                                     list4 <- saveMove [a] b list3
                               let (listA, listB) = splitAt square numberedSquareList         (a, b) <- getMove "x"
                               let numberedSquareList = listA ++ player ++ (tail listB)       list5 <- saveMove [a] b list4
                               outputWholeThing numberedSquareList                            (a, b) <- getMove "o"
                              main = do                                                       list6 <- saveMove [a] b list5
                               outputWholeThing numberedSquareList                            (a, b) <- getMove "x"
                               (a, b) <- getMove "x"                                          list7 <- saveMove [a] b list6
                               saveMove [a] b                                                 (a, b) <- getMove "o"
                               outputWholeThing numberedSquareList                            list8 <- saveMove [a] b list7
                                 getMove uses getLine (self-explanatory) to get the           (a, b) <- getMove "x"
                              square for the move from the user. This will be read            list9 <- saveMove [a] b list8
                              in as a string, so when returning it, we use read to            putStrLn "All done!"



92                                                              www.linuxvoice.com
                                                                                                                               HASKELL CODING


  Monads
  Monads are part of functional programming, and enable
  Haskell to maintain its pure/not pure division by isolating
  parts of code that might have side-effects (like IO code).
  They enable you to guarantee that certain calculations are
  done in a particular order; as discussed above, this isn't
  usually the case in Haskell. Monadic actions enable you to
  pass elements and results from one function to the next in
  a way that is illegitimate in pure code. They also contain a
  way of turning a type into a monad type – the IO monad can
  turn a String into an IO String, for example – again, allowing
  the separation between pure and 'real-world-acting' code.
     IO is a common monad, as is Maybe, which we don't use
  in this tutorial but which is useful for computations that
  could fail. There are many, many explanations of monads
  online, and different people understand them in different
  ways. You can't get all that far in Haskell without them, but
  once you come to grips with them, they're incredibly useful.


   saveMove now takes another argument: a list to
act on. It also returns a list. We've also added a type
                                                                                                                                  Playing the game! Still very
signature at the top to make it more maintainable (this            to use with monads, including unless and when.
                                                                                                                                  basic though...
is good practice to do for all your functions, although            wholeMove is just a helper function to get and save a
not necessary).                                                    specific move; there's no new code.
[String] -> Int -> [String] -> IO [String]                            playGame is the clever bit. It takes a list as an
means that the function takes a String array, an Int,              argument: this is the current state of the game. First
and another String array, and outputs an IO String                 we ask which player has the next move (and offer the
array. If you're struggling to work out a type signature,          chance to quit), and get the answer. If the answer is q,
you can use :type functionname in the interpreter and              the function ends. Otherwise (unless q), we perform
it will tell you what it thinks the type is.                       the next move, get a new list out again, and then call
   In main, we repeatedly call saveMove on the                     playGame again on the new list, which has the new
current list, then use the list it returns as the input            state of the game. We keep going around until the
the next time. This also means we're getting moves                 user types q at the prompt, passing the new state
from the X and O players alternately, which is handy.              back into the method each time.
Note that the last statement in a do block must be an                 main now outputs the initial (blank, numbered) grid,
expression, so we need that last putStrLn line.                    then passes that into playGame to start the recursion.
   The downsides are, firstly, that it's rather untidy, and        When the user answers q, we jump back to main, and
secondly, that there's no way of cutting a game short              output "All done".
if someone wins. Haskell doesn't really do iteration                  There are a few ways you could improve on this
(though there is a way of iterating over lists), but a             code: You could look into the State monad functions
very common Haskell idiom is recursion. Let's try a                to find other ways of passing state around.
recursive approach to our game:                                       Currently, you can keep playing even once all the
import Control.Monad                                               squares are blank; you'll just overwrite them. You
saveMove                                                           could add something to stop the game once that
  -- as before, but delete outputWholeThing line                   happens. Similarly, the user has to decide who has
wholeMove player oldList = do                                      won; could you find a way of checking for that?
  (a, b) <- getMove player                                            More fundamentally, this code isn't super-Haskell-y
  newList <- saveMove [a] b oldList                                in that it could probably have a better separation of
  outputWholeThing newList                                         pure and IO code. Improving that would be a great
  return newList                                                   way of finding out more about how monads and type
playGame list = do                                                 signatures work.
  putStrLn "Who plays next? x, o, or q to quit"                       If you want to get stuck into improving this code or
  continue <- getLine                                              writing your own, there are plenty of online resources
  unless (continue == "q")                                         available. Try Learn You A Haskell For Greater Good
    newList <- wholeMove continue list                             (free online, or in print) for a bunch of great tutorials.
    playGame newList                                               The Haskell wiki is a good reference, and there's a
main = do                                                          thorough Haskell book on Wikibooks. Real World
  outputWholeThing numberedSquareList                              Haskell is also available online. Have fun!
  playGame numberedSquareList
  putStrLn "All done!"                                              Juliet Kemp is a friendly polymath, and is the author of
                                                                    Apress’s Linux System Administration Recipes.
  Control.Monad contains some useful functions



                                                                     www.linuxvoice.com                                                                   93
      CORETECHNOLOGY




                                  CORE
Valentine Sinitsyn develops
high-loaded services and
teaches students completely
unrelated subjects. He also has
a KDE developer account that
he’s never really used.
                                  TECHNOLOGY
                                  Prise the back off Linux and find out what really makes it tick.

                                  Code compilation
                                  Join us for a fantastic voyage trip to the internals of a process in
                                  which plain English words are melt into executable machine codes.


                                  C
                                           omputers speak machine language. Humans                  {
                                           usually don't. Machine code is just too                      return 0;
                                           primitive, too low-level for our brains, which are       }
                                  used to higher-level abstractions. When we design a                 How to run it? Unless you are very new to Linux
                                  house, we decide on materials, the number of rooms,               (welcome!), the answer is straightforward:
                                  and which colour the ceiling will be, not how the bricks          $ gcc -o trivial trivial.c
                                  will stick together. The same applies to most                     $ ./trivial
                                  programs we write.                                                   gcc is the GNU C Compiler, and it is part of GCC,
                                     Except for specific system stuff, our software uses            which stands for GNU Compiler Collection (still
                                  high-level programming languages. They are great for              loving your recursive acronyms, yeah?). Essentially,
                                  programmers, but all Greek to computers. So, what                 this command transforms C code into machine
                                  we need is some way to translate these languages                  instructions and packs them in an ELF executable
                                  into machine code.                                                (LV018). This is sometimes called Ahead-of-time
                                     This is basically what compilers and interpreters are          Compilation or AOT, because the program is built prior
                                  all about. Today, we'll see how this conversion occurs            to execution.
                                  in various situations. Consider a trivial C program:                 The gcc command is really a shortcut for whole
                                  int main()                                                        pipeline of things. First, the lexer recognises the
                                                                                                    tokens (like keywords or variable identifiers) that your
                                                                                                    code is made of. Tokens form syntactic constructions
                                                      abs                                           (say, loops or function definitions) that the parser
                                                                                                    recognises. If the parser comes across something
                                        args                         body                           it doesn't understand (for instance, two tokens that
                                                                                                    don't fit together, like if and for), you get a compilation
                                        x                             return                        error. Otherwise, an Abstract Syntax Tree or AST is
                                                                                                    built in the compiler's memory (see Figure 1), which
                                                                               value                is a program's representation that's not tied to input
                                                                                                    language syntax.
                                                              body                    or else          AST is well suited for semantic analysis and, in
                                                UnaryOp               IfExp                     x
                                                                                                    particular, optimisation. Optimisation is a tricky
                                        op                operand                                   topic, and although gcc provides command-line
                                                                               test
                                                                                                    switches to fine-tune individual optimisations, most
                                                                                                    often you just set the desired optimisation level with
                                            -             x          Compare                        -O<something>.
                                                                                                       At the next pipeline stage, the compiler walks
                                                              left         comp                     through the optimised tree and emits native machine
                                                                     ops
                                                                                                    instructions for your program. Usually, this step is
Figure 1. Simplified AST                                      x                             0       invisible, but you can instruct gcc to stop here to see
                                                                           <
tree for abs(x) function                                                                            the assembler; just use the -S switch. This is what
as seen by the Python                                                                               trivial's main() function looks like:
compiler.                                                                                           main:



94                                                                         www.linuxvoice.com
                                                                                                                      CORETECHNOLOGY

           pushq       %rbp
           movq        %rsp, %rbp
           movl        $0, %eax
           popq        %rbp
           ret
   Compiled code units are saved as object files, which
conventionally carry the .o suffix.
   Finally, object files are combined together in one
executable, or shared library. This is the linking
stage, and in fact it isn't part of the compiler. A
separate program called a linker (ld, in the case of
GCC) resolves external references (like the extern
variables or library functions) and lays out everything
to produce a valid ELF binary. Or, it can produce
something different, as a thing named a "linker script"
dictates. Practically, you don't write linker scripts
                                                                                                                             Figure 2: Python defines
(they are rather low-level) or call ld directly. Everything          for a language makes the compiler simpler. And of
                                                                                                                             quite a few bytecode
happens behind the gcc curtains.                                     course, generated bytecode can run on any platform,     instructions. All of them
   Ahead-of-time (or simply traditional) compilation                 provided the latter has a virtual machine available.    are described in the dis
has several benefits. As it runs "offline" on a build                  But there are also some downsides. In practice, you   reference manual.
farm and not in real time on an end-user device,                     can't ditch platform-specific code altogether, as you
it can involve deeper and more time-consuming                        need some way to interact with the environment you
optimisations. Together with native code generation                  run in. Interpreted languages are also significantly
this yields a more efficient binary. However, it would               slower than compiled ones, as virtual machines have
necessarily be system-specific (or non-portable), and                measurable overhead.
you can't just copy an ELF image from your x86 PC to                   To see is to believe, so let's have a look at the
an ARM smartphone and hope it will work properly.                    bytecode of one popular interpreted language. You
This could be a problem, and if platform independence                guessed it, Python. Consider a simple function that
is a priority, another approach might be helpful.                    returns an absolute value of its sole argument:
                                                                     >>> def abs(x)
In the meantime
The trick is not to target any specific processor                          Ahead-of-time compilation can involve
architecture or operating system during the code
generation phase. Instead, the compiler emits                              deeper and more time-consuming
instructions of a virtual processor, often called
"bytecode". The problem is that virtual processors
                                                                           optimisation than just-in-time
don't exist in silicon, so you need to implement them
in software. This is the approach usually taken by                   ...    return -x if x < 0 else x
interpreters and language virtual machines (VMs).                      The Python Standard Library provides the dis
Some languages (such as Python) bundle the                           module, which is a disassembler for Python bytecode.
compiler and virtual machine together, while others                  Note it is naturally implementation-specific, and if
(Java) keep them separate.                                           you use anything other than CPython, the command
   Bytecode doesn't need to be as low-level as real                  below may not work for you:
machine instructions. For instance, the Java virtual                 >>> dis.dis(abs)
machine has an instruction to get an array's length,                  2         0 LOAD_FAST             0 (x)
something that isn't readily available even in C. Python                       3 LOAD_CONST              1 (0)
implements an instruction to print a string or setup                           6 COMPARE_OP              0 (<)
the with block. Being able to design an instruction set                        9 POP_JUMP_IF_FALSE               17
                                                                              12 LOAD_FAST              0 (x)
                                                                              15 UNARY_NEGATIVE
  Get to know ctypes                                                          16 RETURN_VALUE
                                                                            >> 17 LOAD_FAST              0 (x)
  ctypes is a portable way to create and manipulate C
                                                                              20 RETURN_VALUE
  language types from Python. It can call into shared
  libraries, and wrap Python functions so that libraries can            abs() translates to nine bytecode instructions.
  call them back. ctypes is mainly useful to create bindings         Numbers in the first column denote lines of source
  to C libraries. It isn't blazing fast, but requires zero C code.   code. CPython's virtual machine is stack-based, and
  ctypes works on the ABI (Application Binary Interface) level,
                                                                     it has no registers as real processors. This hurts
  which is somewhat easier to break but doesn't involve any
  compilation steps. However, if you use it carelessly, you can
                                                                     performance a bit, but allows for a simpler design.
  crash the Python interpreter quite easily.                            First, the function pushes the x value and 0
                                                                     constant on to the stack. Then the COMPARE_OP



                                                                           www.linuxvoice.com                                                        95
     CORETECHNOLOGY

                instruction pops both, compares them and pushes            VM runs in monitor mode. It interprets bytecode and
                the result. POP_JUMP_IF_FALSE pops the result of           updates the counter each time a specific location
                comparison, and branches to instruction 17 (marked         is visited. When the counter appears to be above a
                with a double arrow) if it is false. Here, the code        threshold, a hot path is detected, so the VM switches
                again puts x on the stack and returns a value from         to record mode. Then it carefully records all effects
                the stack's top (ie, x) with RETURN_VALUE. Another         of bytecode execution until the code returns to the
                branch works in a similar fashion. The documentation       starting point.
                for the dis module lists all bytecodes known to               Now, the VM has a "trace" of the new hot path.
                CPython's VM. There are quite few of them, but still       Instructions that can diverge from it (like branching)
                less than in a typical processor's instruction set.        are protected with guards that quickly check that the
                                                                           assumptions under which the trace was taken are
                Just in time                                               still true. Then the trace is compiled to native code.
                Conceptually, Just-In-Time compilation is like Ahead-      Next time the VM encounters this hot path, it executes
                Of-Time compilation, but there is one very important       compiled trace instead.
                nuance. It happens "online", on the end-user device,          Mozilla's original TraceMonkey JavaScript engine
                often while the program is running. This poses some        and the PyPy Python language implementation
                challenges, but if implemented properly, can also yield    are both examples of tracing JIT. However, there
                measurable benefits.                                       is no ultimate answer to which JIT flavour is the
                    The main challenge is probably that the end-user       clear winner. PyPy delivers impressive results, while
                device's processor is probably slower than that            TraceMonkey was later superseded with combined
                of the developer's machine or build farm, and is           JIT techniques. Results naturally depend on the
                often battery-powered. Moreover, you don't carry a         languages you compile, and the environment.
                smartphone to build software on it, so the compilation
                process shouldn't be resource-intensive. This limits       Do it yourself
                the amount of optimisation that the compiler can do,       As a roundup, let's build a small JIT compiler for
                and the amount of code it compiles. JIT usually deals      mathematical expressions. To keep things simple, we
                only with performance-critical application parts, and      won't support variables or functions: just plain values
                leaves the rest to the emulator. As a rule, JIT compiler   and arithmetic operations.
                also works on intermediate (bytecode) representation.         We won't start from scratch. The Numba project
                It's simpler to translate than source code, and also       (see boxout) maintains the llvmlite LLVM binding,
                offloads many things to the developer's machine, as in     which focuses on JIT compilation, and we'll use it
                AOT. Sometimes the results of JIT are also cached on       today. We aren't going to use a dedicated parser,
                device for later re-use.                                   though. Instead, we'll employ the ast module to peek
                    At the same time, JIT techniques enable targeted       into the syntax tree generated by the Python compiler.
                optimisation. The compiler knows exactly what CPU          import ast
                it runs on, and can potentially emit machine code          expr_str = '2+2'
                for this particular processor. More importantly, the       ast_mod = ast.parse(expr_str)
                compiler knows how the program is being used, and          expr = ast_mod.body[0].value
                can employ profile-guided optimisations. Say, if you         We start with the expression string and parse it into
                barely use feature A, there's no point spending time       AST. Python delivers the result as a module containing
                and resources compiling it.
                    Perhaps the trickiest part is striking a balance
                between compilation costs and optimisation level.            Python JIT for real
                Again, there's no single solution. One way is to work on     Besides our toy example, there are some real JIT compilers
                method or function level. The VM starts in interpreter       targeting the Python language. As you already know,
                mode and collects statistics on which methods                PyPy (www.pypy.org) sports tracing JIT. Benchmarks
                are executed most often. Then it emits optimised             look promising, and it's mature enough to run the Flask
                                                                             or Django web frameworks. Pyston (www.pyston.org) is a
                machine code, so they could execute faster. Oracle's
                                                                             method-level JIT from Dropbox. Just like our tiny example,
                Java VM behaves this way. In fact, it's called HotSpot       it starts with AST and relies on LLVM to produce fast code.
                VM because it is all about detecting "hot spots" in your     The project is currently in alpha stage, but it would be
                Java bytecode and optimising them properly.                  curious to watch it progress.
                                                                                 The problem with doing effective JIT for Python and
                                                                             similar languages is in their dynamic nature. Variables may
                Hot traces                                                   change their types, and the interpreter dispatches this at
                Tracing JIT is an alternative approach. The idea is          runtime. Objects may have dynamic attributes, and the
                that programs spend most time in loops, or code              interpreter looks them up in a dictionary. This is bad for
                that jumps to the same origin. These loops can span          machine code, where each value is typed, and the meaning
                multiple methods (albeit they don't need to) and are         of `a + b` is totally different for `a` and `b` being integers or
                                                                             strings. Sometimes, the compiler is able to infer types and
                dubbed "hot paths", as opposed to "hot spots" in
                                                                             generate effective machine code, but often it's difficult or
                method-level JIT. Internally, tracing the JIT compiler       impossible, and compiled code ends up being wasted.
                keeps a counter for each code location. Initially, the



96                                             www.linuxvoice.com
                                                                                                                     CORETECHNOLOGY

a single expression (check it with ast.dump(ast_                                                                                             LLVM optimised
                                                                                               Expression JIT benchmarks                     LLVM unoptimised
mod)), and we unwrap it.                                                                                                                     Pure Python
   The next step is to generate an LLVM intermediate
representation (IR). The llvmlite.ir module provides all                  0.2
relevant functionality:
from llvmlite import ir                                                   0.15
def create_ir_builder():




                                                              Time, sec
  fnty = ir.FunctionType(ir.DoubleType(), ())                             0.1

  module = ir.Module(name=__file__)
                                                                          0.05
  func = ir.Function(module, fnty, name="_main")

                                                                          0
  block = func.append_basic_block()                                              1       3         5           7           9            11
  builder = ir.IRBuilder(block)
                                                                                                   No. of Operands
  return module, builder
   Here, we create an IR module and define the _main
                                                                                                                               Figure 3: Execution time
function inside it. The function takes no arguments          com. The binding functions accept IR source code as
                                                                                                                               for varying expression
and returns double. Note how LLVM relies on types for        a string (you get it as str(prog)).                               sizes. Compiled code
its operations. create_ir_builder() returns a module           Finally, we use ctypes (see boxout) to call into the            spends most of the time
and an IR builder we'll use later to emit IR instructions.   machine code we just generated:                                   in ctypes, that's why the
def emit_ir_for_ast(builder, node):                          from ctypes import CFUNCTYPE, c_double                            unoptimised version is
  if isinstance(node, ast.BinOp):                            func_ptr = engine.get_function_address("_main")                   only marginally slower.
    left_ir = emit_ir_for_ast(builder, node.left)            _main = CFUNCTYPE(c_double)(func_ptr)
    right_ir = emit_ir_for_ast(builder, node.right)          print("_main() = %f" % _main())
    if isinstance(node.op, ast.Add):                         ExecutionEngine.get_function_address() returns the
      return builder.fadd(left_ir, right_ir)                 pointer to the _main() function we just compiled.
    # other operations follow                                   To try this code yourself, you'll need to obtain
  elif isinstance(node, ast.Num):                            llvmlite first. This could be tricky, so I suggest you
    return ir.Constant(ir.DoubleType(), float(node.n))       use the Miniconda installer (http://conda.pydata.org/
                                                             miniconda.html). It keeps everything in your home
prog, builder = create_ir_builder()                          directory along with system-wide Python, and is great
result = emit_ir_for_ast(builder, expr)                      for trying new stuff. Download the installer script from
builder.ret(result)                                          the link above and simply run conda install llvmlite
   This fragment walks AST in descent-recursive              when done.
manner. It converts any number encountered to a                 What does the _main() function look like at
double floating-point constant, and generates IR             machine code level? Disassembly (TargetMachine.
instructions for binary operations. ast.Add represents       emit_assembly()) gives the answer. And there's
addition, and fadd is floating point addition in LLVM IR.    another surprise: it's just three instructions long. LLVM
Finally, we return the result of the top-level expression    is an optimising compiler, and as it detects that all
from _main. Operator precedence is handled                   operands in the expression are constant, it evaluates
automatically in the Python parser.                          it compile-time. This is called "constant folding", and
   Then, the program calls into the llvmlite.binding         that's why optimised LLVM execution time (blue bars)
layer to compile the IR into machine code. It's rather       doesn't depend on expression complexity. To make
long and we won't show the details here; refer to            comparison fair, we can disable optimisations in LLVM.
comments in sources available at ww.linuxvoice.              However, this doesn't change the results drastically.




Command of the month: pycc
Python's JIT is fun, but wouldn't it be nice to simply       explicitly exported with numba.export(), specifying
compile your script into static binary, as we do in C or     both arguments and the return type:
C++? Well, it probably would, but pycc won't help you        import numba
there. Instead, pycc compiles your Python functions          def add(x, y):
into shared libraries (.so) that you can use in a              return x + y
language of your liking. pycc is also part of Numba          export('add i4(i4, i4)')(add)
(see boxout), and it uses the same LLVM machinery              Here, i4 means 32-bit integer. Alternatively, you may
that the @jit decorator does.                                ask pycc to output LLVM bytecode with pycc --llvm.
   Usage is straightforward: you tell pycc which               Numba advertises pycc as an experimental feature,
Python sources to compile, and get a .so object.             and at the time of writing it had some known issues.
Note that any function you want compiled should be           Nevertheless, this tool looks rather promising.



                                                               www.linuxvoice.com                                                                          97
     /DEV/RANDOM/ FINAL THOUGHTS




Final thoughts, musings and reflections
                            Nick Veitch
                            was the original editor
                            of Linux Format, a                                                                             Marmite
                            role he played until he                          Amazing Space
                                                                                                                           for morning
                            got bored and went                               Shuttle poster which
                                                                                                                           crumpets.
                            to work at Canonical                             Paul bought for me.
                            instead. Splitter!

                                                                                          Photos of my
                                                                                          daughter to remind
                                                                                          me to go home.          Rigol DS2072A
                                                                                                                  2-channel oscilloscope




R
                                                                                                                  for debugging circuits.
            ecently, the Linux Foundation
            promoted a new animation series “A
            World without Linux” (http://goo.gl/
H8UrrT). The intention seems to be to
remind people that they use Linux all the
time – though, since only Linux types are
going to know about it in the first place, I
guess they are hoping that it will get tweeted                          Intel NUC i7 + 34-inch
or instagrammed or whatever it is you do on                             curved IPS LCD. My                               Fluke 287 multimeter,
Facebook these days apart from dodge                                    primary computer.                                which is possibly my
taxes. Tip: Omit the word ‘Linux’ from the link                                                                          favourite toy.
if you want non-Linux people to look at it.
    It is a very reasonable thing to do, but I am
not sure that having watched a few episodes
everyone in the world is going to rush to
download a distro. I went to a friend of a            MY LINUX SETUP
friend’s birthday a few weeks back, and not
wanting to go empty handed, I took him an
Ubuntu T-shirt. When he opened it, I had to
                                                      JON WILLIAMSON
explain what it was – he uses Ubuntu                  Ninja-coder, product designer and co-founder of Pimoroni.
because it is free and it works and he can do
all the stuff he wants to on it. He probably                What version of Linux are you                 moving to Debian (then naturally on to
never noticed the logo before.                              currently using?                              Ubuntu).
    People *do* use Linux every day, but they               Ubuntu 15.04 (though I’ve just
don’t know, and, I suggest, they don’t care.                upgraded to 15.10 at home). All of                  What Free Software/open source
That’s fine with me. For people who do care,          our Pimoroni infrastructure is running on                 can’t you live without?
it is more interesting to see the people who          Ubuntu Server.                                            All of them! It’s amazing to be able to
do embrace Linux and open source doing                                                                          install something like wkhtmltopdf
cool stuff – Netflix recently updated its                   And what desktop are you using at             through your package manager and
GitHub repository and is doing a major push                 the moment?                                   produce a PDF from a webpage then
on its open source software (http://goo.gl/                 Unity – it’s great with a little tweaking.    email it to someone all without leaving the
it5wUH). Why? Because more people using                     Matches my workflow well.                     terminal. Lots of great tools is where the
it (and finding bugs and fixing things) makes                                                             power lies.
it better. The average viewer may be very                   What was the first Linux setup you
slightly interested to know that without                    ever used?                                         What do other people love but you
Linux their show wouldn’t exist, but                       Yikes, that was a long time ago! It was             can’t get on with?
convincing non-open-source coders is                        a painful night spent installing                   Vim/Emacs. I’m a Sublime Text 3 user
probably more beneficial. And they might              Slackware in… err 2001? It took hours and                and I while I wish it were open source I
appreciate T-shirts more.                             wasn’t a pleasant experience. I ended up            wouldn’t change it for anything.



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




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



              shop.linuxvoice.com