Plaintext
9 REASONS LINUX BEATS WINDOWS 10
How
INSIDE
SUSE’S
Britain is
OPEN BUILD leading the
SERVICE charge in free
software and
KDENLIVE Edit professional-quality video
open data
RASPBERRY PI Control the physical world!
SEARCH ENGINES Find one that respects your privacy
116 PAGES OF AWESOME
O c tober 2015 £5.99 Printe d in the UK
JOHN SULLIVAN BLOGGING
NETHACK
FREEDOM! WORDPRESS
Richard Stallman’s boss Spread your immortal
talks freedom, formats words across the web
and the future with a customised blog
WELCOME
Polygon Windows
The October issue
Linux Voice is different.
Linux Voice is special.
Here’s why… GRAHAM MORRISON
A free software advocate
At the end of each financial and writer since the late
1
year we’ll give 50% of our 1990s, Graham is a lapsed
profits to a selection of KDE contributor and author
organisations that support free of the Meeq MIDI step
software, decided by a vote among sequencer.
our readers (that’s you).
I SUBSCRIBE
have a lot to be thankful to Microsoft for. Its operating system
No later than nine months made computers affordable, despite itself, and one of my first
2
after first publication, we will
relicense all of our content under
jobs was looking after some Windows 3.0 machines. But it was
also what led me to Linux. In the late 1990s, I was trying to get
ON PAGE 64
the Creative Commons CC-BY-SA back into programming, and wanted to write something that would
licence, so that old content can specifically scratch my own itch. But I wanted my code to also be
still be useful, and can live on even useful to anyone else with the same problem. I was genuinely
after the magazine has come off shocked by the restrictive nature of what you could and couldn’t
the shelves. share when you developed software on Windows using its own
developer tools and APIs.
We’re a small company, so It was this realisation that led me back to Linux and Free
3
we don’t have a board of Software (after a previously bad experience trying to run X11 on an
directors or a bunch of Amiga 4000). All these years later, Microsoft is a different
shareholders in the City of London company. It attends open source events and has its own well-
to keep happy. The only people maintained GitHub account. But it still doesn’t believe in open
that matter to us are the readers. source enough to open more of its own code, or spend time
opening its licences. To me, it’s still opposed to sharing great ideas,
and that, dear Linux Voice readers, is our killer feature.
THE LINUX VOICE TEAM
Editor Graham Morrison
Graham Morrison
graham@linuxvoice.com Editor, Linux Voice
Deputy editor Andrew Gregory
What’s hot in LV#019
andrew@linuxvoice.com
Technical editor Ben Everard
ben@linuxvoice.com
Editor at large Mike Saunders
mike@linuxvoice.com
Games editor Michel Loubet-Jambert
michel@linuxvoice.com
Creative director Stacey Black
stacey@linuxvoice.com
Malign puppetmaster Nick Veitch
nick@linuxvoice.com
Editorial contributors:
Mark Crutch, Marco Fioretti, Juliet
Kemp, John Lane, Vincent Mealing, ANDREW GREGORY BEN EVERARD MIKE SAUNDERS
Simon Phipps, Les Pounder, Mayank “Running your own website is “Our feature on Windows 10. Any “Us Brits seldom take pride in our
Sharma, Valentine Sinitsyn. exciting and liberating, which is new Windows release is an ideal history, but delving into our long
why WordPress makes such a opportunity for reminding people computing heritage has been
great platform and subject.” p84 why Linux is so awesome. ” p34 fascinating.” p20
www.linuxvoice.com 3
CONTENTS
October LV019
Celebrating a year and a half of server uptime, it’s your new Linux Voice…
20 REGULARS
SUBSCRIBE News
ON PAGE 64 06
All the goings-on from planet
Linux, distilled into nine
bite-sized pieces.
08 Distrohopper
A security layer for Arch
Linux and a semi-rolling
SUSE release.
10 Gaming
Dinosaurs, magic, and a
game that’s a satire on
games development.
12 Speak your brains
Vent your spleen, share your
How one small island is making a massive opinions, let us know what
you’re thinking.
contribution to Linux. Cor blimey! Jings! etc
16 LV on tour
PGDay UK – PostgreSQL UK
2015, on the wonderful world
of databases.
42 Group test
58
Search engines: because
The FSF’s if you’re relying on Google
to search the web, you’re
Executive Director leaking personal information
like a sieve.
John Sullivan 64 Subscribe!
Save money, get Linux Voice
delivered to your door, and
Why it’s vital that all of get access to every singe one
of our back issues.
us keep up the fight for
Core technologies
Free Software. 66
Look into the soulless eyes of
the daemons that live in your
Linux box.
70 FOSSpicks
The free-est, freshest
software on the internet,
corralled into six pages of
pure excellence.
110 Masterclass
Administer machines
remotely, with SSH on the
30
OPEN BUILD SERVICE 34
WINDOWS 10 40
FAQ: WEBASSEMBLY command line and Webmin for
Write once, deploy Just some of the Meet the younger, the graphically inclined.
anywhere: that’s the reasons why we won’t cleverer, better-
My Linux desktop
dream shared by be making the switch looking cousin of 114
Featuring our very own
SUSE’s Open Build to Windows 10 this JavaScript. The next Ben Everard!
Service team. summer. web awaits!
4 www.linuxvoice.com
TUTORIALS REVIEWS
78 Manage
passwords
with
KeePassX
Life online
brings too many
passwords to
remember – so
LibreOffice 5.0
set up a password
50
The standard bearer for cross-
manager and platform Free Software keeps
sync your secrets getting more refinement, more
across all your features and more polish.
devices.
80 84
52 VirtualBox 5.0
Virtualise as many Linux
distributions as your RAM
Raspberry Pi: Write a WordPress: Build a banks can handle.
controller for a crane custom blog
53 Drawpile
Interact with the physical world Control every aspect of this Collaborate on sketches, plans
using a HAT and some Python. flexible, simple CMS. or games of snakes and ladders
with distributed graphics.
90 96
54 Geany
Write your code in the luxury
of this simple, clean integrated
development environment.
55 Shadow of Mordor
Pipe-smoking don JRR Tolkien
never played games on Steam,
but he would have liked this.
Grub 2: Add a custom Kdenlive: Edit video
Books The Linux Command Line:
command with Free Software
56
because sometimes the man
Extend the functionality of Turn raw footage into a page just isn’t enough.
the Linux bootloader. masterpiece.
100
Old code: 104
Code Ninja: 106
Faster code
Prolog GNU parallel with profiling
Natural
Xxxx xx language
xxx xxxxx Keep your
Xxxx xx xxxCPU
xxxxx Fix
Xxxxthe
xxslow bits in
xxx xxxxx
for
xxxxcomputers.
xxxxxx xxxx cores happy.xxxx
xxxx xxxxxx your
xxxx code.
xxxxxx xxxx
www.linuxvoice.com 5
ANALYSIS
NEWSANALYSIS
The Linux Voice view on what’s going on in the world of Free Software.
Opinion
On selling Open Source software
Freedom isn’t free – and nor is Free Software, necessarily.
Simon Phipps Being free to charge to deliver software is source software. Even including adverts in
is ex-president of the so fundamental that everyone has the software is considered poor taste in open
Open Source Initiative
freedom to do so – including for zero fees. source, and since any developer can get the
and a board member
of the Open Rights That makes it uneconomic to charge unless same source code and simply remove them
Group and of Open you’re adding a valuable service, as anyone they are uncommon in open platforms.
Source for America. can get the same software without paying This is how we can see that Windows 10,
you. The value of any commodity is decided although apparently “free”, is not free in any
at the margins, and if you’re competing with sense that actually delivers freedom.
something that’s zero cost, the most you According to reports, the new version
can charge is the same – zero. But you can includes adverts in such basic applications
O
ne of the more common questions
on the user support mailing lists and
forums I follow for large open “Windows 10, although apparently “free”, is not free
source projects concerns paying for open
source software. When someone sees CDs
in any sense that actually delivers fredom.”
for sale on eBay, for example, they assume
that must be a scam. That old confusion in charge if you add something of value. as the calculator – and even in Solitaire
the terminology of free software leads them Burning a CD and mailing it to you, for – along with a demand for a subscription
to believe that it’s wrong to charge for example, may be a valuable service if you fee every year to stop them being displayed.
software – this is just another of the have poor connectivity. With no access to the source code, there’s
problems that comes from the ambiguous A few projects do have concerns about no way round this. Seeing adverts like this is
term ‘Free Software’. you selling their software. Mozilla would a pretty good indication that your software
As I’ve previously written here, there are rather you did not attempt to sell Firefox for doesn’t come with software freedom
indeed scams on the internet around open example, and uses its trademark as a tool to included!
source software. But charging for the prevent it. While there are excellent
software itself is not one of them. It’s arguments on both sides, since Firefox truly You chose… poorly
allowed – implicitly in the Free Software is open source developers have taken the So please don’t write to complain when you
Definition and explicitly in the Open Source code, removed Mozilla’s trademark and see open source software for sale. It’s
Definition – and while it is not the objective, released the browser under names like perfectly legitimate to do so, and there’s
the freedom to charge money is an IceWeasel and IceCat so that it can be nothing any open source community can
important consequence of the presence of included in Debian GNU/Linux. That’s not so – or should – do to prevent it, apart from
software freedom. If you are not permitted it can be sold; it’s just to be absolutely sure making the software freely available
to do so, that’s a good diagnostic of its there can be no question about Debian’s themselves to make the practice
absence. As the GNU project says, “we open source credentials. uneconomic. And please do tell any of your
encourage people who redistribute free friends unfortunate enough to be stuck with
software to charge as much as they wish or Filthy lucre a proprietary operating system that’s trying
can. If a licence does not permit users to While it’s definitely a basic part of software to gouge them for pennies for every tiny app
make copies and sell them, it is a non-free freedom, one reason people think it’s not that they have a choice. With proprietary
licence.” allowed is that it’s uncommon in open software and service, the old adage is true
that if you’re using something for free, you
aren’t the customer – you’re the product.
“The confusion in the terminology of Free Software When even your calculator wants to charge
leads people to believe it’s wrong to charge for it .” you money, you know there’s something
wrong. You have a choice – use it.
6 www.linuxvoice.com
ANALYSIS
North Korea • Debian • Fedora 23 • Microsoft • NSA • OwnCloud
CATCHUP Summarised: the biggest news
stories from the last month
Fedora 23 to get Microsoft gives big chunk LibreOffice 5.0 coming up
1 Cinnamon spin 2 of cash to OpenBSD 3 with Wayland support
By default, the Fedora What a time to be alive. LibreOffice 5.0 should be
distribution ships with Gnome 3 as its Microsoft, once generally regarded as available by the time you read this, and
desktop environment, but “spins” are the arch enemy of FOSS, is making will run on the Wayland compositor
available that provide alternatives. They steps to repair its relationship with thanks to new GTK 3 support.
share the same Fedora base packages, the community. In July, the company
but have KDE, Xfce, LXDE and Mate became a gold sponsor of the OpenBSD
on top. One desktop that has been foundation – which means it donated
conspicuous by its absence, however, somewhere between $25,000 to
has been Cinnamon, as pioneered in $50,000. This helps Linux indirectly, as
Linux Mint. Well, Fedora 23, which is virtually every Linux distribution ships
due to arrive around the end of October, with OpenSSH, a tool developed by the
will have its very own Cinnamon spin OpenBSD project. Who knows what
thanks to developer Dan Book. Thanks! else the Redmond behemoth plans…
Debian drops support for NSA releases open source Lenovo starts shipping
4 SPARC machines 5 security toolkit for Linux 6 Linux laptops in India
SPARC isn’t the most popular The USA’s National Security Finding laptops with Linux
CPU architecture out there, but it’s still Agency doesn’t have many fans in the pre-installed isn’t so easy in the west,
crunching numbers in data centres FOSS world, after the uncovering of its but if you happen to live in India (or
around the world. SPARC was originally massive spying and surveillance you’re planning a trip there), you can
developed by Sun, and is now owned by programmes. Still, if you fancy running now pick up a ThinkPad L450 for
Oracle. The Debian project has decided some NSA code on your Linux box, try 48,000 rupees (that’s about £480, or
to remove SPARC support in upcoming SIMP, the System Integrity Management $750). That’s around £100 cheaper
releases, as few developers were platform. This provides a “complete than the Windows model, and the
spending time keeping it up to date. management environment focused on machine has an Intel Core i3 CPU, 4GB
This isn’t the end of open source Unix compliance with SCAP profiles and of RAM and a 500GB hard drive. It’s
on SPARC, however: the NetBSD and industry best practice”. Sounds bundled with Ubuntu. Hopefully the
OpenBSD projects will carry on awesome, right? https://github.com/ machines will be a success and we’ll
supporting it for a while. NationalSecurityAgency/SIMP see them in other markets.
North Korean distro OwnCloud 8.1 released
7 watermarks files 8 with better performance
Red Star Linux, the official OwnCloud is rather good for
distribution of hermit kingdom North hosting your own “cloud” (ie document
Korea, isn’t particularly freedom collaboration and file sharing), but
friendly to its users. Security analyst has been lacking in certain areas. The
Florian Grunow has discovered that new 8.1 release is a step forward:
the operating system watermarks files the documentation has been greatly
such as office documents and images improved and more tightly integrated
with hidden codes, based on the with the interface, making it more
hardware’s serial numbers. In theory, welcoming for new or non-tech-
this should make it easier for Kim savvy users. Performance has been
Jong-Un and his cronies to discover boosted by up to four times with some
the source of any anti-regime content. operations, and the Documents app has
http://tinyurl.com/redstarlol been refined. www.owncloud.org
www.linuxvoice.com 7
DISTROHOPPER
DISTROHOPPER
What’s hot and happening in the world of Linux distros (and BSD!).
OpenSUSE Leap
First milestone arrives.
S
USE has plenty of distros on the go
right now. There’s OpenSUSE, the
community-supported variant that
many of us use at home. Then there’s
Tumbleweed, a rolling-release version of
OpenSUSE that gets the latest packages as
soon as they’re built and tested – rather like
Arch. And then there’s SUSE Linux
Enterprise, a long-term support distro
designed for businesses and a competitor to
Red Hat Enterprise Linux. And now, to top it
all off, we have OpenSUSE Leap 42.1.
This is a distribution based on the SUSE
Linux Enterprises (SLE) sources, so it’s OpenSUSE is going through some major changes right now, but the end result should mean more
similar to CentOS. But with Leap, the SUSE consistency between the different SUSE distros.
team wants to bridge the gap between the
OpenSUSE and SLE projects. Maintaining but with newer packages where it makes like so: “Leap will target people who are
multiple distros takes a lot of time and sense for home desktop users. Whereas the looking for a stable base for workstations
developer effort, so Leap is an attempt to current SLE release is using Linux kernel and servers. and Tumbleweed addresses
have one core distro and then alternative 3.12, Leap uses kernel 4.1, which has much people who are looking for the latest and
sets of packages on top of it. improved hardware support. greatest Free and Open Source software
Leap 42.1 is a development snapshot The Tumbleweed rolling-release distro will and sometimes can live with a little
release; the goal is that future releases of continue as well, and the SUSE team sees instability.” Hop over to https://en.opensuse.
OpenSUSE will be based on the SLE sources, the differences between the different distros org/openSUSE:Leap for more information.
ArchAssault
An Arch Linux variant with maximum security in mind.
O
ver on our Linux Voice forums cracking). For instance, if you’re about to flip
(http://forums.linuxvoice.com), the switch on some internet-facing web,
reader ddickinson recommended email and database servers, it’s a good idea
that we take a look at ArchAssault, an “Arch to run some penetration testing tools
Linux layer for penetration testers”. What against them beforehand. Love Arch? Try securing your installations (and
does “layer” mean in this sense? Well, it’s a ArchAssault includes a range of software then trying to break in to them)!
repository and set of packages that can be in this field, such as the Metasploit
added to an existing Arch Linux installation Framework, which tries to attack a machine possible to normal Arch packages, but will
– but you can also install ArchAssault from using hundreds of different security holes. occasionally offer alternatives with
scratch. And also like Arch, it’s geared There’s also Faraday, a similar tool, along additional security-related features enabled.
towards advanced users. with the Snort intrusion detection system Of all the (many) Arch spinoffs we’ve seen,
Penetration testing is the process of using which tries to identify break ins and this is one of the most impressive, with an
tools to break into another computer, but not attempts to replace critical system files. The active team, good documentation and
maliciously (otherwise it’s plain old ArchAssault team tries to stick as closely as regularly updated packages.
8 www.linuxvoice.com
DISTROHOPPER
News from the *BSD camps
What’s going on in the world of FreeBSD, NetBSD and OpenBSD.
I
n the Linux world, various mechanisms
exist for containing programs and
restricting their access to a limited set of
resources. The idea being, if there’s a
security hole in a piece of software and
crackers exploit it, they won’t be able to get
very far afterwards. AppArmor and SELinux
are the two most notable examples of these
mechanisms.
Theo de Raadt, lead developer of
OpenBSD, has started work on a similar
system called Tame. Designed to restrict
programs into a “reduced feature operating
model”, Tame isn’t a bolt-on tool, but rather a
system call that developers can place
directly into their programs. Early on in your
code, before you do anything of importance,
you call tame() with a series of flags Tame on OpenBSD allows programs to restrict their abilities and minimise damage if they’re exploited.
describing what operating system features
you need. For instance, you can say that these restrictions can never be dropped. If a various OpenBSD tools such as cat and ping.
your program needs to call malloc(), or have program that uses Tame tries to perform a “In the simplest non-network programs,
write access to the filesystem, or access restricted operation or access something it network access is disabled. In simple
network sockets. shouldn’t, the kernel will terminate it with the network programs, file access goes away.
Anything else is blocked by default. A SIGKILL signal. That is the trend.” See http://tinyurl.com/
program can place multiple calls to tame(), Theo de Raadt has demonstrated the pdn9rma for all the details of how this is
with further restrictions each time, but for capabilities of Tame by introducing it into making OpenBSD even more secure.
Alternative OS news
Haiku is a project we’ve been keeping an eye on over the last decade.
Whereas Linux and the BSDs are designed as all-round OSes for use
on servers, desktops and mobile devices, Haiku has a much narrower
focus. It originated as an open source clone of BeOS, a multimedia-
oriented operating system that achieved some minor success in the
late 90s, but was ultimately doomed when few PC vendors would ship
it (preferring to stay on good terms with Microsoft instead).
While Haiku has some Unix-like elements, its very much its own OS
with its own libraries, drivers, toolkit and desktop design. Currently
it’s still in the alpha stages of development – the latest release being
Alpha 4 – but it’s certainly usable enough for testing, with various
apps including a WebKit-based web browser. Its system requirements
are low; you can get it running on an old Pentium III box with 256MB
of RAM, so it’s a good way to revive old hardware.
Alex Dörfler, one of Haiku’s most prolific contributors, has
announced a new launch_daemon to replace the old boot process.
Dörfler describes it as “a similar solution to Apple’s launchd and
Linux’s Systemd”, but whereas Systemd is growing into a fully fledged
base system for Linux, launch_daemon focuses on the boot process.
With launch_daemon, programs can be started automatically
during the boot sequence, and it’s easier for users to disable certain
services. In addition, it allows programs to start based on events
– for instance, when a network interface comes up. See the Haiku
project’s website at www.haiku-os.org to try the latest releases.
Originally inspired by BeOS, Haiku aims to be a fast
and lightweight operating system for desktops.
www.linuxvoice.com 9
GAMING ON LINUX
GAMING ON LINUX
The tastiest brain candy to relax those tired neurons
MORE ENGINES!
ARK: Survival Evolved
A great survival game that provides tonnes of fun, even in early access.
J
ust one glimpse at ARK is enough to tell
that this game will be one of the biggest
titles of this year. With its intriguing world,
stunning visuals and tonnes of dinosaurs, it
seemed to be one of those games where the
screenshots and trailers set the bar too high.
However, it is clear that, even in the early stages
Michel Loubet-Jambert is our Games
Editor. He hasn’t had a decent night’s of this game, ARK has not disappointed.
sleep since Steam came out on Linux. Other than the game’s curious setting and very
welcome lack of zombies, it doesn’t necessarily With higher-end hardware, the game is one of the
T
he Unity game engine is reinvent the survival genre. It follows the usual best-looking of this year.
finally getting a Linux editor, narrative of being put in the shoes of a half-
meaning that Linux users will
naked survivor stranded on an island with no Being in early access isn’t without its
be able to create games natively on
what is quite possibly the most idea about how you came to arrive there. What drawbacks, and in the first few weeks of release,
popular game engine at the moment. ARK does, however, even in its current Alpha ARK had plenty of glitches. However, the game is
The engine has had Linux support for state, is refine the genre and create something being patched-up and developed at an incredible
a long time now and was one for the akin to what many gamers would envision as pace and the issues are disappearing fast. The
earlier mainstream engines to do so,
the “perfect” survival game. Even as features biggest omission at the moment is the game’s
bringing us games like Wasteland 2,
Guns of Icarus, Gone Home and are being added, the game feels huge, with a story, though the curious objects scattered
Kerbal Space Program. massive varied map, lots of dinosaurs to tame around the island create a sense of intrigue
A native Linux editor has been and turn into beasts of burden, tonnes of building which hopefully the story will make good use of.
demanded by developers for a long options and plenty of challenge. Similarly, with
time now, so the news that it has Website http://store.steampowered.com/
local and online options, the player can choose
been worked on behind the scenes app/346110 Price £22.99
since 2011 has been met with a very between more laid back or aggressive games.
positive response. In a blog post, one
of the lead developers stated that a
Linux editor has been one of the most ARK is the first major Linux
requested features, so it seems that title to use the impressive
many developers want to ditch new Unreal Engine.
proprietary operating systems in
favour of Linux for their game
development.
More games!
The editor, which was originally
released for OS X in 2009 and later
Windows, will first be released as an
experimental build and then become
more stable if it proves popular.
Chances are that if you’ve played
games in recent years, you will have
played a Unity-powered one, and the
prospect of more games being
developed atop Linux rather than
other OSs is an exciting one to say
the least, especially with other big
engines like Unreal releasing editors “The game feels huge, with a massive varied map, lots of
for Linux recently.
dinosaurs to tame… and plenty of options.”
10 www.linuxvoice.com
GAMING ON LINUX
The Magic Circle ALSO RELEASED…
Explore and complete an unfinished game in this dark comedy.
A
n unfinished game usually isn’t needing instead to mess with the game’s
a selling point, unless referring code in order to progress.
to one of those “so bad it’s good” There are great vocal performances,
simulator games. However, The Magic which help to confirm that this is in fact
Circle is very different, providing a hilarious a well thought-out game and not just an
story where the player “play tests” a game excuse to publish something broken under
stuck in development hell, attempting the guise of irony. That said, it is difficult to
to fix it and using workarounds to get call the game fun at times, and should be Portal Stories: Mel
through the unplayable mess. viewed instead as a good piece of video This is undoubtedly one of the best
The main comedy is provided through game satire, focussing on dialogue over community-created mods out there and on par
the game’s egomaniacal lead developer gameplay. with the original Portal 2. As per the title, the
and his disgruntled employees, but also game tells the story of Mel, an employee of
Aperture Labs. The puzzles are considerably
through the fact that they have not yet Website http://store.steampowered.com/
harder, while the story adds a lot to the Portal
app/323380 Price £14.99
programmed the hero to have any abilities, universe and is thus highly recommended to
fans of the series.
http://store.steampowered.com/app/317400
A variety of visual styles Coffin Dodgers
convey a disjointed This fun racer ditches the go-karts and the
mess of a game. cute animal drivers in favour of mobility
scooters and pensioners trying to avoid the
grim reaper. Aside from its blunt humour, the
game is a good deal of fun and possibly the
Anna’s Quest closest thing to Mario Kart available on Linux,
with its split-screen local multiplayer and
controller support. The ability to tune-up and
A point-and-click gem inspired by the stories of the Brothers Grimm. customise the mobility scooters is a nice
F
added bonus.
ull of deep, dark woods and http://store.steampowered.com/app/320540
witches who eat children, Anna’s
Quest draws on a storybook
narrative appealing to younger audiences,
while also giving players familiar with
the adventure genre something to smile
about. The genre’s audience is certainly
an ageing one, with many perhaps having
children the same age as when they first The beautiful 2D graphics are reminiscent of
discovered adventure games, and this is the adventure games of the late 1990s.
probably the most sincere attempt made
at welcoming those potential players. innocent chuckles while not doing away Knights of the Old Republic II
This classic critically acclaimed Star Wars
The game doesn’t shy away from the with entertaining characters. game got ported to Linux month, complete
dark themes prevalent in German folk Puzzles are perhaps easier than most, with a few features like controller support,
tales, but its good dose of humour and the but manage to cater to established achievements and support for high resolutions.
heartwarming story of a little girl trying to players while not alienating potential The game takes place some 4,000 years before
save her sick grandpa make the themes newcomers, and the excellent artwork and The Phantom Menace, in a time where the Jedi
were being destroyed by the Sith. If you like
feel far from disturbing. The humour itself animation will please everyone. Star Wars, RPGs or story-rich games, this one
takes a turn away from the dry humour is worth picking up.
and witty protagonists favoured in Website http://store.steampowered.com/ http://store.steampowered.com/app/208580
app/327220 Price £14.99
adventure games, instead delivering more
www.linuxvoice.com 11
MAIL
YOUR LETTERS
Got something to say? An idea for a new magazine feature?
Or a great discovery? Email us: letters@linuxvoice.com
LINUX VOICE STAR LETTER
JOIN US NOW AND SHARE THE SOFTWARE
I just wanted to thank you for
excellent reviews that I find in
your magazine. I’ve just read the
interview with Cory Doctorow
and I found it really inspiring.
Many previous ones, as well as
opinions by Simon Phipps, were
also great.
Reading your magazine
from the very beginning I find
myself more and more enjoying
not the technical tutorials but
the articles that help me to
even more believe in FLOSS,
that show me broad picture of
this software in today’s world
and that encourages me and
motivates me to act in favour of
digital freedoms.
Dawid Węckowski
Andrew says: Wow, thanks David!
If we’re making someone out there
believe in Free Software a little bit
more, we’re doing something right.
Long may it continue! Author, campaigner and speaker Mr Cory Doctorow makes a lot of sense.
FREE AS IN SHOOTING, JUMPING ETC
Dear LV, I am so grateful for your software gaming isn’t great, but
information on privacy. I now use what about pushing DRM-free
TextSecure and RedPhone, and games like those on the Humble
am also setting up using Tor. Store or gog.com?
Loving the whole mag but there is Stephen
always one section I think could
push software more in line with Mike says: The fact that Valve has
the rest of the mag’s values more, chosen Linux rather than Windows
and that’s gaming. Most games for its platform of choice is a massive
reviewed are Steam games, a news. It’s worth celebrating – but then
service which seems just as bad so are FOSS games, which always get
for DRM and privacy. I know free a mention in our FOSSPicks pages. Gondor feels empty without Sean Bean. For Frodo!
12 www.linuxvoice.com
MAIL
LIBREOFFICE: YAY OR NAY?
This is in response to Sarah McKie uses but nine of these functions nor would it be possible for LV
asking for a beginner’s tutorial on so my question is what part of to please everyone it would be
If you create a lot
LibreOffice [in LV016]. Sarah with the functions and procedures will like trying to please Linux users
of documents with
all due respect there are hundreds you use? Which part should be LibreOffice, paragraph on which desktop to use. If you
of functions in LibreOffice, and a beginner’s tutorial? There are styles can save loads of aren’t happy, learn to change it: I
within these functions there are many books on the market for this time – but if you don’t did, my desktop does not exist in
over a thousand procedures and it as well as the ever-so-informative they’re useless. That’s a any distro that is on the market
was proven that the average user websites, so NO this is not needed bit of a quandary. because I took the time to learn
how to change it to suit me. Isn’t
Linux beautiful?
Eugene
Andrew says: I’m not sure it’s a valid
argument to say that something is
complicated, so we shouldn’t go
near it. I also don’t think it’s all that
helpful to say “go and look on some
websites”, because there’s so much
information out there that it can be
overfacing – as Mitch Kapor once
said, getting information out of the
internet is like trying to drink from
a fire hydrant. Part of our job is to
filter the mass of information into
something more digestible.
Where I do agree with you is that
it would be pretty hard to choose
which bits of LibreOffice to put into
a tutorial series. I never use the
presentation tool, for example, but
I know that if I were just 5% more
proficient with spreadsheets, I’d save
hours every month. All we need to do
is find someone to write a tutorial…
then I could spend less time juggling
columns of numbers about and more
time on the fun stuff.
www.linuxvoice.com 13
MAIL
TUX: SHOULD HE STAY OR SHOULD HE GO?
FATTY BUM BUM A NEW HOPE
Tux’s time is clearly not up. Linus Many thanks for offering us the
seems to be doing everything in chance to express our opinions of
the ‘overweight and sitting on his the Linux penguin. So here goes!
bum’ department to emulate him. This icon is just as embarrassing
John R Hudson as a soccer team mascot. It’s
obese, meaningless and stupid-
Andrew says: As I live in a glass looking. How on earth did it
house, it would be remiss of me to come to represent our esteemed
throw stones in the ‘overweight and computer system? I agree that
sitting on his bum front’. But at least some distros use rather far-out
I’ve made an effort to update my look images; PCLinuxOs has its raging
since 1996. As has Linux; the moment bull and Debian is symbolised by
we got Compiz and the spinning cube a big swirl of something. But the
of wonder on the desktop, we stopped elephant in the room is that bird.
being second-class citizens in in Of course there are problems in
desktop glitz, and now Linux can give visualising something as abstract
you the best-looking system out there. as a computer operating system.
That’s why Tux needs to go! And the fact that nobody ‘owns’
Linux is an extra snag. But this is
an opportunity, not an obstacle.
IN THE BRINY There have been competitions
Further to David’s letter in Sept 15 in the past for the best
issue, I too would like Tux to be Linux logo but they never
retired in his present appearance. entered the mainstream. So
While nowadays there’s probably this is where Linux Voice
a greater chance of seeing, say, could come to the rescue.
Ubuntu or Red Hat’s logo on First, you could ask for
something commercial rather submissions for the
than generic Linux, there is a new Linux
need for an all-encompassing logo and
umbrella logo. The current Tux, your LV
where I’ve seen it, looks slightly team could
embarrassing, plus it’s also hard choose the
to reproduce in monotone, since winner.
an outline of the logo doesn’t Second,
stand out as a penguin, but we need
more of a ‘splat’ of ink! I believe a backing to
streamlined son (or daughter) of promote a
Tux logo is required to match our new image
lean and speedy operating system for Linux with a mass
of choice, just like a penguin in publicity campaign. LV could
water. head this with a grant from your Fond of sitting about, growing ever more corpulent, Andrew thinks
Chris Sandles admirable donations from your it’s time to change the Tux logo.
annual profits.
Graham says: Yes! Pengins are Microsoft has its ‘four flags’, But on a serious note, not all football
graceful, streamlined creatures, but Apple has an apple (?), Intel has mascots are useless – look no further
not on land, where their stumpy legs its ‘Inside’ sticker and so on. So, than H’Angus the monkey, mascot of
make them wobble about like Mike please let’s get rid of that member Hartlepool FC. He ran for mayor on
Saunders after two pints of shandy. of the Spheniscidae family. a promise of free bananas for local
Now that Linux is more than “just Maurice George school children, and won. He was
a hobby OS” (as Linux Torvalds set Andrew says: If only Linux had re-elected twice, but the people of
out to produce way back on 1991), some sort of foundation to promote Hartlepool abolished the position of
it makes perfect sense to transfer publicise and maintain brand mayor after they discovered that he
our feathered friend to his natural awareness; maybe it could update wasn’t a real money, but a man called
environment. the logo to something more fitting? Stuart. Mascots matter.
14
MAIL
Email andrew@linuxvoice.com to advertise here
www.linuxvoice.com 15
LUGS ON TOUR
LUGS ON TOUR
PGDay UK – user group meeting
Josette Garcia reports on what’s new in Python or how to enjoy a bunch of friends.
P
GDay UK took place at 30 PostgreSQL fits into the strategy at
Euston Square on 7 July. Goldman Sachs.
The location is perfect as Mike Lujan from Manchester
it’s easy to get to via underground, University talked to us about the
buses or trains. AXLE project… but what is the AXLE
After the usual registration, project? AXLE, advanced analytics
refreshments, welcome and for extremely large European
introductions came the long- databases, brings together a
awaited talk “Working in Open diverse group of researchers
Source” by Liam Maxwell, CTO covering hardware, database kernel
for Her Majesty’s Government. and visualisation all focused on
This talk was followed by Magnus solving the needs of extremely large
Hagander, president of PostgreSQL data analysis. The project partners
Europe, who alerted us to the new are 2ndQuadrant, Barcelona
key features of the next release Supercomputing Centre, Portavita,
which is now available in alpha and the University of Ljubljana and
soon to be available in beta before the University of Manchester. The
the final version is released towards project, like PostgreSQL, is of course
the end of the year. Some new key open source.
features include: With “PostgreSQL Back Up and
“Upsert” (INSERT ... ON Recovery: Best practices and tools”
CONFLICT): 9.5 brings support by Devrim Gunduz, we discovered
for “UPSERT” operations. solutions for common issues along
BRIN (Block Range Indexes): with pros and cons for each of
BRIN stands for Block Range them. There are of course many
INdexes, and store metadata on a backup solutions – both open and
range of pages. At the moment closed source.
this means the minimum and Gianni Ciolli gave us some
maximum values per block. “PostgreSQL Administration
pg_rewind: pg_rewind makes it Recipes”. These recipes should Magnus Hagander,
possible to efficiently bring an old enhance the user’s experience of president of PostgreSQL In his “Fun Things to Do with
primary in sync with a new PostgreSQL by making it speedier Europe, unveiling some Logical Decoding” Mike Fowler
primary without having to and more effective. of the new features looked at trigger-less auditing,
perform a full base backup. Marco Slot discussed the coming soon. partial replication and full
Import Foreign Schema: with internals and performance of statement replication. The next talk
PostgreSQL 9.5, you can import pg_shard and some of its latest had a great title – “The Elephant
tables en masse. You can also features. pg_shard is a free, open and the Snake” – could it be a
filter out any tables you don’t source extension for scaling out story by Rudyard Kipling or one of
wish or limit it to just a specific PostgreSQL across a cluster of Aesop’s fables? No, but Tony Locke
set of tables. commodity servers. told us how to connect from Python
Inheritance with foreign table: to PostgreSQL, including tips and
Foreign tables can now either tricks.
inherit local tables, or be inherited “The audience was very diverse, The day ended with a plea from
Simon Riggs for users to upgrade
coming from universities,
from.
David Kennaway showed us the and test the new 9.5 release to
challenges presented in a financial companies and governments.” ensure the version is bug-free,
services environment and how helping the PostgreSQL community
16 www.linuxvoice.com
LUGS ON TOUR
currently working on the 9.6 release generate_series(numeric)
and beyond. Administration and DBA Simon Riggs, founder
With around 100 people Row-level security of 2ndQuadrant.
attending the conference, PGDay REINDEX SCHEMA
UK 2015 was one of the most Event triggers – table_rewrite
dynamic PosgreSQL meetings that Parallel VACUUM with vacuumdb
I have ever attended. The audience ALTER SYSTEM RESET
was very diverse, coming from Infrastructure and replication
universities, big corporations, Abbreviated keys
small companies and government New WAL format
institutions. Actions at the end of recovery
Thanks to the sponsors Improvements of Windows build
2ndQuadrant, EDB, Brandwatch and Logging of replication commands
CitusData, we were provided with cluster_name
good food and a drink reception at Exported snapshots with
the end of the day. pg_dump
Interested in PostgreSQL? Why To-be-committed features?
not come to the PostgreSQL UPSERT
conference Europe 2015, which WAL compression
will take place in Vienna on 27–30 ALTER TABLE log_min_vacuum_
October? Hope to see you there! duraQon
File-level incremental backup
Four categories of new features: New types for abbreviated keys
SQL-related features CRC improvements
BRIN indexes Redesign of checkpoint_
UPDATE tab SET segments
SKIP LOCKED for row-level locks Pgaudit
ALTER TABLE SET LOGGED / IMPORT FOREIGN SCHEMA
UNLOGGED width_bucket()
www.linuxvoice.com 17
SHOW REPORT OSCON
We counted far fewer Linux desktops than in
previous years, when even the Macs would be
running Linux.
Allison Randal was one of the
few keynote speakers whose talk
looked at the future of Free
Software and open source.
Graham Morrison visits Portland in the United States for
2015
the Oregon Brewers Festival O’Reilly’s Open Source Conference
T
here’s change in the air at OSCON. Having tutorial days of Monday and Tuesday, to the
found its spiritual home among the micro- conference sessions proper, held over the Wednesday,
brewers and bridge lovers of Portland, Oregon, Thursday and Friday. But most of all it was felt in the
and after 12 years of (almost sequential) events here, absence of Larry Wall, whose ‘State of the Onion’ talk
OSCON is moving. First to Amsterdam at the end of was a long tradition at a conference that began as The
October in a new attempt to bring what’s been Perl Conference. When we enquired further, we were
traditionally a US-centric conference to Europe. And told Larry’s talk had been declined by the OSCON
more dramatically, in May next year, to Austin, Texas. program committee. There was certainly a more
This wind of change could be felt throughout the week, corporate feeling at the event than usual, especially in
from the Kids Day held on the Sunday, through the two the exposition hall, where the main areas were
18 www.linuxvoice.com
OSCON SHOW REPORT
The loneliness of the costume
mascot is understood only by
Leonard Cohen and lighthouse
keepers.
dominated by PayPal, GitHub, Microsoft and Google.
The ‘Non-profit Pavilion,’ including the FSF, the EFF,
Software Conservancy, the Perl Foundation and OSI,
was separated from the main conference area by a
black boundary, which felt a little uncharitable.
Session management
The sessions themselves, however, maintained the
exceptionally eclectic quality we’ve come to expect
from OSCON, with many being videoed for later Portland has more
viewing. The Go, Python and even PHP languages breweries than any
(PHP’s creator, Rasmus Lerdorf, was in attendance) study where GPL enforcement and compliance other city on the
were popular, as were many of the testaments given created a better community at Kallithea. planet.
on open source strategy within big business. Outside of the tracks, there were two big
Despite the corporate gloss, the majority of announcements. First was the creation of the Cloud
sessions were still suited to open source hackers of all Native Computing Foundation (CNCF) by the Linux
abilities. One session delved into embedded Foundation, which aims to advance the state-of-the-
processors; another art for building open
looked at what
happens after you’ve
“When we enquired further, we were source cloud native
applications and
typed “google.com” told Larry’s talk had been declined services. Second was
into your browser,
while Matthew
by the OSCON program committee.” the 1.0 release of
Google’s Kubernetes
Garrett, currently at orchestration
CoreOS, ran an excellent session on building a platform. We’ve seen plenty of announcements like
trustworthy computer. On the community tracks, these over the years, but we have to admit that the
Simon Phipps talked about using resources at the OSI growing culture behind containers seems like a
to help open source, while Bradley Kuhn, president of genuine revolution, from package management on
Software Freedom Conservancy, gave a great case phones to massively scalable data networks.
www.linuxvoice.com 19
LINUX IN THE UK
) so ftw are is a w o rldwide movement,
Free (as in speech d ing p laye r in its development.
a le a
but the UK has been d B e n E ve rard investigate.
Mike Saunde rs a n
nd the
L
bscribers all arou
inux Voice has su pe , As ia, Africa
icas, Euro
world, in the Amer ar e sc at te re d
r write rs
and Australia. Ou re te am –
too. But the co
across the planet British born
, An dr ew , Be n and Mike – are
Graham ’s involvement
ed , an d ha ve followed the UK
an d br classic 8-bit
industry since the
f
“It’s easy to think o g
in the computing rly ’80s. The UK
devices of the ea
plug-into-your-TV s of home
ein
the IT industry as b A,
er in many aspect
has been a pione rgotten.
legacy won’t fo be
computing, and its
S
dominated by the U
th e IT ind ustry as
think of
Today, it’s easy to A, bu t th er e’s plenty
by the US
f
but there’s plenty o
being dominated Op en source
ening elsewhere.
of innovation happ free
ing
as it’s
innovation happen
ibl e,
make this poss
software helps to so yo u ca n be at the
and share,
to obtain, modify re m ote
elsewhere.”
in a
odem connection
end of a dial-up m ut e to yo ur
e and still contrib
Cambodian villag m e Gi t pull requests will
. (O K, so
favourite project idea…)
at, but you get the
take a while like th ime Minister
its part as well. Pr
Britain is playing th e country as
trying to promote
David Cameron is lle nc e” , and cities
hu b of te chnology exce
a “g lob al ions for game
erging as top locat
like Bristol are em ich power
ios. ARM chips, wh
development stud to p PCs and
g outside of desk
virtually everythin itis h cr ea tion and
y em be dd ed de vices, are a Br
tin
e world.
are dominating th mpanies
en th er e ar e British Linux co
And th e software. So
and promote fre
helping to develop ra te everything
ght we’d celeb
this issue, we thou asant
m our green and ple
that’s jolly good fro co puting
m
e UK shaped the
isle, seeing how th an d looking
its earliest day,
industry right from co m pa nies have
-based Linux
ahead to what UK p of tea, turn
ture. So grab a cu
planned for the fu
s, and read on…
down The Archer
20 www.linuxvoice.com
LINUX IN THE UK
From tiny acorns
British scientists were inventing computers before they even existed.
P
inpointing the invention of the
“computer” is tricky. Designs for Charles Babbage spent years
grafting on hypothetical computer
calculating machines date back
designs so that we can watch cat
2000 years, such as the Greek Antikythera
videos 24x7 on YouTube today.
mechanism which was used to predict
astronomical events. In the 17th century,
French mathematician Blaise Pascal created
a mechanical adding machine, while his
German contemporary Gottfried Wilhelm
Leibniz produced a more complicated
calculator that was plagued with problems
due to the intricacy of its design.
The first machine that could be described
as a general-purpose computer, however,
was the Analytical Engine, described by
English mathematician Charles Babbage
in 1837. This went far beyond performing
simple mathematical operations: it had its
own memory, it could perform branches
and loops, and could be fed “programs” on
punch cards. At least, that was the idea.
Babbage worked extensively on the design
of the Analytical Engine, but it was never
completed in his lifetime.
Many computing milestones were
reached in the 1940s with the German Z3
and US ENIAC, but the first ever electronic
stored-programmable computer, the
Manchester Small-Scale Experimental
Machine (nicknamed “Baby”), was brought
into operation in England in 1948. This
machine was designed for testing purposes, to payroll and inventory management, and – and the companies behind them would go
and only three programs were ever written was followed up by more powerful models on to snap up chunks of the home computer
for it, but it led to the development of the with multi-tasking operating systems. market in the 1980s with the ZX Spectrum,
Manchester Mark 1, which in turn developed Acorn Electron and BBC computers.
into the Ferranti Mark 1, the first general- PETs at Home The Spectrum ended up dominating the
purpose electronic computer that could be While the USA produced late-70s UK market, although in 1986 Sinclair sold it
bought commercially. breakthroughs in home computing with the to Amstrad, another British company.
In 1957, the British LEO II became the Commodore PET and Apple II, Britain wasn’t Many of Acorn’s inventions – such as
first computer to be sold and used for sitting still and companies started producing the ARM chip – went on to influence the
commercial business applications, sporting very cheap (in comparison) kit models for future of computing, as we’ll see in the
a blazingly fast 500kHz operation speed and assembling at home and plugging in to a next few pages. The 1990s were largely
almost 9KB of RAM to play with. The LEO II regular TV. The Sinclair ZX80 and Acorn the domain of American companies such
was used in various business tasks relating Atom are two of the most notable of these as Commodore, Atari, Dell (and
countless other white-
Spinning a web box PC providers),
but today the
Before this turns into a massive celebratory fest of in 1989 by Tim Berners-Lee, a Brit working at CERN British hardware
Union Flags and 4pm tea breaks, however, we’d like in Switzerland. While his work had a huge impact
to give some kudos to our American friends across on the way we access and share information, we
industry is
the pond for creating the internet. Their work should also give credit to the many technologies going through
on ARPANET and similar technologies helped to he built upon to create it, such as hypertext and something of a
develop the sprawling network that we have today, SGML. A relatively obscure fact is that Berners-Lee resurgence thanks
so we’ll raise a glass of Miller Lite to them. wrote the first web browser on a NeXT computer – to a little credit-card
Arguably the killer feature of the internet, one of the machines developed by Steve Jobs and
though, is the World Wide Web. This was invented his team after he left Apple in 1985.
shaped computer you
may have heard of…
www.linuxvoice.com 21
LINUX IN THE UK
Hardware
Chips and devices designed in Britain are taking over the world.
H
ere’s a mind-boggling statistic: for ARM’s enormous success is more a
every human being on this planet, product of chance rather than intention,
there are seven ARM chips. That’s however. Back in the 1980s, the UK
over 50 billion in total. Most people tend to company Acorn Computers started work on
think of Intel or AMD when it comes to a next-generation chip to replace the 8-bit
CPUs, and it’s true that those companies 6502 it had been using in the Acorn Electron
totally rule the roost in the desktop and and BBC range of machines. Acorn wanted
server markets. But in the rapidly growing to create a computer with a graphical user
mobile space, where everyone is buying interface, to compete with other home
smartphones, tablets and low-end netbooks computers from Apple, Commodore and
(and upgrading them every six months), Atari, and tried various in-production CPUs
ARM chips are dominating. such as the Motorola 68000 (which was
But why is this? Aren’t x86 chips from Intel used in the Amiga, Atari ST and Sega Mega
and AMD much better when it comes to Drive/Genesis).
performance? Well, yes, but that’s only part
of the story. ARM processors are simpler, Floats like a butterfly…
easier to make, cheaper and have very low Ultimately, Acorn wasn’t happy with any of
power requirements. They are RISC designs the available chips, so one of its employees,
(Reduced Instruction Set Computing), which Sophie Wilson, designed a new one from
means that they have a relatively small scratch: the Acorn RISC Machine, aka ARM.
set of instructions compared to x86 CPUs. Little did she know that billions of them Sophie Wilson designed the original ARM chip.
(Modern x86 chips are actually more RISC would be made. ARM became the chip that Since then, 50 billion have been made.
internally, but still have to deal with the large powered the Acorn Archimedes range of
range of instructions from the previous CISC computers, which were especially popular in companies started to show interest in the
designs due to backwards compatibility.) UK schools, and in the early 90s other chip. Apple, for instance, worked on newer
ARM designs for use in its ill-fated Newton
PDA, and Acorn spun off its ARM team into
a separate company: Advanced RISC
Machines Ltd.
Today, this company is part of ARM
Holdings plc, a Cambridge-based firm that
designs ARM chips and licenses them
out to companies around the world.
(It doesn’t actually manufacture
any itself.) However, its list
of customers is impressive:
IBM, Microsoft, Samsung,
Broadcom, AMD, Intel and
others have all bought ARM
designs and manufactured
chips based on them. ARM
chips power over 95% of
smartphones – although
Intel is eager to get more
established in this market
as well. Sophie Wilson
now works for Broadcom,
which is well known for its
networking and Wi-Fi chips.
Pi in the sky
The Raspberry Pi needs no introduction
here, but it’s worth investigating its origins
and the effect that it has had on British
The Raspberry Pi’s success has bolstered new companies making add-on hardware and robots. industry. Eben Upton, founder of the
22 www.linuxvoice.com
LINUX IN THE UK
Raspberry Pi Foundation, was inspired to
create the device by the success of the BBC
Micro in the 1980s. That computer wasn’t
just designed for playing a few games at
home – it was part of the Computer Literacy
Project from the UK’s national broadcaster.
In other words, it was designed to get a
whole generation interested in computing
and programming.
Upton and his team designed the
Raspberry Pi to be a functional equivalent
in the modern age. Anyone can plug it
into a TV and start programming straight
away with Scratch. Today, over 5 million
Raspberry Pis have been solid, making it one
of the most successful computers in British
history, right up there with the ZX Spectrum
range of machines.
Made in Britain
But the Pi has done a lot more for the UK. In
a world where virtually every low-end
electronic device is being produced in giant With RISC OS on a Raspberry Pi, you can run a UK-made operating system on a UK-made computer
city-sized factories in China, the Raspberry with a UK-designed CPU – and it’ll be super fast and energy efficient.
Pi is something of an anomaly, as it’s
manufactured in Wales. In the early days of computers, can now run on the Raspberry Pi most of us simply download the latest distro
the Pi, many observers were sceptical that and is being open sourced. So it’s possible releases when we want them, if you want to
the machine could retain a low price get a friend or colleague into
while being manufactured in the Linux, it helps if you can give them
British Isles, but the Pi team has “It’s possible to run a computer made an attractive, pre-pressed DVD.
achieved that.
And it goes even further: the
in the UK with a chip designed in the And then there are UK-based
hardware vendors selling Linux-
success of the Pi has spurred on UK, with an OS designed in the UK.” powered machines. Entroware
whole other industries around (www.entroware.com) is one of
it. Many small companies have our favourites, offering a variety
cropped up offering add-on hardware for to run a computer made in the UK with a of desktops and laptops with Ubuntu pre-
the Pi, such as cases, GPIO interfaces and chip designed in the UK, with an operating installed. The computers themselves are
displays. The Pi’s success has generated system written in the UK on top. Not bad. from ODMs (original design manufacturers)
more widespread interest in Linux, which in Something similar could be said in China, but Entroware does the testing,
turn made it easier for four crazy people to about GNU/Linux. Sure, it’s a worldwide sales and support in the UK.
launch a new Linux magazine… collaborative effort and only a small We’ve reviewed two Entroware laptops
Of course, as well as being produced in portion of the code comes from UK-based in Linux Voice before:
the UK, the Raspberry Pi also houses an developers, but Canonical is a British the Proteus in issue
ARM chip – a British invention as mentioned company and doing a lot of work on the OS. 11, and the Apollo in
before. RISC OS, Acorn’s operating system Canonical has developers in many countries, issue 15. We found the
that ran on its Archimedes range of and a good chunk of them are based in the Proteus to be a well-built
United Kingdom. (albeit chunky) machine
Silicon Roundabout with a great keyboard,
Linux shops while the Apollo
Forget Silicon Valley – the place to be now is The UK also has a handful of small ultrabook was sturdy
East London Tech City, more commonly known businesses dedicated to selling Linux-related and attractive, but had
as Silicon Roundabout. Formerly a rather
software and hardware. The Linux CD Shop fan and trackpad issues.
run-down area of the UK’s capital city, Silicon
Roundabout is now home to hundreds of tech (www.thelinuxshop.co.uk), for instance, Still, the Entroware team
companies, from big names to tiny startups. sells DVDs with all major distros along with has been responsive and
Some of the more notable players include some merchandise such as keyrings and very open to feedback in
Amazon, Google Cisco and Facebook, while case badges. The company also offers our experience, so if you’re
smaller startups include TransferWise (a peer-
desktop PCs with Linux pre-installed. For in the UK and shopping
to-peer money transfer service) and PaveGen
(which makes paving slabs that convert users new to Linux, there’s a Starter Pack around for a new Linux
footsteps into electricity). – a bundle of the latest releases from machine, it’s worth giving
Ubuntu, Mint, Fedora and OpenSUSE. While them a look.
www.linuxvoice.com 23
LINUX IN THE UK
Software
The United Kingdom of code.
S
oftware development is a truly global
process, and almost all software is
developed by (or brings together work
that is developed by) people across the
globe. Because of its collaborative nature,
open source software is even more global
than usual.
Almost all open source projects include
some contributions from Britons, but then,
by the same measure, almost all FOSS
contains contributions from Americans,
Germans, and just about every other
nationality. In order to get a better picture
of what’s going on, let’s take a look at the
most prestigious open source project, the
Linux Kernel. Since the shift to Git in 2005
made the gathering of statistics more
straightforward, Britain has been the fourth
top contributor to the Linux Kernel in terms
of total number of patches submitted
(after the USA, Germany and China in that
order). However, development of the kernel
is so distributed that the USA – the top
contributing country – contributed just 15% Ubuntu’s Unity desktop is hated by some and loved by others, but it has brought some innovation
of the patches. to the desktop environment metaphor.
Many hands make light work share any software is fantastic news for than the next most popular distro (Fedora),
If the software itself is created around the user freedom, but makes it really hard to but not all distros identify themselves.
world, we can at least look for British work out how many people are using what Arch, for example, is one of many distros
organisations that bring it together. Linux versions of which software. that just identifies itself to web servers as
usage statistics are notoriously unreliable. Among visitors to LinuxVoice.com, generic Linux. These unidentifiable Linuxes
The fact that anyone can download and Britain’s Ubuntu is 10 times more popular outnumber Ubuntu, so it could mean that
there’s another distro that’s more popular,
or just a lot of less popular distros. What’s
The government’s failings Where Whitehall is holding us back more, many Ubuntu derivatives
will also identify themselves as
Not everything is looking up for the British tech “This government supports encryption, which vanilla ubuntu.
scene. David Cameron, the Prime minister, has helps keep people’s personal data and intellectual The numbers may be fuzzy,
announced plans for a sweeping surveillance law property safe from theft by cyber means. It is
but it’s clear that if Ubuntu
dubbed the Snooper’s Charter. In January 2015, fundamental to our everyday use of the internet.
David Cameron came out as appearing to want to Without the development of strong encryption isn’t the most popular desktop
ban all encryption with the statement: allowing the secure transfer of banking details Linux, it’s certainly very close.
“In extremis, it has been possible to read there would be no online commerce.” This doesn’t just go for people
someone’s letter, to listen to someone’s call, to At first this seems like the government is flip- installing their own distros, it’s
mobile communications… The question remains: flopping on the issue, but then Baroness Shields
also by far the most popular
are we going to allow a means of communications went on to say:
where it simply is not possible to do that? My “However, the prime minister has been clear distro for computer makers to
answer to that question is: no, we must not” that there cannot be areas of the internet which preinstall on machines, and you
That appears quite straightforward. He’s are off limits to the rule of law — and this has can buy machines from HP and
proposing banning any form of data transfer that to include, where necessary and proportionate, Dell as well as specialist Linux
the intelligence services can’t eavesdrop on, and individuals’ private communications”
companies.
that includes anything that’s encrypted. Naturally, This appears to be a complete contradiction.
this caused some consternation in the tech world The government isn’t seeking to ban encryption, When Ubuntu first came out
as this would mean fundamentally weakening it’s just seeking to ensure there’s no way for people in 2004, the tagline ‘Linux For
things like online banking. to communicate that it can’t spy on. This appears Human Beings’ was actually quite
After six months of standing by this statement, contradictory. Until the Government reveals the revolutionary. Canonical and the
Baroness Shields, the minister for Internet Safety exact wording of the proposed law, it’s impossible
Ubuntu developers hadn’t focused
and Security said in a letter to Business Insider: to know what’s being banned and what isn’t.
on technical supremacy, but on
24 www.linuxvoice.com
LINUX IN THE UK
making a distribution of Linux that ordinary
people could use and enjoy. This in turn
forced other distros to focus on their ease
of use, and the general standard of Linux
distros improved significantly following
Ubuntu’s entry into the market.
Canonical isn’t just a company making
a distro though: it’s pushing the frontiers of
Linux. This includes everything from a new
paradigm for mobile phone interaction to
a new approach to package management,
to desktop interfaces and a controversial
display server. It may not always be the
most popular Linux company, but it has
certainly been one of the most innovative
over the last 10 or so years.
Beyond operating systems
British technology has always been at its
best when it’s efficient and innovative rather
than brash and overly complex. The
Raspberry Pi is the perfect hardware
example of this., But what doesn’t get
noticed that often is the work that the
Raspberry Pi Foundation puts into improving
the performance of existing software.
According to Eben Upton, it’s put in: “Two
man years on Squeak and Scratch. Two
man years on Pixman and libav. Four Man
years on the web browser.” That’s a
significant contribution to the free software
world from the small Cambridge company.
It’s also a significant contributor to the LibreOffice for Android is currently only capable of viewing files, but editing is coming soon thanks
Wayland display server, though that is yet to to the superb work being done by Collabora.
become release-ready.
LibreOffice is another global software impact, particularly in newer aspects of that’s pushing the project into new areas.
engineering effort. It started life as StarOffice the code. Collabora Productivity (based in LibreOffice for Android and LibreOffice Online
in Sun Microsystems in the heart of the Cambridge, UK) employs some of the most (a web-based version of the office suite) are
USA’s Silicon Valley, but is both developed by engineers from
now under the leadership of
The Document Foundation,
“Cambridge’s Collabora Productivity this British company.
Open source software
which is headquartered in accounted for 28% of LibreOffice development is global in its
Germany. Along the way, the
code has been written, re-
development in the first half of 2015.” nature, but British companies,
organisations and people are at
written, modified and adapted the very front pushing forwards.
by programmers in almost every country active developers. The company accounted Whatever the future holds for the open
around the world. However, despite its for 28% of LibreOffice development in the source world, we can be sure that some of it
global nature, it’s easy to see Britain’s first half of 2015, and it’s also Collabora will hail from this fair isle.
The government’s successes Where Whitehall is pushing us forward
The UK Government has a chequered relationship with the technology industry. The government’s push for open standards has perhaps been stronger than
Some proposed legislation is, justifiably, vilified by the tech world, but it’s not its push for open source software. This is ostensibly in an effort to avoid vendor
just making enemies. In some areas, Her Majesty’s Government is doing an lock-in, to ensure that it can always switch to more cost effective software,
excellent job at using and promoting open source software. rather than because of any philosophical commitment to open standards.
The Government’s GitHub page (https://github.com/alphagov) lists 396 The most famous decision in this area was the move to ensure all office
project that are all being developed in the open. Some of them are small documents were stored in Open Document Format (ODF) files. This is the
projects only really relevant to a single purpose, but it also includes large standard format of LibreOffice, OpenOffice and several other open source office
projects such as the government’s e-petitions platform (https://github.com/ suites. However, it’s not only supported by open source tools. Since 2013,
alphagov/e-petitions). Most of the government’s software is provided under a Microsoft Office supports the standard, and the government isn’t yet showing
very liberal BSD-like licence. any sign of switching away from this proprietary office suite.
www.linuxvoice.com 25
LINUX IN THE UK
Into the future
What next for this scepter’d isle?
B
ritish technology hasn’t always done
well. After starting the computing
revolution, things went quiet for a
while. Our nation’s technology rose again in
the 1980s, but was eventually crushed
under the weight of the Microsoft and Intel
pairing in the 1990s. Now, though, we think
we’re rising with a new British technological
renaissance with open source technology at
its heart.
The standard bearer for this new
movement is the Raspberry Pi and its push
to improve the standard of computing
literacy across the country. It’s this new
generation, who are just now learning about
computing using Raspberry Pis and Linux
in classrooms up and down the UK, that will
drive the next generation of British tech.
The enthusiasm for the Raspberry As well as schools, there are a growing number of organisations to help kids learn computing skills,
Pi showed that there was a significant such as Young Rewired State and Code Club.
latent demand in the UK for homegrown
technology. Soon after the Pi Foundation in 2014 a new curriculum came into force 11, how to use at least two programming
released the first board, a small industry that emphasised creating and moulding languages to solve computational problems;
sprung up making and selling add-ons. In technology with a strong emphasis on to design, use and evaluate computational
the intervening three years, this industry programming. abstractions that model the state and
has continued to grow and expand, and Michael Gove (the education minister behaviour of real-world problems and
shows no sign of stopping. This could be at the time) said at the launch: “ICT used physical systems; and how instructions
the foundation of a resurgence in UK tech to focus purely on computer literacy – are stored and executed within a computer
manufacturing that died out significantly at teaching pupils, over and over again, how to system. “
the end of the last century. It’s the children of today that will
be the programmers of tomorrow.
Planting seeds “The best place to start is where the By making sure that every child is
Of course, if there’s going to be a
resurgence of UK Tech in either
engineers of tomorrow are currently exposed to coding, hopefully, the
new education system is ensuring
hardware or software, the best learning their skills: schools.” everyone who has a talent for
place to start is where the programming learns how to utilise
engineers of tomorrow are currently learning word process, how to work a spreadsheet, that talent. If this goes to plan, the Britain of
their skills: schools. This is a place where how to use programs already creaking the future will have the skills to continue to
Britain has turned itself around in the past into obsolescence; about as much use as push technology forward.
two years with the release of a new teaching children to send a telex or travel in
computing curriculum. The old curriculum a zeppelin.” Enter Auntie
based on using IT has been thrown out, and “Now, our new curriculum teaches Perhaps, though, the best sign
children computer science, information that Britain’s tech future
technology, and digital literacy: teaching looks bright is the return of
them how to code, and how to create their the BBC to the hardware
own programs; not just how to work a scene. Although this
computer; but how a computer works, and institution is
how to make it work for you.” best-known for its
The most significant part of the new TV and radio
curriculum is focussed on teaching children stations, in the
to program. Michael Gove went on to explain 80s the BBC
this in a little more detail: released a
“From 5 [years old], children will learn series of
The BBC is hoping to repeat the coding success to code and program, with algorithms, computers
of the 1980s with its Micro Bit board. sequencing, selection and repetition; from that drove the tech
26 www.linuxvoice.com
LINUX IN THE UK
scene of the time. In
the intervening
decades, it
remained quiet
on the hardware
front, until the
release of the
Micro Bit.
The Micro Bit
is a microcontroller
designed specifically
for teaching children. A
microcontroller is a stripped-down
processing unit with a little memory and
a little storage. It doesn’t have enough
power to run an operating system. Instead,
programs are written on other computers
and uploaded onto the device, which can
just store and execute a single program at
a time.
The Micro Bit can be programmed via
a Microsoft-developed web app known as ChillHub’s smart refrigerator runs Ubuntu: the future of technology or pointless frippery?
Touch Develop, which enables programs
can be uploaded through a USB or processors are very different from the for sale both in the UK and internationally.
Bluetooth. The web-based software should Cortex-A series chips that commonly power This means that it will rival the Arduino
work on Linux, though as we go to press, mobile phones). to be the most popular microcontroller
we don’t have the hardware to test this with. At 5 x 4 cm, the Micro Bit is about half board from release, and with this number
This environment is based on ARM’s Mbed the size of a credit card. Unlike an early of boards in the wild. If the response to the
platform but it’s written specifically for the prototype, the final version is rectangular, not Raspberry Pi is anything to go by, we can
Micro Bit by Microsoft. We haven’t been able bug-shaped. It has five easily accessible pins expect to see a strong level of community
to confirm whether the system will work (three input/output pins and power outputs) support, and a range of expansions soon
with other mbed systems. that can be accessed with crocodile clips, after launch.
The BBC has made some promises banana plugs and conductive thread. There
about opening up the hardware, but when are also an additional 17 GPIOs (including The future’s bright
we pushed for details, its press contact I2C and SPI buses) accessible via the edge The UK’s relationship with technology has
simply replied ‘details will follow in due varied over the past 200 years. At its
course’.
The finalised design of the board
“The UK is surging forward best, the UK has lead the world. At its
worst, the UK has been little more
is well suited to an educational with technological development than a consumer of hardware and
microcontroller. It includes a motion
sensor and a magnetometer to detect
based on open source software.” software that’s both designed and
made abroad. When it’s at its best, our
the environment around it, two push small island becomes a bountiful
buttons for input and an array of LEDs connector, but this will require a special clip source of technology that the whole world
for output. All this will be powered by an to access. The board will be given free to 1 benefits from. That benefit can come in the
ARM Cortex-M0 processor (the Cortex-M million UK schoolchildren, and will also be form of theoretical advances, nicely
packaged software or low-cost boards that
open up the technological world to a new
Internet of Things It’s everywhere! generation.
If there’s one phrase that’s bound to cause an this is just the beginning and soon everything will
At the moment, the UK is surging forward
argument among a group of engineers it’s ‘The link together to form the aforementioned internet with technological
Internet of Things’. It’s the buzzphrase du jour, but of things. Other people claim that there’s little development based
some people actually think it will amount to more to be gained from your desk lamp hosting a web on open source
than a lot of hot air from advertisers. The basic page so the fad is sure to die out (anyone who’s software. There’s
idea of the internet of things is that as internet interested in making a web-based light a reality
connections become ubiquitous, and processors using a Linux stack should note that LAMPlamp.
a huge wave
become small, cheap and low-power enough, we’ll com is available for sale). of fantastic
start connecting everything to the internet. One person who believes in this technology is creativity just
We’re already seeing this to some extent George Osborne, the Chancellor of the Exchequer. around the
with IP-enabled webcams and even a fridge In the March 2015 budget he announced a £40m corner, and
that runs Ubuntu (https://firstbuild.co m/smart- fund to help startups create new devices and
refrigerator), but proponents of the idea tell us that applications for the Internet of Things.
we can’t wait
to be part of it.
www.linuxvoice.com 27
Linux Voice wants your ideas for tutorials, guides, how-tos and insights from
the hacker world. If you’ve found something you want to tell the world about,
let us know
What material is Linux Voice interested in?
Most of the time we’re more interested in what you can do with software X,
rather than singing the praises of software X itself. Clever software is good
but useful software is better. Proprietary software that works on Linux is
acceptable, but what we’re most interested in is Free Software.
What don’t you want?
We sometime get submissions that go like “I’ve been using Linux for X years;
can I write for you?”. This isn’t very helpful, to us, because what we want to
see is that you:
Have an idea
Can explain it clearly
If you can point us to examples of something you’ve written, please do
– we’re not looking for Shakespeare; we value clear communication and
enthusiasm above all else.
What do you want?
Tutorials. We want tutorials, of around 3,300 words in length usually. We pay
money! All tutorials should have a clearly stated aim, so readers know at
first glance why they should follow it. “Get started with XX software” doesn’t
tell you anything; “Build a weather tracker with Python” is much more active
and informative.
These are common reasons why we reject ideas:
Something which has been covered repeatedly on Linux Voice
and/or elsewhere
Material not obviously related to Free Software
Incoherent writing
Email ben@linuxvoice.com
to write for Linux Voice
PACKAGING FOR ALL DISTROS
SUSE’S
OPEN BUILD SERVICE
Want to build packages for a wide range of distros with
just a few clicks? Henne Vogelsang and Markus Feilner
of SUSE explain their distro’s Open Build Service.
W
e at Linux Voice dread having to administer But enough about Microsoft. The point we want to
Windows machines. Fortunately, we don’t make is: software installation on Linux is something
have to do it very often, and we get pretty we can all be proud about. But! It’s by no means
much all of our work done inside our comfy and perfect. Due to all of the niggling differences between
familiar Linux distributions. Every now and then, distros, there’s no guarantee that a package made for
however, some friend or relative will get on the phone distro A will work on distro B. Sometimes there will
and ask us to fix something with their Windows box. be no compatibility issues – but in other cases little
With heavy hearts, we glitches can creep
trudge over to their
places to poke around “Software installation on Linux in, which are often
hard to spot.
in registries, System32, is something we can all be proud Various solutions
and other horrors.
But the worst about, but it’s not perfect.” to this problem
have been proposed
part is dealing with over the years,
software. Compared with Linux, software installation such as Autopackage, but arguably the best is SUSE’s
in Windows is a nightmare, as you probably know. Open Build Service. This takes a lot of the effort out
Instead of using a consistent, secure and well- of packaging software for different distros, so we
checked repository of software, as we have in Debian, thought we’d ask the SUSE developers to explain how
Ubuntu, Fedora, SUSE and many other distros, it works. If you’re a software developer this is vital
Windows users tend to grab random EXE and MSI reading – or if you’re just a regular end user, it’s worth
files off the web, double-click them, and let them run knowing what goes on in the background. So, take it
wild over the system. away, Team SUSE…
34
30 www.linuxvoice.com
PACKAGING FOR ALL DISTROS
A bit of background
S
USE, OpenSUSE, Red Hat, Fedora, Mandriva,
Ubuntu, Debian, Arch – there’s a long list of
distributions that are supported by SUSE’s
development platform Open Build Service (OBS,
http://openbuildservice.org). The OpenSUSE Build
service (https://build.opensuse.org), a public
instance of OBS, has been around since about 2006
when SUSE’s Adrian Schröter first announced it. Since
then the tool has grown, sponsored by SUSE and
contributors like the German admin company B1
Systems. As of July 2015, more than 500 CPU cores
host some 39,000 software projects with almost
300,000 packages in 52,000 repositories, contributed
to by almost 42,000 developers.
The basic challenge of distributing free software
is compiling that awesome open source code into
machine code for different Linux distributions in a way
that makes it easily consumable for users. That may
sound simple, but once you get started, you’ll find out
it very often isn’t simple at all.
If you look at the dependencies of a typical free
software project you will find thousands of other
projects in the stack. They build on top of each other
and have functional dependencies; sometimes they
are interdependent – they conflict with each other
The OpenSUSE build
and what not. In short: building free software is like for different distributions or versions of these and
service is a public offering
herding cats. But it’s even more than that: the users different CPU architectures. that shows the web
of the software will expect a steady, well behaved, Build instructions describe how to compile interface to the Open Build
streamlined herd of cats! the source code into machine code, defines the Service.
The Open Build Service (OBS) is the tool that makes dependencies and the conflicting capabilities the
this possible. It helps free software distributors to software has in relation to other software, itemise
automatically and consistently build binary packages which files are needed to run it, and provide a whole
from free and open source code. Engineers upload lot of other metadata.
source code and build instructions to the OBS via
its APIs either through the web interface seen in the A unique problem solver
OpenSUSE build service or its command line client The job of the OBS is to interpret all this information,
osc (https://en.opensuse.org/Build_Service/CLI). to provide an up-to-date build environment matching
Then the system compiles that into binary packages the requirements, the execution of the build, and of
course the reporting of the outcome.
The end result is a bunch of binary packages out of
one single source. The twist is this: if other software
depends on the package in some way, the OBS will
trigger a rebuild of the depending package afterwards.
This ensures that changes propagate through the
whole stack and that the user gets a consistent
product to install.
Sadly, software is sometimes defective and people
make mistakes. Nobody is perfect. That’s why the
second basic service that a free software distributor
delivers to its users is the art of exchanging pieces
without breaking the whole: Updates. Your distributor
does not want to interrupt you in going about your
business, and to be able to do this they need to
reproduce the software builds at any given time in the
Who is doing what? Where are the current problems, long lifetime of the software.
which platforms are we building? Find out, with OBS’s The OBS helps distributors to achieve this by
extensive reporting service. tracking who has made changes, when changes are
www.linuxvoice.com 31
PACKAGING FOR ALL DISTROS
Your OBS home project is ready to start.
model – which also helps users because they get
a tightly integrated software solution. OBS brings
together people who collaborate on the integration of
free and open source software; each of the thousands
of software projects is maintained by one or more
developers that collaborate with each other. This is
the third basic challenge a free software distributor
The search for a single
made, and what has changed. The OBS also helps solves for its users.
package reveals the
almost distribution- by using a clean, virtualised build environment. This
agnostic approach of OBS. is how it goes: When an engineer triggers a build in Integration
In this case, the developer the OBS by changing the software in it, the system The OBS formalises this collaboration into workflows
of the Whatsapp Plugin saves the current state, gathers all the dependencies that all engineers use. Everybody uses the same
for the chat client Pidgin and kicks off a virtualised environment to execute way to submit new software, to update existing
obviously favours Fedora the build. As the information on how to assemble the software to a new version, to submit bugfixes and
over SUSE. build environment is contained in the software, and as features. Everyone uses the same means to branch,
all dependent software gets rebuilt too, it makes every study, change, and improve the software. Thus many
build reproducible. different distributors utilise the Open Build Service
If something is reproducible it is also predictable, for the benefit of the users: build binary packages for
and that’s what distributors aim for. If you can predict a wide range of distributions and architectures from
how all of the software projects in your stack influence source code in an automatic, consistent, reproducible
one another, you and collaborative way.
“OBS supports more than 20 can make sure
that a change
But there’s more: OBS itself is free software. You
can run, copy, distribute, study, change and improve
distros, half a dozen architectures to a single piece it. The source code and the developers are on GitHub
and three package formats.” can be managed
through all of its
(https://github.com/OpenSUSE/open-build-service).
As free software, OBS can keep up with the ever-
dependencies, evolving ecosystem, which constantly produces
ensuring that the whole system of software continues new distributions, new package formats, new
to work after a change. This is how the OBS helps you architectures, software, standards and tools.
as a user, because updates from the OBS don’t get in At the current time, OBS supports more than 20
the way of your business. different distributions, half a dozen architectures
The software isn’t the only aspect that needs some and three different package formats. It can
work. OBS also helps free software engineers to cryptographically sign your software and products;
harness the power of the open source development different instances of OBS can connect to each other;
and OBS can be used in conjunction with source
code revision systems like Git/GitHub in continuous
Learning the specifics for each distro
integration workflows.
For those who want to dive into the vast Deb https:/wiki.debian.org/
realm of software packaging, all major IntroDebianPackaging
Linux distributions have great introductions Pkgbuild: https://wiki.archlinux.org/index.
to their package formats and the best php/Creating_packages
practice processes that we suggest beginner The GitHub repository for this tutorial is at
packagers should read: https://github.com/hennevogel/obs-tutorial,
RPM http://fedoraproject.org/wiki/ and contains build instructions for all kinds
How_to_create_an_RPM_package of different distributions.
The new package has been filled with source code files.
32 www.linuxvoice.com
PACKAGING FOR ALL DISTROS
Step by step: Build your package
E
nough talk, let’s get practical! The following
directions will show you how to make available
your own free software to a bunch of
distributions via the build service. It will use
OpenSUSE’s reference server, which is freely available
for developers to build packages for the most popular
Linux distributions including OpenSUSE, Debian,
Fedora, Ubuntu, Arch, Red Hat Enterprise Linux and
SUSE Linux Enterprise.
Building packages is the most basic feature of the
OBS. All you need to for that is a modern web browser
(we recommend Firefox) and an account on the OBS
reference server.
1
Create an account and log in
Point your browser to https://build.opensuse.org and source code archive (www.hackl.dhs.org/data/
click the “Sign Up” button in the upper-right corner. Fill download/download.php?file=ctris-0.42.tar.bz2) and
out the required information (please take note of the RPM build description (https://raw.
SUSE’s Privacy Statement at www.suse.com/ githubusercontent.com/hennevogel/obs-tutorial/
company/policies/privacy) and create your account. master/ctris.spec) onto your computer. Then use the
Once finished, log into the OBS (the “Log In” link is also “Add file” dialog to upload them to your OBS package.
in the upper-right corner). Now your OBS package contains everything it
needs to produce RPM packages that your users can
2
Create your home project install; however, nothing has happened yet! Did you
Every user in the OBS has their own little space for notice the “Build Results” box next to your files? It
building packages, called “home project”, it always has tells you the last missing piece you need: the project
the name of home:USERNAME, for example that this package belongs to currently has no “build
home:hennevogel. You can also navigate to your targets” defined. Alright, let’s change that – click on
home project via the link in the upper-right corner. the “build targets” link in that box.
After first login you’ll have to create it, and that’s
why you are greeted by a form. You can give your 5
Add build targets
home project a nice title and a description of its Build targets are basically the Linux distributions that
content, and once you’re done, click on “Create you want the package to be available for, such as
Project”. In the next step you’re greeted by your own Debian or Arch Linux. On the OBS reference server
shiny little space on the OBS reference server to build you’re greeted by an impressive collection of build
your packages. Hooray! targets to choose from. For this tutorial let’s pick
An OBS project can contain zero or more OBS some RPM-based distributions: OpenSUSE 13.2 and
packages. For now your home project is empty, but Fedora 22. After you have added the build targets you
that’s boring so let’s create your first package! are redirected to the configuration for them; don’t
bother with that (yet) and click straight on the
3
Create a package “Overview” link in the upper-left corner.
Find the “Create package” link and click on it. Another
form creeps up on you. Fill in the information like this: 6
Building
“Name”: ctris. “Title”: Console-based Tetris clone. Now the magic happens! Do you notice the “Build
“Description”: A colorised, small and flexible Tetris Results” box? If you did everything right it will have
clone for the console. Once you’re done press “Save kicked of your first OBS build already. Your ctris
changes”. This will lead you to your new package. package will be in one of the following states:
An OBS package can contain multiple files that are “scheduled”, “building” or “succeeded”. If you click on
needed to build it. But for now your ctris package is those links the OBS will take you to the log file of this
empty. Let’s change this by uploading some files. build that you can inspect, follow and download.
4
Upload files 7
Download binary packages
Typically an OBS package consists of two parts: the Once all four build targets are in the state “succeeded”
source code archive and the build description. As this you can click on the “Download Package” link, which
is a tutorial on how to use the OBS and not about will lead you to a page that includes instructions on
getting you started with packaging we have prepared how to download and install the ctris package for
some files to exercise with. Please download the Fedora and OpenSUSE.
www.linuxvoice.com 33
FEATURE WINDOWS 10
THINGS
WRONG
WITH
WINDOWS 10
We banish Graham Morrison to the isolation chamber to test out
the latest from Microsoft and report objectively on his findings.
T
hree years after the release of Windows 8, suite enjoys plenty of momentum. As if to put an
more people are still using Windows 7 by a impermeable force field between its past and the
huge margin: 60% vs 13.12%, according to Net future, Microsoft has skipped Windows 9 entirely,
Applications statistics from June 2015. passing through an event horizon to release Windows
Thanks to tablets and smartphones, Linux is 10, which we’ve been playing with occasionally since
now the dominant the Technical Preview.
operating system, at
least in Android form.
“A major release of a competing We know we’re
preaching to the
48.61% of devices operating system is a great time converted. But as
shipped with Android
in 2014, compared
for a little proselytising.” the Free Software
Foundation’s executive
to 14% for Windows, director, John Sullivan,
according to a Gartner report from January 2015. We says in this month’s interview, a major release of a
won’t even mention that 97% of the top 500 fastest competing operating system is a great time for a little
supercomputers use the Linux kernel, the others proselytising. Or as Sun Tzu wrote, “If you know the
mostly running UNIX. Oh, sorry, we just did. But like enemy and know yourself, you need not fear the result
most old brands, Microsoft Windows and its office of a hundred battles.” So that’s what we’re going to do.
34 www.linuxvoice.com
WINDOWS 10 FEATURE
1 Product activation
This one’s first because it’s one of the first anyone’s permission, whether that’s a
things you have to do when you install any Raspberry Pi, your router, a laptop, multiple
Microsoft operating system. Product virtual machines or cloud instances.
activation takes your product serial number, As Windows 7 and 8 users are getting a
generates a unique hash from your system’s free upgrade, it’s more likely you’ll need to
hardware configuration, and makes sure the upgrade or replace your machine at some
serial is being used according to the licence point, and it’s unlikely you’ll be able to move
Microsoft is granting you. We’ve had many your Windows 10 licence across. You will
conversations with Microsoft in the past be able to perform a clean install on your It may be a free upgrade, but you’re still not
when activation has been declined, probably new machine, even if you upgraded from a free to install Windows wherever and whenever
due a hardware change, and each time previous version of Windows, but you’ll still you like – unlike Linux.
we’ve needed to beg someone on the end of need to be careful with upgrades. It’s unclear
a support line to re-instate our system. With what will happen if you don’t activate your too early to say whether features will be
Linux, you can install the same copy on 1 machine. You get a constant reminder, and removed and updates held back unless you
machine or 1,000 machines. You don’t need the system remains ‘non-genuine’, but it’s activate your system.
2 Desktop
In some ways, Windows has been going one of the main reasons Windows 8 has had
through a similar design transition to Gnome such poor adoption.
and Unity. This was most evident in This confusion continued to applications,
Windows 8, where Microsoft seemed where some were redesigned for this new
hellbent on making everything touchable, full-screen world, and some weren’t. If
draggable and full-screen, despite very few you hacked your way back to the old Start
of its users wanting to interface with their menu, Windows 8 started to feel broken,
computers via a touch display. like running GTK 3 apps on KDE. Things
The biggest change was the have improved with Windows 10 (there’s a
disappearance of the old Start menu. setting that switches ‘Tablet Mode’ off), but
Windows 8 replaced this with a full-screen it’s a paradigm shift away from what Linux
launcher, where the search field required a offers, where your desktop can be exactly
mouse drag to the top-right and the power what you want it to be, and this is unlikely to It’s now possible to switch between tablet and
controls were hidden beneath an arrow change regardless of where Microsoft takes desktop modes, but there’s little other control
pointer and page scroll. We reckon this is Windows. over the visuals.
3 Launcher
Don’t tell your friends, but the launcher in As such, the new launcher could be
Windows 10 is vastly improved over Windows 10’s biggest threat to Linux
Windows 8, and Microsoft has done a great adoption, because there isn’t anything quite
job at taking a step back from the previous as powerful while remaining old-school
version and stealing what worked while familiar. Gnome 3.x is more capable, in
dropping what didn’t. The new launcher is terms of what you can do from the launch
one-third ‘Start’ menu, one-third ‘Metro’ input – from virtual desktops and context
styled tablet interface and one-third context switching, to customising your distribution.
search. All this fits into the lower-left quarter Unity too is doing remarkable things with We dislike the Windows 10 launcher because
of the screen, and feels much more Scopes, adding shopping, search news and it’s good, and it’s going to keep people using
in-keeping with old versions of Windows. It’s email in a way that makes sense on both Windows.
probably our favourite thing about the new mobile and desktop. KDE has a few menu
version of Windows, and it’s something we systems that are augmented in a similar the design success of what’s going on in
think is going to be integral to people way to Windows 10, but there’s nothing Windows 10. Which is why we’re listing the
migrating from Windows 7 or 8. that embeds the social side, the live tiles, launcher here. It’s actually good!
www.linuxvoice.com 35
FEATURE WINDOWS 10
4 Forced updates
Of course, updates are essential. But computers running on the internet. But
updates for Windows are typically larger and there’s a more draconian side to updates
more frequent than Linux updates, and they too, and that’s the likelihood that features
can take a long time to install. When the will be removed that you don’t want to be
frustration gets too great, it has always been removed. It’s the lack of user control that
possible to delay updates or to disable the worries us, especially as the idea you no
feature entirely, but not any more. From longer have control over what you own is
Windows 10, updates are going to be growing – whether that’s a Kindle removing
mandatory, at least for Home users. Pro and 1984, or Apple removing Google Maps.
Enterprise users can defer updates. Linux distributions will never have these
This is important for a couple of reasons. problems. You can choose not to update
Firstly, these enforced security updates are your machine, or select only those updates
going to reduce the number of Windows that are relevant to you. We’ve also got more Windows 10 Home users will be forced to
machines running malware, which make trust in almost any Linux distribution to only update their machines, whereas Pro and
up, by far, the majority of compromised roll out security patches. Enterprise users will be able to defer an update.
5 Privacy
With Linux, it’s clear when your data is A big part of the new agreement seems
leaving the system, or when you’re using to be designed to build a profile much like
services that store your data on external Facebook’s user profile, “We collect data
services. You don’t have to agree to intrusive about your interests and favorites, such as
processes running through your photos or the teams you follow in a sports app, the
email unless you want them to, and you stocks you track in a finance app, or the
don’t have to agree to privacy decimating favorite cities you add to a weather app,” is a
end-user agreements. The same isn’t true of good example from the Privacy statement.
Windows 10. Microsoft’s new Services Microsoft also creates an ‘Advertising ID’ for The privacy panel in Windows 10 puts all your
agreement, effective from 1 August 2015, is each device you activate. “Your advertising privacy options in one place, but it can’t stop
12,000 words long. Microsoft’s Privacy ID can be used by app developers and your data being shared.
agreement, fully expanded, is 17,000 words. advertising networks to provide more
These agreements are so ambiguous that relevant advertising, “ according to voice input and generates sensible output
they seem to grant Microsoft access to Microsoft, and major new features such as like Google Now or Siri, is another worrying
every facet of your computer use. the Cortana ‘personal assistant’, which takes addition for privacy advocates.
6 Usability
Subtle use of animations and a new, thinner where a set of virtual desktops can be
window manager helps Windows 10 feel like pre-configured per-application or use case.
a modern operating system. We like it. But The new notifications system has
Windows 10 has also taken some serious taken inspiration from OS X, which took
inspiration from Linux with its new Task inspiration from Linux. They appear in their
View. This is essentially a re-implementation own area, now called the Action Centre,
of virtual desktops, and while old versions of which slides in from the right of the desktop.
Windows had this to some extent (or via It’s a big improvement over the chaos of
proprietary graphics drivers), it’s being notifications in Windows 8, and we’d like to Virtual desktops make a welcome return as
touted as a major feature. For those of us see something like this on a Linux desktop. first-class citizens in Windows 10.
who rely on multiple virtual desktops, it’s Linux has become very good at dealing
certainly a step in the right direction. But it’s with notifications. Gnome’s notification here, adding real interaction to updates that
a long way from the facilities currently system is improving with each release, are usually passive. But we’d like to see
offered by the average Linux desktop, and a and we currently prefer the way it displays Windows 10-like integration, even if as Linux
whole dimension short of KDE’s Activities, messages. Ubuntu’s Scopes also work well users, we still have more control.
36 www.linuxvoice.com
WINDOWS 10 FEATURE
7 App store
This is a big category because of the way for small utilities to be crippled, or run as
both operating systems handle the shareware. Whereas, as Linux users, we
installation of new software. Like Apple, sometimes take for granted the incredible
Microsoft is using security as an excuse for selection of software we have available,
making it harder to install downloadable .exe freely installable through your distribution’s
files. And it has a point, as random package manager without anyone making
executables downloaded from the internet notes on what you’re installing.
are probably responsible for more viruses Microsoft Office is also a huge part of
than any other feature. But its replacement, Microsoft’s strategy, and while it’s not App stores, such as the one in Windows 10, are
Microsoft’s Store, is a conduit designed for yet part of Windows, its download and really package managers with built-in DRM, and
sucking your privacy and your money. This management has been part of the Windows must be resisted.
is a huge difference between Linux and eco-system for some time. However, with
Windows, of course, and it has more to do the release of LibreOffice 5.0 in early August from proprietary office software to an open
with the culture behind both operating 2015, with its open source and open source alternative is imperative, even when
systems. Under Windows, it’s typical even standard credentials, we think switching people still need to use Windows.
8 Web browsing
Once upon a time, the thought that Internet JavaScript engines of the other browsers.
Explorer would no longer be a dominant But it’s also new, and its rendering engine
force in web browsing seemed like a – EdgeHTML – is entirely proprietary, rather
fairytale. But the rise of Google, rapidly than the open source KHTML/WebKit/Gecko
accelerated JavaScript engines and serious derivations of Safari, Chrome, Opera and
security flaws have slowly eroded Internet Firefox. As a result, we’ve still far more
Explorer’s viability. confidence in the future of these than
So Microsoft has started again, bundling a EdgeHTML.
new browser that it’s calling Microsoft Edge The other big omission is that Microsoft
(previously Project Spartan). Edge is a huge Edge has no support for extensions,
improvement over the bloated anachronism although Microsoft has said in the past it
of IE. Its sharp, borderless UI is the best should support Chrome’s and Firefox’s. This
example of Windows 10 design. The URL means no ad blocking, or any of the other
doesn’t even appear until you click on the extensions that lots of us rely on as part of If Edge doesn’t work, you can still use Internet
top. It’s also fast, finally competing with the our web experience. Explorer, which isn’t dead yet.
9 Closed source
Our last gripe is the most fundamental, and a far healthier, and we think, far more secure
while it’s not something new to the release system. The same is true for privacy. It’s
of Windows 10, the fact that Windows is almost a given that there are backdoors into
proprietary is still its biggest hindrance. Windows, sending data back.
Open source is better for so many reasons. While the same could be said for Linux, if
For security, Microsoft is usually very quick there are backdoors, they’re from a lack of
to patch problems when they occur. But eyeballs rather than machiavellian intrigue.
there’s no transparency about how long an We’re far more likely to trust a messaging
exploit has been exploited, or what was application when the source code is
needed for the fix, or even how major one available, than promises of good faith from a
vulnerability might be in comparison to proprietary offering (cough, Skype). But open
another. Even after several open source source is also more innovative. Many of the
projects have had their own vulnerabilities ideas taken and integrated into both
exposed, the transparency and self- Windows and OS X started life as ideas on Imagine not being able to check or share the
regulation that accompanies open source is the Linux desktop. code running through your CPU….
www.linuxvoice.com 37
38
39
FAQ WEBASSEMBLY
WebAssembly
Does the web need another binary format, and can a new one
avoid the pitfalls of the past?
than being restricted to a particular negligible; however, web designers are
BEN EVERARD object on the page in the same way putting more and more functionality
that Java and Flash are. into web apps, and the number of
If you really get down to the details of scripts web browsers have to parse is
WebAssembly? I’ve never WebAssembly, it’s actually getting larger and larger.
heard of it, but I guess it’s implemented in quite a different way to This isn’t usually a major problem for
something to do with the internet. bytecode. Bytecode is a machine code desktop machines, but on lower-power
Yep. It’s a new binary format for for a virtual machine that runs in devices such as phones, some larger
code that runs in the web software and can be implemented on scripts can take tens of seconds just to
browser. Basically, it will enable many different platforms. parse. If that has to happen on every
programmers to compile languages to WebAssembly, on the other hand, is a page, it’s a significant slowdown in
create executable files that will run binary representation of the abstract browsing speed.
inside web browsers on any platform. syntax tree.
For example, the same executable A simple way of thinking of this is Isn’t a better solution just to
should run in Firefox in Linux and that it’s the midway point in compiling consider excessive use of
Internet Explorer on Windows. This code. So, rather than raw code (like JavaScript a bug, and just start
binary format will also be processor JavaScript), or pseudo-machine code shouting at web designers until they
agnostic, so will run on ARM mobile (like Java), WebAssembly is half- use less of it?
chips, x86 desktops and any other compiled code. Much of the most-time There are certainly sites that use
processors that you may find. consuming part of compiling has too much JavaScript, in fact,
already been done, but the platform- there are quite a lot of sites that use too
What is this binary format you dependent part of is still to be done by much JavaScript. However, there are
speak of? A bytecode similar the browser. None of this should matter also some really good uses of large
to Java or Flash? to the users, but technically, amounts of JavaScript. Take, for
As far as the user is concerned, WebAssembly isn’t a bytecode. example, online document editing,
it’s probably best to think of browser games or even video codecs.
WebAssembly as a binary executable So if it has the same These are always likely to be JavaScript
similar to Java or Flash, but one that capabilities as JavaScript, and (or WebAssembly) -heavy, but they’re
runs directly in the browser, so can it runs in the same model as also really good uses of technology.
change the whole page in the same JavaScript, why don’t we just use Even if you don’t want to move all
way as you can with JavaScript, rather JavaScript? It’s been around for your programs to web apps in the cloud
ages and seems to be working OK. (and there are very good reasons why
WebAssembly is designed to be you shouldn’t), having the option to use
“WebAssembly will give like JavaScript but faster. Every
time your browser visits a website that
web apps when it is appropriate is very
useful. In other words, good web tech is
programmers a language other uses JavaScript, it has to download and a bit like freedom of speech. Lots of
than JavaScript for the web.” parse the language, and this takes time
and memory. For simple scripts, this is
people abuse freedom of speech to
spout silly or offensive views, however
40 www.linuxvoice.com
WEBASSEMBLY FAQ
it’s still vital because without it,
important things can’t be said. In the
same way, lots of programmers abuse
web tech to make silly interactive
graphics that just convolute the
interface and slow down browsers, but
it’s still important, because without it,
there are whole classes of web app that
can’t be made.
Another advantage of WebAssembly
is that it will enable programmers to
use languages other than JavaScript to
program for the web. There are also
quite a few languages that compile to
JavaScript already, but compiling to
WebAssembly should make them run
faster and easier to debug.
The final version of WebAssembly isn’t quite ready yet, but development is happening
I run NoScript to stop websites on GitHub, where you’ll find the design documents and prototypes.
running code in my browser. Is
this just another attempt by (Mike Saunders, who wrote an entire Since WebAssembly runs in the
advertising companies to get inside operating system in assembly, cannot same engine as JavaScript, the two will
my browser? How can I stop it? be considered normal by any be able to talk to each other. We expect
WebAssembly will run in the reasonable metric). to start seeing libraries in
JavaScript engine, so won’t be Initially, the aim is to make it easy to WebAssembly that are designed to be
another way in. From a privacy and compile C and C++ code to web used from JavaScript. This should
security perspective it should be no assembly. The reason for this is that enable people to gain the load and
different from running JavaScript. At there are currently a lot of large performance of WebAssembly, but still
the same time, it should be possible to performance-critical codebases in C use an interpreted language that they’re
block it in the same way. We expect and C++ that would benefit from a fast familiar with.
NoScript and other extensions to be web-based version. Games and Video
updated in due course to protect those Codecs are obvious examples, but The history of the web is
who don’t wish to run WebAssembly. anything that is too big or slow to run littered with the corpses of
on the web would be a candidate. binary formats: ActiveX, Flash and
So what’s assembly got to do In time, it’s likely that compilers will Java to name but a few. One factor
with it? expand to support more languages in the demise of all of them was that
Actually very little. The name is a compiling to WebAssembly. There are not all browsers supported them,
little bit of a misnomer. Assembly no fundamental restrictions on what and if you needed users to install a
language is a text language that directly languages can be compiled; it will plugin to work with your site, then
maps to binary machine code. simply depend on what languages you’d lose visitors. How is
WebAssembly, on the other hand, is people are willing to take the time to WebAssembly going to avoid this?
itself binary. There is a text version of support. It’s even possible that WebAssembly has a real
WebAssembly that programmers can JavaScript will be compiled to advantage here because it can
write in directly, but this is known as the WebAssembly. run quite efficiently in a JavaScript
WebAssembly textual representation polyfill. That means that if someone
rather than WebAssembly assembly (or Ah, that brings us back to with an older browser visits your site,
WebAssembly2). Even the binary format JavaScript. How will and it relies on WebAssembly, you can
isn’t machine code, so a textual version WebAssembly work with load a JavaScript library that will
of it isn’t assembly anyway. JavaScript? convert the WebAssembly into
There are so many existing skills JavaScript and run that. Obviously this
Ah, that brings me onto my in JavaScript that it would be has a performance impact, but early
next question: How will people foolish to expect it to go away anytime indications are that the performance of
program WebAssembly? Using this soon. In cases where you just need a the polyfill is quite good.
textual representation? little code, JavaScript currently runs Not only that, but this is the first
While it will be possible to code fast enough that there won’t be any binary format to have support from all
directly in WebAssembly textual significant speed increase from major browser developers. Mozilla,
representation, it’s unlikely that many WebAssembly, so the simplicity of Google, Apple and Microsoft all have
people actually will for the same reason JavaScript may outweigh the negatives people working on WebAssembly, so
that not many normal people program – like the way people still write in it should be widely supported in new
directly in regular assembly language Python despite C code running faster. web browsers.
www.linuxvoice.com 41
INTERVIEW JOHN SULLIVAN
“Use the GPL if you want
to make sure that nobody
turns your software into
proprietary software.”
42 www.linuxvoice.com
JOHN SULLIVAN INTERVIEW
JOHN SULLIVAN
FSF EXECUTIVE DIRECTOR
Graham Morrison meets one of the only people in the world of Free Software who
Richard Stallman can legitimately call ‘boss’.
F
ounded by Richard Stallman in Software Foundation puts the GNU in GNU/ making sure the FSF sticks to its principle
1985, the Free Software Foundation Linux, and it’s vital for the future and well- while adapting to an ever-changing world
is now 30 years old. It predates being of our favourite operating system, of technological development. The GPL is
the world wide web, Linux, laptops, and a future where we can all request and being used more than ever before, and Free
smartphones, social media and the Amiga change the source code. As its Executive Software now requires little introduction, as
500. As the custodian of the GPL, the Free Director, John Sullivan has a tough job he explained when we met him for a chat.
The GPL has been vital for the The number of programs that are to choose it. It focuses on restrictions.
growth of Linux, but is it released under a Free licence is way We would like the language to focus on
becoming marginalised by larger than it ever has been. protections, so, “Use the GPL if you
permissive licences such as Apache want to make sure that nobody turns
and MIT? That’s important to remember. your software into proprietary
John Sullivan: I gave a talk at JS: There’s definitely a lot of talk, software”, it prevents that from
FOSDEM a few years ago about the again, about why younger developers happening, as opposed to “choose the
what had been written about the are not choosing copyleft. One specific GPL if you want requirements like this.”
decline of copyleft licences, and I do case for that seems to be codified in I think it would probably have some
have a lot of issues with that premise. the GitHub ‘Choose a licence’ tool. We influence, on choices and somebody
I’m planning to write an article to lay would really like them to change the else, if maybe someone else were to
them all out because these studies language that they use to describe the provide a different tool that would
keep getting published periodically like GPL, to make it parallel with the other accomplish the same ends. But really
the GitHub one that was published a licences – MIT, BSD-style, as they call it, I’d just like to see them improve their
little while ago, showing licence and Apache. The GPL is described in a wording, make it a bit more clear and
preferences on GitHub. way that would make people not want less judgemental.
But there’s also a feeling,
especially around big open
source companies like Facebook,
Twitter, that permissive licenses are
becoming a developer’s first-choice.
JS: One thing to keep in mind is that it’s
not just a question of whether you’re
choosing copyleft or choosing
permissive licences; we’ve added
another element to this, which is that
we now have companies that would
normally either not distribute their
software or at all, or have been
distributing it as proprietary software.
[These companies] are a lot of the ones
doing a lot of the permissive
distribution. We have to keep in mind
that it might not be trading off with GPL
adoption, as much as trading off with
proprietary software licences. We’re not
just counting two categories here, you
have to also count the third category.
www.linuxvoice.com 43
INTERVIEW JOHN SULLIVAN
Google not releasing the
source code to Android is
a prime example of why we
need the FSF to preserve Free
Software for everyone.
What can you do to help spread Another example of why GPL is in governance, so it’s really not that
the word? so important is in the complicated. Complications are over
JS: I think that one thing we could do to revelations that The Hacker Group stated.
advocate copyleft better is to compile had used GPL software to build its
the cases that give us concern with tools, much to the initial chagrin of Yes, and it’s easier for
permissive, lax licences. I don’t think Free Software developers. But development teams to publish
we’ve done that work yet, just as other because they took GPL’d software, it stuff within a company without
people maybe aren’t giving the also means those developers have consulting their legal department.
consideration they should. We also some course of action against those JS: Yeah, the problem is that patents
haven’t done the work to present the hackers, should they want to take it. are still an issue for that. Companies
information as well as we could. JS: Also, in that case in particular, the wanting to hold them back as a
Particularly in the spaces where code is only way to ensure that your programs weapon they can use.
being made proprietary in a way that aren’t being used against you is to be
disrupts other development. People able to see what they’re doing, and GPL So, perhaps more
depend on Android. People depend on is the only licence that guarantees that. optimistically, what are your
the compiler. And to have bits and We need to do more for just providing feelings on free software at the
pieces of that taken away screws up assistance. One activity we’ve done for
“The GPL functions as a licence
other people’s work – that’s something a very long time is just to provide, free
I want to avoid. of charge, help to developers to
The challenge of all this is that a lot of understand the licence and use it
that can be used effectively in
jurisdictions around the world.”
people who would prefer that software properly. And it’s not just the GPL – it’s
not be copyleft are businesses – like also interactions with other Free
Facebook, as they said in the keynote Software licences. I’d like us to be doing
the other morning [at OSCON], “We do it more in that area. We need to be doing moment? Do you feel good about it,
in the end because it’s good for the more to push back against this idea and take any pride at the success of
company.” And we have no argument that GPL is somehow too complicated. conferences like this?
with that. We still welcome their It’s really not. The GPL functions as a JS: Yeah. There are plenty of people
participation in Free Software, but we licence that can be used effectively in here who support us, who do not fully
need people to recognise that it’s jurisdictions all around the world to agree with the idea that there should be
contingent that way because a lot of distribute any kind of software – even no proprietary software, they just think
this attitude comes from larger things that aren’t software – and that’s free software is really good. So, even
companies, with lots of resources, up how many words it takes. A single though we may agree that we’re not as
against a bit of a marketing. website has the same number of words close to the goal, there are a lot of
44 www.linuxvoice.com
JOHN SULLIVAN INTERVIEW
people getting together talking about development in the last several years conference. We care about why people
sharing code both commercially and that has had free software involved in it are using free software more than what
non-commercially and the benefits of somewhere? You know, Netflix, iPhone, they’re using it for.
doing that. iOS, Android, Amazon Kindle, they all
One of the dangers that we’re seeing have free software in them. Are there companies that are
is free platforms being used just as particularly responsive to the
ways to run proprietary software. Like, And it leads us to the difficulty message of the FSF? Are there
Netflix has several talks here and of dealing with proprietary companies that embrace the
they’re doing a lot of work in free software used in the cloud. obligations of the GPL and GNU and
software and sharing that, and using a SF: With network services that take the make it part of their ethos?
lot of free software internally, but in the programs out of the user’s hands we SF: Yeah, for one thing there are some
end they’re using it to deliver DRMed can see how powerful free software is, smaller companies that are doing really
media that requires proprietary and how wrong the argument that if amazing things. We have a hardware
software on the user side. So that’s software is free then nobody will endorsement program, called the
taking us farther away from some develop software anymore. Obviously “Respect Your Freedom” program, and
important goals. And I think that’s one false, but it’s not getting us closer to the the companies that we’re working with
of our major threats right now and it’s goal of users actually being respected. under that banner like Aleph Objects,
connected to the copyleft question, And that’s where you would find the ThinkPenguin, Gluglug in the UK. They
which is: how do we can stop literally differences between us and some of are making products that are
every exciting popular technological the companies represented at this completely free, so I guess that’s the
pinnacle of what we have right now.
And I think there’s a lot of room in
that space. I’m really excited about that
program, because I think one of the
most important things we need to be
doing is make it easier for regular
people to buy a free system or device
without having to do so much research.
Lots of things work with free software,
but for years Wi-Fi and Bluetooth
required proprietary blobs, and laptops
have proprietary Wi-Fi and proprietary
graphics acceleration a lot of times. But
if you were to line up all the different
devices, you could take from each of
them and put them into one package,
you’d get pretty close to having a fully
free option. So I think it’s just a case of
single businesses not making the right
decisions. The components are there,
and I think if more companies started
doing that they would find a market for
that kind of product, especially now
with the privacy concerns.
Being able to sell a product and say
you can see everything that it does is
potentially powerful if somebody with a
marketing budget were to pick it up and
run with it. But there are plenty of
companies sharing the source code
properly under the GPL, there have been
forever, but unfortunately, especially in
the mobile space, there are lots of
companies that need to be doing more
about, otherwise companies that are
following the terms have a legitimate
Contributing to Free Software gripe about playing by the rules…
isn’t just about being a good
citizen – for companies, it can
also be good marketing material. But then resources are really
limited – perhaps 40 people in
www.linuxvoice.com 45
INTERVIEW JOHN SULLIVAN
total including WordPress, Software
Conservancy and the FSF. It must be
hard to pick the fights!
JS: Well that’s part of the reason I’m
excited about the endorsement
program. If we can just get people to
make fully free products then there are
no GPL issues, because everything is
already free software. That’s the easiest
way to resolve that. We announced the
copyleft.org project a while back… the
whole idea is that individuals are
supposed to be able to request source
code for a device and see the source
John told us that the IT
code for a device to be able to build it,
infrastructure at the FSF runs
and while we’re doing the enforcement
on Trisquel, the totally Free
work ourselves, we really ought to be Software Linux distribution.
doing more to help other people
exercise those freedoms. Plus I think
that it will have an impact on the space knew that our membership had a understood our relationship between
if we get more people just trusting the variety of skill levels and interests and in proprietary software and forced
source code. the most parts, they actually care about obsolescence. There’s been, since I
Part of the compliance issues with working with computers in terms of started in 2003, a rise of interest from
some if these companies is that they developing software. But I’d always other political groups. The idea of being
don’t get requests frequently enough to thought that everybody had at least in control of your own communications,
have a system, and so they don’t treat reached the stage of being able to try your own tools that you use to connect
them the right way. That’s not an installing GNU/Linux. And it’s really to your supporters, so that no company
excuse, but I think it would probably encouraging actually, because it means can just yank that out from underneath
improve things if more people were that this person joins because he likes
“We’re seeing a lot more
actually requesting the source code. the ideas. So that was really cool. Since
any kind of advocacy now requires
That’s a great point. Do you using computers, I think we’re seeing a
interest from other politically
oriented advocacy groups.”
think attitudes towards Free lot more interest from other politically
Software have changed? oriented advocacy groups.
JS: We’ve definitely seen much bigger
interest outside the hacker/developer Has this been after the Edward you. Organisations still have a time
core of supporters that got the whole Snowden revelations? getting started with Free Software but
thing started. We had a member write JS: Not entirely. I think even before they’re more interested in it than they
to me once and ask “How do I install then, when (Microsoft) Vista came out were 12 years ago, for sure.
GNU/Linux?”, for example, and it was we had Greenpeace to support our
kind if a wake up call for me because I campaign against Vista, because they Are you doing anything for the
Windows 10 launch?
JS: Definitely. We have an on-going
‘Upgrade from Windows’ campaign,
and we’ll update when we know about
Windows 10. One thing we know is that
updates are now mandatory, so users
can’t disable the software updates any
more, which has great potential for
abuse, since updates have been known
to be used to take features away that
users like, or install anti-features.
We also have an update in our
Restricted Boot campaign because
there may be some changes with
Windows 10 around SecureBoot, and
The FSF exists to keep
we’ll definitely be doing more because
everyone else honest –
those launches are good opportunities
it’s the heart and soul of
Free Software. – Free Software people tend to not like
to be too critical. Folks would rather
46 www.linuxvoice.com
JOHN SULLIVAN INTERVIEW
In his non-FSF time John’s a Debian
developer (even though it’s not
completely non-free).
send the positive message of Free would be related to publishing. Then I ultimately we want to be accountable
Software rather than ‘Windows is bad’, worked part time on my own writing, to. But I also think we could be receiving
or ‘Mac OS’ is bad. At the same time but then when I got working at the FSF, a lot more funding from businesses
those launches are great moments for all of my computer geek stuff came that are involved in Free Software.
reaching new people. People who have back again. I went from part time to full
just got Windows 8, they don’t want time and got back to learning a little bit With so many companies
Windows 10, so they start searching for about programming again. It was really reliant on what the FSF has
alternatives and our campaign that consistent with other political values achieved, it’s perhaps surprising
mentions Windows 10 and GNU/Linux that I had, and I hadn’t had that really they haven’t made more of a
together is a way for people to discover strong political components to my early financial contribution.
what they’re searching for. experience with computers. And JS: And prospective employees like to
Searching for information on bringing those things together was see it. They like to see the place that
Windows 10 and finding a different OS powerful for me. they’re going to work be a contributor to
sentirely, that’s a gateway – it’s not just groups like the FSF, because it’s a great
about bashing, it’s about linking our How many full time staff are statement about that company’s
option, alternative or our replacement, there at the FSF in the US? culture and can make the difference in
whatever people are looking for JS: We have 12 right now. We’ve been someone’s decision between wanting
because that’s what they know already. growing, so we’ve added new positions to work for one company versus
in the last few years. I would like to see another company. There’s a lot of
How did you get involved with us be much larger. Part of my goal as willingness out there in the business
Free Software Foundation? the Executive Director is to try and world to support us. But we do have to
JS: When I was a teenager I was very make that happen. ask, and we do have to make the case.
active. I was a wannabe hacker, I ran a
bulletin board system. I tried to learn to Is funding the main issue? Is RMS funded from the FSF?
do some programming. And then I got JS: We’re about 85% funded by JS: We don’t fund his travel or
away from that completely in college individuals and then the rest, there’s a give him a salary. Events normally cover
because of the math class little bit from sales of manuals and expenses to get him to different places
requirements, and studied philosophy T-shirts and then the rest from and of course he prefers to stay with
and creative writing instead. I ended up companies and other large non-profits local people. But we do have the
applying for a job at the Free Software that contribute funds. I really like that position of his assistant, and some of
Foundation to work on the manuals, the vast majority of our funding comes the other roles help to support his travel
because I wanted a part time job that from individuals, because that’s who and work.
www.linuxvoice.com 47
LISTEN TO THE PODCAST
WWW.LINUXVOICE.COM
BUY MUGS AND T-SHIRTS!
shop.linuxvoice.com
INTRO REVIEWS
REVIEWS
The latest software and hardware for your Linux box, reviewed
and rated by the most experienced writers in the business
On test this issue...
50 52
Andrew Gregory
No Google, I’m not 10 minutes away from the
office; that’s the pub.
W
indows 10 is out, and
already the usual suspects LibreOffice 5 VirtualBox 5.0
are falling over themselves Graham Morrison formats some More speed and some extra compatibility
to tell us how amazing it is. What paragraphs in one of Free Software’s options for this stalwart virtualisation
seems to have gone unnoticed in the flagship applications. Today, open platform make Mike Saunders a very
mainstream media, however, is the documents, tomorrow, the world! happy distro hopper.
intrusive amount of data that Windows
10 reports back to Microsoft and its
‘trusted partners.’ 53 54 55
By default (you can change the
default settings, but the option to do
this is hidden in blue text on a blue
background) Windows 10 reports your
location back to Microsoft; it sends
details of your calendar, and your
typing. The Edge browser sends your
Drawpile 1.0 Geany 1.25 Shadow of Mordor
browsing data to Microsoft, which is Collaborate on drawings Ben Everard turns his back Michel Loubet-Jambert has
egregiously bad. But possibly the worst with teams halfway round on the Vim vs Emacs editor gazed into the palantír and
of the default settings is that Windows the world – Ben Everard wars to explore a clean seen the future of gaming
10 automatically connect to open tests an application eight GTK 2- based development on Linux, and it’s based on a
wireless hotspots. years in the making. environment. book published in 1954.
Seriously, just use Linux
Most people accept the defaults; that’s BOOKS AND GROUP TEST
just what we do as humans. Which
As we know, Google and Microsoft are trying to take
means that pretty soon there will be
every bit of your personal data and feed it into the
millions of devices vulnerable to dodgy monetising machine. But there are other ways to
routers running malicious software. So interact with the world. In this issue’s Group Test
there are lots of opportunities here: we’re exploring search engines for the privacy
identity theft is going to be a growth conscious, including one fascinating option that
uses distributed, shared processing rather than
industry, which should spur a new wave
sending data through a central server.
of no-win, no-fee legal cases. And And if you’re sick of living in Jeremy Bentham’s
maybe, just maybe, we’ll see some panopticon, you might be interested in a little book
disgruntled users switching to Linux. by Cory Doctorow – it’s fiction, but only just.
andrew@linuxvoice.com
www.linuxvoice.com 49
REVIEWS LIBREOFFICE
LibreOffice 5
Graham Morrison needs to find a collective noun for people who love word processors.
W
e must admit. Despite their prosaic nature, demarcation of everything that’s been achieved.
DATA and a tendency to be associated with open Notably, we loved the new icon theme that came with
Web
plan offices, we quite like office suites. This 4.2, and the OpenGL and UI overhaul of 4.4, which was
http://libreoffice.org may be something to do with the Amiga, and the only released in January 2015. Our huge datasets
Developer emergence of proper graphical word processors like have also been grateful for the re-written computation
The Document Wordsworth and Final Writer. Even to our younger engine in the spreadsheet, along with many other
Foundation selves, opening the physical packaging around those small updates and refinements along the way.
Licence
LGPLv3 & MPLv.20
(costly) products and patiently installing a single The LibreOffice report for 2014, released by The
application off several floppy discs was exciting. To be Document Foundation in June 2015, for instance,
then presented with a WYSIWYG view of your writing, is worth a perusal just to see how much has been
as you typed, seemed revolutionary. achieved. It’s great to know, for example, there were
We had the same warm and fuzzy feeling when a total of 67,500 donations throughout 2014, raising
Sun Microsystems bought StarOffice in 1999 and then nearly €595,000.
open sourced the project in 2000. We had the same As usual, the release notes that accompany
feeling when The Documentation Foundation was LibreOffice 5 are longer than a Microsoft EULA. It’s
formed to help LibreOffice fork itself from the then good that they’re comprehensive, because so many
incumbent OpenOffice.org, which remained under projects fail to document what they’ve been working
the control of Oracle Corporation after its acquisition on. But they’re also too long for immediate
of Sun. Even now, when installing the latest version gratification. It would be great if alongside the release
of LibreOffice, it feels wonderful that we have such notes there were a visual overview of what was new
a powerful suite of office applications, free in both and what had changed.
cost and principle. That there’s a graphical database,
a spreadsheet, a presentation creator and a drawing Close to the edit
tool alongside the wordsmith feels like a free pass We’ll start with the word processor, Writer, as this is
to an all-you-can-eat buffet. It’s a good job major likely to be the most commonly used component of
releases like this don’t come along too often. the entire suite. There are small graphical refinements
everywhere. Some of the menus have changed, and
High five there’s a new icon set based on Breeze from KDE.
New style previews, more
LibreOffice 5 comes three years after 4.0, but it’s also a Whether this looks good is subjective, but as this
icons and auto-correction
are the highlights of this little unexpected. It was due to be version 4.5, but review is written by a KDE user using exactly that icon
release, and we found the perhaps because the 4.x release cycle has set on the desktop, it’s a very pleasing update,
entire suite a step-up in consistently delivered great upgrades, the project has especially when KDE integration always feels a few
stability. ‘done a Linus’ and upped the major number as a steps behind GTK and what the Ubuntu team does
themselves for better unification.
Styles now have a rendered preview, just like the
font selector does, which is a great help if you use
more than a few styles. If you want to flag your
friend’s spelling mistakes, text highlighting is now
compatible with Microsoft Word formats, and images
can be cropped with your mouse. We’d like to see the
integration of word definitions, perhaps using an
offline database, so we can look up a word while
writing. We’d also love to see a more configurable
writing environment where we can remove all
distractions and have an on-screen word count for the
total document, paragraph and selection.
Editing and creating text documents, especially if
you need Word compatibility or if you’re working with
downloaded templates, works brilliantly. We use it
almost every day for label printing, for example, and
we’d be lost without LibreOffice and its exceptional
format support. One of the best new features is the
addition of the timestamp protocol to PDF exports.
50 www.linuxvoice.com
LIBREOFFICE REVIEWS
The Document Foundation
One of the best things about the betterment of a single project.
LibreOffice is The Document And like The Mozilla Foundation,
Foundation. This is the charity the importance of its custodianship
responsible for its development, and cannot be underestimated. That we
it’s a remarkably transparent and now have the ability to edit and email
accountable organisation. It was built documents to people regardless of
from the OpenOffice community after their operating system or office suite
it started to become obvious that a is partly to do with the legacy of
fork was the best direction to take OpenOffice and LibreOffice, and the
the project. Foundation is determined to keep
The Foundation has a board of pressure on standards commitees to
directors, a membership committee ensure this momentum continues.
and a board of trustees. Anyone can If you’d like to find out more, we
become a member and get their voice spoke to its Executive Director (he
heard, and many companies are doing was Chairman at the time), Florian
just that. An additional advisory board Effenberger in our very first issue, and
includes members from Red Hat, we chatted with Michael Meeks, VP
Google, AMD, Intel and even the city of Productivity, in issue 05, both of
of Munich. It’s rare in open source which are now free under the Creative Only a very small percentages of the updates added to LibreOffice get
that a Foundation like this exists for Commons BY-SA licence. merged into the old OpenOffice.
This enables you to sign a document with an external compatibility with Excel. We still experienced stability
authority that guarantees the authenticity of the issues when using large spreadsheets. This may be
timestamp. It’s easier than getting an image of because Calc has received a lot of internal work for
yourself with today’s newspaper, and is a serious this update, as part of the computational engine
requirement for all kinds of legal and archival uses. rewrite. Similar updates have been made to the other
applications in the suite. Draw and Impress both look
Almost too good? smarter, and the entire suite works well with our High
We love new features, but we still think that LibreOffice DPI display now.
could do with a feature purge, or at the very least, LibreOffice is undoubtedly looking to the future, with
some menu and option pruning. The suite seems the new editable Android app and the soon-to-be-
to have continued getting more complex for over released cloud version. This is particularly clever,
a decade, despite there being a minor revolution in because it
distraction-free editors and online suites. We know encapsulates the real
LibreOffice needs to compete with Microsoft Office and code and functionality “We can’t imagine Linux being
match as many features as it can, but we’d love to of the native a viable alternative to OS X or
see a genuine overhaul of the interface, and we don’t application, rather than
mean by adding the abysmal ribbons. being a web interface Windows without LibreOffice.”
The spreadsheet has had some cosmetic changes connected to an API.
made to the data bars, plus conditional formatting, We know of no other online office suite that’s as
which can now be exported to XSLX. There are also a comprehensive, and LibreOffice could genuinely find
handful of new spreadsheet functions to improve success with cloud/online users who want something
more comprehensive than the low-fat office suites
currently available.
LibreOffice 5.0 is another strong release, tempered
perhaps by its own successes and the expectations
that come with a major version number. We may be
beholden to LibreOffice for its cross-platform
compatibility, but development has never stalled. Each
release adds hundreds of features, fixes and
improvements. It still has rough edges – especially
around the GUI – but we can’t imagine Linux being a
viable alternative to OS X or Windows without it.
LINUX VOICE VERDICT
We’d like to see some UI rationalisation,
but version 5.0 is a strong update to
Version 5 could have been version 4.5, as it contains this cornerstone of FOSS success.
mostly cumulative updates, but the spreadsheet does get
faster and more stable.
www.linuxvoice.com 51
REVIEWS HYPERVISOR
VirtualBox 5.0
Mike Saunders spends half of his life inside VirtualBox, and finds out
what’s new in version 5.0.
I
f we had to name one piece of software that has
DATA been absolutely instrumental in the making of
Linux Voice, it has to be VirtualBox. Sure, there are
Web
www.virtualbox.org plenty of other PC emulation and virtual machine
Developer options out there, but we’ve always had a soft spot for
Oracle VirtualBox: it’s very easy to use, it’s a good performer,
Licence and it has all the features we need for testing and
GPL/CDDL (base)
reviewing Linux distros (and indeed other operating
systems). For instance, it’d be hard to imagine life
without snapshots, which let us test new distros or
poke around inside them, and revert to the previous
state quickly if/when something goes wrong.
Chances are that you’ve used VirtualBox at some
point as well, probably for the same purposes or With paravirtualisation, VirtualBox 5.0 can now use Linux’s
perhaps for running the odd Windows program on KVM for an extra speed boost.
your Linux desktop without having to reboot. Originally
a product of German company Innotek GmbH, it was Additionally, more CPU instructions are now
acquired by Sun in 2008. Just two years later, Oracle available to guest OSes, such as SSE 4.1/4.2, AVX,
snapped up Sun, which led to nail-biting times for AES-NI and RDRAND. A virtual xHCI controller has
VirtualBox fans. Oracle’s relationship with the free been added, which provides USB3 device support in
software community has been topsy-turvy at best, guests, and bi-directional drag-and-drop support has
and many Linux users doubted that VirtualBox would been implemented so you can move files around
remain open source. But luckily, it still is – although more easily. It’s now possible to scale the output of
there are some closed-source extensions providing the virtual display, so you can shrink it down and leave
better USB support along with RDP and PXE booting. it in the corner of your screen if you’re waiting for a
process to finish and a dialog box to pop up. Or you
Distro-Inception! can start VMs headless, and attach and detach virtual
VirtualBox 5.0 is available as a 60MB download, and displays to them later on.
thankfully, the developers have created packages for Another major update is encryption for the virtual
all the major Linux distributions including Ubuntu, hard drive images. You’ll find this under Settings >
Debian, Fedora and OpenSUSE. If you’re using a General > Encryption, and two AES ciphers are
different distro, however, you can try the .run version supported. This is very handy if you’re working on a
(available in 32-bit and 64-bit editions) which you just confidential project inside a VM but don’t have full disk
need to make executable and encryption on your host OS enabled. Then there’s
run. It’s also worth noting HiDPI support, hotplugging for SATA disks, a new
“The biggest new feature in that VirtualBox runs on other modular audio architecture, and minor updates and
VirtualBox 5.0 is support for OSes as well, such as
Windows and Mac OS X, so if
bugfixes all over the code.
So in all, VirtualBox 5.0 is a mightily impressive
paravirtualisation.” you’re forced to use one of release and genuinely worthy of the major version
those proprietary OSes in number bump. We’ve never had big issues with
your workplace, maybe you’re still allowed to install VirtualBox’s performance (at least, not for the sort of
VirtualBox and get your Linux fix… distro testing work we do), but the speed increases,
The biggest new feature in VirtualBox 5.0 is support scalable display, USB 3 support and disk encryption
for paravirtualisation. Essentially, this enables guest keep VirtualBox competitive with the other options on
machines (ie the OS you’re running inside VirtualBox) Linux. All we can hope now is that Oracle remains a
to work more closely with the real hardware of the good custodian of the project and it will have a healthy
host. With fewer layers of virtualisation and emulation future for the next few years.
between the guest OS and the host machine,
performance should be improved. VirtualBox 5.0 can LINUX VOICE VERDICT
use KVM on Linux for this purpose, or if it’s running on
Bags of new features and performance
Windows, Microsoft’s Hyper-V. Of course, if you’d improvements mean this stays our
rather stick with the normal VirtualBox virtualisation favourite VM.
you can disable this – go to Settings > System and
you’ll find the option under the Acceleration tab.
52 www.linuxvoice.com
DRAWPILE 1.0 REVIEWS
Drawpile 1.0
Ben Everard can’t draw, but he does enjoy scribbling on the internet.
C
ollaborative working via cloud applications is
becoming an increasingly important part of
many organisations’ workflow. There are
plenty of ways to work together to produce text or
code even when you’re thousands of miles away from
your collaborator. Drawpile brings the same sort of
instantaneous collaboration as Etterpad or Google
Docs to artists.
It’s not hard to see that collaboration could work the
same way in this field as it can in others. Concepts
can be sketched out, worked on and discussed by
groups without these groups having to be physically
together. Drawpile supports the Open Raster file
format, which is also supported by other free software
drawing applications such as Krita, so artists can
switch between multiple programs for different stages
in the work’s creation.
Unlike many online collaboration tools, Drawpile
Of course, more artists
doesn’t run in a web browser. Instead it’s a standalone Currently running public sessions are listed on the
doesn’t always mean more
program that acts as both client and server. When project website at http://drawpile.net/servers. quality. This is the result of
you first launch it, you can use Drawpile as you would The brushes in Drawpile aren’t as advanced as 14 artists over 15 hours.
any other raster image editor to open, manipulate those in, say, Krita, but that’s to be expected. This is
and save images. You can then enter a collaboration the first stable release of the software, so naturally the
by either hosting a session or joining one hosted by features aren’t as complete as more mature drawing
DATA
someone else. In a session, all members can edit tools. It does, however, have all the basic tools artists
the image and see the edits made by other people. need including layering and the ability to work with Web
There’s a chat session built into the Drawpile window, Wacom’s stylus devices. http://drawpile.net
Developer
but many people may prefer to use this software
Calle Laakkonen
alongside another collaboration tool such as a Work in progress Licence
WebRTC video chat. Drawpile enables users to record sessions, so that GPL v3
It’s not always possible to host your own server they not only have the finished image, but a record of
because of various restrictions with network setups. how they worked together to create that image.
Drawpile can get around this by letting users host The documentation of Drawpile is particularly
sessions on remote servers. You can also announce impressive given that it’s the first stable release. It’s
public sessions and invite other artists to join you. not only detailed and accurate, but well presented
and easy to navigate, which is something that a lot of
more mature open source projects could learn from.
Head to http://drawpile.net/help to find out how to
use the software.
Overall, we really like Drawpile. It is a little lacking
in features compared to pure drawing tools, but at
the other end of the spectrum, it’s a far nicer drawing
experience than the shared whiteboards that many
video conferencing tools have. It’s easy to use and a
great way of working together with other artists (or
clients) to create pictures.
LINUX VOICE VERDICT
Drawpile is now our favourite way of
scribbling nonsense across the web (it
can also be used for serious work).
Drawpile is easy to use, but there’s still a excellent help
section on the website to help if you get stuck.
www.linuxvoice.com 53
REVIEWS IDE
Geany 1.25
In a never-ending quest for a better programming environment, Ben Everard and his
trusty pet monkey starts rubbing lamps.
T
here are almost as many ways of writing code
DATA as there are programmers. A few hardy souls
Web
still insist that Ed, the Unix text editor, is the
www.geany.org best way to code. Slightly less masochistic than these
Developer are the people who prefer to use a powerful text editor
Enrico Tröger and Geany (such as Vim) with separate compilers, etc. At the
Project opposite end of the spectrum are those who prefer to
Licence
GPLv2 or later
use integrated development environments (IDEs) that
bring everything together in one massive program.
The trick with programming environments isn’t
waiting around for a perfect one that will be all things
to all programmers, but finding one with the right
set of features for your programming style. Geany Geany is more powerful than its interface suggests.
occupies a middle ground.
“Through judicisous use of It’s not a fully featured IDE,
yet it’s more powerful (from
If you want the full features, you’ll need to make sure
you install this as well as the standard Geany package.
plugins you can adapt Geany a programmer’s perspective) Alternatively, you can browse the available plugins and
to your way of working.” than most text editors.
All the basic
just get the ones you want at http://plugins.geany.
org. Once they’re installed, you can add and remove
programmer’s features are plugins via the Tools > Plugin Manager. It’s these
present: syntax highlighting, code folding, integration plugins that really lift Geany above general text editors
with compilers and interpreters, and terminal support and can add features such as a debugger, a pretty
are all present and working for just about every major printer and more. Through judicious use of plugins,
language. Compared to a serious IDE, there’s less you can adapt Geany to your way of working, though
support for managing projects and there’s no GUI the scope for customisation isn’t as large as it is in
builder, while compared to a Vi or Emacs setup, there’s some text editors.
less flexibility in how everything links together.
New in version 1.25 is support for GTK 3. By default, Spread the code
Geany is still shipped with GTK 2, but if you’re using a Geany works on Linux, Windows, Mac OS X and
desktop environment built on the newer toolkit, you several BSDs, so it’s a good option if you want to have
can switch and get an interface that’s more in-keeping the same programming environment on more than
with the rest of your software. one OS. Because so much is built-in, you can have
You can extend the features of Geany via plugins, almost the same experience on every environment.
and there’s a standard set of plugins though this is Geany does its job well, but not everyone will
often included in a separate package in Linux distros appreciate it. If you program a lot and are happy with
(called geany-plugins in many package managers). your programming environment, you’re probably
not going to gain much by switching to Geany. The
limited customisation means that you may have to
adjust the way you work slightly to fit with Geany
rather than the other way around. However, if you’re
new to programming, or only program occasionally,
then Geany is worth a try. The simple interface is ideal
for smaller projects, and the features are easy to use
without having to learn shortcuts or wade through
deep menus. It’s a great compromise between the
complexity of an IDE and a simple text editor.
LINUX VOICE VERDICT
Plugins give Geany the As a programming environment
power to compete with for intermediate and occasional
more complex programmers, Geany is hard to beat.
development
environments.
54 www.linuxvoice.com
GAMES REVIEWS
Middle-earth: Shadow of Mordor
Michel Loubet Jambert finds out if one of the biggest games to land
on Linux meets all the hype and expectations.
W
hen we’re getting critically acclaimed AAA
games like Shadow of Mordor, based on the
huge Lord of the Rings franchise, it’s easy to
forget just how far Linux gaming has come in these
last few years. The story of Shadow of Mordor takes
place between the events of The Hobbit and The Lord
of the Rings, featuring both new and old characters
true to the Middle-Earth canon. The game puts the
player in the shoes of Talion, a Gondorian ranger out
for revenge in a world turned upside-down by Sauron’s
dark forces.
Ironically, story is perhaps Mordor’s weakest area.
The player is immediately presented with a few
somewhat rushed cutscenes and action sequences
where Talion’s sole motivation to avenge his family is
revealed. The player is taken to the action as quickly
Mordor looks great, even
as possible with little backstory, as if the developers though Mordor perhaps pulls it off better. The strategy
on mid-range graphics
have a very pessimistic view of the attention spans elements of the game are the most original and cards, though to get insane
of the millennial generation. Though the game’s plot intriguing of its features, showing the hierarchy of high-res textures you’ll
is coherent and unfolds at a good pace, it continues Sauron’s army evolving as the player kills off captains need some very pricy
to feel rushed and condensed at times. That said, and warlords, engaging in power struggles and hardware.
the voice acting and music make up for a lot of this, planting sleeper agents. Similarly, each encounter with
while well-written and plentiful codex entries draw on an orc leader is unique, with enemy-specific dialogue
the world’s rich lore, providing a lot of much-needed and traits, while encounters make the player feel as if
DATA
context to those who want it. they are having a significant impact on the world. Web
The port itself is excellent, and at the standard www.shadowofmordor.
I smell man flesh expected from a professional porting house. We com
Developer
The combat and game mechanics are where Mordor found no bugs or visual quirks, and performance
Monolith Productions,
really excels. Being able to take on dozens of orcs is at similar levels to what Windows gamers would Feral Interactive (Linux
simultaneously with an impressive fast-paced and get. The visuals are also impressive, and if you’re port)
responsive combat system is incredibly satisfying. fortunate enough to have a high-end card, it’s one of Price
When needing to block an attack, Talion immediately the best-looking games out there. On Nvidia cards, the £29.99
stops any other action and game recommends
focuses on the task at the latest drivers,
hand, and the game always “Shadow of Mordor is a great so players may
seems to do exactly what
the player wants
game that you don’t need to be find themselves
fiddling with PPAs
throughout combat, a Lord of the Rings fan to enjoy.” or compiling drivers
making it feel very fluid. from the Nvidia
There is also a huge variety of abilities and special website to get the most out of the game.
moves which, along with the three available weapons, Shadow of Mordor is a great game which you don’t
provide many different ways of taking on the orcs. The need to be a Lord of the Rings fan to enjoy. It has plenty
game places an emphasis on player choice, and while of innovative features that it pulls off naturally without
all these tools remain at the player’s disposal, it makes them coming off as gimmicks, and while the story
no attempt to shove them down your throat. won’t win a Pulitzer prize any time soon, it does its job
In other areas of gameplay, Mordor draws from an in tying together the incredibly fun gameplay.
array of different genres, incorporating stealth, open
world and strategy elements. The game world is not LINUX VOICE VERDICT
as big as that of other games like Skyrim, but it’s big
A very fun open world game that
enough to get sidetracked in and necessitate fast provides countless hours of gameplay
travel to go to different areas. The stealth is similar and plenty of replay value.
to that of the Assassin’s Creed series, with plenty of
climbing, sneaking and use of environmental objects,
www.linuxvoice.com 55
REVIEWS BOOKS
When sysadmins ruled the earth
Ben Everard wishes someone would put a sysadmin in charge of the trains and get
five nines of them on time.
S
cience fiction, at its best, is an the story, but you should get a good of what
exploration of the very nature of this story is about from the title.
humanity. It’s not about the science, We’re cheating a bit by including this story
but by placing humans in new and unusual in the book review section, since it’s not a
circumstances. We get to imagine what book by itself but a short story. You can get
we would do in a similar setting – the it via the anthology Overclocked: Stories of
dissonance provides the central conflict. the Future Present, or it’s also available as
Perhaps the most unusual circumstance a standalone story in various digital forms
possible is a group of geeks inadvertently from Cory’s website, http://craphound.com/
ending up running the world. When overclocked/download.
Sysadmins Ruled The Earth explores the
relationships and power struggles between LINUX VOICE VERDICT
the people running various datacenters as Author Cory Doctorow
they debate global leadership. Publisher Thunder’s Mouth Press
Google’s data centre queen vies with Price Free
ISBN 978-1560259817
the sysadmin of a bank and hacktivists
to decide the fate of the world using the A fast-paced tale that manages to be both sad
and uplifting, and leaves us wondering whether
ultimate democracy tool of the future: the principals of cyberspace should be applied
Usenet. Through online discussion they try to the real world.
to chart a course for humanity. We can’t say If you like When Sysadmins Ruled The Earth,
much more than this without giving away there are five more stories in this anthology.
The Linux Command Line
Ben Everard could get to work quicker if his bike had a command line
interface and not pesky handlebars.
W
hen you open a terminal and completely cover it. The Linux Command Line
start to type commands, is ideally suited to people who have a little
you’re using the most powerful experience of Linux and are looking to make
computer control system ever created. the jump from graphical use to command
I don’t actually have any proof of that line use. It starts with the complete basics
statement, but I’m pretty sure it’s true. of opening a shell and navigating through
Nothing else has the sheer range of features the filesystem, but if you’re already familiar
that a good Linux install does, and if you’re with this, you can easily skim through the
connected to a deep set of repositories, you first few chapters. By the end of the book,
can always get any more software you need the reader should be familiar with shell
from the same command line. scripting and other more advanced uses of
There is, however, one flaw in the the command line.
command line system: it can be hard to
learn how to use it. Sure, you’ll pick up bits as LINUX VOICE VERDICT
you go along from websites and magazines, Author William Shotts
but unless you make a concerted effort to Publisher No Starch Press
systematically learn, you’ll never fully unlock Price Free or £26.50
ISBN 978-1593273897
the system’s power.
If you struggle with the command line, get this
There are many, many books about the book. It will improve your life.
Linux command line. In fact, it’s such a The best book on Linux you don’t have to buy
complex interface that no one book could (and better than most that you can buy too).
56 www.linuxvoice.com
REVIEWS BOOKS
Practical Electronics ALSO RELEASED…
Graham Morrison finds a guide for building the ultimate synthesizer.
I
f there was one thing we wish they’d
taught us at school instead of Home
Economics, it was some simple
electronics theory. We’ve been playing with
circuit boards and components ever since,
Knowing very
but our lack of any educational rigour and little about
perspective makes it much harder than it electronics The cover
needs to be. Unlike computers, where trial shouldn’t stop image made
and error seldom leads to smoke, playing you building us initially
with electronics is less intuitive, more stuff. think of Bash.
costly and slightly more dangerous. Beyond Legacy Code
This is why Practical Electronics is one of and comprehensive nature of this book Dealing with old code is much more common
the best books we’ve read for a while. It fits that makes it effective, and we have no than starting a fresh project, so it’s surprising
our collective ignorance perfectly, never hesitation recommending this to anyone that there aren’t more titles that deal with this
thorny subject. The book promises to provide
patronising or over explaining a subject, with a little theory and a soldering iron.
nine technical practices that will help any
and covering everything you need to know project head off the problems of old code.
to start hacking circuits like you hack LINUX VOICE VERDICT
Python code. We really like the early parts Author JM Hughes
on background theory, especially as it does Publisher O’Reilly
away with the water flow/pressure Price £26.50
ISBN 978-1449373078
analogy that’s getting long in the tooth,
Not for experts, but for anyone else this is a
and we much preferred the allusion to the comprehensive read and great value.
real physics of neutrons, electronics and
protons. Ultimately, though, it’s the size
We chose this
book purely for
the nice bird
How Linux Works 2nd Edition on the cover.
Graham Morrison finally learns the difference between su and sudo. Creating a Data-Driven Organization
We like to think of ourselves as a data-driven
I
organisation here at Linux Voice. Each month
f there was one book that did more we plough through a LibreOffice spreadsheet of
than anything to help us get into Linux, stories, sales and re-subscriber rates, print
it was Linux in a Nutshell, by O’Reilly. pretty charts and discuss it all in Hangouts.
In the 1990s, it offered a rare insight into What we really need is a C-level chief data.
how the whole thing held together, and
how you could harness the various parts
of Linux to start doing practical things with
your computer. The original Nutshell is still
a classic, but it does read a little like a man
page, which is why this is such a good
alternative. It’s absolutely crammed full of
information, building up from the basics
of layers and the kernel, through the most What happens
important commands, devices, storage when the
and networking. The only things missing are robots. machines build
What’s so good about How Linux Works more machines?
is that while it’s undoubtedly dense, it’s far LINUX VOICE VERDICT 3D Printing with Delta Printers
more readable than the average manual, Author Brian Ward We all think 3D printing is fascinating, even if
and there are plenty of examples to help Publisher No Starch Press it’s still slightly costly. But the technology is
Price $39.95 moving all the time, and it’s worth investing
put the information in context. Even those
ISBN 978-1593275679 some time to understand how things are
with no prior Linux, if they’re patient, will
It’s like having a friendly and experienced changing and how things might improve. Delta
become proficient sysadmins. It’s also sysadmin show you the ropes. printing is one such innovation.
huge (366 pages) and sensibly priced,
making it our go-to recommendation.
www.linuxvoice.com 57
GROUP TEST SEARCH ENGINES
SEARCH GROUP TEST
ENGINES Google may rule the web, but alternatives are worth checking out.
Mike Saunders explores them and shows you some tricks and tips.
On test Search engines
I
n a departure from the norm, it hard to find alternative opinions or
Google we’re not looking at Linux- lesser-known sites, so you end up
URL www.google.com specific software this month, with a lot of confirmation bias.
COMPANY Google Inc. although many of the search Similarly, due to Google’s
LAUNCHED September 1997 engines on test here use Linux in domination of search, many
The best known, but with growing one way or another. But we feel that companies are doing everything
concerns about privacy.
it’s a subject that’s well worth possible to get high up in the list
investigating, as virtually every of results. So you’ll often click
Bing Linux user makes use of a search links that contain nothing of use
URL www.bing.com engine, usually multiple times every except adverts, or simply ripped-
COMPANY Microsoft day. Google has dominated this off content from another site that
LAUNCHED June 2009 market for so long, but times are someone else is trying to monetise.
Microsoft is snapping at Google’s heels, changing, and alternatives are This isn’t so easy for Google to fix,
with almost 20% market share in the US. starting to win attention. but it’s frustrating nonetheless.
But why are people leaving Then you have privacy issues.
DuckDuckGo Google? Doesn’t it simply provide
the best results out there? Well,
By and large, Google has been
one of the better players in the
URL www.duckduckgo.com
historically, that has been the case. industry in this regard, and has
COMPANY DuckDuckGo Inc.
LAUNCHED September 2008 For many years, Google provided fought against mass surveillance
“The search engine that doesn’t track hands-down the best results – and efforts by western governments.
you.” But how good are the actual results? in a clear and fast way. But the Nonetheless: the company makes
situation is rather different today. money from advertising, and stores
Google users often find themselves a huge amount of data from your
YaCy in the “filter bubble”, whereby search habits, browsing history, and
URL www.yacy.net/en Google shows results very much email content (if you use Gmail).
COMPANY YaCy developers tailored to your previous search So if privacy is your number one
LAUNCHED November 2011 (v1.0)
history and websites you’ve visited. concern when searching, you’ll
Built on a peer-to-peer network, this is a
This can be helpful, but it can make want to try other options.
free and distributed search engine.
Wolfram Alpha “Google stores a huge amount of data
URL www.wolframalpha.com
COMPANY Wolfram Alpha LLC
from your search habits.”
LAUNCHED May 2009
More than a search engine, this is a
Different name, same engine
computational knowledge engine for
answering scientific queries. You’ll notice that a few famous names search engine, but now gets results
in search, such as Yahoo and Ask, aren’t from a third-party provider.
Ixquick included in this group test. The reason Similarly, some readers might be
URL www.ixquick.com for this is simple: they’ve outsourced asking why we haven’t covered www.
COMPANY Surfboard Holdings BV their web search facilities to other startpage.com. This is a useful privacy-
companies. Yahoo, for instance, now oriented engine that claims to not store
LAUNCHED March 2005
gets its results from Bing, so apart from any of your data, but ultimately it’s just
A metasearch engine that aims for
its website design there’s not a lot to a front-end to Google Search, so the
maximum privacy. talk about. Ask used to have its own quality of the results is the same.
58 www.linuxvoice.com
SEARCH ENGINES GROUP TEST
Yandex – the next big contender?
Russian search giant is making moves into the English-language market.
W
hat Google is to the huge Although Yandex has been in operation of its results – in case you’re not happy
markets of Europe and the since 1997, it has only recently started with Yandex’s. That’s very nice of them, but
United States of America, Yandex targeting the English-language market with it’s strange for a fledgling company (in the
is to Russia. It’s by far the biggest search a search engine at www.yandex.com. The English market at least) to point people at
engine in that country, with over 60% of the design is clean and tidy, and along with text its competitors. Still, Yandex’s own results
market, and it also hosts additional services search the site also offers image searches are fairly good, and cached versions are
such as email, maps and videos. Yandex and a rather effective translation system. available for many pages, which is useful if
has even produced its own web browser, Intriguingly, Yandex also includes buttons the original site is down or has been moved
based on Google’s Chromium. for Bing and Google searches at the bottom to another location.
Google
Close to the “creepy line”.
I
n October 2010, Eric Schmidt, the
then-CEO of Google, explained his
company’s goals thusly: “Google policy
is to get right up to the creepy line and not
cross it.” In other words, because of the vast
amount of information that the company
collects – from your web searches, image
searches, calendar, email and Google+ posts
– Google should be able to provide you with
information so specific and useful, it
becomes almost creepy in its accuracy. He
added: “We don’t need you to type at all. We
know where you are. We know where you’ve
been. We can more or less know what you’re
thinking about”.
Now, plenty of people found this useful at
the time; if you’re willingly giving information Google’s data-harvesting capabilities sometimes give us the creeps, but the company makes it easy
to Google, there’s nothing wrong with to opt out of them.
the company parsing it, poking around
in it, and trying to make your life better history and so forth). It also lets you disable particularly descriptive term anyway. From
with it, right? Unfortunately, following the adverts based on your interests – or here, the bubble shouldn’t affect your results.
Snowden revelations of mass government more specifically, what Google thinks your The second annoyance we have is with
surveillance, and the use of government interests are. unrelated results that don’t contain the
force to secretly extract information from words we specify, even when we provide
companies in the name of “terrorism Bubble bobble them in quote marks to search for an exact
prevention”, many people have become a We have two main beefs with modern phrase. You need to click Search Tools >
lot more cynical. Google – along with other Google, the first being the “filter bubble”. Just All Results > Verbatim to actually retrieve
companies – has joined campaigns to recently, as the Linux Voice team was talking results for what you’re looking for. This
reduce the levels of mass surveillance, and on our IRC channel, we saw this in action: becomes very tedious after a while.
wants to make it very clear when it is forced one of us noted that a certain search put On the whole, Google still offers the
to hand data over to the spooks. Linux Voice right at the top of the results, but most comprehensive set of results when
One problem Google has is the sheer on another team member’s machine, it was you fiddle with its default settings, and the
number of services that it operates. So we’ll much further down. integration between its services is excellent.
give the company some kudos for creating Now, it is possible to prevent this from
a “Privacy Check-up” page at https:// happening, but it’s rather fiddly. You have to VERDICT
myaccount.google.com/privacycheckup, go to Google’s front page for your language Still the best for results,
but by default it’s lacking
which provides an at-a-glance list of things (not a search result page), then click in terms of privacy and
you may want to turn off (web search Settings > History. From there you disable power-user options.
history, location history, YouTube video “Signed-Out Search Activity”, which isn’t a
www.linuxvoice.com 59
GROUP TEST SEARCH ENGINES
Wolfram Alpha
More than search – it’s a computational knowledge engine.
W
olfram Alpha isn’t a direct The site is also excellent for
competitor to most of the performing comparisons between
search engines on test here, things. Enter “Paraguay vs Uruguay”,
in that you wouldn’t use it to find a for example, and you’ll receive a vast
decent curry house in a town you’re amount of data comparing the two
going to visit. Instead, it’s all about countries’ geographies, economies,
performing comparisons between huge demographics and so forth. You
sets of data. For instance, if you search can narrow down to specifics with
Google for “tallest buildings in Japan”, “Paraguay vs Uruguay GDP” and
Google will try to find a relevant page get more detailed information, often
for these words – in this case, some accompanied with graphs generated
pages on Wikipedia. on the fly. And right at the bottom, you
Wolfram Alpha, in contrast, will try can see the sources for this data: the Wolfram Alpha taps data from a vast number of sources
to make more sense of the words and UN, the WHO, World Bank etc. and is great for making comparisons or charts.
look at its own data sources. Its 10,000 Wolfram Alpha can do incredible
CPUs chug away to process statistics work, but it can be quite tricky to use showing how to harness all the maths,
stored in its database, and present you properly. Fortunately, the developers statistics, history, nutrition and other
with useful results without having to have created a broad set of examples data that the website provides:
direct you to another page. It can also www.wolframalpha.com/examples.
perform calculations itself, so you can
use a query like “days until Christmas “Wolfram Alpha is all about VERDICT
2017”, and Wolfram Alpha will show performing comparisons Takes time to master, but
between huge sets of data.”
fantastic for research and
you the result and related queries investigation.
(number of weeks, weekdays etc).
YaCy
“Web search by the people, for the people.”
W
hile Google, Bing and co. are if you want to try it yourself without
centralised search engines booting up the software, a demo search
– in other words, they’re portal is available at http://search.yacy.
operated by single companies from a de. And here’s the downer: the search
bunch of datacentres – YaCy is a results are rather bad. “Linux Voice”
distributed engine, which relies on brings up several completely irrelevant
contributions from users around the results, followed by a Slashdot story
world. It’s decentralised, so anyone can about the magazine, but our actual
contribute computing power to it by main website doesn’t appear until the
downloading the software and hooking bottom of the page.
up with the other 600+ nodes that are
crawling the web and generating Potential
indexes of content. YaCy is written in Now, the YaCy community is rather YaCy’s results page is a bit cluttered, but the “provider”
Java with no other dependencies, so it’s small at this stage and doesn’t have the links on the left can come in useful.
fairly quick and easy to get it up and vast resources of Google and Microsoft,
running: just run the program and so this is to be expected. You wouldn’t resources to it, but for now we consider
access it via the web-based interface at want to use YaCy for your daily queries, it more of an intriguing tech demo
http://localhost:8090. but it’s a noble project nonetheless, rather than something for practical
YaCy can be used to provide search especially as it promises to be resistant day-to-day usage.
facilities for a local network such as against widespread censorship and
an intranet, but here we’ll focus on centralised advertising campaigns. VERDICT
Plenty of promising tech
its capabilities as a web-wide search YaCy could be a major player in search in here, but the results
engine. Currently it receives around a few years down the line, if more and leave a lot to be desired.
130,000 search queries every day, and more people contribute their computing
60 www.linuxvoice.com
SEARCH ENGINES GROUP TEST
Bing The future
Microsoft has its fingers in many pies.
of search
Out with the reactive, in
with the proactive.
W
hile the traditional search engine
won’t go away any time soon,
Google, Microsoft and others want
to feed you with information you ostensibly
need – without you having to explicitly look for
it. To some extent this is already available
today with Google Now and similar services,
which pull together all your contact, calendar
and location data, and try to present you with
relevant information on the move.
As an example: Google claims that 30%
of mobile searches are restaurant-related.
If Google knows where you are from GPS
coordinates, who you’re meeting from your
calendar entries (business or personal), and
where you’ve been before, it can suggest
It’s very clear that Microsoft hasn’t tried to game the suggestion box when you type “Bing is”… places to eat without you having to look them
up. And this is a boon for advertisers – on a
B
ing may be a relatively new player clear why Microsoft removed it, but it puts dull, rainy evening when you have nothing to
in the search engine market, Bing way behind Google for certain types do, they can suggest events and things to see
having been launched in June of searches. and do nearby.
2009, but Microsoft has been involved in
this field for many years, starting with “Bing is for doing” Rage against the dying of the search!
MSN Search in 1998. At the start, Bing Results-wise, though, Bing is catching up But, of course, this is all at the expense of
distinguished itself from Google by having with Google. We tried dozens of searches privacy. Some people will love this level
a fancy front page (with large background across all sorts of categories – food, of integration between different services,
images showing places around the world) travel, technology etc – and rarely did we whereas others will run a million miles in
and a slightly cheesy slogan: “The sound see any great differences. the opposite direction. Many of us will just
of found”. Microsoft marketed Bing as a Bing has various advanced features want to use search engines as they always
“decision engine”, claiming it would such as the ability to search for pages were, anonymously and outside of a filter
provide more relevant results than the on a specific URL with “site:”, or show bubble, and those people will find challenges
competition along with tools to narrow results that only match a specific filename up ahead. Websites are constantly cropping
down searches. extension. Bing also caches many pages, up supposedly offering useful data (actually
Today, Bing has around 20% market which comes in useful. copied from elsewhere) and loaded with
share in the US – a respectable figure, For most users, Bing offers everything annoying adverts, and it’s a constant battle for
although it must be noted that Internet available in Google, and it even looks Google et al to sort the wheat from the chaff.
Explorer, while not as dominant as it was, remarkably similar. We’ll give Microsoft
is still used on a vast number of Windows credit for producing good results, but
installations and has Bing set as the while the company (or at least parts of it)
default search engine. Bing also offers is still hostile to Linux and FOSS, we can’t
image searches and rather good maps. recommend it in good conscience just yet.
By default, Bing keeps a history of your And while privacy is a hot topic, we would
web searches, even if you’re not signed be happier if Bing let new users know that
in; it’s possible to disable this by clicking it stores their search history with a big
the cog icon in the top-right. One useful pop-up, along with information on how to
feature that Bing lacks and which Google disable this “feature”.
has, however, is the ability to narrow down
results to a certain period of time. You can VERDICT
Approaching Google for Search companies are trying to be all things to all
narrow down by language and location, results quality, but still people; here’s hoping they don’t forget the basics.
but not to specific dates. Bing did have with issues about privacy.
this facility a few years ago, and it’s not
www.linuxvoice.com 61
GROUP TEST SEARCH ENGINES
DuckDuckGo vs Ixquick
Two privacy-oriented engines go head-to-head.
D
uckDuckGo is the better known
of these two engines, and
proudly proclaims that it helps
you to “take back your privacy”, because
it doesn’t track you. However, that
doesn’t mean that the search engine
doesn’t store any data – indeed it does,
but not in a “personally identifiable
way”. So whereas Google stores all
search terms along with the IP
addresses from which they were sent,
DuckDuckGo only stores the former
and uses it to improve results. Similarly,
DuckDuckGo doesn’t save any cookies
by default, and only if you change the
default settings.
Out of the box, DuckDuckGo’s results
page is one of those infinitely scrolling
beasts, which rather annoys us. Still,
you can turn this off by clicking the
three-line “hamburger” icon in the
top-right, which also lets you disable
safe search, narrow results down to DuckDuckGo’s “bangs” are a killer feature of the engine, and can search via 6,000 other websites.
a particular region, and even disable
advertising. DuckDuckGo just asks that other sites – so you can do “!g Linux strives to collaborate with the open
you spread the word about the website Voice” to search for Linux Voice on source community via
if you do the latter. Google, “!r” for Reddit, and so forth. http://duckduckhack.com.
DuckDuckGo offers a huge range of There are over 6,000 bangs currently
“!bang” features for instantly searching available, and the DuckDuckGo team The Ixquick alternative
Ixquick is a similar service that doesn’t
record your IP address with your
searches, and only uses a cookie to
store your preferences. One nice touch
is its ability to auto-generate a URL
with your preferences encoded in the
string, so if you don’t even want the
anonymous cookie, you can still keep
your search settings.
Ixquick has a useful proxy server,
with links provided next to each result,
so you can view a page indirectly
using Ixquick’s own servers. This
isn’t a foolproof way to anonymously
access a website, but it’s another little
bit of privacy and it all adds up. Ixquick
isn’t a bad server per se; it’s just that
DuckDuckGo has more power user
features thanks to the bangs, and a
more proactive approach to FOSS.
VERDICT
DUCKDUCKGO IXQUICK
Rapidly improving, and Some good privacy
becoming our features, but results
favourite. aren’t fantastic.
Ixquick makes it easy to visit pages via a proxy, which adds another layer of anonymity.
62 www.linuxvoice.com
SEARCH ENGINES GROUP TEST
OUR VERDICT
Search engines
M
any of us in the FOSS and especially the FOSS world,
world have been keeping is worthy of a thumbs-up. A lot
one eye on DuckDuckGo of code has been uploaded to
in the last few years, but we’ve https://github.com/duckduckgo,
usually come away slightly for instance, and the whole engine
disappointed due to the low quality is run on a mixture of Ubuntu and DuckDuckGo has it all: good results, privacy, and user-contributed
of the search results. Well, those FreeBSD, with Nginx doing the web power searches.
days are gone now. Google is still serving. DuckDuckGo has also
the king when it comes to the most
accurate and relevant results, but
handled the extra load placed on it
in recent years – its traffic has shot
1st DuckDuckGo
Alexa Rank 520
Bing and DuckDuckGo are very up 600% since the Snowden leaks
much providing competition. came to light. www.duckduckgo.com
DuckDuckGo is now usable as So DuckDuckGo is the winner Rapidly improving, with lots of hidden feature gems and a good
a day-to-day engine: the quality of this month, and we recommend privacy policy.
its results is improving with every that everyone gives it a try. Ixquick
month, it’s very easy to integrate has some privacy benefits too, and
it with Firefox or Chromium, and its Bing is worth a shot if you just want
2nd Wolfram Alpha
privacy policy is respectable. Of to escape from Google’s mighty Alexa Rank 1,932
“The quality of DuckDuckGo’s results
www.wolframalpha.com
If you’re doing any kind of research and need to compare
is improving with every month.”
statistics, this should be your first stop.
course, DuckDuckGo is still based talons for a while. But for the overall 3rd Google
in the USA, which poses its own best mixture of search results, Alexa Rank 1
set of privacy issues (we don’t privacy and advanced features,
www.google.com
know what happens when the DuckDuckGo takes the top spot. Excellent results, but becoming frustrating to use, and tries to
government comes knocking on And in all honesty, that’s something put a filter bubble around you.
its door), but assuming its privacy we never thought we’d say six
policy is 100% legitimate, your months ago – the engine has
searches won’t be leaked. come on in leaps and bounds, so if 4th Bing
Additionally, DuckDuckGo’s you gave it a go before but weren’t Alexa Rank 27
interaction with its community, satisfied, give it one more shot.
www.bing.com
Our old nemesis Microsoft is catching up with Google, but also
Privacy-centric email has issues with privacy.
Google and Bing both have email mailbox. This means that you can use
services to complement their search it as webmail without having to set up
engines, and rumours abound that a local email client and fiddle around 5th Ixquick
DuckDuckGo will eventually launch an with GPG keys, but it also means that
email service as well. The premise here you have to trust that you’re being
Alexa Rank 9,858
is simple: your email should only be served the right JavaScript each time
www.ixquick.com
readable by you. This means that the you access your mailbox (eg it hasn’t
A mixed bag when it comes to results, but has some decent
company providing the email service been intercepted and modified by a
features for privacy and anonymity.
can’t poke around inside your messages third party). Still, it’s a start. Some other
and deliver relevant advertising, so it’s services worth looking at include:
a thorny topic when it comes to free CounterMail: https://countermail.com.
providers. But a number of startups are Neomailbox: www.neomailbox.com. 6th Yacy
offering end-to-end encrypted mail for Mailpile: www.mailpile.is. Alexa Rank N/A
free, with paid add-ons. Many of these are relatively new and
Protonmail (http://protonmail.com), only open to invitation while they build www.yacy.net
for instance, is a Swiss-based provider up their infrastructure, but if you’d like Not usable on a day-to-day basis, but could revolutionise web
that uses a dual password system – us to cover them in a future group test, searches one day.
one to log in, and one to decrypt your just drop us a line.
www.linuxvoice.com 63
SUBSCRIBE
SUBSCRIBE shop.linuxvoice.com
Introducing Linux Voice,
the magazine that:
Gives 50% of its profits
back to Free Software
Licenses its content
CC-BY-SA within 9 months
12-month subs prices
UK – £55
Europe – £85
US/Canada – £95
ROW – £99
7-month subs prices DIGITAL
UK – £38 SUBSCRIPTION
Europe – £53
US/Canada – £57
ONLY £38
ROW – £60
Get 114 pages Access our Save money on
of tutorials, rapidly growing the shop price
features, interviews back-issues archive and get each issue
and reviews – all DRM-free and delivered to
every month ready to download your door
Payment is in Pounds Sterling. 12-month subscribers will receive 12 issues of Linux Voice a year. 7-month
subscribers will receive 7 issue of Linux Voice. If you are dissatisfied in any way you can write to us to cancel your
subscription at subscriptions@linuxvoice.com and we will refund you for all unmailed issues.
64 www.linuxvoice.com
NEXT MONTH
NEXT MONTH IN
ON SALE EVEN MORE AWESOME!
THURSDAY
Inside ORG
24 SEPTEMBER Meet the people who
are trying to
persuade the UK
government not to
sell our digital rights
to the highest bidder.
Keep up the good
work, team.
Blender
Model collisions in
3D, use crazily hard
maths and impress
everyone you know
by mastering the
most powerful
graphics known to
Free Software.
Two-factor
THE BEST LINUX DESKTOP
authentication
Keep your secrets
safe with a
Discover the finest graphical glitz available password and a key,
right now for your humble Linux machine. and never worry
about leaving
confidential files on
the bus ever again.
LINUX VOICE IS BROUGHT TO YOU BY
Editor Graham Morrison Editorial consultant Nick Veitch through the use of advice in this magazine. Copyright Linux is a trademark of Linus
graham@linuxvoice.com nick@linuxvoice.com Experiment with Linux at your own risk! Torvalds, and is used with permission.
Deputy editor Andrew Gregory Distributed by Marketforce (UK) Ltd, Blue Anything in this magazine may not be
andrew@linuxvoice.com All code printed in this magazine is licensed Fin Building, 110 Southwark Street, London, reproduced without permission of the editor,
Technical editor Ben Everard under the GNU GPLv3 SE1 0SU until May 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
CORETECHNOLOGY
CORE
Valentine Sinitsyn develops
high-loaded services and
teaches students completely
unrelated subjects. He also has
a KDE developer account that
TECHNOLOGY
he’s never really used. Prise the back off Linux and find out what really makes it tick.
Daemons
Reveal the dark world of things that usually slip unnoticed behind luxury GUIs of Linux distros.
T
he first scary thing that Windows Daemons are typically written in systems the Unix Environment (APUE) by W Stevens
converts usually learn about Linux is programming languages, with C and C++ and S Rago. Another good reference is the
that it doesn’t have disk C:. The next being the most common choices. However, daemon(7) man page. Note that the steps
one is arguably that it has that mystical nothing prevents you from using Python or are slightly different in both resources.
daemon thing. A typical example is crond: it even more exotic languages like Erlang. Again, a daemon is merely a set of
sleeps most of the time, but wakes up once conventions, and there’s more than one way
a minute to execute periodic tasks. Why on Daemons in a nutshell to follow them.
the Earth would you use a haunted OS? When you execute a command, the shell Daemons need a clean predefined
In fact, Linux daemons are just long-living normally forks a new foreground process environment to run, so usually the first step
background processes that follow a set of (see LV018). It inherits many of the shell’s is to create one. First, umask must be reset.
conventions. By convention, This ensures that the files the
their names end with a letter “d”
to distinguish them from regular “Daemons are typically written in daemon creates will have the
exactly those permissions it
processes. Just a decade ago, systems languages, with C and C++ expects. Signal handlers are also
you were mostly on your own
if you wanted to implement being the most common choices.” normally reset to their default
state. Selected signals like
daemons properly (although SIGHUP are assigned custom
there were helper libraries available). resources, for instance, the controlling handlers later.
Now, with Systemd, Upstart, and friends, terminal. This can be a real device that the The first “real” step is the fork(2) syscall,
boilerplate code is reduced to a minimum. user logged from, or a pseudo terminal which serves two purposes. First, the parent
created by xterm or ssh. Everything you type process can now exit, tricking the shell into
goes to the process; everything it writes is thinking that the command has completed.
Controlling terminal sent to the terminal. If you press Ctrl+C, the Then, it ensures the child won’t be a
process receives the signal (SIGINT) and process group leader. Process groups are
Signals terminates. When the controlling terminal is subdivisions inside a session used mainly
closed, the process receives SIGHUP which for signal delivery and job control. We won’t
also terminates it, by default. discuss them here, but you can find all the
Session 8174 Daemons are a bit different. They break details in APUE.
Session leader
the ties with whatever gave birth to them to “Demoting” the child is essential for
bash Foreground
be as self-contained as possible, because the later step. The daemon must lose its
process group
find/ I less the daemon can last much longer than its controlling terminal. To do that, it creates a
Background
process group parent. So it shouldn’t be run on a filesystem new session with no controlling terminal and
make -j & that the user may want to unmount, or becomes its session leader. The setsid(2)
keep open file descriptors for the same syscall does exactly this, but succeeds only
reason. Neither should it send anything to if the process isn’t a process group leader.
Session 4727
the terminal as the user can log out shortly Some recipes even suggest two fork()s so
after starting the daemon. Signals are also the daemon can’t re-acquire the terminal,
handled differently; for instance, SIGHUP is but it’s not strictly necessary.
Roughly, here’s the relationship between often used to reload configuration files. At this point, the daemon is already
process groups, sessions and several other Steps for proper daemonisation are running standalone. Now, all file descriptors
terms you’ll encounter. detailed well in Advanced Programming in are closed, except 0, 1, and 2 (standard
66 www.linuxvoice.com
CORETECHNOLOGY
input, output, and error), which are redirected
to /dev/null. The easiest way to achieve
this in Linux is to iterate over /proc/self/fd.
Portable code can’t rely on it though, so it’s
common to iterate up to getrlimit(RLIMIT_
NOFILE), or the highest file descriptor
number available. Finally, the daemon’s
working directory is changed to / or
another location on a known unmountable
filesystem. Optionally, a daemon can also
disable core dumps to prevent the leakage
of sensitive data.
Daemons don’t have to run as root except Iterating over /proc/self/fd is a convenient way to know which file descriptors are open in a process.
when they do privileged operations. The
common case is binding to a network port Pid files are sometimes created with a if (daemon(nochdir, noclose) != -1) {
below 1024, or writing to a system-wide write lock. This ensures atomicity: only one postinit_daemon();
location such as /run (see below). Usually, process can hold such a lock at any one run_daemon();
daemons do this during initialisation and time. So, only one daemon instance can } else {
drop privileges afterwards. Many daemons be started. This is not the only possible /* Check errno, handle error and exit */
have their own designated user (such as approach, though. Many daemons opt for }
www-data for Apache’s httpd), or run as simpler ways, like opening the pid file with }
‘nobody’, which is essentially the same. This an O_EXCL flag. daemon(3) accepts two Boolean
limits potential negative effects in case the arguments. The first of these, nochdir,
daemon appears to be vulnerable. A bit of C code prevents it from changing the current
That’s enough theory – let’s practice a bit. working directory to /. The second, noclose,
Are you alive? Writing portable daemonisation code that prohibits redirecting standard input,
Quite often, only one instance of a daemon runs across Unices is somewhat non-trivial. output and error to /dev/null. The function
can run at a time. So, a mechanism for Luckily, there are some helpers (albeit with automatically calls exit(2) for the parent
mutual exclusion is needed. In Windows, it caveats). The GNU C Library (glibc) provides process, so error-handling appears in the
would be a mutex, and if we were to follow the daemon(3) function, which already does child only. Keep this in mind because it may
this route, we could also use a semaphore forking, creates new sessions, changes the already have no terminal to print the error
(covered in LV015). However, historically current directory to / and redirects standard message on.
Unix had another, much simpler tool for this input, output and error to /dev/null. It’s Note that daemon(3) neither closes file
job – a pid file. non-standard (although BSD systems have descriptors, nor resets umask or signal
A pid file is just a text file with a known it as well), so you can’t rely on it in portable handlers. Pid files are also your duty. Indeed,
name, which contains the daemon’s PID. If it code. Also, daemon(7) advises against the function is quite straightforward and
exists, the daemon is either running or was using it as it doesn’t produce a proper encompasses fewer than 50 lines of code
shutdown uncleanly. In the former case, you System V daemon. But again, sometimes it’s in the glibc 2.21 release. So, the postinit_
can do kill -SIGHUP $(cat /run/daemon. more than enough. daemon() should take care of these details:
pid) to send the daemon a signal. This is how your daemonisation code may #include <signal.h>
Traditionally, pid files used to live in /var/ look like: #include <stdio.h>
run. Newer Linuxes switched to /run, as /var #include <errno.h> #include <string.h>
was often unavailable during early system #include <unistd.h> #include <sys/types.h>
initialisation steps. The Filesystem Hierarchy #include <sys/stat.h>
Standard (FHS) 3.0, now current, made int main(int argc, char **argv) #include <fcntl.h>
it official. In your distribution, /var/run is {
probably a symlink to /run. int nochdir = 0, noclose = 0; #define PIDFILE_PERMS (S_IRUSR | S_IWUSR |
S_IRGRP | S_IROTH)
Leaving traces
void postinit_daemon()
Daemons are non-interactive, but they also need closelog(3) functions are used to send messages {
your attention from time to time. When this to a syslog flavour listening on /dev/log Unix struct sigaction sigact;
happens, they usually send a message to the socket (LV015).
struct flock lock;
system log. The log level indicates when an action New-style daemons unify these mechanisms.
on the administrator’s side is required immediately, They just print log messages to stdout/stderr, char buf[32];
or the daemon merely informs him of some event. whether it is real or intercepted by Systemd as int fd;
Old-style daemons usually use two logging per the StandardOutput= parameter in unit file
mechanisms. If they run in foreground, the or system-wide settings. Log level is encoded /* Clear the umask */
messages are sent to the console, and sometimes in square brackets at the very beginning of the
umask(0);
logs are made more verbose automatically. In message itself (<0> This is an emergency!), much
background mode, openlog(3), syslog(3) and as it is done in the Linux kernel.
/* Assign signal handlers */
www.linuxvoice.com 67
CORETECHNOLOGY
manager protocol, and can be used with
with. To make a daemon, you created an
instance of DaemonContext configured the
way you want, and then run your code under
it:
import daemon
with daemon.DaemonContext():
# call your main() function
You can try it and see that the empty
non-configured DaemonContext is already
usable, as python-daemon provides
sensible defaults for all parameters. But
there are many adjustments available as
With ps(1), you can easily see which sessions and process groups exist on your system. Note that well:
a shell is usually the session leader. import signal
from lockfile import pidlockfile
sigact.sa_handler = reload_config; well. It will also have `0644` permissions,
if (sigaction(SIGHUP, &sigact, NULL) != 0) { as the third argument to open(2) dictates. daemon_context = daemon.DaemonContext(
/* log error and exit */ That’s why resetting umask is important: pidfile=pidlockfile.PIDLockFile(‘/run/coretechd.
} otherwise, actual permissions could differ pid’),
... from what we set here. signal_map={
Here, we reset umask and assign SIGHUP Then we request a write lock to a whole signal.SIGTERM: cleanup_and_exit(),
a custom handler that re-reads the config. file with fcntl(2). If the file is already locked signal.SIGHUP: reload_config(),
In many real-world cases, reload_config() (which means another daemon instance },
would merely set some flag. The main loop is running), the code complains and exits. chroot_directory=’/var/lib/coretechd’
(not shown here, but discussed in LV016) will As noted above, locks are not the only )
check it periodically, and reload the config if option. However, they have some benefits. Here, we specify a custom pid file and
the flag is raised. Generally, you should avoid When a process exits, the lock is released signal handlers, something you would have
signal handlers containing heavy logic such automatically, so if the pid file exists but to do yourself in plain C code. Note this
as reading and parsing files. is unlocked, we know it’s stale. Finally, the is done in a declarative manner: you say
The rest of the function creates a pid file: file is truncated to discard possible leftover what you need, and it’s up to the library
... contents, and the new value is written. to implement how to do it. Unfortunately,
fd = open(“/run/coretechd.pid”, O_RDWR | O_ As you see, creating daemons this way due to the way that pylockfile 0.10.2 is
CREAT, PIDFILE_PERMS); involves a decent dose of elbow grease. implemented, multiple daemon instances
if (fd == -1) { may still hang around.
}
/* Likely insufficient permissions. */
“Love it or hate it, but it looks like The chroot option sets /run/
lib/example as a root directory
Systemd is here to stay – even in for the daemon. Chroots are good
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
Ubuntu, the motherland of Upstart.” for limiting what the daemon
can access on the filesystem.
lock.l_start = 0; For this reason chroots must be
lock.l_len = 0; We’ll learn some ways to reduce boilerplate self-contained, as there ‘s no easy way for a
if (fcntl(fd, F_SETLK, &lock) == -1) { in the next few sections. daemon to call a command or load a library
if (errno == EACCES || errno == EAGAIN) { from the outside. For instance, many FTP
/* Already locked: complain and exit */ A Python way servers chroot into an FTP directory tree,
} Remember I told you that C is not the only which is why you spot /bin/ls in FTP listings
} choice for writing daemons? You can do it in occasionally. Note there are still ways to
ftruncate(fd, 0); Python if you wish, and as with many things escape the “chroot jail”, so this is not a
snprintf(buf, sizeof(buf), “%lu\n”, (unsigned long) in Python, it’s usually simpler. In fact, security measure (as some may tell you).
getpid()); Python’s standard daemonisation interface You should really have a look at PEP-
write(fd, buf, strlen(buf)); is in PEP-3143, and a reference 3143: it’s short, concise, and provides a
} implementation is also available from PyPi good summary of what a well-behaved Unix
Note that we ignore some errors for as python-daemon. Together, they provide a daemon is. A useful read even if you’re not
brevity reasons (don’t do this in real code!). high-level interface that hides much of the going to code your next daemon in Python.
open(2) creates the file, which can fail if the grunt work needed to produce a well-
daemon’s user has no write permissions to behaved Unix daemon. New-style daemons
/run. The assumption is that the daemon python-daemon is centred around the Now you have some understanding of how
runs as root while executing this function, DaemonContext() class. As the name to write a daemon. The truth is you don’t
so the pid file will be owned by root as suggests, it implements Pyhton’s context need to do it in modern Linux. With newer
68 www.linuxvoice.com
CORETECHNOLOGY
initialisation systems like Upstart or Systemd,
all you have to do is to make a simple Ad-hoc daemonisation
terminal application, and they handle the Imagine you started a command and expected it to to the command prompt. Now, make the command
rest. You get a clean environment to run run for a minute. Now imagine that it spent half an a background job with bg. Finally, run disown -h
your code and can focus on your application hour working and you realised that you needed to %job_id, where job_id is what bg returned. This
logic instead of implementing infrastructure close your laptop and move to another place. What removes the command from the shell’s job list, so
should you do not to lose your work? it won’t get a SIGHUP when the terminal will be
things like logging.
Effectively, you want your command (a closed.
Love or hate it, but it looks like Systemd is foreground process) to become a daemon. There Note that if you anticipate that the command
here to stay. Even Ubuntu, the motherland are several recipes, but we’ll discuss one. First, will last for long from the beginning, using tmux or
of Upstart, made a switch with its 15.04 press Ctrl+Z to pause the command – you’ll return screen will probably be a better alternative.
release. The approaches to new-style
daemons are quite similar in both systems,
but the syntax is (of course) different. Given [Service] boot. If the daemon terminates uncleanly,
these facts, we’ll focus on Systemd here; Type=simple Systemd will restart it automatically.
you can easily adapt to Upstart, should you ExecStart=/usr/sbin/coretechd There are some caveats, though. First,
need it. Restart=on-abort your daemon must not fork. In fact, it
Systemd operates daemons as units. shouldn’t be a daemon at all: it should be a
Units are described in INI-style text files, [Install] regular program. Many daemons provide
and administrator-created units are stored in WantedBy=multi-user.target a command-line switch (often called -f) to
/etc/systemd/system. Many unit types are Surprisingly, that’s already enough for enable foreground mode; use it, if possible.
supported; for daemons, you need a .service Systemd to daemonise your code. ExecStart For daemons that absolutely need to
unit. Try this: is a command to execute when starting the fork, use Type=forking and PIDFile=/run/
[Unit] daemon. WantedBy effectively makes it a coretechd.pid, so that Systemd knows which
Description=Core Tech example daemon soft dependency for a multi-user (or normal) process to track.
Now, you can start your daemon with
systemctl start coretechd and grep the logs
to see if it succeeded:
$ sudo journalctl -b _SYSTEMD_UNIT=coretechd.
service
-- Logs begin at Thu 2013-09-12 00:28:54 YEKT, end
at Tue 2015-07-07 00:58:06 YEKT. --
Jul 07 00:53:52 y550p coretechd[8291]: Hello from
a new-style daemon!
This log entry comes from the ordinary
printf(3) (see the boxout).
The approach shown here isn’t optimal.
It’s just simplest for the code not written
for Systemd specifically (hence the name).
Tighter integration opens many more
possibilities like socket or bus activation, but
discussing it would take us too far from the
topic of general daemonization. However, if
you feel Systemd is worth a Core Tech of its
Should you ever need to write an Upstart job, Upstart Cookbook has everything you’ll need to know. own, please drop us a line.
Command of the month: daemon(1)
Systemd and Upstart aren’t the only ways to command-line: While this works, it’s not the way you
“automagically” daemonise your code. A daemon --respawn --name coretechd --chdir / \ usually create daemons. Most of the time,
small tool creatively named daemon (http:// --pidfiles /run --umask 0 \ they are started on boot with an init system.
libslack.org/daemon) does the same, and --stdout daemon.info --stderr daemon.err \ For System V init, this means the daemon
plays well with plain old System V init. /usr/sbin/coretechd needs an init script to be placed in /etc/
daemon(1) starts the command you This creates a single named daemon init.d. The good news is that daemon
choose in a well-defined environment, instance and stores its PID in /run/coretech. comes with the template, and adjusting it
restarts it if necessary, and captures its pid. The daemon’s standard output is sent to your needs is usually a matter of setting
output as logs. It’s highly configurable and to syslog as info messages. If the daemon some variables. daemon(1) is arguably a
you can also use it to manage the daemon crashes, it is restarted (--respawn) and the preferred way to daemonisation if you can’t
or check its status. Here is an example error is supposedly logged (--stderr). rely on Systemd or Upstart.
www.linuxvoice.com 69
FOSSPICKS
FOSSpicks Sparkling gems and new
releases from the world of
Free and Open Source Software
Our editor Graham Morrison is a fearless explorer of the internet – look,
he’s found some excellent Free Software on his travels!
CLI news feed
hnwatch
T
he internet is so full of for your browser. But browsers are
distractions that we’re evil tools of distraction. They make
contemplating leaving it impossible to have only a single
pervasive data behind and founding tab open. hnwatch is the answer, at
a disconnected commune in the least until you find a story you want
Garonne, purely to preserve our to read. You run it from the
sanity and some meaning to life. command line and it fills your
However, there are still a few terminal with the latest or top
online bastions of collective Hacker News stories in real time, as
wisdom, and one of these is Hacker they move up and down the
News (https://news.ycombinator. hierarchy. You can click on links to
com). Despite a few bumps along open them in your default browser,
the road, Hacker News has mostly or read the comments directly from
been able to maintain both a high the command line.
quality of linked content and
comments for several years, PROJECT WEBSITE Don’t open that browser! Access your favourite Hacker News
https://2ton.com.au/hnwatch
making it a worthwhile destination stories from the command line instead.
Secure group chat
sshtalk
W
hile perusing the site of and build the assembler framework,
the developer, Jeff which adds to the complexity. But if
Marrison, who created you want to connect to the server,
‘hnwatch’ above, we found another you don’t need anything other than
little nugget written in the same the humble SSH itself. Just ssh to
Turbo Assembler-alike code. It’s a the server address and you’ll see a
great little utility that can turn any banner screen followed by a login
SSH server and client into a secure window. You don’t need an SSH
chat server, a little like IRC but account, but you can create a new
without the configuration files. chat account from this login
The huge advantage that sshtalk prompt, after which you’ll be
Hand-crafted assembler
has is that it uses SSH’s perfect dropped into the chat interface tools like hnwatch and room name. All the Ctrl commands
forward secrecy, protecting your itself. You need to first connect or sshtalk feel like the are listed in below the buddy view
communication with the same join a room, so you’ll need someone products of a computing on the right. You can also create
heavyweight encryption protocols else to invite you or tell you the artisan movement. rooms easily with Ctrl+J, after
as SSH itself. It’s also easy to run, which you can chat away without
attaching itself to port 4001 on your worrying about security or setup.
server after simply executing the “sshtalk can turn any SSH server
binary. If you want to build these
tools yourself, you’ll need to grab
and client into a secure chat server.” PROJECT WEBSITE
https://2ton.com.au/sshtalk
70 www.linuxvoice.com
FOSSPICKS
NAS distribution
Rockstor
T
here are several great installation has completed, reboot
network attached storage your system and connect to the IP
distributions, enabling you address of the machine (the IP
access your files from anywhere. address is output on the console of
But Rockstor is the first we’ve seen the server). You now need to create
to specifically take advantage of the an account, if you hadn’t at install
features found in Btrfs. Btrfs, or the time, and log in. The first time you
B-tree filesystem as it’s sometimes do this, you’ll likely be prompted to
known, is finally considered update your installation. Rockstor is
production quality, after many years developing at a rapid pace, and
in development. It’s considered a recent releases have cleverly
next-generation filesystem because side-stepped a few issues with
it integrates many advanced ideas Btrfs, so it’s worth keeping things up
that used to be added alongside the to date. Our first update took around
filesystem, rather than part of it. five minutes to apply.
These features include storage
The dashboard provides
redundancy, replication, device Share the rocks a great overview of
devices, enable Samba file sharing
linking, quota groups, sub-volumes, Rockstor is easy to use. Your network, storage and from the System page, then add a
snapshots and encryption. storage can be divided into shares CPU activity for your Samba export profile by clicking on
Rockstor has used all these for different categories of data, and entire NAS Storage > File Sharing > Samba.
features as the foundation for its different access permissions. Click Select a share and a user from the
NAS solution, along with lots of on Storage to manage these. By drop-down lists and disable
other tools for adding apps and default, ‘Home’ and ‘Root’ are ‘read-only’.
containers and even for migrating created by the operating system, One final awesome aspect to
your NAS into the cloud, which is and you’ll need to add at least one Rockstor we’d like to highlight are
where Rockstor is hoping to make more for your own data. the ‘Rock-ons’. These are Docker-
its living. As it’s open source, Thanks to Btrfs, shares can be based containers for running all
Centos-based, and easy to install, cloned or snapshots made of their kinds of web apps, installed via an
it’s perfect for running at home. current state, and these features are app store front-end. There are
One of the things we really like available from the Shares ‘Rock-ons’ for easy WordPress,
about both Rockstor’s installer and Management window. For OpenVPN, OwnCloud, Transmission
the running environment is that the accessing files from other Linux and BtSync, and we think they’re a
user-interface design is exceptional. brilliant idea.
Installation requires just a couple of
clicks and the creation of a couple “Rockstor is the first NAS we’ve
of user accounts, if needed, and
takes only a few minutes. After
seen to take advantage of Btrfs.” PROJECT WEBSITE
http://rockstor.com
How it works: Install Rockstor
Download the ISO and either burn it to an The installer is easy to use. Unless you want to After installation, reboot, and from another
1 optical drive or write it to a USB stick. First
2 partition your storage manually, just check the
3 machine on your network, point a browser at
boot should bring up the above menu. date and create a root account/password. Rockstor’s IP address. Allow it to update.
www.linuxvoice.com 71
FOSSPICKS
Password manager
QtPass v0.9.0
T
he problem with passwords something like OwnCloud to keep
is that we need to use so passwords synchronised.
many of them – from online But KeePassX is old and we’re
shopping to email – that it’s easy to always looking for new solutions.
forget how important any single One of which is a command line
password is. Many people use a tool called pass. Pass is brilliant
simple sequence for passwords, or because it uses GPG and your own
worse, use the same password for identity key, along with the Unix
multiple sites, exposing them all if filesystem itself to store your
one site is hacked. passwords, naming the files after
QtPass is a simple GUI
There isn’t a perfect solution, but where they’re used and encrypting wallet, and it’s just as secure.
to the various
using a password manager is a the contents of each with GPG. commands that make There’s even an Android app, a
huge improvement. This That means, apart from creating up a working pass Firefox plugin and a GUI client:
encapsulates all your passwords and decrypting, you can manage system. QtPass. QtPass makes pass operate
into a single ‘wallet’ that can be your wallet with normal filesystem like any other wallet manager, with
opened with a one password, commands, and there are no weird password creation and retrieval
hopefully one that’s unique and far file formats or databases to integrated into the simple, clean UI.
more secure than the multitude you contend with. It all feels much less It’s easy to use, and because the
used before. KeePassX is our cryptic than the average password back-end is still pass, you get all the
favourite, and has become advantages of a GUI and its unque
something of a standard. Many way of creating a wallet.
people use the Qt front-end and the “Pass is brilliant because it uses
Android client, for example, sharing
the encrypted keyfile using
GPG and your own identity key.” PROJECT WEBSITE
https://qtpass.org
Password manager
KWallet 5.12.0
T
here are many different and it’s slightly disappointing that
password managers, and the management app – KWallet
the one we’d recommend Manager – hasn’t yet been updated
for general use is a stable version for KDE/Plasma 5. The frameworks
of KeePassX, as mentioned above. that do the clever stuff have,
But if you spend most of your time though, and the latest release
in KDE, or using KDE applications, includes a neat feature we think is
we’d recommend KWallet as a worth covering.
better alternative.
This is primarily because of its Keep it secret, keep it safe
integration with the desktop. Any Normally, the wallet is a transparent
Even though the
KDE tool that uses a password can part of your system, only visible can also write new entries and
KWallet front-end hasn’t
use KWallet. There’s also an when you log on or an application been updated, it still overwrite existing passwords. The
excellent add-on for Firefox, which makes a request to access a works perfectly with the reason why these facilities are so
means KWallet can be used for password. But a new feature in latest back-ends. useful is that it means you can
nearly everything on a KDE desktop, KWallet 5.12.0 adds an essential create your own integration with
and it works well with system command line tool that gives you another password manager,
events like suspending a session or the ability to interact with your enabling you to import or export
when the screensaver kicks in. In wallet directly from the command your passwords as and when you
those cases, you can choose to line. The command interface can, need to.
close the wallet, requiring you to for example, list the passwords
enter your password again. KWallet being stored and even access those PROJECT WEBSITE
www.kde.org
has been around for a long time, passwords. More importantly, you
72 www.linuxvoice.com
FOSSPICKS
SSL wrapper
stunnel 5.20
S
tunnel has been around for a certificates and then a
long time. It’s a proxy that’s configuration file. Creating the
used to add SSL encryption certificate is easy enough, as long
to clients and services that don’t as you’ve got the openssl packages
support it. It’s a little like using SSH installed. We used the command
as a SOCKS proxy, where you openssl req -new -out /etc/ssl/
create an SSH connection with the certs/stunnel.pem -keyout /etc/
-p and -d arguments before ssl/certs/stunnel.pem -nodes
configuring your browser to use -x509 -days 365 to generate the
this connection as a SOCKS proxy. prerequisites. The next step is to
Your local HTTP data is create a configuration file. At its
There’s not much to see
encrypted via SSH until it appears simplest, you can define both a ‘accept’ and ‘connect’. In this way,
with stunnel running, so
at the server. stunnel is more flexible source and destination port, and we’ve split our console you can tunnel data from one port
and more complex as a result. It the IP addresses needed for both. view to show the on the client to another port on the
can be used to wrap lots of different You’d need two sections in the configuration file and server, which is useful if the client’s
services without configuring them configuration file for this – [In] and the binary output. network connection is blocking the
specifically for SSL, such as [Out], for instance (those names are port, for example. In this specific
SAMBA, POP3 or IMAP, as well as arbitrary), and they’ll both need case, the data would go from the
getting around port restrictions. entries for ‘client’ (yes or no), tunnel in Accept > Tunnel In
Before you can use it, on the Connect > Tunnel Out Accept >
machine that you want to use as Tunnel Out Connect.
the ‘server’, where your remote “Your HTTP data is encrypted via
clients will connect to, you’ll need to
create your own OpenSSL
SSH until it appears at the server.” PROJECT WEBSITE
https://www.stunnel.org/index.html
Encryption
Tomb 2.1
E
dward Snowden famously than a standalone project,
used the open source encapsulating a variety of common
encryption tool, TrueCrypt, to encryption tools, such as gnupg,
secure data partitions and portable Cryptsetup and Steghide, into a
storage that could be shared with simple command-driven interface.
his contacts. However, in May 2014, What makes Tomb rather good is
the TrueCrypt website announced that this script is well documented,
the end of development while enabling almost anyone with some
pointing to a final new (and programming experience to take a
read-only) restricted version. look and audit for themselves. You
This version was eventually start by creating a ‘tomb’ (tomb dig
declared safe by security firm -s 100 filename.tomb). A tomb is a
Gibson Research Corporation, and single file that acts like a locked
One of Tomb’s best
as development had halted, several folder containing the data you want features is the ability to password. The key file can be kept
projects forked from the original. to secure, which can then be hide a key within an separately for maximum security.
VeraCrypt is one such fork, and is unlocked, copied or transferred just image file, or as a QR When you now open the tomb file
now considered TrueCrypt’s as you would any encrypted file. code for physical (sudo tomb open filename.tomb -l
successor. Tomb, on the other hand, You next need to bind a key to the printing. filename.tomb.key), your tomb file
isn’t a fork a fork of TrueCrypt, but it file (tomb forge filename.tomb. will be mounted into the filesystem
has been designed to offer much of key), lock and generate the LUKS for general use.
the same functionality while filesystem on the file (tomb lock
keeping usability as simple as filename.tomb -k filename.tomb. PROJECT WEBSITE
https://www.dyne.org/software/tomb
possible. It’s also a script, rather key) – you’ll be asked for a
www.linuxvoice.com 73
FOSSPICKS
Audio editor
Eko 2.1.0
L
ike Gimp for image files, Jack as a requirement, making it
Audacity edits audio. And it’s work with native audio hardware
a wonderful tool. It can edit without configuration. It’s difficult to
multiple tracks of audio at the same get hold of, however, as the site that
time, process them with all kinds of hosts the source code was offline
effects, and perform many as soon as the update was posted.
essential audio tasks. It’s capable of We ended up extracting the tar.gz
such professional results that many file from the source RPM build for
professionals use Audacity to OpenSUSE, and building it that way,
fine-tune their recordings after so hopefully the home site is back
Eko is a simple audio
they’ve mixed down or recorded online by the time you read this. which makes editing more intuitive
editor. It’s quick with
their audio. But Audacity does have The application itself uses Qt for real-time effects, but no than Audacity.
a few problems. It’s not 100% the interface. It’s quick and easy to input monitoring. However, there’s still a long way
stable, nor is the user-interface to use. You can load more than one to go before we’d recommend this
everyone’s taste. Which is a long audio file and they’ll appear as tabs as a replacement. Zoom levels
way of saying, as with Gimp, there’s in a display that can be themed. aren’t great, sample rate support is
space for some competing Most importantly, and unlike poor and there’s no absolutely no
applications. Audacity, you can add effects and input feedback while recording;
Which is why the appearance of process audio during playback, however, if you’re interested in
first a 2.0 and now a 2.1 release of audio, it’s definitely worth a try.
another audio editor, Eko, has us
excited. Eko is a simple audio editor “Eko is a simple audio editor with
with a simple set of dependencies.
Recent releases have also removed
a simple set of dependencies.” PROJECT WEBSITE
http://semiletov.org/eko
VirtualBox manager
RemoteBox 2.0
R
emoteBox is a rather clever should also provide an extra level of
management interface for security in case the server you’re
VirtualBox, enabling you to accessing is doing other important
remotely manage a remote server things at the same time.
running VirtualBox. This gives you With everything installed and
access and remote control of running, RemoteBox provides a very
whatever virtual machines are similar interface to the native
installed on the server, turning a VirtualBox, communicating with the
low-powered remote machine into server through SSL and SOAP,
a virtual desktop, or enabling you to which provides access to nearly
With RemoteBox, you
manage containerised VirtualBox every parameter of the native client. machines you have running. It’s a
can perform almost any
servers as you would a local The interface is actually cleaner and task you can with the good way of getting access to a
installation. more intuitive in many ways. Virtual VirtualBox GUI, only powerful desktop from a less-
RemoteBox is written in Perl and machines are listed, run and saved. from a remote client. powerful client. You can
has a fair few dependencies. You You can connect to their remote accomplish the same thing by
also need to create a simple desktops too, using the RDP simply using RDP from VirtualBox,
configuration file on the server and protocol, letting you point and click but the management and control
run the vboxwebsrv command, your way around whatever interface for more than one
either through Systemd or your own machine helps RemoteBox to be far
init scripts. We found it easier when more flexible and powerful.
running vboxwebsrv as a simple “RemoteBox provides a very similar
user and using that user’s login
credentials from RemoteBox. This
interface to the native VirtualBox.” PROJECT WEBSITE
http://remotebox.knobgoblin.org.uk
74 www.linuxvoice.com
FOSSPICKS
FOSSPICKS Old Games
https://launchpad.net/pybik/
Strategy game
Battle for Wesnoth 1.12.4
B
attle for Wesnoth is not a the project admitted that it’s
new game – it’s been 12 understaffed.
years in development – “At this time, there are fewer than
nor is this a recent release, both half a dozen developers working on
normally prerequisites for being each new version of the game, and
featured here. The last major even fewer of them are able to work
update was version 1.12.0, on the engine itself. We do not
released in November 2014 after collectively have the time or skills to
almost three years of work, and is fix bugs as quickly as we should, or
one of the best and most implement features as rapidly as
professionally finished open we would like,” states the post,
source games you can install. before simply stating “the ship is
It’s a tactical turn-based sinking”. The project needs
There are many, many
strategy game, which means you programmers. Either intermediate expand into new territory. It’s
hours of gameplay to be
make decisions while the game is C++, especially for Windows and had in Wesnoth. There’s really not that difficult, and far too
in a pause state, moving your OS X, Python programmers able to even a multiplayer easy to get addicted. You’ll soon
units, upgrading and attacking maintain the project’s toolchain, mode. find yourself sucked into the plot
the enemy before finishing your and coders of the Wesnoth Markup of one of the campaigns,
turn, when the enemy will then Language, used to create the attacking each challenging
respond. There are small campaigns played within the game. mission one after the other.
missions, tutorials and fully There are very few games we
fledged campaigns, all wrapped Get involved! could recommend that are of a
around excellent art work, audio, If you think you might be able to similar quality, having been
scripting and translations, not to help, this might be a great chance developed for so long, and we’d
mention an engaging and to dive into a well established open love to see a new generation of
proactive community. It’s one of source project (and one with lots of contributors get involved with the
the best examples of what potential if you’re thinking of a project. If you think this sounds
successful open source gaming career in games design). Take a like you, download the latest
can look like. look at the #wesnoth-dev IRC version and take a look at the
But the reason why we’re channel on irc.freenode.net. code then get in touch with the
covering it now and not waiting Wesnoth is undoubtedly worth developers. Then let us know
for the 1.14.0 release is that saving. The tutorials ease you into how you get on!
1.14.0 might never happen. The the technical aspects of what each
project needs help. In a post on race is capable of, how to build your PROJECT WEBSITE
www.wesnoth.org
the main site, dated 25 July 2015, resources, work your units and
Battle for Wesnoth’s best features
There’s a brilliant map editor where you can There’s a huge amount of variety in the But there’s nothing like dealing with the
1 create your own challenges, and later, script
2 difficulty and type of campaigns offered
3 unpredictable nature of playing with real
your own missions and campaigns. within the game. humans – Wesnoth has this too.
www.linuxvoice.com 75
TUTORIALS INTRO
TUTORIALS
Dip your toe into a pool full of Linux knowledge with eight
tutorials lovingly crafted to expand your Linux consciousness
In this issue…
78 80
Ben Everard
His power consumption has already drowned
five polar bears. Bring on climate change!
I Stay safe with KeePassX Build a crane
run five machines for my personal
computing needs (a little excessive
I know), and between them, they The internet’s a dangerous place, but Raid the craft cupboard! Les Pounder lives
have 10 different operating systems Graham Morrison knows how to protect out a child hood fantasy and becomes a
installed. Nine of these are Linux himself. Follow him down the path of crane operator thanks to a Raspberry Pi
distros, but one is Windows 7. That security to the safe haven of KeePassX. and some ingenuity.
Windows system now has the option to
upgrade to Windows 10, and so I find
84 90 96
myself facing the eternal question: to
upgrade or not to upgrade. Usually, the
decision focuses on which software is
available, how stable I expect it to be
and other technical considerations.
This time it’s different. The two
questions I’m pondering are: will it wipe
the other OSes on the same machine,
Wordpress Customise Grub Video editing
and what are the new terms of use? Marco Fioretti likes to run The venerable bootloader Help out fellow geeks with
The answer to the first one is a his own website but doesn’t can’t do everything… yet. screencasts. Ben Everard
slightly annoying yes, but that’s easily like dealing with HTML John Lane shows you how unleashes Kdenlive, open
fixed with some backups. The answer and PHP. The solution is to add extra features and source software’s finest
to the second one is quite shocking. WordPress! master your boot. video editor.
The Privacy agreement for Windows 10
is 22 pages long, and in those 22 pages,
Microsoft outline just how much they’ll PROGRAMMING
hoover up from your device and, if they
choose, share with unnamed partners. Prolog Parallel Optimisation
I don’t consider myself a particularly 100 Have you ever wondered 104 Why use just one core of 106 Never content with code
paranoid person, but I’m not why you always have to tell your CPU when there are that merely runs correctly,
your computer how you want it to three more sitting around idle? We we push ours to the very limits of
comfortable agreeing to give up all my
solve problems? Why are take a look at some ways to add speed, and sacrifice
information to a company that is has programs a series of steps to be parallelisation to your shell scripts maintainability on the altar of
performed some morally dubious performed? After all, we’re very to make them run in a quarter of performance. How do we do this?
business manoeuvres in the past. For nearly living in the future, the time. You need never sit Should we do this? Optimisation is
now, I’ll stick with Windows 7 and retain shouldn’t we be able to tell them around drinking tea while waiting equal parts skill, black magic and
what we want and let them figure for processing to finish again (just clever use of tools. We take a look
what little of my privacy I have left.
out the rest? Enter Prolog! don’t tell your boss). at the first and last of these.
ben@linuxvoice.com
www.linuxvoice.com 77
TUTORIAL KEEPASSX
KEEPASSX: CREATE A SHARED
TUTORIAL
PASSWORD DATABASE
Keep all your secrets safe in one place that can then be shared
GRAHAM MORRISON
safely wherever you need access.
P
asswords aren’t exciting unless someone to store lots of different personal data, including
WHY DO THIS?
guesses yours. In the internet age, your usernames, passwords, files and notes and stores
• Remember one
passwords are the keys to both your online these in a single secure database, and the database
password for everything
and, increasingly, offline life, whether that’s your itself is stored using AES 256-bit encryption, so it’s
• Encrypt all kinds of data
and access credentials Facebook profile, your bank or your one-click enabled secure even if someone else gets the file. There are
• Synchronise those Amazon Prime account. The solution is to make every versions for all the popular operating systems, which
details to phones and password you use complex, and every password you means that if you can find a way of synchronising the
other machines
use different. But that’s hard to do, so so we database file across all your devices, you’ll have an
• Secure password
generation
recommend a password manager called KeePassX. always up-to-date password manager, regardless of
KeePassX is really just a secure database with a whether you’re using your phone or your laptop. And
simple front-end for data entry. But it’s been fine-tuned that’s what we’re going to do in this tutorial.
Step by step: Install and configure Google Authenticator
1
Installation 2
Create the database
At the time of writing, beta versions of KeePassX 2 Click on ‘New’ from the Database menu. This opens
have started to appear. Version 2 is a significant the ‘Change Master Key’ pane. This is where you need
upgrade on version 1, making its installation over the to enter a password that’s going to be used to encrypt
previous versions worth the slight stability risk. There’s your database. It’s going to need to be strong and
also a good chance that 2.0 will be available by the unique. The good news is that from now on, it’s going
time this tutorial escapes Linux Voice Towers, so there to be the only password you’ll need to remember. You
may be no downside. also have the option of using a key file. This file can be
It also uses a different database format to previous anything, but because it’s used to encrypt your data,
versions but remains compatible with the majority of the more complex the data in the file the better
tools and apps built to talk to the original KeePass 1 encrypted your data will be.
and 2 database formats, so you’ll still be able to Key files are convenient because you don’t need to
access your passwords from Windows, OS X and remember a password, but used on their own, they’re
Android. Installation is obviously going to depend on also a significant security risk. If an attacker gets
your distribution, especially if KeePassX is still in beta, access to both the key file and the database, they’ll be
but there’s a PPA for Ubuntu derivatives, and version 2 able to access your data. For that reason, key files
is in Arch’s AUR repository. When first launched, there should be considered an added level of security,
really is nothing to see. It’s not a sign that anything is alongside the password. That way, if someone gets
broken, it’s just that KeePassX needs a database from hold of your database, even if they guess your
which to work. password they won’t be able to decrypt your data.
78 www.linuxvoice.com
KEEPASSX TUTORIAL
3
Save the database 4
Populate the database
If you do use a key file, make sure you don’t save it Adding your secret information is the most arduous
with the database. Keeping a key file on an external part of the process. Groups can be used to categorise
USB drive is a good option, for example, or mounted your collection of information, just as you would use
from your phone. As long as the two aren’t together, folders in a filesystem. Use ‘Add New Entry’ for each
your secrets will be safe. new secret, and there are lots of different fields that
After the database has been created, you’ll next can be used to store your data. You can create
need to save it. We’d recommend saving the database attributes and attach files, for instance. But going
to a specific folder for these files. Using more than through each entry is also a good opportunity to
one database can be useful if you want some level of update your passwords, especially as the ‘New Entry’
separation, perhaps between banking and browsing, dialog includes an excellent password generator. Use
for instance, but there’s a tradeoff in convenience. this to create passwords that you can paste into your
Saving them all to the same folder makes things online password fields for maximum security. The
slightly easier to manage, and as we don’t really only downside is that you need to make sure you don’t
believe in security via obscurity, represents no lose your KeePassX database or passwords, as this
more of a security risk than naming your database will have a huge impact on how you access your
pagefile.sys and hoping for the best. various resources.
5
Synchronise 6
Android compatibility
After entering your data into a single password store, Our preferred Android app for handling the password
you don’t want to have to worry about keeping the database is called KeePassDroid. It can be installed
database synchronised across your various devices. either through Google Play or the open source
The best solution we’ve found is to run your own repositories of F-Droid. The only difficulty is that it
OwnCloud server and use its folder synchronisation. expects a database file ending in kdb, so you may
(Our tutorial on installing OwnCloud can be found in need to rename the file created by the desktop client.
issue in issue 6 and online.) With OwnCloud running, If you’ve synchronised the folder holding this file, when
you can then use a local client on your desktop or on you first launch the app you can use the file navigation
your phone to synchronise the contents of the folder to access the location and load up the database and
containing your KeePassX database. We’d also keyfile, if you’ve used one. You’ll then need to enter the
recommend enabling ‘Automatically Save On Exit’ and password, after which you should find all the
‘Automatically Save After Every Change’ in the information you’ve entered. For convenience, there’s a
KeePassX options panel, so that everything is saved menu option that lets you copy and paste usernames
and synchronised as you add and edit your database. and passwords from each entry, and you can lock the
database so it can’t be accessed if someone gets hold
of your phone.
www.linuxvoice.com 79
TUTORIAL EDUCATION
RASPBERRY PI: BUILD A CRANE
TUTORIAL
WITH AN EXPLORER HAT PRO
When Les Pounder grows up he wants to control a crane –
LES POUNDER
until that day he'll have to be content with building one!
W
hen we think of computing we naturally
WHY DO THIS?
think of code. In movies, whenever they
• Learn Python need to illustrate the dark art of computing
• Control motors there's usually line upon line of text flying up the
• Learn engineering screen as a hacker frantically types commands into a
principles
keyboard. But in recent years we have seen a growing
• Hack hardware
trend of makers merging physical skills such as model
making and electronics with single-board computers
TOOLS REQUIRED such as the Raspberry Pi. In schools we're seeing
more cross-curricular activities where design and
• A Raspberry Pi Model Pi
2 or B+ technology are merging with the computing
• Raspbian operating department to encompass product design with a
system technological twist. At a recent Picademy in Exeter I
• Explorer HAT Pro had the pleasure of working with a design and
• 2 x micro gear metal technology teacher who built a basic crane using card
motors
and sticky-backed plastic. This got me thinking about
• Male-to-female jumper
how lucky we are now, with technologies such as
cables
• Strong magnet
Raspberry Pi and the Explorer HAT Pro enabling us to
• Craft materials to make
hack working models of engineering marvels. In this
the crane tutorial we shall construct our own crane.
Setting up Explorer HAT Pro
Explorer HAT Pro is the bigger brother to the The finished project – how will you tackle building your
successful Pibrella add-on board. To set up the very own desktop crane?
Explorer HAT Pro, ensure that your Raspberry Pi is
powered down and gently attach the board to the desktop. From the desktop open a terminal; you can
GPIO (General Purpose Input Output) pins so that the find the terminal icon in the top-left of your screen.
Using the micro gear metal
motor is really easy with board overlaps the Raspberry Pi. Now attach all of In the terminal type the following line by line, and at
the Explorer HAT Pro. Here your peripherals and ensure that your Pi has an the end of each line press Enter and wait for the action
you can see the soldering Ethernet or Wi-Fi dongle to connect to the internet. to complete.
used to connect the wires. Power up your Raspberry Pi and boot up to the apt-get update
First we ensure that our list of software repositories
is up to date, which ensures that we use the latest
software available.
apt-get install python3-smbus
apt-get install python3-pip
Second we install the Python 3 smbus package,
which enables Python 3 to use the I2C interface
between the Explorer HAT Pro and the Raspberry Pi.
Next we install the pip package manager for Python 3.
This works in much the same was as apt-get in that
it downloads all the software and dependencies for a
package.
pip-3.2 install explorerhat
Finally we download and install the Explorer HAT
library for Python 3.
The Explorer HAT Pro has a lot of functionality, so
let's get better acquainted with this board. To start
using the board open a terminal and type in the
80 www.linuxvoice.com
EDUCATION TUTORIAL
following command and press Enter at the end of the
line. It will launch Idle 3, the Python 3 editor, and put
the command into background freeing up the terminal
for further use, if we wish.
sudo idle3 &
Lights
The Explorer HAT Pro comes with four surface mount
LEDs that are above the numbers 1 to 4 on the board.
They are coloured red, green, yellow and blue. Let's
start by controlling the LEDs. Click on File > New
Window to open a blank document.
import explorerhat
import time
explorerhat.light.on()
time.sleep(5)
explorerhat.light.off()
Save this code as test.py and click on Run > Run
Module to test the LED on your board. At the start of
We used lolly sticks and a hot glue gun to build our crane, as it enabled us to quickly
the code we imported the Explorer HAT Python library
prototype an idea and test in situ.
(we installed this earlier using pip), next we instruct all
four LED to turn on for five seconds and then turn off.
This is known as a blink, and it is the “Hello World” of import explorerhat
hardware hacking. import time
If we wanted to create a looping blink then normally explorerhat.light.pulse(1,1,1,1)
we would use a loop to contain the instructions that time.sleep(5)
perform the blink. But the Explorer HAT library has a explorerhat.light.stop()
special function that we can use in its place: So in this code we changed the blink function for
import explorerhat pulse and passed four arguments, conditions for the
import time function to follow, which controlled the fade in time,
explorerhat.light.blink(0.5,0.5) fade out time, on time and off time for the LED. Save
time.sleep(5) the code and click on Run > Run Module to test.
explorerhat.light.stop() All of the code created thus far can also be used on
So this code will blink all of the LEDs, half a second each of the LED individually.
on, half a second off for five seconds before the LEDs import explorerhat
are turned off. Save this code and click on Run > Run import time
Module. We can also create a pulse effect using the explorerhat.light.red.pulse(1,1,1,1)
LEDs, similar to the pulsing effect that you can see on time.sleep(5)
laptops that are sleeping. explorerhat.light.stop()
This repeats the pulsing code we created earlier but
now only the red LED will pulse. Save and run the code
Soldering to see it in action.
In this tutorial we used micro gear metal motors to power
the winch and control the direction of the crane, but these Motors
motors required us to solder wires for connection to the Our next test is to learn how to use the built-in motor
Explorer HAT Pro. Soldering is a great maker skill to learn controller. Unlike the Pibrella, which had a basic motor
and surprisingly it's not very hard to do. Soldering uses controller only capable of movement in one direction,
a hot piece of metal (an iron) to melt solder, which when
the Explorer HAT Pro features an H bridge, which
cooled creates a bond between a component and whatever
it is being attached to. Getting started with soldering is enables a motor to run bi-directionally. To test you will
great fun, thanks to videos such as Carrie Anne’s Geek Gurl need two micro gear metal motors with wires that
Diaries http://bit.ly/LV19-Solder. Remember to solder in have been soldered correctly – see the boxout for
a well ventilated place and ensure that your workspace is details on motors and soldering. Connect the wires for
clear and well laid out before turning the iron on. A great tip
one of your motors to motor 1 and the other to motor
from Carrie Anne is to use a hot glue gun after soldering the
wires to ensure they are firmly held in place. 2. For each motor you will have one wire in “+” and the
Soldering kits come in many different price brackets but other in “-”.
the key thing to remember is that you get what you pay for, Now we shall write some code in Idle to test the
so a cheap kit may look attractive to start with but you will motors. You'll need to open a new blank document
soon grow out of it. Our preference is the Antex range of
(File > New Window).
irons, in particular the XS25, which is the right balance of
quality and cost www.antex.co.uk/home. import explorerhat
import time
www.linuxvoice.com 81
TUTORIAL EDUCATION
Running the code via explorerhat.motor.one.forward(i)
Idle 3 we can check the explorerhat.motor.two.forward(i)
output of the code and sleep(0.5)
spot any errors quickly. explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
Here we use a for loop to iterate between 0 and
110 in steps of 10; this gives us the value i, so for the
first time the loop is run the value is 0, then 10, 20,
30 and so on. This value is used to control the speed
of our motor. We then sleep for half a second before
repeating the loop. Once we reach the maximum
range of the loop, it ends and both of the motors are
turned off. Save this code and run it to see the motors
gradually speed up.
Touch input
Our last test covers the 8 touch inputs that are on the
board. Numbers 1–4 are capacitive touch buttons
and register a touch; numbers 5–8 work in the same
way but we can also attach crocodile clips to each of
the inputs and use conductive materials, such as tin
foil and fruit, as inputs.
import explorerhat
from time import sleep
def lights(channel, event):
explorerhat.motor.one.forward(100) explorerhat.light.on()
explorerhat.motor.two.forward(100) time.sleep(5)
sleep(5) explorerhat.light.off()
explorerhat.motor.one.stop() explorerhat.touch.one.pressed(lights)
explorerhat.motor.two.stop() In this code snippet we import the libraries as
In this code snippet we import the Explorer HAT before, but then we create a function called lights that
and time libraries and then instruct both motors to go has two arguments, channel and event, which are
forwards at full power (100). The code then sleeps for used by the Explorer HAT to identify the input and how
five seconds before we stop both the motors. Save it was triggered (long press, short etc). In the function
this code as motor.py and click on Run > Run Module we instruct the code to turn all the lights on for five
to test. Both of your motors will spring into life. seconds before turning them off. Save this code as
You saw in the motor forward function that we can touchtest.py and click on Run > Run Module to test.
pass an argument to the function to control the speed, Press the number 1 button and all of the lights will
The Explorer HAT Pro
which gives our motors an element of precision. To come on for five seconds.
is a powerful platform
for invention. The mix see this in action we shall use a for loop.
of motor controller and import explorerhat Putting it all together
capacitive touch interface import time So we have tested all of the functionality for our crane.
sparks many project ideas. for i in range(0,110,10): Touch input to control the crane.
Lights to warn users that the crane is in operation.
Motors to control the rotation of the crane and for
the grabber.
Now we need to put it all together.
In Idle open a new file and save it as crane.py.
import explorerhat
from time import sleep
We start the code by importing the Explorer HAT
library and importing the sleep function from the time
library.
def rotateleft(channel, event):
explorerhat.light.red.blink(0.5,0.5)
duration = 0.5
explorerhat.motor.one.forward(XX)
sleep(duration)
explorerhat.motor.one.stop()
explorerhat.light.off()
82 www.linuxvoice.com
EDUCATION TUTORIAL
Next we create a function to handle rotating the
horizontal motor that controls the crane's direction.
The function starts by blinking the red LED, and then
we use a variable, duration, to set the length of time
that the motor is on. Next, motor one is set forward
at XX percent, then we sleep for the length of the
duration variable before turning the motor and red
LED off.
def rotateright(channel, event):
explorerhat.light.green.blink(0.5,0.5)
… #All other code is as per rotateleft function.
explorerhat.motor.one.backward(xxx)
To rotate the crane to the right we use a similar
function to before, but this time we call it rotateright
and make two further changes illustrated in the code
above. This time we flash the green LED, and motor
one is run backwards.With the motor used to control
the horizontal direction of our crane configured, our
attention now turns to the motor that will be used to
power the winch that lowers our grabber.
def winchdown(channel, event):
explorerhat.light.yellow.blink(0.5,0.5) We now move from creating functions to the main We used an old jam jar to
give us a solid base for our
duration = 0.5 body of code, which handles the user input and
crane but in the spirit of
explorerhat.motor.two.forward(XX) triggers the functions that we have created.
hardware hacking you can
sleep(duration) explorerhat.touch.one.pressed(rotateleft) use whatever fulfills your
explorerhat.motor.two.stop() explorerhat.touch.two.pressed(rotateright) design.
explorerhat.light.off() explorerhat.touch.three.pressed(winchdown)
Again we reuse the code that powers our two explorerhat.touch.four.pressed(winchup)
previous functions but we make a couple of changes. We will use the buttons for 1, 2, 3, 4 and 8, and for
This function is called winchdown, and it lowers the each of these buttons we'll assign a function as per
grabber down to its target. When this happens the the code above. Buttons 1 and 2 handle the direction
yellow LED blinks and motor two is driven forward at of the crane. Buttons 3 and 4 handle the winch, and
XX percent. button 5 is used to toggle the magnetic grabber.
def winchup(channel, event): Save your code and ensure that everything is
explorerhat.light.blue.blink(0.5,0.5) connected correctly
(it is wise to keep the
“We've used coding, electronics
… #All other code is as per winchdown function.
explorerhat.motor.two.backward(100) magnet away from
To pull the grabber back towards the crane we first your Raspberry Pi and and engineering practices to
blink the blue LED and then run motor two in reverse. any storage media!).
When you're ready, click build our very own model crane.”
Motors on Run > Run Module
and test each of the inputs in sequence.
The Raspberry Pi has seen its fair share of robotics projects
and as such it has also seen many motors. In this tutorial
we used the micro gear metal motors from Pimoroni.com,
Crane design
as they offered the best power for their size. There are other Congratulations, you have used coding, electronics
motors on offer, and a quick search of eBay will show the and engineering practices to construct your very own
many on offer. The motors that come with the RyanTeck model crane. The design of our crane is entirely based
Budget Robotics kit are much larger and faster than those on research via web searches. Your crane can look
used in the tutorial but they can be easily controlled via the
entirely different to ours and it would be great of you
Explorer HAT Pro, as they also use 5V.
The Explorer HAT Pro uses a motor controller with an to show us your constructions by tweeting us at Linux
H bridge, which is a circuit that enables a voltage to be Voice!
applied in either direction, or in simpler terms the direction All of the code for this project can be found at our
of the motor can be reversed without having to rewire the GitHub repository: https://github.com/lesp/LV_19_
circuit. This makes the Explorer HAT Pro ideal for robotics
Education and you can download the project as a ZIP
as the robot can spin on the spot. Also in the tutorial we
specified the speed of the motor using a percentage, this file from https://github.com/lesp/LV_19_Education/
uses PWM (Pulse Width Modulation) to achieve analog archive/master.zip.
precision using digital signals. This gives our project
precise control for the speed of the motors, essential when Les Pounder divides his time between tinkering with
trying to accurately control the direction and position of the hardware and travelling the United Kingdom training teachers
two motors. in the new IT curriculum.
www.linuxvoice.com 83
TUTORIAL WORDPRESS
WORDPRESS: SET UP A SIMPLE
TUTORIAL
BLOGGING ENGINE
MARCO FIORETTI
Most of the time the best solution is the simplest – so here’s the
simplest way to set up a dynamic-content website (aka a blog!).
B
eing the master of your own online space, and
WHY DO THIS?
managing it with Free Software however you
• If you want your own want, wherever you want, may be less
blog, this is the best way
to do it. It’s fun, it’s easy fashionable and convenient than squatting in some
and it’s really yours. A corner of the walled garden du jour (yesterday
man’s WordPress blog is MySpace, today Facebook, tomorrow – who cares?)
his online castle.
but believe us: it feels really good. It may also be your
• Publishing with
WordPress is quick, even small, but still necessary contribution to keep the
while you are browsing whole web as open as possible. Of course, there are
the web, and can be many ways of doing this.
partially automated
One of these solutions is WordPress (http://
• It’s a skill that may
turn useful on the job, wordpress.org), the Free Software behind the
someday. Look at us at wordpress.com blogging platform that you can run
Linux Voice! yourself on any web space with PHP support and
access to a MySQL or MariaDB database.
WordPress is not only for personal websites.
The best proof we can give you of this fact is that
www.linuxvoice.com itself, where many authors and
editors work together, thanks to WordPress 4. Fig 1: We like old text editors as much as the next Linux
This tutorial, however, is about the original, main fan, but the WordPress editor (only partially visible here) is
mission of WordPress: make the most common things hard to beat when it comes to user-friendliness.
that 90% of individuals who want to really self-publish
their writings online as easy as possible. need to know and do, especially before installation,
WordPress 4 is easy enough to install and upgrade to properly design and manage a WordPress website
that in these pages we give as little space as we can without unnecessary effort.
to those two topics. We prefer to explain what you
Main functions and concepts
The internal editor of WordPress is shown in figure 1.
Clicking on the “Distraction-Free” button on the right
makes everything disappear except the actual text
box and the toolbar above it. It’s not as flexible as plain
text editing with MarkDown or a similar system but it’s
as easy as it’s possible to get without having to dumb
yourself down to Facebook-level “posting”. Just try
clicking on all the buttons and then on Preview to see
how it works.
The other publishing options of WordPress are just
as powerful as they are easy to miss. You can publish
posts remotely with scripts or desktop tools (see the
Installation And Updates box), or activate the Post Via
Email function in the Writing panel.
You can also go from looking at any web page to
writing a post about it in your blog in one click. Go to
the Tools panel and drag the Press This button in the
bookmarks bar of your browser. Then, whenever you
find some inspiring paragraph in a web page, select it
and click on that button: you’ll get a simplified version
Fig 2: WordPress pages and categories can be easily dragged and dropped (on the left) to of the WordPress editor, with that text and a link to the
build menus. How they actually look to visitors depends on which theme you install. source already pasted in!
84 www.linuxvoice.com
WORDPRESS TUTORIAL
By default, what WordPress creates when you click information like “About” or “Privacy Policy”. Pages and
on the Publish button is a standard “post”: a piece of Categories can be arranged in Menus, as in figure 2.
content to list in the home page, with all the others Its left half shows the WordPress dashboard panel
of the same type, in reverse chronological order. The where you drag and drop page titles to build a menu,
URLs of all posts have a common pattern, which and the right-hand side shows what the result looks
you can customise in the “Permalinks” section of the like in the default theme.
dashboard. Another essential component of WordPress is its
collection of widgets: little frames, each encasing one
Categories and Tags piece of constant or dynamic content, that you can
Each post can have both Categories and Tags drag and drop in
attached to it. They help your readers and search the available areas “Themes are the graphic and PHP
engines to immediately understand what each post is
about. Categories – which ideally should all be defined
of the chosen
theme. Figure 3
files that define every detail of
before you start blogging – should correspond to shows some of the the layout and visual style.”
the main sections of your site. A blog on tourism, for default widgets in
example, may have Categories like “Backpacking”, WordPress, but you can create your own ones, with
“Cruises”, “B&B” and so on. Categories can also be custom HTML code.
arranged hierarchically. We have already mentioned themes twice, so let’s
Tags are completely free labels that you can explain them. Themes are the graphic and PHP files
create and attach as you please to each single that define every detail of the layout and visual style of
post, to describe its content in more detail. A post your blog. Switching themes takes only a few clicks,
PRO TIP
in the “Cruises” category above may get tags like but can completely alter what WordPress looks like.
Be prepared for the worst!
“Caribbean”, “Family-Friendly” and “Low Cost”. You can see what we mean in figure 4, which is the
Go to the PHPMyAdmin
One way to explain all this is that Categories are dashboard “Theme Preview” pane: the blog is the demo at http://demo.
the Table of Contents of your blog, and Tags its same as in figure 3, but the visual elements (colours, phpmyadmin.net/master-
config to get acquainted
Index: adding new tags with each new post is no fonts, backgrounds) and the layout of menus and
with the MySQL
problem, but if you find yourself doing the same with widgets, are changed. administration tool that
Categories, it may mean that you had not structured Finally, there are plugins – optional bunches of can save your WordPress
installation should
your blog well when you started it. code to perform any function you may imagine. Half
anything go wrong.
Beside posts, WordPress can create several other the rest of this tutorial describes just how you can
types of content, but here we’re only looking at its manage several key aspects of a WordPress website
Pages, which are meant for high-level, relatively static with the right plugins.
Fig 3: WordPress widgets
are little, single-purpose
blocks of content that you
can place in several areas
of a WordPress blog, with
an interface very similar to
that used to build menus.
www.linuxvoice.com 85
TUTORIAL WORDPRESS
(Media > Add). Then, from the post editor, select “Add
Media”, choose and reorder from the Library all the
images you want, and click on “Create Gallery”. Done!
If the result looks dull, however, or if you want to
generate independent galleries and/or sliders, no
problem: try plugins like NextGen, Simple Photo
Gallery or (especially for videos and Flash widgets)
the WP Video Lightbox. Another useful image
management plugin may be the EWWW Image
Optimiser, which automatically reduces the size of
every uploaded image, to make backups and page
loads faster.
There are several ways to draw users to your blog,
keep them there as long as possible and get feedback.
The most “traditional”, but still valid tools include post
notifications, newsletters, contact forms, and good old
RSS feeds. They can all be handled with plugins. The
Mailpoet Newsletters plugin can help with the first
two cases, and many other plugins generate forms for
all uses. If the RSS feeds built into WordPress are too
generic, try the solutions listed at https://wordpress.
org/plugins/tags/rss-feed.
To engage with your readers in more interactive
Fig 4: Compare the right
The last general thing to know about WordPress ways, you can use both comments and buttons that
half of this picture with
the same part of figure is what it cannot do as well as other website facilitate “sharing” what you publish on the main social
3 to see how merely management software, for example Drupal. To networks.
switching theme can really begin with, running more, independent sites off WordPress can run its own commenting system
change the appearance of the same WordPress installation is not impossible, or embed (again, with a plugin) the Disqus platform.
WordPress. strictly speaking, but we frankly don’t recommend We recommend the first choice, even if it means
it. The same is true for sites that should be 100% more load for your server and, very likely, extra
multilingual. In both cases, you are likely to find both plugins to fight spam. Online discussion is already
structural limitations that too centralised in too few places to contribute to that
“WordPress can run its own are hard to cope with,
as well as lots of plugins
trend. On the other hand, reality says that if you don’t
at least make it easy to announce what you write on
commenting system or embed and themes that simply certain social networks, almost nobody will know
the Disqus platform.” aren’t designed to work
in such environments. If
about it and come to you.
Of the many “social sharing” plugins available for
you really need to handle WordPress we prefer the one called “Simple Social
several independent WordPress blogs, install one Share”. It’s lightweight, simple to configure and looks
database and a copy of the software for each of them. good. Don’t take our word for it though: what will work
It’s inelegant, yes, but it also is much less troublesome for you depends on what theme you choose and
than the alternatives. which networks you want to support!
One other thing that is more difficult in WordPress
than, say, Drupal, is relocating an existing blog to
A great WordPress add-on: PHPMyAdmin
a different URL. Check the online documentation
about the WP_SITEURL, and WP_HOME WordPress To keep WordPress happy, its database must always be in
variables for details. good health. Sometimes, however, peaks of traffic, server
glitches, software bugs or plain human error may corrupt
that database in ways that cannot be fixed from inside
What can you do with WordPress? WordPress. When this happens, there is only one solution,
A lot! As we anticipated, there are enough plugins (and besides replacing the whole database with its last working
tutorials) around to make most of what you may want backup (which will cause you to lose everything that
happened after that point). First, find online what the exact
from WordPress pretty easy to do. In order to give you
problem is, then fix it directly inside the database tables.
a better, though still incomplete idea, we’ll look at three This is much less scary than it may seem. Install
very different “services”: image management, user PHPMyAdmin (www.phpmyadmin.net) alongside WordPress,
engagement and SEO (Search Engine Optimisation) and you will be able to see and change any field in the
– how to format your content to make it show up as database right inside your browser. PHPMyAdmin will also
accept raw, complex SQL commands, if manual field editing
high as possible in online search results.
is not enough. Besides, PHPMyAdmin is the only way to
WordPress 4 can embed a simple Gallery, with “Next access your database on many web hosting providers, so
Image” and “Previous Image” buttons, inside a post you’d better know how it works!
(see figure 5): first, you upload all the images you need
86 www.linuxvoice.com
WORDPRESS TUTORIAL
The YARPP and “Simple
Another great way to keep people on your blog is to Server with root access to use them. The exception
Social Share” plugins at
show them content similar to what they are already is setting the file permissions as described in the work, adding social icons
reading. Try YARPP (Yet Another Related Posts WordPress documentation, which is possible even and lists of related content
Plugin) for that. Finally, you can increase the chances on low-end accounts. On your own server, you may below each post.
of appearing at the top of online searches related to also allow access to the WordPress administration
your blog with plugins like Yoast or the “All in One SEO folder (/wp-admin) only from your home IP address.
Pack”. Beware though: these plugins will improve your Alternatively, you may protect the same folder with a
rankings only if you take the time to add to each post totally separate password, which has to be entered
the metadata they require. even if you’re already logged into WordPress proper.
You may also configure the web server to only allow
Security secure (HTTPS) connections to that area of your blog,
A blog that is only fast and good looking won’t last to avoid password sniffing.
very long, if it is an easy target for crackers. WordPress One easy way to harden WordPress from inside its PRO TIP
is reasonably robust out of the box, but there are own dashboard is based on a principle that is very Managing WordPress
many ways to increase its security, almost all outlined stupid but, as long as you do not rely only on it, can with your mouse is easy.
at https://codex.wordpress.org/Hardening_ block many of the equally stupid, script-kiddie-level Having your server do it
for you is much better. If
WordPress. attacks: security through obscurity. you have shell access to
The available techniques can be roughly During installation, set both the first account name it, try the WP-CLI (http://
grouped according to the three levels at which and the DB table prefix to something different than the wp-cli.org) command line
interface to WordPress.
they operate: web server configuration; core standard admin and, respectively wp_ values. Then,
WordPress configuration and WordPress plugins. Of configure the user account(s) to use a nickname
course, there’s nothing to stop you mixing different (what shows as post author) that is different from the
techniques. Here’s a simple overview, since the username (what you have to type to log in!) and tell
configuration details heavily depend on your own WordPress to only display the former string in all public
setup. pages. Used together, these three tricks will stop all
Working at the (web and/or MySQL) server level the attacks written to exploit the default settings of
is very effective, but rarely possible on standard WordPress. Plugins-wise, try BulletProof, the “All In
shared hosting: you need to lease a Virtual Private One WP Security & Firewall” or Wordfence to (among
www.linuxvoice.com 87
TUTORIAL WORDPRESS
The joy of WordPress is
other things) enforce strong passwords or block login plugin you may have installed. A more sophisticated
how tweakable it is; here’s
LinuxVoice.com, gloriously attempts, or other attacks, after a predefined number way to reduce load times could be serving images,
powered by WordPress. of failures. Of course, the best plugin-related security stylesheets, scripts and other completely static
measure is… using as few plugins as possible! Code content from a “cookie-free domain”. Check the
that is not there will never be exploited (and won’t WordPress documentation on WP_CONTENT_URL
slow your server down). and COOKIE_DOMAIN to know how to do that.
Years ago, a very simple way to make a blog
Optimisation load faster was to trim its home page, setting it to
“The default WP themes may If your posts take too only show the excerpts of a few posts, with as few
long to load, many widgets (including sharing buttons) as possible.
be dull, but they are fast and people won’t even start These settings are less effective these days, when
guaranteed to work.” reading them. Very sad, most visitors won’t pass through your home page
but true. Besides,
slowness may lower your SEO ratings, if you care
about that. Solutions to these problems are in the
same categories as those for security: web server,
WordPress itself and WordPress plugins.
Reliable and high bandwidth, as well as enough
RAM and CPU cycles to make web and MySQL servers
work decently, cannot be free. If you really want a fast
website, paying (within reason, of course!) for a good
hosting account will do at least half of the job.
Your website may also go faster by just changing
looks, if your aesthetic conscience can afford it. The Figure 5: Adding single images, or whole galleries, to a
default WP themes may be dull and anonymous, WordPress post is much easier than on other content
but they are fast and guaranteed to work with any management systems.
88 www.linuxvoice.com
WORDPRESS TUTORIAL
Installation and updates
The WordPress claim of a “5 Minute Install” is true… as [root] cd /var/www/html
long as you read, before installing, the boring but simple [root] wget https://wordpress.org/latest.tar.gz
documentation at https://codex.wordpress.org/Installing_ [root]# tar xf latest.tar.gz
WordPress and https://codex.wordpress.org/Editing_wp- [root]# mv wordpress wptutorial
config.php. To prepare yourself, here’s a stripped-down Next, we pointed our browser to http://localhost/wptutorial
example of how it may work in the most complicated case, and followed the instructions, entering parameters like site
that is when you have root access to the web server. On a title, name of the WordPress username (which is not the same
shared hosting account, things would be simpler. First, create, as the MySQL account!) and MySQL table prefix (beware:
just for WordPress a new MySQL database, and a MySQL user unlike the others, this setting cannot be changed after
with enough privileges to modify it: installation!).
> CREATE DATABASE wptutorial; WordPress stores all its configurations inside one file called
> GRANT ALL PRIVILEGES ON wptutorial.* TO wp-config.php, which the installer attemps to create and fill
“linuxvoice”@”localhost” IDENTIFIED BY “golinux”; with the parameters it asks you for. Should it fail to create
> FLUSH PRIVILEGES; that file because of file permission issues, it will ask you to
> EXIT; do it manually, showing you the text to copy and paste into it.
Next, download the current version of WordPress from WordPress updates are a variant of this procedure that takes
https://wordpress.org/latest.tar.gz, uncompress it and move care to not remove the configuration and any other media
the resulting folder, named wordpress, to what will be the file attached to posts. Sample scripts to partially automate
blog root directory on the web server. The test blog in these updates, or post to WordPress from the command line, are
screenshots, which ran at http://localhost/wptutorial on a available on the author’s blog at http://freesoftware.zona-m.
Linux desktop, was created with these commands: net/tag/Wordpress/.
but directly land on a post from some social network. risky!) doing it one step at a time, than jumping three
However, applying them takes 10 seconds and cannot version numbers only to discover that your database
hurt, so go for them in “Settings > Reading”. is corrupted, because nobody had tested that
By default, every WordPress post is regenerated particular update path!
more or less from scratch, every time somebody The “last” step: pre-installation planning
asks for it, by PHP code that also queries the MySQL If reading this tutorial has left you very eager to try
database. This is a useless overload when many WordPress we’re very happy, but before going live,
people try to access a post that would always look the remember to:
same anyway. The usual antidotes to this behaviour 1
Figure out and write down all the functions (widgets
are the so-called caches, that is (simplyfying!) archives and plugins) that you really need. The fewer, the
of static HTML copies of all your posts. better: your blog will run faster, need updates less
Plugins like “W3 Total Cache” or “WP Super Cache” frequently and be less exposed to crackers. Oh, and
create just such copies and then pass them to visitors always check what other users say of a plugin (or
right away, instead of running the whole WordPress theme) before considering it!
engine every time. You can get similar results 2
Using the default theme, try different combinations
playing with the web server, but caching plugins are of site-wide settings, categories, permalinks, menus
more portable. Don’t expect performance miracles, and widget layouts until you have found a structure
however. Their real-world effectiveness will heavily you like. Don’t waste time on looks yet.
depend on how many other plugins are running, 3
Create several dummy posts, just to see what they
actual traffic patterns and other factors equally hard look like.
to estimate beforehand. 4
Find and test, possibly both on your desktop and
Other optimisation plugins that are worth trying, at your smartphone, a theme that renders the
least for certain blogs and themes, are WP-SmushIt structure that you just created. Again, go for the
and WP Minify. The first automatically reduces, as simplest one you can live with. Regardless of their
much as it’s possible without visible degradation, licence and price, many great-looking themes for
the size of all the images you upload; the second WordPress have the same intrinsic limit: just
combines and compresses, for the same reason, the because they are so sophisticated and tweaked to
JavaScript and CSS files associated to each page. the very last pixel, they may work as advertised only
with some combinations of plugins than may not
Other best practices have been documented before.
First, backups! Regular backups, of both the database If at all possible, perform the whole analysis above
and the whole WordPress folder! Again, if you can at home, on a throwaway blog inside your own Linux
handle this at the server level, that’s the best solution. computer. When you’re happy, and not one minute
Otherwise, try the BackUpWordPress plugin to before, install WordPress from scratch on the real
schedule automatic backups. server, cloning that test installation.
Second, never skip an upgrade, whenever the
WordPress dashboard tells you that it is available. Yes, Marco Fioretti is a Free Software advocate and open data
campaigner who has advocated FOSS all over the world.
it’s boring, but it’s much less time consuming (and
www.linuxvoice.com 89
TUTORIAL GRUB
EXTEND GRUB WITH A CUSTOM
TUTORIAL
MODULE
JOHN LANE
Is your favourite bootloader lacking that killer function you need?
Here’s how to add custom commands to Grub…
G
rub is the bootloader used by most Linux Grub modules are relocatable ELF binary object
WHY DO THIS?
distributions. It’s one of those applications that files that are usually written in C. Grub is a 32-bit
• Have the very latest many of us rely upon to deliver us safely to our single-threaded real-mode application that is mostly
Grub
login prompt. Thanks to its modular architecture, it’s written in ANSI C with a little sprinkling of assembly
• Add your own custom
commands able to boot from a multitude of devices and disk language. You’ll need the GCC compiler, along with
formats. This also makes it extendable – if you find it the usual development utilities like git and make. We’ll
lacks a capability that you need, you can write your assume a basic knowledge of writing and building C
own modules to extend its functionality. This month, applications, along with a working knowledge of git.
we show you how.
Modules contain functionality that can be loaded Get the latest code
on demand rather than being part of Grub’s core. The Before you begin, it’s well worth obtaining the latest
Linux kernel uses a similar concept, but don’t confuse development checkout (the master branch is updated
kernel and Grub modules – they’re entirely different almost daily) and familiarising yourself with its
and have nothing in common beyond that concept. changelog in case your killer feature is already there -
Modules are usually there’s little point reinventing the wheel!
loaded according to Go to a suitable working directory (we’ll use
“Modules are usually loaded the needs of the Grub ~/work for this tutorial) and grab the latest sources
according to the needs of the configuration. This uses
insmod commands to load
from the git repository. You can browse at https://git.
savannah.org/cgit/grub.git and use git to download:
Grub configuration.” the modules it needs (the $ cd ~/work # or wherever you please!
kernel also uses a similarly $ git clone http://git.savannah.gnu.org/r/grub.git
named command but, again, they aren’t the same). Change into the directory that this creates. You can
You can also use insmod from an interactive Grub create your own working branch if you prefer not to
prompt to load modules and there’s also rmmod to work on the master branch.
unload them. $ cd grub # our git clone
Loading a module augments Grub’s available $ git checkout -b work
commands with any new ones defined in the module. The source code needs to be prepared before it can
be built. This step generates various files that the build
process needs. Run the supplied script:
$ ./autogen.sh
You can build in the directory containing the
prepared source code or in another one, either below
or separate to it. Do either:
$ ./configure
$ make
or something like this:
$ mkdir ~/work/build
$ cd ~/work/build
$ ~/work/grub/configure
$ make
The default install destination is /usr/local, but you
can install to a different location if you prefer. Either
install to the default location (use sudo to gain the
permissions to write there):
$ sudo make install
or somewhere else; perhaps a run subdirectory:
$ make DESTDIR=~/work/run install
The DESTDIR is used by GNU makefiles and must
We booted Grub in VirtualBox to try out its “hello” module. be given as an absolute path.
90 www.linuxvoice.com
GRUB TUTORIAL
You should check that your custom install is
used, and perhaps try it out (we describe some test The Grub legacy
environments in the boxout, right). There are two main versions of Grub. The original version
The usual programming introduction is to write is now called ‘Grub Legacy’ and is what you have if your
something that outputs a greeting and our first Grub version is less than 1. The last release of Grub Legacy is
module need be no different. In fact, we don’t even version 0.97; if you have a version of at least 1 then you
have Grub 2, which is what’s now called ‘Grub’. The latest
need to write it, because such an example is provided
version, 2.00, was released in June 2012, but some distros
for us as our springboard into Grub module writing. carry a more recent beta release.
It’s built along with the rest of Grub so you can try You can check which version you have. It’s displayed
it out the next time you boot your computer. Open at the top of the Grub boot menu or you can view it from a
a Grub prompt (press C at the menu) and do the command prompt:
$ grub --version
following:
2.0.0-5ubuntu2
grub> insmod hello Grub is a complete rewrite of Grub Legacy. It has
grub> hello completely different and incompatible internals and
Hello World configuration files. It does, however, include a legacy
The source code for each Grub module is located module that can read the menu.lst configuration file used
by Grub Legacy.
within its own subdirectory of the grub-core directory
in our git clone. Take a look at the source for the hello
module at grub-core/hello/hello.c. We’ve also printed MOD_FINI calls grub_unregister_command to
it in the box on page 92 so you can refer to it quickly. unregister the module.
The hello module implements a single hello The grub_register_extcmd function takes a number
command. Its code is pretty straightforward: it of arguments, the first of which is the command’s
includes some headers, declares its licence and name; what the user would type at the Grub prompt
implements the new command in the grub_cmd_ to use it. The second argument is the function that
hello function. implements the command and the third one is for PRO TIP
flags that can restrict how and where the command make clean removes
compiled files from
More Grub can be used (most commands, like hello, aren’t your build directory.
There are two more functions that register (GRUB_ restricted; they just pass 0 here). make distclean also
MOD_INIT) and unregister (GRUB_MOD_FINI) the Two strings follow this: the first is a short usage removes what configure
generated.
module. The upper-case names reflect the fact that summary and the second is for more verbose help
these function definitions use macros (they’re defined text. The final argument is an array describing the
in include/grub/dl.h); a lot of Grub functions use command’s options (we’ll cover this in more detail
macros to simplify their usage. later). These arguments accept a 0 value if they are
When the module is installed (eg by insmod), not required – hello doesn’t provide usage information
the GRUB_MOD_INIT function calls grub_register_ or options. All commands automatically get --usage
extcmd to register the new hello command. This and --help options that display their usage and help
returns a pointer (cmd) that’s used when GRUB_ text. The latter option displays the usage and the help
Test environments
Testing Grub requires installing to a bootable medium and You need to build the emulator separately – it isn’t built
booting from it. This would quickly become very tiresome if along with the real Grub. To do this, configure your working
you needed to keep rebooting in order to test but, fortunately, copy to build the emulator. Here’s one way to do this:
you don’t have to. $ mkdir ~/work/build-emu
One option is to install to a removable medium such as a $ cd ~/work/build-emu
USB stick and then boot it on a spare machine. Use dmesg $ ../grub/configure --with-platform=emu
to identify your device after inserting it – take care to get $ make
the right device, because mistakes can cause data loss! Our $ make DESTDIR=~/work/emu install
examples use /dev/sdX, but you’ll need to replace X with the Then, to run it:
digit that matches your setup. $~/work/emu/usr/local/bin/grub-emu
# mount /dev/sdX /mnt Enter exit at the emulator’s grub> prompt to exit back to
# grub-install --no-floppy --boot-directory=/mnt /dev/sdX your shell. Run it with --help for more information.
# umount /mnt The emulator will use libSDL (Simple DirectMedia Layer)
You could use a virtual machine, say with VirtualBox, to to run in a window if possible, but it will otherwise run in your
boot a USB stick that you’ve installed Grub on. If you want to terminal. Adding --disable-grub-emu-sdl to the configure
do this, create a raw disk image first: command will disable SDL if you don’t want to use it.
$ VBoxManage internalcommands createrawvmdk -rawdisk /dev/ Modules are built into the emulator, so you don’t need to
sdX -filename usb-stick.vmdk use insmod to load them. You can still do it but insmod does
Then create a new VirtualBox machine and use usb-stick. nothing in the emulator. The emulator has a few limitations
vmdk instead of creating a hard disk. Start the VM and it that may affect your testing depending on what your module
will boot from the USB. The other option is to use the Grub does. If you encounter problems with it, a virtual machine is a
emulator, grub-emu. good fallback option.
www.linuxvoice.com 91
TUTORIAL GRUB
either in the Grub source tree in a similar way to hello
or in a separate, self-contained one. The latter is
useful if you want to keep your work separate,
perhaps in its own Git repository. We’ll use ~/work/
modules. This working directory must not contain the
Grub source tree.
If you want to work in the Grub tree, use the grub-
core subdirectory as your working directory.
Your module’s files will go in a subdirectory of
your chosen working directory. Go to your working
directory and copy the hello sources:
$ mkdir argshow
$ cp ~/work/grub/grub_core/hello/hello.c argshow/argshow.c
$ sed -i -e ‘s/hello/argshow/g’ argshow/argshow.c
A module definition needs to be provided to tell
autogen.sh about the new module so that it gets built.
Write a module definition file, Makefile.core.def in the
same directory as argshow.c:
Grub’s new argshow command, shown here in all its glory in the emulator. Booting will
AutoGen definitions Makefile.tpl;
never be the same again!
module = {
name = argshow;
text followed by a summary of any options that the common = contrib/argshow/argshow.c;
command supports. };
The _() and N_() macros that are used in the hello If you chose to write your module under grub-
module are for native language support. core, just append the module block at the end of the
Grub commands accept command-line arguments existing grub-core/Makefile.core.def file but without
– a mixture of options and positional parameters. the contrib path element.
Options begin with a hyphen and can be given in a You need to set GRUB_CONTRIB to the parent of
short form such as -h or long form such as --help.
They can appear in any order and may expect a value.
The basic structure of a Grub module.
Positional parameters don’t begin with a hyphen, but
the command will usually expect them to be given in a #include <grub/types.h>
#include <grub/misc.h>
specific order.
#include <grub/mm.h>
A command is implemented in the function passed #include <grub/err.h>
to grub_register_extcmd like the hello command’s #include <grub/dl.h>
function grub_cmd_hello. Command functions take #include <grub/extcmd.h>
three arguments: #include <grub/i18n.h>
struct grub_extcmd_context_t ctxt is a pointer to
GRUB_MOD_LICENSE (“GPLv3+”);
the command’s context,
int argc and static grub_err_t
PRO TIP char **args point to its positional parameters. grub_cmd_hello (grub_extcmd_context_t ctxt __attribute__
It’s a good idea to The command’s context contains its options and ((unused)),
follow the GNU coding int argc __attribute__ ((unused)),
standards and is essential
other things. The body of the function outputs the
char **args __attribute__ ((unused)))
if you plan to submit your famous greeting: {
work upstream www.gnu. grub_printf (“%s\n”, _(“Hello World”)); grub_printf (“%s\n”, _(“Hello World”));
org/prep/standards.
It highlights a major difference to most Linux C return 0;
code: Grub doesn’t use the standard C library (libc). }
Instead, it includes equivalent implementations of
static grub_extcmd_t cmd;
the main functions. These have the same names but
are prefixed with grub_. Most of these functions are GRUB_MOD_INIT(hello)
accessible after including misc.h instead of the usual {
C headers such as stdio.h. cmd = grub_register_extcmd (“hello”, grub_cmd_hello, 0, 0,
N_(“Say `Hello
World’.”), 0);
Your own module }
An easy way to start developing a new module is
simply to copy the hello module and modify it. As an GRUB_MOD_FINI(hello)
example, we’ll write a module that just displays its {
grub_unregister_extcmd (cmd);
arguments. We’ll call the module and its command
argshow. }
You can choose where to write your module –
92 www.linuxvoice.com
GRUB TUTORIAL
your module’s directory if that isn’t grub-core. From
your working directory:
Native language support
$ export GRUB_CONTRIB=~/work/modules Grub can display text in languages other than English. It
This is used by autogen.sh to symlink grub-core/ uses GNU GetText for this native language support, which
can provide text translations into multiple languages.
contrib to your working directory. Any modules
To help with this, wrap translatable text _(“like this”) and
beneath it will be included in the build. text that should not be translated N_(“like this”). If writing a
That completes the plumbing for our module and new .c file, include the relevant internationalisation header:
it’s sufficient for a build. Return to the Grub source #include <grub/i18n.h>
directory and run autogen.sh again. Then return to the Here are some examples:
grub_printf (_(“Hello %s, this will be translated.”), name)
directory in which you want to build and run configure
grub_printf (N_(“Hello %s, this won’t be translated.”), name)
and make like we did before. Grub participates in the Translation Project
If all went well, install Grub in a test environment, (translationproject.org) so that others can translate text
try installing the module and then execute the new that coders mark up in this way. You don’t need to provide
command. From a Grub prompt: translations yourself – if you use the text wrappers in your
code, other translators will be able to do it for you.
grub> insmod argshow
grub> argshow
hello, World!
You should see the same familiar greeting because command and its options:
we haven’t written any code yet. Let’s do that now. GRUB_MOD_INIT(argshow)
{
Make your argument cmd = grub_register_extcmd (“argshow”, grub_cmd_argshow, 0,
Before you start coding, decide how you want to N_(“[-s STRING] [-i INTEGER] [-1] [-2]”),
license your work and declare this in the source file N_(“Show given arguments”),
(the build will fail otherwise). We’ll follow Grub’s lead options);
and use the GPLv3; we declare this in our source file
like this:
}
One disappointing
“Grub takes care of invalid
GRUB_MOD_LICENSE (“GPLv3+”); thing to note here is that options before invoking the
The headers included by default cover the module’s
basic needs and are sufficient for our example.
grub_register_extcmd
expects the help text
command function.”
You may need to include others when writing a real to be a constant; this
module; browse include/grub to see what’s available. means that it can’t be translated.
Most commands will need some data to work with Now that the command accepts arguments its
and this is usually supplied on the command line. Our function can process them. Grub takes care of invalid
module demonstrates how command-line arguments options before invoking the command function so
(options and other positional parameters) work in it only needs to consider valid ones. Their “state” is
Grub. Positional parameters are easy – they’re passed contained in the command’s context that is passed
into the command function as argc and args. into the function. An option’s state describes whether
Options, however, need to be defined in an array it is set and, if applicable, its value.
of grub_arg_option structures, one per option, and We set up a “state” pointer to access options’ states.
passed to grub_register_extcmd when registering the struct grub_arg_list *state = ctxt->state;
command. Each definition comprises: Our example function just iterates over its options
A long (string) name; and displays their state:
A short (character) name; int i = 0;
A string for “--help” to display; for (i=0; options[i].shortarg; i++)
A default value and; {
A type. grub_printf(_(“option ‘-%c’ ‘--%s’ is “),
We declare some options below; the end of the list options[i].shortarg, options[i].longarg);
is marked by an empty record: if (state[i].set)
static const struct grub_arg_option options[] = { if (options[i].type == ARG_TYPE_STRING)
{“string”, ‘s’, 0, _(“Option with a string argument”), 0, ARG_ grub_printf(“’%s’\n”, state[i].arg);
TYPE_STRING}, else if (options[i].type == ARG_TYPE_INT)
{“integer”, ‘i’, 0, _(“Option with an integer argument”), 0, ARG_ grub_printf(“%lu\n”, grub_strtoul (state[i].arg, 0, 0));
TYPE_INT}, else
{“option1”, ‘1’, 0, _(“Option 1 with no argument”), 0, ARG_TYPE_ grub_printf(_(“set\n”));
NONE}, else
{“option2”, ‘2’, 0, _(“Option 2 with no argument”), 0, ARG_TYPE_ grub_printf(_(“not set\n”));
NONE}, }
{0, 0, 0, 0, 0, 0} The options are described in the global options
}; array; this is where you can find their name, value,
Update the command registration to describe the description and type. You get their states via the state
www.linuxvoice.com 93
TUTORIAL GRUB
argshow.c – the code
/* argshow.c - Linux Voice Tutorial */ grub_cmd_argshow (grub_extcmd_context_t ctxt, int grub_printf (“%s\n”, _(“Positional parameters:”));
#include <grub/types.h> argc, char **args) for (i=0; i<argc; i++)
#include <grub/misc.h> { grub_printf (“%d : %s\n”, i, args[i]);
#include <grub/mm.h> struct grub_arg_list *state = ctxt->state;
#include <grub/err.h> int i = 0; return 0;
#include <grub/dl.h> }
#include <grub/extcmd.h> /* options */
#include <grub/i18n.h> for (i=0; options[i].shortarg; i++) static grub_extcmd_t cmd;
{
GRUB_MOD_LICENSE (“GPLv3+”); grub_printf(_(“option ‘-%c’ ‘--%s’ is “), options[i]. GRUB_MOD_INIT(argshow)
shortarg, options[i].longarg); {
static const struct grub_arg_option options[] = { if (state[i].set) cmd = grub_register_extcmd (“argshow”, grub_cmd_
{“string”, ‘s’, 0, N_(“Option with a string argument”), if (options[i].type == ARG_TYPE_STRING) argshow, 0,
0, ARG_TYPE_STRING}, grub_printf(“’%s’\n”, state[i].arg); N_(“[-s STRING] [-i INTEGER] [-1]
{“integer”, ‘i’, 0, N_(“Option with an integer else if (options[i].type == ARG_TYPE_INT) [-2]”),
argument”), 0, ARG_TYPE_INT}, grub_printf(“%lu\n”, grub_strtoul (state[i].arg, 0, N_(“Show given arguments”),
{“option1”, ‘1’, 0, N_(“Option 1 with no argument”), 0)); options);
0, ARG_TYPE_NONE}, else }
{“option2”, ‘2’, 0, N_(“Option 2 with no argument”), grub_printf(_(“set\n”));
0, ARG_TYPE_NONE}, else GRUB_MOD_FINI(argshow)
{0, 0, 0, 0, 0, 0} grub_printf(_(“not set\n”)); {
}; } grub_unregister_extcmd (cmd);
}
/* positional parameters */ Listing of argshow.c. You can download the
static grub_err_t if (argc) sources from http://git.io/vqc4s.
pointer. Notice how the integer option is given as a since the last time, so running make once more
string and needs should get the job done. Install again to your test
“With the basics in place, you’re to be converted.
The command
environment and try out the module’s argument
handling.
free to enhance Grub with that function receives
Environmental impact
command you’ve always wanted.” any positional
parameters as The Grub environment is another place where your
args and the module can access information. It’s basically a list of
number of them in argc. They’re just string values, and name/value pairs that you can read and write. You
we can use a simple loop to display them: use grub_env_get and grub_env_get to do this. They
if (argc) read and write string values; you need to include grub/
grub_printf (“%s\n”, _(“Positional parameters:”)); env.h in your source file to use them.
Grub is magic. Without for (i=0; i<argc; i++) With the basics in place, you’re free to go ahead
it, we would be able to grub_printf (“%d : %s\n”, i, args[i]); and enhance Grub with that command you’ve always
try nearly as many Linux Return to the directory where you build from and wanted. Your next step will probably be to learn more
distributions as we do. remake Grub. The build configuration hasn’t changed about what’s actually possible. Most of the interesting
source code is under grub-core and organised in
subdirectories such as disk, net and video to name
just a few.
There’s an active mailing list at https://lists.gnu.
org/mailman/listinfo/grub-devel, which is where
you need to send anything you want to contribute
upstream. If you’re considering contributing upstream,
http://bit.ly/code4opensource is a good read.
An alternative, and perhaps more appropriate,
potential home for your work is in the “Grub Extras”
repository. You’ll find it at http://savannah.nongnu.
org/projects/grub-extras. It takes advantage of Grub’s
framework for building modules externally in order to
provide them from a separate package – just like we
did in this tutorial.
John Lane hacks on Linux for fun and profit. Even his
bootloader couldn’t escape.
94 www.linuxvoice.com
TUTORIAL VIDEO EDITING
EDIT VIDEO WITH KDENLIVE
TUTORIAL
FOR YOUTUBE STARDOM
BEN EVERARD
Free software can help you make it big on the silver screen, or
reach millions of the great unwashed via YouTube.
V
ideo screen captures are a great way of bit more involved, but it can result in a much higher
WHY DO THIS?
sharing tips and tricks with the world at large. quality video. The choice, as they say, is yours.
• Learn how to cut and With YouTube and other video sharing sites, Whichever option you use, you’ll need a method for
mix video like a pro
you don’t need to worry about bandwidth or the recording the screen and a microphone for recording
• Create helpful videos for
your fellow Linux users complexities of hosting streamed videos; only about the audio. RecordMyDesktop does a great job for the
• Amass a YouTube making the content interesting for your viewers. In this former. There are GTK and Qt front-ends available
following and become tutorial, we’ll look at how to make a tutorial video using in most package managers that make the task
rich the popular Kdenlive video editor. straightforward.
The first step of making a video isn’t the editing You could use a laptop’s built-in microphone for
though; it’s not even the recording of it. The first step audio, but these won’t allow you to record high-quality
is to make sure you’ve got a proper plan of what you audio. It’s much better to use an external mic. You
want to shoot. It’s best to break the plan down into don’t need a top-of-the-line microphone for this, and
the constituent scenes, each of which will be you an external USB mic should be fine.
performing one task and explaining it. By planning in
this way, you’ll make it easier to record, and avoid the Recording the easy way
problem of realising If you’re recording video and audio in one go, all you
halfway through need to do is configure RecordMyDesktop to capture
“After you’ve got everything recording that you both the audio and video, and you’re done (we told you
recorded and exported, it’s time forgot to perform a it was easy). However, if you want to make a higher-
task earlier on. quality recording with the video and audio done
to mix it all together in Kdenlive.” Once you’ve got separately, you’ll need to first record the video. This is
your plan, the next best done in one go (we’ll chop it up into the scenes a
step is to record the video and audio. There are two bit later). Once the video’s done, you can record the
approaches here. One is to record them together. This audio, and Audacity is the best software for this.
method is quicker and easier since you don’t have The basic usage of Audacity is just to make sure
to worry about cutting, and mixing becomes easier. that you’re recording from the right source, press the
GTK-RecordMyDesktop has
However, it’s hard to do this well since it’s difficult to big red button to start recording, then press it again
lots of options if you want
to tweak the recording, cut out any umms and arrrs you say, and redoing a when you’re finished. If you get everything in a single
but we find that the single bit usually means rerecording everything. The recording, you can copy and paste sections of the
defaults are right for most other approach is to record the two pieces separately. track into new Audacity projects to get the bits you
purposes. This takes longer to do, and the editing stage is a want in the right clips.
Microphones can pick up a lot more than just the
sounds you want, so it’s a good idea to run the noise
reduction effect. This removes a lot of hissing and
background noise, leaving a much clearer sound.
Once you have a project with just the sections you
want, you can export the audio by going to File >
Export Audio. The default settings will produce clips
that you can import into Kdenlive.
After you’ve got everything recorded and exported,
it’s time to mix it all together to create your final video.
The first thing to do is import all the bits into Kdenlive.
You can do this by going to Project > Add Clip and
selecting the files that you’ve recorded. Both audio
and video segments are termed clips, and they will
appear in the clips list on the top-left of the window.
From here, you can drag and drop them into position
on the various tracks. If you’ve recorded your video in
one take, you should now have one video clip and a
96 www.linuxvoice.com
VIDEO EDITING TUTORIAL
bunch of audio clips. To start with, drag the video clip
onto the first video track. You can now play the video,
and it should appear in the monitor on the right-hand
side of the window.
Matching audio and video
In order to match up the video with the audio, you
need to separate the video into the scenes that you
recorded the audio against. First find the point where
one scene ends and the other begins. You can either
do this by playing through the clip (press Space to
play and pause), or by moving the cursor by clicking in
the timeline. Once you’ve found the end of the scene,
you can cut the video by right-clicking and selecting
Cut Clip from the popup menu (or press Shift+R). This
will cut the clip into two separate ones. You can drag
the second clip (which contains the remainder of the
video) down to the second video track. This gives us
space to alter the scene without it overlapping.
With the clip cut to length, you can now drag the
relevant audio clip into the audio track inline with the
video (you named them well enough to be able to
identify the right one didn’t you?). You’ll probably find
at this point that the two aren’t the same length. Either
the video is longer than the audio or vice versa. Exactly
what you do here is a question of artistic preference.
If the video is intricate, it may be best to leave a few
seconds of silence to let the viewers focus on what’s
happening.
One of the great things about screen captures
is they can be sped up or slowed down without
making them look strange. You can use this to your
advantage to make the video the same length as the
audio. This is particularly useful if there’s something
that’s slow to start or load -- there’s no need to waste
the viewer’s time with unnecessary pauses.
When you start a project
To adjust the speed, right-click on the clip in the the same length, and it can be good for a video to
you have to select the
timeline and select Add Effect, Motion, Speed. In the have some slight pauses so the viewer doesn’t feel profile. This can’t easily be
Effects list pane, make sure that the Effect Stack tab overloaded with information. changed afterwards.
is selected, and you will be able to adjust the speed by
changing the percentage (a smaller percentage runs Add clips to the video sequence
slower and a faster percentage runs faster). You can Once you’ve adjusted the speed of the clip to sync,
either calculate the correct value, or just find it using you can then go through the same process for the
a bit of trial and error. It doesn’t have to be exactly remaining clips. Each time, after you cut out the
Non-Linear Video Editor Other open source video editors
The name Kdenlive may sound confusing, but it’s an acronym €23,000 out of a goal of €35,000. At present the pre-1.0
of what it is: a KDE Non-Linear Video Editor. The split between release has a nice interface, but we found it a little too
linear video editing and non-linear editing came with the buggy for serious work. It’s progressing quickly, and if the
advent of digital video. This ended the reliance on reels of film cash injection can help apply polish, this could become a
that had to be viewed (and therefore edited) in sequence, also great option in the future.
known as linearly. With digital video, you can instantly jump OpenShot For a while, OpenShot was the go-to video editor
to any point in the video, so can change a frame without first on Linux, but not much seems to be happening with the
having to go through all the previous frames, therefore you project any more. The last version came out in 2012. It still
can edit it non-linearly. Almost all modern video editors are works, though can be a little crash-prone. In recent years,
non-linear. this software has been surpassed by Kdenlive and Pitivi.
We’ve used Kdenlive for this tutorial, but it’s just one of a Blender The 3D modelling tool also has a built-in video
growing number of open source non-linear video editors that editor that’s really quite capable. We could easily have done
run on Linux. Here are a few of the other options: this tutorial using Blender instead of Kdenlive, but ultimately,
Pitivi This project is raising money to help develop version we prefer Kdenlive. However, it’s well worth investigating if
1.0 of the project. At the time of writing, it had raised you’re doing serious video editing.
www.linuxvoice.com 97
TUTORIAL VIDEO EDITING
start, but that wouldn’t have left us with a way to
introduce Kdenlive’s grouping feature. This works in a
very similar way to grouping in other media software.
You highlight all the clips (in the tracks rather than in
the clips list) that you want to group, then right-click
on one of the clips and select Group Clips. Once this
is done, any action you take on one of the clips will
be performed on all of them. To move all of the clips
further to the right and create space for our intro, you
just need to select all of the clips with Ctrl+A, then
group them and drag them about 6 or 7 seconds to
the right. This will move everything and keep the video
and audio in sync.
Add a title screen
You should now have space to insert your title screen.
You can expand still image clips by dragging the edge
of the clip to the length you want it to be. If you put
the title clip immediately before the start of the first
Audacity has a lot of
correct section of video, you can drag and drop it into video there will be a jarring cut from the title to the
options, but don’t let it
intimidate you: it’s easy video track one next to the previous clip, and likewise screencast, but there are a few things you can do to
to use for basic audio with the audio. make this cut a bit more pleasant on the eye. The
processing. There’s a slight bug in some versions of Kdenlive simplest option is to fade out the title screen, then
where it sometimes won’t let you drop a video clip fade in the video. This is done in a very similar way to
next to another one after the speed of a clip has been fading in and out audio tracks except instead of using
changed. It just throws an error and puts the video the effects Fade Out and Fade In, you need to use
clip in its previous place. If you get this, just save the Fade To Black and Fade From Black.
project, close Kdenlive, then reopen the program and Another option is a transition. There are several
the project and it should work. different types of transition that swap from one track
to another with different effects. The first thing you
Rough cut need to do when applying a transition is put the two
By this point you should have a rough version of your video clips on separate tracks. In our case, it’s easiest
video. There should be a full set of video and audio to put the title clip on the second video track and leave
clips, but let’s take a look at how to make it a bit more the main videos on the first. You then need to make
polished. One problem with cutting audio together is
that it can leave audible clicks at the point where
tracks start or finish. This can be solved by fading
tracks out and in. If you left a
“There are are several types small period of silence at the
start and end of your audio,
of transition, which swap this is quite simple to do using
from one track to another.” effects. Right-click on the
audio track and do Select >
Add Effect > Fade, and you’ll
need to add both fade ins and fade outs for every
track. As with the speed effect we added to the videos,
the fades create an entry in the effects stack pane.
Using these you can adjust the amount of time the
fade takes. The amount will depend on your
recordings, so just experiment and use the smallest
amount that gets rid of any audio artifacts.
Another thing our video is missing is an opening
title that will introduce the video to the viewers.
Kdenlive can import most image files as clips, so
the first thing is to create your intro scene in your
favourite image editor and export it as an image file
(a PNG works well). Once you’ve got this, you need to
add it to the front of the video, but there’s no space Video formats are a minefield of quality and compatibility
there because the first clip starts at 0. Of course, issues, but you can always re-export in another format if
we could have planned ahead and left space at the you have problems.
98 www.linuxvoice.com
VIDEO EDITING TUTORIAL
The Kdenlive interface
3
1
2
4
5
6
1 The clips list From here you can drag clips on to the required tracks. Each 4 Effects pane Here you can adjust the effects and transitions.
clip can be on more than one track if desired. 5 Transition You can place a transition between two video tracks to add an
2 Notes This is free-form text that you can use to add any notes that you want effect as the video mixes from one track to the other.
to remember when doing the editing. This doesn’t change the video. 6 Tracks Place video or audio clips onto the tracks to add them to the film.
3 Monitor You can see the current state of the video in this box.
sure that there is an overlap between the two video with more devices, while MPEG-4 produces smaller
clips. It’s this overlap that is where the transition will files at higher qualities. If you’re uploading video to an
take place. Since we can expand the title clip without external site such as YouTube, check their guidelines
problems, the easiest way is to extend this another on what they accept.
second or two over the other track. Rendering the video can take a while depending
on the speed of your computer and the complexity
Transitions of the video. Rather than locking up the interface for
You can then create a new transition by right-clicking this time, Kdenlive will start a background process for
on the title clip, selecting Add Transition and selecting rendering and notify you when it’s complete.
one. Slide, for example, will slide the old video out It’s always a good idea to keep the Kdenlive project
revealing the new video clip as it goes, while Dissolve files even after you’ve exported the video because
will gradually fade out the old video showing the new these keep all the data, so if you need to make any
clip behind it. Kdenlive can sometimes place the further edits, it’s better to use this than trying to import
transition in funny places when you first insert it, but a previously exported clip. You can also re-export the
you can drag and drop it to the correct position. project if you need it in a different format.
Once you have everything in place, the only thing That’s all there is to it! By choosing your subject
left to do is export the project to a video format that’s well, planning properly and spending a little time
best for your intended use. Go to Project > Render editing, you can make interesting and useful videos to
to begin the process. The first thing you need to do help other Linux users and gain online fame.
is select the correct video format. There aren’t any
hard-or-fast rules about what’s the best format, but Ben Everard is the author of books, builder of robots, maker
of cider and rider of bikes.
a good basic guideline is that MPEG-2 is compatible
www.linuxvoice.com 99
CODING PROLOG
PROLOG: NATURAL LANGUAGE
TUTORIAL
AND ARTIFICIAL INTELLIGENC
JULIET KEMP
Instead of operating on objects or performing functions, Prolog
works backwards to find a result – weird, eh?
I
n lots of ways, Prolog is quite different from the with Trudel and Roussel’s theorem-provers, the
other languages we’ve looked at. Its roots are in team developed a very basic natural language
natural language processing and computational communication system. A user could give the
linguistics, and it’s strongly associated with artificial computer a set of facts in natural language, and
intelligence. If you’re used to other types of language, the computer would be able to draw certain logical
its structure can be a bit challenging to get your head conclusions from those facts and respond to
around initially. But if you put the effort in, it’s a questions; just like the Tom and Jerry example. It was
fascinating language – and still used in anger in some after this that they met up with Robert Kowalski, at
artificial intelligence work, in database searching, and the University of Edinburgh, who was a specialist in
in natural-language applications. automated theorem-proving, working particularly on
Prolog originated from research at the University SL-resolution (a type of inference rule which enables
of Aix-Marseille around 1971, where Alain logic sentences to be proved or refuted).
Colmerauer and Phillipe Roussel were working, Between them, they worked throughout 1971 and
not on programming languages, but on computer 1972 on what would become Prolog, and the first
processing of natural languages. Colmerauer was version was implemented, in Algol-W, in autumn
interested in communicating directly with computers 1972. At the same time, a natural language computer
in French (and in natural, or human, languages in program was being written in this new Prolog
general). This meant, among other things, finding language. A second version of Prolog followed in 1973
ways for a computer to draw the implicit conclusions that bears a stronger resemblance to modern Prolog.
and inferences that humans do from sentences in Over the next years, copies of Prolog slowly made
natural languages. For a human, saying “Tom is a cat; their way out into the world, as researchers from
Jerry is a mouse”, together with the base knowledge other institutions would come, spend some time
“Cats chase mice”, would enable them to answer the in Marseille, and take a copy away with them. This
question “Will Tom chase Jerry?”. Getting a computer was still an interpreter, though, and thus very slow-
to do this was a significant challenge. running. The first Prolog compiler, the Warren Abstract
Getting the interpreter Roussel, together with another colleague, Jean Machine, was written in the mid 1970s by David
to say hello, and Trudel, were working on automated theorem-proving Warren at the University of Edinburgh. Compiling
experimenting with (a mathematical/computational logic challenge). Prolog into a lower-level language meant that it
unification (see boxout). This fitted well with Colmerauer’s research. Working could run much faster, and the WAM’s Prolog dialect
became the basis for most modern implementations.
Turbo Prolog, released by Borland in the 1980s,
helped popularise Prolog further. For more on
the rise of Prolog compilers, and some detailed
discussion of how they work, see this paper by Peter
van Roy – http://citeseerx.ist.psu.edu/viewdoc/
summary?doi=10.1.1.37.8982. Prolog is still in use
today: Watson, the natural language AI computer that
won the TV quiz show Jeopardy in 2011, uses Prolog
(among other languages). Read on to try it out.
Hello world
The most popular Prolog interpreter for Linux is the
free SWI Prolog. This is available as a package for
most major distros (check their website for more
information). For Debian/Ubuntu, just install the
package swi-prolog. A GNU Prolog compiler is also
available but seems to be less fully-featured and
doesn’t have the libraries and other tools that SWI
Prolog does. I’ll use SWI-Prolog in this tutorial.
100 www.linuxvoice.com
PROLOG CODING
Once you’ve installed your Prolog interpreter, fire up
the interactive interpreter with swipl. You’ll get a bit of Variables, constants and atoms
boilerplate, then an interactive prompt. Try it out: Prolog has four basic building-blocks: and a sequence of arguments separated by
?- write(‘Hello World’), nl. Atoms Either a character string beginning commas. In other languages you might call
Hello World with a lower-case letter and containing no something like this ‘function’ or ‘method’.
true. spaces; or any character string (including foo(bar) is a complex term, as is
spaces) enclosed in single quotes; or a write(‘hello’). foo, bar, write, and ‘hello’ are
write(‘Hello World’) is a Prolog fact. (See the boxout
special character string (like :-), which may all atoms.
for more on Prolog atoms, facts, and predicates.) In have a particular meaning. Atoms can also Complex terms are also known as
this case, we use the built-in predicate write/1, which be thought of as constants. predicates: a predicate is, then, a type of
has the side-effect of outputting something to the Numbers As you’d expect: numbers! Prolog function that produces a true/false answer.
screen, and which is useful entirely for this side-effect. is most interested in integers, but can You may also see a predicate being
handle floating-point arithmetic if need be. evaluated with an argument referred to as
The number 1 in its description means that it takes
Variables Variables are, as you would a fact – so write/1 is a predicate and
a single argument (in Prolog terms, it has arity 1). It expect, variable; that is, they can be write(‘Hello’). is a fact.
evaluates true simply because it exists. nl is also a assigned a particular value (see the box on Rules are if-then structures, with the head
predicate (nl/0, strictly speaking), which outputs a unification). Variables begin with either a (a predicate) and body separated by :-.
newline. As here, you can run several clauses one capital letter or an underscore, and can’t This reads as “head if body”, ie the head is
contain spaces. true if the body is true. The rule body can
after the other, separated by commas; to actually
Complex terms A functor (a name, which be built out of multiple Prolog clauses or
evaluate them all, you need a full stop at the end. must be an atom), followed by brackets sentences, separated by a comma, which
To exit the interpreter, type halt.. Now, let’s try (no space between functor and bracket!) acts as an ‘and’ operator.
running a code file. Open a file hello.pl in your editor:
main :- write(‘Hello World!’), nl.
Now start up swipl again: take a database of roads between towns, and find
?- [hello]. the shortest route that covers all of the towns. In
% hello compiled 0.00 sec, 3 clauses our variant, we’ll ask Prolog to provide all the routes
true. between any two towns, and the total distance for
?- main. each route.
Hello World! Prolog is useful for this kind of problem because
true. of the way it deals with its knowledge base. Given a
This loads in the file, so the Prolog interpreter now particular rule, Prolog will try to find as many solutions
knows about this rule. A rule is a way of connecting as possible, trying to instantiate variables in ways that
two items together, and :- can be read as “if”. So: fit the constraints. As with the box on unification, I find
A :- B. it useful to think of Prolog as doing its best to find a
means that A is true if B is true. In this case, main is way in which the rule can be true, and only returning
true if write(‘Hello World!’), nl, halt is true. When we “false” if all its efforts fail.
then type main., we are asking “is main true?”. To We’ll start off by creating a basic database of roads
evaluate this, the interpreter evaluates the B side of between four towns. Open a file, travelling.pl:
the rule, with the side-effect that the string is printed. road(a, b, 3).
It then tells you that yes, main is true. You can also set road(b, c, 4).
up a file to call the interpreter internally: road(c, d, 5).
#!/usr/bin/swipl road(d, b, 6).
:- initialization(main). Next, let’s create a predicate that finds the distance
main :- write(‘Hello World!’), nl, halt.
Make this executable with chmod u+x hello.pl,
then run it with ./hello.pl and you’ll get the expected A
output. (Note that this time we’ve added halt to the
list of predicates, so the interpreter halts at the end.) 3 B
The initialisation at the start does various bits of
necessary Prolog setup to call the main goal.
Finally, you can return to this single line:
main :- write(‘Hello World!\n’), halt.
and compile it like this:
swipl --goal=main --stand_alone=true -o hello -c hello.pl 6
Run it with ./hello. The --goal flag identifies where the 4
code should start; -o gives the name for the output
file, and -c identifies the source code file or files.
C
Travelling around D
To get a bit further into Prolog, we’re going to look 5
at a version of the Travelling Salesman problem. If Towns and roads in a
you’re not familiar with this, the basic idea is that you connection graph.
www.linuxvoice.com 101
CODING PROLOG
Loading the file, asking TotalDistance = 3;
for a non-existent location false.
which returns false, asking Enter the semi-colon to continue Prolog’s search for
for an existent location solutions. In this case there is only one solution.
and getting multiple So, what’s that code doing? The first thing to notice
solutions. (Note that I’d is that the right-hand side of this rule is made up of
made a mistake in this several independent sentences separated by commas
version and have too many
(“and” operators). The whole sentence here will be true
brackets in my lists.)
if and only if all the sentences within it are true. In this
With many thanks (as
ever!) to StackOverflow case, the first sentence will return false unless there is
commenters, especially a road between Start and End; if there is such a road,
m09 in a 2011 thread. Distance gains a value, and the sentence is true.
The next sentence uses a SWIPL library predicate,
reverse/2. This takes two lists, and returns true if
between two connected points: the first list, reversed, is equivalent to the second list.
get_distance(Start, End, Distance) :- However, in this instance, the variable Visited is not
road(Start, End, Distance). yet assigned. Prolog always tries to find a solution to
Start up the interpreter, load the file, and try the the given constraints; a way to return true. Here, the
predicate out: obvious way to do that is to assign the reverse of the
?- [travelling]. first list to Visited. Now they are equivalent and the
?- get_distance(a, b, Distance). sentence is true.
Distance = 3. But what is this list? [End|[Start]] uses Head|Tail list
?- get_distance(a, d, Distance). notation. You can use this to decompose a list:
false. ?- [1, 2, 3, 4] = [A | B].
To use the predicate, you put in two constants and A=1
a variable, Distance. Prolog will then return possible B = [2, 3, 4]
solutions for Distance (in this case, only one solution A is assigned to the Head of the list, the first
exists for each question). It works fine for the facts element of the list; B is assigned to the Tail of the list,
exactly as we put them in; but you can’t reverse the all the rest except for the first element.
order of the towns. As our roads run in both directions, But you can also use H|T notation to create a list.
we’ll improve the rule: [Start] turns the variable Start into a list with a single
get_distance(Start, End, Distance) :- member, then [End|[Start]] prepends End to that
road(Start, End, Distance). list. This gives the list [End, Start], which we then
get_distance(Start, End, Distance) :- reverse to give [Start, End] which is then assigned to
road(End, Start, Distance).
Our predicate now has two clauses. A predicate
consists of one or more clauses, and two clauses Unification
belong to the same predicate if they have the same One of the basic ideas of Prolog is unification. The operator
functor (name) and the same arity (number of that symbolises unification is the equals sign, =, but the
arguments), as is the case here. get_distance(Start, idea isn’t quite the same as our normal concept of equals.
End) :- CLAUSE would be a different predicate as Two terms (constants, variables, or complex terms) unify
if either:
it has arity of 2, not 3. Prolog will try to solve both
They are the same term; or
clauses in its attempt to find a solution; so if you They contain a variable that can be instantiated to make
reload the file and try the reversed roads query, get_ them the same term.
distance(b, a, Distance). should now return 3. Here are some examples. foo = foo. is true, because the
You could also write this as terms (in this case a constant) are the same. Similarly 15 =
15. is true.
get_distance(Start, End, Distance) :-
What about foo = X.? Well, X is a variable, so it can be
(road(Start, End, Distance) ; road(End, Start, Distance)). instantiated to foo, in which case the terms can be unified.
The semi-colon acts as an ‘or’ operator. So that’s what Prolog does. (You can think of Prolog as
Next, let’s start on the travelling problem proper. trying to solve for unity if at all possible – so it looks for
First, let’s tackle the case where there is a road a way to make the unity true and does that.) You’ll get the
output X = foo.. If you now type bar = X., that’s fine too. But
between the start and end points:
X = foo, X = bar. will return false; you can’t instantiate X
get_route(Start, End, Visited, TotalDistance) :- twice in the same statement.
get_distance(Start, End, Distance), Prolog will also try to unify complex terms like
reverse([End|[Start]], Visited), predicates, if they have the same functor (name) and arity
TotalDistance is Distance. (number of arguments). Again, it will assign variables as
necessary to make this work:
Load this and run a query:
?- foo(X, Y) = foo(bar, baz).
?- [travelling]. X = bar
?- get_route(a, b, Visited, TotalDistance). Y = baz.
Visited = [a, b],
102 www.linuxvoice.com
PROLOG CODING
Visited. In this instance, since you have only two list You can step through the
members, you could just as easily use the Head|Tail code slowly and find out
concatenation the other way around, and avoid the exactly what Prolog is
use of reverse/2. However, in general, prepending up to. Load the graphical
to a list is much easier and cheaper in Prolog than debugger with guitracer.
appending to a list. In later stages of development then start tracing with
trace. – subsequent
of this code, Start might already be a long list of
statements will fire up the
previously-visited places, in which case prepending
tracer.
End is much easier.
The final sentence is easy: assign the value of
Distance to TotalDistance, the variable passed into
the rule at the start. This allows it to be output, as
Prolog is solving for Visited and TotalDistance. is is
an arithmetic operator used to compute the right-
hand expression and assign (unify) it with the left- is a bit theoretically complicated, but for now just
hand variable. think of it as Prolog’s version of not, which indeed was
And that’s it. However, this will only work if there the older form of the same operator.) So we’re looking
is a single road between the start and end points. for a solution to the first line where Next hasn’t been
We want something that calculates a longer route if visited before. (This avoids loops.)
needed, so let’s expand it into a recursive rule. Once we’ve found such a solution, we record
First, let’s recast the rule above so that it’ll work at the new distance in a temporary variable,
the end of a longer recursive process: NextDistanceSoFar, then recurse by calling get_
get_route(Current, End, VisitedSoFar, DistanceSoFar, Visited, route/6 again, with Next in the place of the Current
TotalDistance) :- node, adding Next into the VisitedSoFar list (using
get_distance(Current, End, Distance), Head|Tail notation again), and using the new distance
reverse([End|VisitedSoFar], Visited), tally. Note that Visited and TotalDistance pass
TotalDistance is DistanceSoFar + Distance. through the whole process unchanged. This is so
The logic of this is the same, but if we imagine that in the end, once a route has been found, they can
that this is the final step of a route, it’s clear that we be returned to the
will already have an ongoing distance tally, and we
will already have a set of visited points. So if there
user with their final
values. “If you get hooked, you too might
is a road between Current, the point we’re currently The final thing find yourself trying to work out
solving for, and End, the first sentence returns true, we
go on to assign values to Visited and TotalDistance,
we need to do is to
create an easy way the logic behind language.”
and we’re done. to call this rule (to
start the problem-solving process):
What about the recursive step? get_route(Start, End, Visited, TotalDistance) :-
get_route(Current, End, VisitedSoFar, DistanceSoFar, Visited, get_route(Start, End, [Start], 0, Visited, TotalDistance).
TotalDistance) :- We seed the VisitedSoFar list with our starting
get_distance(Current, Next, Distance), point, and set DistanceSoFar as zero. Prolog will then
\+ member(Next, VisitedSoFar), go forth and try to find a solution or solutions within
NextDistanceSoFar is DistanceSoFar + Distance, the given rules.
get_route(Next, End, [Next|VisitedSoFar], NextDistanceSoFar, Load it and run it (eg get_route(a, d, Visited,
Visited, TotalDistance) and see what happens.
TotalDistance). If you want to take your Prolog experimentation
The first line (the expression on the left-hand side of further, we strongly recommend the excellent
the rule) is identical to that of the rule above. As with website www.learnprolognow.org. There’s a free
get_distance/3, these are acting as two clauses of a online version or a dead-tree book. You could also
single rule. Prolog will try the first one, then the second look at the Prolog debugger, which can give you a
one, in its search for a solution. lot of information about what’s actually going on
The get_distance line has one assigned variable, when Prolog tries to find solutions for your code.
Current, and two new variables, Next and Distance. Try extending the code above to solve the ‘original’
Since these are unassigned, Prolog will try to find Travelling Salesman problem (the shortest possible
solutions to slot in; in this case, it will try to find values tour), or to look through solutions for a minimum one.
for Next such that the sentence evaluates true and Who knows, if you get hooked, you too might find
there is thus a value for Distance. yourself trying to work out the logic behind language
However! The next line gives an extra constraint like Prolog’s original designers.
for Next: it must not already be a member of
VisitedSoFar. \+ in Prolog is the negation operator Juliet Kemp is a scary polymath, and is the author of
Apress’s Linux System Administration Recipes.
(also known as negation-as-failure). (Logical negation
www.linuxvoice.com 103
CODING NINJA
CODE NINJA: SPREAD THE LOAD
TUTORIAL
WITH GNU PARALLEL
Speed up your shell scripts by sharing the load across all the
BEN EVERARD
under-utilised cores of your CPU.
I
n this month’s code ninja we’re going to take a A simple way to spread this load across all the
WHY DO THIS? detailed look at an often overlooked command cores on a machine is to start each tar command in
• Write scripts that run that can make your programs run faster. Parallel is its own process. This is done by adding an
faster
a command for running the same program multiple ampersand to the end of the tar line. With this in place,
• Instantly add
parallelisation to your times with different inputs. The idea is simple: we live the code runs through every subdirectory and starts
programs in a world where almost every computer has a compressing it, then moves straight onto the next
• Fully utilise your multicore CPU, yet very few programs can balance without waiting for the previous one to finish.
multicore CPU their work effectively across many cores. This means Another approach is to use a different compression
that you can often find yourself waiting for something program. Pigz is an implementation of Gzip that
to finish running, yet most of your CPU cores are idle. parallelises the compression for better performance.
Lets take a look at a simple example: compressing You can do this with the following script:
every subdirectory of the current directory into for dir in */
separate tar.gz files. This is useful when archiving files do
that you’ll need later. This can be done with a simple tar -cf - ${dir%/} | pigz > “${dir%/}.tar.gz”
script like so: done
for dir in */
do Introducing Parallel
tar -cfz ${dir%/} “${dir%/}.tar.gz” Here’s where we start using the parallel tool. This is a
done load-balancing program that executes tasks and
The expression ${dir%/} just returns the contents of spreads them out among the available CPU cores in
the dir variable with slashes stripped away. This code the most efficient way. In some respects, this is
loops through every subdirectory in turn, compresses similar to the version above where we put an
it, and moves on to the next one only once the ampersand at the end of the tar line; however, parallel
previous directory has been successfully compressed. doesn’t just launch all the tasks simultaneously.
Since the tar command only uses one CPU core at a Instead, it will launch one per CPU core and then when
time, this script will likewise only run on a single core each is finished, it launches another on the free core.
leaving the rest of your computer idle. This approach keeps the load on all CPU cores evenly.
To compress our subdirectories in this manner, we
need two parts. First, we need to write a script to list
all the subdirectories that we want to compress
(without the path or trailing slash):
for dir in */
do
echo ${dir%/}
done
Then we can pipe the output of this into parallel.
This will take each line of the input and use it as an
argument to the tar command. Each time it, it
replaces the {} symbols with the line read from input.
bash parallels-out.sh | parallel tar -czf {}.tar.gz {}
Don’t fall into the trap of premature optimisation!
For simple jobs, it would be easy to spend longer
thinking of ways to parallelise them than you would
actually save in computation. As well as simplicity, the
single-core method has the advantage that it won’t
overload the computer’s processor. By only using a
single core and not distributing the work over all the
The official Parallel tutorial is a very detailed, but quite dry, guide to the tool. cores, the first method won’t lock up the machine if
www.gnu.org/software/parallel/parallel_tutorial.html. you run it on a large data set. Other processes can use
104 www.linuxvoice.com
NINJA CODING
the other cores and the machine should remain
responsive.
The second method we looked at, which used
simple forking to run each process in its own thread,
should work well for most tasks. If the whole
computation is going to take less time than it takes to
look through the parallels or pigz man page, then this
is definitely the best option for a quick speed boost.
Save time carefully
It’s only worth investigating more complex operations
if it’s either a very complex computation, or if it’s a
computation that you have to perform many times.
The two most advanced forms of parallelisation we
look at here (pigz and parallel) have different payoffs.
Pigz should run faster on each file, so if you have
fewer files than processor cores, pigz should be the
quickest to run. The more files there are, the better
It is possible to run parallel with graphical software (such as the Pluma text editor),
parallel can balance the load across all the cores.
although we can’t think of a reason why you’d ever want to.
The biggest advantage that parallel has over pigz is
that it’s a standard method that you can apply to
anything, where as pigz is a specilised tool that does bash parallels-out.sh | parallel -j2 tar -czf {}.tar.gz {}
just one task. This means that if you want to go down
this route, you’ll have to learn how to use the Clustering
parallelised tools for every task rather than just The biggest speedup you can get running commands
remeber one (parallel), and use that in every situation. using parallel is by distributing the load around not
Another advantage of parallel is that you can use it only different cores, but different machines entirely.
to instantly parallelise any program you create. As long This means that you
as you design your program so that you split up the could launch a task
data to be processed (as we did in our compression from a lowly Raspberry “Another advantage of parallel is
example by creating a script that put together the
directories and filenames that should be processed)
Pi yet take advantage
of the CPUs on a
that you can use it to parallelise
and the actual computation (which in the previous cluster of high-end any program you create.”
example was the compression tool), then you can just servers. In order to
launch your program via parallel. This works take advantage of this, you first need to set up SSH
regardless of the language that you wrote the program certificate logins for each machine (see this month’s
in. It is worth noting that interpreted languages can be Masterclass for details). Once that’s done, you just
slow to start, so this may not be a great solution if need to create a file with a list of all the logins in the
there are a lot of small computations to do. form user@host, with one per line. You can tell
Before we get too carried away with when to use parallel to use this with the --slf flag.
parallel, let’s take a closer look at how to use it. In our Since parallel usually operates on files, you need to
example, we piped out a series of lines of text, and tell it what you want it to do with the files that are on
each line contained just the directory name. This the local machine when the processing is on remote
method of piping data to parallel is a common way of machines. The most common options are --transfer
using the command, but it’s not the only one. You can --return <filename> --cleanup. The --transfer option
also put a series of inputs after three colons. As a copies the local file to the remote server before
trivial example, the following will print the numbers starting the computation; --return <filename> copies
one, two and three (though not necessarily in that the file with the name <filename> back again
order): afterwards; and --cleanup deletes the files from the
parallel echo ::: 1 2 3 remote server once the processing has finished. You
can use the shorthand --trc <outfile> to use all these
Tuning performance together. These are used when the filename being
By default, parallel will choose the optimum number worked on is the argument passed into parallels, so
based on the amount of cores in your CPU, however, won’t work in a situation like our example.
there are times when you want to change this. For bash parallels-out.sh | parallel --slf loginfile --trc {}.tar.gz tar
example, by leaving a core or two free, other programs -czf {}.tar.gz {}
can continue to run without too dramatic a slow There are many more options to parallel, and many
down. This is done using the -j flag. For example, to different ways of triggering the same options, but
run our previous command but using just two tasks at using the ones we’ve looked at here you should be
a time, use the following: able to significantly speed up many of your scripts.
www.linuxvoice.com 105
TUTORIAL PROFILING
PROFILING: MAKE CODE RUN
TUTORIAL
MORE QUICKLY
BEN EVERARD
Optimise your code by finding out which parts of it
are swift and which bits are sluggish.
I
f there’s one thing everyone loves in a program it’s
WHY DO THIS? speed. Sitting around waiting for a computer to do run1()
• Write programs that run something isn’t fun, and now in 2015 when we
faster
have multi-core computers that can perform tens of print primes
• Gain a better
understanding of how thousands of millions of operations a second, it really This code works quite simply. It loops through
your programs run shouldn’t happen. every number between 1 and the maximum, which
• Use a 2000-year-old We’re going to take a look at a simple Python is stored in the variable i. The program then loops
algorithm to find prime program for calculating prime numbers. In case through every number between 1 and the square root
numbers
you’re unfamiliar with these, they’re numbers that are of i (the square root because every non-prime must be
only divisible by 1 and themselves. So, 2, 3, 5 and 7 divisible either its square root or a smaller number). It
are prime numbers, but 9 isn’t. These numbers have then divides the first iteration by the second iteration
quite a few quirky mathematical properties, including (y). If the result is a whole number, the program has
some very obscure maths that makes them useful found a divisor, so i can’t be prime.
to encryption. Our task for today, though, is simply to
calculate them as quickly as possible. Yes, we know it’s not perfect…
We’ll start with a simple Python program that can You may well have spotted some things that can be
calculate the prime numbers between 1 and 1000: improved. But we won’t just dive in and start changing
max_num = 10000 things. We’ll do this methodically. First, we’ll get a
import math benchmark to see how it runs. We can do this using
primes = [] the time program. You can do this with:
time python primes1.py
def run1(): Where primes1.py is a file containing the above
i=2 program. This will output three different times: real,
while i < max_num: users, and sys. The real time is the time between
prime = True starting the program and it terminating. The user
y=2 time is the amount of time spent in userspace, and
while y < int(math.sqrt(i)): sys is the amount of time in system calls. Since we’re
if (float(i)/float(y)).is_integer(): interested in the total time the program takes, we’ll
prime = False look at the real values in this tutorial. On our test
The line profiler’s output y=y+1 system, this program took 0.589 seconds. That’s not
makes it easy to see which if prime: bad, but we can make it faster.
lines in our program are primes.append(i) Before looking at making it faster, let’s find out
slowing us down. i = i+1 what’s making it slow. We can use a tool called a
profiler to analyse how our program runs and see
which parts of the code are taking the longest. Python
does have a built-in profiler, but the one in the module
line_profiler does a much better job for code like ours.
First you need to install the Python header files
through your distro’s package manager. These are
usually in a package called python-dev. Once you’ve
done that, you can install the profiler with:
sudo pip install line_profiler
To use this, we first need to add a line directly above
the function definition to tell the profiler that we want
to investigate that function. It should now read:
@profile
def run1():
With this in place, you can profile the code with:
kernprof -vl primes1.py
106 www.linuxvoice.com
PROFILING TUTORIAL
This will run the program, then let you view how
much time each line in the program took. The table
that it outputs is quite revealing, and the % time
column shows that it’s the inner loop that takes the
most time, specifically, the lines:
while y < int(math.sqrt(i)):
if (float(i)/float(y)).is_integer():
prime = False
y=y+1
Between them, these make up 33% of the number
of lines in the program, but they take up 97.9% of the
total running time. In other words, it doesn’t matter
what we do with the rest of the program – unless we
can get these running faster, it’s not going to make
much difference.
Low-hanging fruit
There’s a reason that these lines take so much time.
They’re run far more frequently than any other line
because they’re the inner loop. For every iteration of
the outer loop, these run many times.
Of these lines, the slowest is the if statement. In
order for it to run, it has to do four things: convert i
from an int to a float; convert y from an int to a float; As well as finding a way to calculate prime numbers,
divide float(i) by float(y); and see if the result is a Eratosthenes calculated the earth’s circumference
whole number. That’s quite a lot of processing for the without leaving Egypt (he was out by just 16%).
simple goal of checking if one number is a divisor for
another, and since this accounts for 35% of the total speed has increased, but this line is still the source
time, it’s worth trying to find another way. of a lot of the speed simply because it’s run so many
Mathematically, this operation is the same as times. We can now turn our full attention to the
dividing one integer by another and checking whether While loop.
there’s not a remainder to the division. This can be Generally, when programming, it’s best to use
done using the modulo operator. This slightly obscure the standard features of the language as much
operator returns the remainder of a division, not the as possible. Doing this means you can program
actual result, and it’s performed with the percent more quickly (because you have to write less code).
symbol. The if line can be changed to: It usually also makes your code faster and less
if i % y == 0: error-prone, because
Running the profiler again, you should see that the the standard parts
of most languages “In general it’s best to use
Profiling in other languages
are written by people
who are experts in
the standard features of a
In this tutorial, we’ve looked a profiling using the popular
the field, and they language as much as possible.”
usually expend a lot of
Python language, but almost all languages have at least
one profiling tool to help you speed up your code. effort to make sure each part of the language runs as
Gprof is the most famous profiling tool for Linux (and quickly as possible. In interpreted languages such as
other Unix-like systems). It’s most commonly used with Python there is even more of an advantage, because
C and C++ code that’s been compiled using GCC. You the standard parts of the language are compiled into
can instruct the compiler to insert profiling code into
native code while any code you write is interpreted.
executables when they’re built, and then use these to
analyse the performance of the code in a similar way to the The speed differences can be huge.
profiling we’ve done in this tutorial. The code:
JavaScript is, like Python, an interpreted language, y=2
so you need a profiler that works with the interpreter. while y < int(math.sqrt(i)):
Most major browsers (including Firefox and Chrome)
y=y+1
have profilers built in to their JavaScript engines so web
developers can keep track of their pages performance from Is functionally equivalent to:
within the browser. for y in range (2, int(math.sqrt(i)):
It’s not just programming languages that benefit from Both of these will iterate through the whole
profiling. Database engines often come with performance numbers from 2 to the square root of i, but the second
analysis tools. In the case of MariaDB and MySQL, this is the
one will do all the processing in highly optimised
slow query log that can be used to track which queries are
performing poorly. native code, while the first one does it in unoptimised
interpreted Python.
www.linuxvoice.com 107
TUTORIAL PROFILING
if prime:
primes.append(i)
run1()
print primes
You can see here that we’ve also changed the first
while loop to a for loop to increase speed as well,
though this has a much smaller speed increase than
the inner loop change. Another optimisation we’ve
included is the break. This is because we can stop
checking a number after we’ve found one divisor. It
doesn’t matter whether or not there are more: as long
as there’s one, it’s not prime.
With these speedups in place, the code runs in
0.036 seconds. That’s another 300% speed increase
over the previous 300% speed increase. With just a
few simple optimisations, we’ve been able to make
our prime number calculator run faster by a factor of
10. That’s pretty good going!
The profiler in Firefox
On our test machine, the version with the while loop
keeps track of the
performance of JavaScript, ran in 0.33s, while the version with the range ran in Excess speed
and the web browser in 0.1s. That’s running over 300% faster just by changing So far, our optimisations have led to our code
general. the type of loop! becoming a bit more readable. However, this isn’t
always the case. You’ll often find that pushing for
Skipping steps gains can lead to code that’s more complex and
We’ve now made each line run much faster, but a confusing. This can make it hard to maintain as you
major problem for our code is simply the number of may not fully remember how the optimisations work if
times that the loops are running. Even a really efficient you have to come back to the code later.
line can be a major slowdown if it’s running millions of In the previous example, complexity has crept in a
times. Here we have to look at the nature of the little bit because, by optimising out the even numbers,
calculation that’s going on to see where speedups we’ve introduced a special case for the number 2.
may lie. The more you understand about the problem The first prime now has to be added manually to the
you’re solving with your code, the better you will be list of primes. This is a fairly simple case, and with
able to optimise your algorithms. the judicious use of comments, you should be able to
One fairly simple fact about prime numbers is explain it (optimisations are something that should
that no even number larger than 2 can be prime. always be commented).
This is simply by definition, since an even number
has to be divisible by 2. Another slightly less obvious
cProfile
fact is that any odd non-prime number has to be
divisible by an odd number. This is because of the In this tutorial, we’ve used a line profiler, but that’s not
property multiplication that says that an odd number the only option. Python’s default profiler, cProfile, is also
multiplied by an even number is odd, while an odd a powerful tool for understanding your code. However,
instead of working on a line-by-line basis, it works on a call-
number multiplied by an odd number is even and an
by-call basis, so it’s great for working out which functions
even number multiplied by an even number is even. and methods are taking the most time to run. Take a look at
The result of all this is that we can cut into a quarter the Python docs for details on how to use it (https://docs.
the number of times that the inner loop must run python.org/2/library/profile.html).
by eliminating any unnecessary loops through even
numbers. The code can be changed to:
max_num = 10000
import math
primes = [2]
#@profile
def run1():
for i in range(3, max_num, 2):
prime = True
for y in range(3,int(math.sqrt(i)), 2):
if i % y == 0: The SnakeViz tool can be used to make diagrams out
prime = False of the output from cProfiler.
break
108 www.linuxvoice.com
PROFILING TUTORIAL
Let’s look if we try to optimise it further. with numbers of the form 2*x where x itself is 2 or
The algorithm we’re using to find primes is probably larger. This is why we start our inner loop with i*i. Any
the simplest one possible. It just checks every number numbers of that form where x is smaller than the first
against every possible divisor, and if it doesn’t find a number can be ignored, because we will have found
divisor, it classes the number as prime. It’s so simple them (if they exist) in an earlier iteration of the loop.
that a new programmer coming to the code should Then, we take the next smallest prime, 3. Anything
be able to tell what’s going on almost straight away. smaller the 3*3 that’s not a prime must have already
It isn’t however, the fastest method for calculating been marked (for example 6, which was marked off
primes. Take, for example, the following code: in the first iteration since it’s a multiple of 2), so the
import math algorithm then checks off all the multiples of 3 larger
than 9. The algorithm then continues until it’s reached
max_num = 1000000 the square root of the maximum, since no number
primes_list = [True] * max_num smaller than the maximum can have a smaller
smallest divisor than the square root of the maximum.
for i in range(2, int(math.sqrt(max_num))): This method is called the sieve of Eratosthenes,
if primes_list[i]: and was discovered by Eratosthenes of Cyrene
for j in range (i*i, max_num, i): circa 200BC. It’s much faster (around 10 times)
primes_list[j] = False faster than our original method, but it’s also much
break harder to understand. Indeed, even after reading the
previous explanation, you may still have difficulty fully
out_list = [] understanding what’s going on. There are some even
for i in range(i,max_num): more efficient methods of calculating primes that are
if primes_list[i]: even more complex.
out_list.append(i) The problem we have here is that we’ve optimised
for speed, but
print out_list
If you run it, you’ll find that it outputs all the primes
in doing so
have sacrificed
“The problem here is that we’ve
between 1 and a million, and it’s fiendishly fast. If readability and the optimised for speed, but in doing
we remove the print lines (which take up most of
the running time), and compare it with the previous
understandability
of the code. If you
so have sacrificed readbility.”
code (again with 1,000,000 as the maximum and the do this at every stage
print lines removed), this code runs in 0.48s (on our in your programs, you’ll very quickly end up with an
test machine) compared to 5.67s for the other code. unmaintainable mess. You need to target just the
That’s a massive speed up, but how on earth does it parts that are most worth optimising for speed, and
do it? If you fancy a maths challenge, try to work it out optimise the others for readability instead.
before reading on.
Keep it sensible
Ready? Let’s carry on… Donald Knuth, legendary programmer and author of
First, the algorithm starts by assuming each number the epic book The Art of Computer Programming
is a prime until it finds that it’s not. The primes_list advises, “We should forget about small efficiencies,
variable holds a True or False value for each number, say about 97% of the time: premature optimisation is
and we’ll set them to False when we find out if a the root of all evil. Yet we should not pass up our
number is not a prime. opportunities in that critical 3%.”
Starting with the number 2, and working up to the Note the term premature optimisation. Back at the
square root of the maximum, if the number is marked start of this tutorial, we used a profiler to find the parts
as a prime, it loops through the numbers i*i, i*i+i, of our code that were running the slowest. You can
i*i+2i, i*1+3i until this number gets larger than the do the same with whole projects. If we did this on our
maximum number. The program marks every number program that included the prime generation code,
in this sequence as not prime since it’s divisible by i. and discovered it only needed the first 100 primes
It should be fairly obvious that every number once and never again, it would be foolish to include
marked as not a prime by this isn’t a prime, but what’s the sieve of Eratosthenes, as doing so would save
not immediately clear is why we can be sure that your code fractions of a second, at a huge cost to
every number that’s not a prime is marked as such, maintainability. On the other hand, if it’s spending 10%
leaving only the prime numbers remaining. It’s crucial of its time calculating prime numbers, then it would
to realise two things: every non-prime has at least be equally foolish to throw away a significant speedup
one prime divisor (actually, they have at least two, but for a few lines of complicated code. Just make sure
that’s not necessary here), and we start our loop with they’re properly commented.
the smallest prime, 2. We need to find any numbers
that are multiples of 2. However, since we are looping Ben Everard always comments his code, though as we can’t
read his handwriting, it’s often not much help.
up from the smallest, we only need concern ourselves
www.linuxvoice.com 109
MASTERCLASS REMOTE CONTROL
MASTERCLASS
Ferry files like a master with an oft-overlooked protocol that
BEN EVERARD changed the nature of the web when it debuted.
LEARN THE SECRETS OF
REMOTE ACCESS WITH SSH
The ubiquitous login tool has more than a few tricks up its sleeve to help experienced users.
S
SH is one of the most familiar Linux commands
BEN EVERARD to many people. In its simplest use, it’s a way of
getting command line access to a remote
computer, however this isn’t all it does. Even if you’re
familiar with its basic use, it’s still worth taking a little
time to investigate it fully.
In order to use ssh, the remote host needs to have
the server software installed (you can also log into
localhost using ssh if you want to try out some
options). This varies between distributions, so check
the docs for details. On Ubuntu-based systems, it can
be done with: Need to do some remote admin but don’t like command
sudo apt-get install openssh-server line text editors? ssh with X forwarding to the rescue!
You’ll also need the ssh client on the machine you’re
logging in from, but this is almost always installed by host is the IP address or hostname of the machine
default (Arch users should read the wiki). you want to log into. If you have certificates set up for
The most basic usage of the ssh command is: that use on that host, it will log you in automatically
ssh user@host (see boxout), if not, it will prompt you for a password.
Where user is your username on the remote host, and Once it’s connected, it will present you with command
Certificates
When you first install an SSH server, you’ll be able to log in just need to copy your newly created public key into the
with your system password. However, passwords are authorized_keys file on the remote host. You can even use
fundamentally limited by our ability to remember them. Our SSH to make this easier!
weak, squishy brains struggle to hold enough information for cat ~/.ssh/id_rsa.pub | ssh user@host “mkdir -p ~/.ssh && cat >> ~/.
properly secure passwords, and attackers routinely scour the ssh/authorized_keys”
internet for servers with SSH open and try to guess these With this set up, you’ll no longer be asked for a password
passwords. when you log in. Remember, though, that the client now has
The best solution to this is to remove the squishy part of access to the server, so if it’s a laptop and it gets stolen, you’ll
the problem. Rather than having to remember passwords, we need to remove the key from the authorized_keys file to lock
can store the details needed for authentication on our out the thief. If the remote server is important, you should also
computers. We don’t just mean that you should copy and consider encrypting every machine that has certificates to
paste your password into a text file, but create a certificate access it.
that enables you to securely log into an SSH server. This You can now disable password logins to make the system
requires a little bit of setup on both the client and the server. more secure. This will block everyone from logging in via SSH
The first thing you need to do is on the client (the machine using a password, so make sure none of your users rely on this
you log in from). You need to generate a new SSH identity with: before moving on.
ssh-keygen -t rsa Just insert the following line in the /etc/ssh/ssh_config file,
This will create key files in the .ssh directory in your home and restart the SSH service (or reboot the computer):
folder. In order to be able to log in to the remote machine, you PasswordAuthentication no
110 www.linuxvoice.com
REMOTE CONTROL MASTERCLASS
Each ssh key has an associated bit of art. This is to make Using Cluster SSH, you can
it easier for people to tell if the key of a server has A side advantage of running commands via SSH is
run the same command on
changed, but we don’t know anyone who would notice. that you can use it to stream files between machines. multiple machines (or the
For example: same machine multiple
line access to the remote machine. This standard cat myfile | ssh user@host “cat - > myfile-remote” times if you must).
method is great when you’re sitting at a computer, but Of course, it’s usually best to use SCP to securely
you can’t use it easily in scripts. The solution here is copy files between computers, but there are
just to add a new argument that’s the command you occasions where SSH can be a better choice. Usually,
want to run on the remote machine. For example, you this is when the file itself doesn’t yet exist, and using
can find out the disk usage of a remote machine with: SSH rather than SCP, you can avoid creating the file
ssh user@host “df -h” locally in the first place. For example, you can stream
a hard drive image directly to a backup server with:
X forwarding dd if=/dev/sda | ssh user@host ‘dd of=sda.img’
You don’t have to restrict yourself to just command Similarly, data can be streamed the other way, so
line programs. SSH also enables you to run graphical you could restore this image with:
programs on the remote system but display the ssh user@host ‘dd if=sda.img’ | dd of=/dev/sda
output locally with the flag -X. For example, you could SSH can also be used to connect computers for
edit a configuration file on a remote server using the purposes other than running commands. It is, at its
graphical Gedit text editor with: heart, just a system for securely sending data
ssh -X user@host gedit between two computers. So far, we’ve seen how this
can be used for commands and files, but it can be
anything, and SSH has a
Fail2ban
If you can’t disable password SSH logins (see the box on
whole host of options to
make it easy to set up. The
“SSH can be used to connect
Certificates), then it’s a good idea to add a little more
security to SSH through Fail2ban. This tool monitors SSH
-D <portnumber> option is computers for purposes other
connection attempts, and if it finds someone repeatedly
used to set up a SOCKs
proxy, which can be used to
than running commands.”
trying to log in, it blocks them for a specified length of time.
Although this doesn’t give as much security as certificates, channel web browsing data
it should prevent an attacker brute-forcing any but the very through another machine. To do this, first create the
weakest of passwords (though this is no excuse not to use SOCKs proxy with:
secure passwords!).
ssh -D 12345 user@host
You should find Fail2ban in your distro’s repositories, but
it can be a little tricky to configure (although depending on Then you can connect your web browser to this by
your distro, the defaults may be fine). The file /etc/fail2ban/ changing the proxy settings to localhost and port
jails.conf holds all the options. Fail2ban monitors services 12345. Once this is done, your browsing will appear to
that are set up with jails. These jails are specified through be coming through the remote machine. This can be a
sections in the jails.conf file. For example, the following is
the default jail for SSH on Debian:
useful way of accessing an intranet, or accessing a
bantime = 600 web page from a different part of the world.
findtime = 600 We’ll finish our tour of SSH with something that’s
not a core part of SSH, but a useful feature of some
[ssh]
implementations: the ability to run commands on
enabled = true
port = ssh
more than one machine a once. There are a few SSH
filter = sshd clients that enable you to do this such as Cluster SSH
logpath = /var/log/auth.log (https://github.com/duncs/clusterssh/wiki). Using
maxretry = 6 this tool, you get a terminal window for every machine
This will monitor the log for anyone who tries and fails to you’re logged into, but also a cluster window, and
log in six times in 600 seconds (set in the findtime option).
Anyone who triggers this will be banned for 600 seconds
anything you type into the cluster window gets sent to
(the bantime). After this time they can try again. every machine. If you need to upgrade lots of
Fail2ban isn’t just for SSH, and can be used to protect machines, you can simply enter it once rather than
many services. Take a look at the documentation at having to log into each machine and perform the
www.fail2ban.org/wiki/index.php/MANUAL_0_8 for more. operation manually.
www.linuxvoice.com 111
MASTERCLASS REMOTE CONTROL
REMOTE MANAGEMENT WITH
WEBMIN
Connect to and administer remote machines quickly and securely.
W
ebmin is a great tool for remotely
BEN EVERARD administering a server without having to go
near the command line. Unlike SSH, which
just provides access to the remote machine, Webmin
is as the name cunningly suggests, a web-based
administration tool.
Webmin is available for most distros, but it’s not
always in the repositories, so if you can’t find it via
your package manager, you’ll find RPM and Deb files
on the project website, http://webmin.com.
Webmin comes bundled with its own web server
and runs on port 10000 by default, so it shouldn’t
interfere with any other services that are running.
Once you’ve installed it, you
“By picking the modules you can log in by pointing your
need, you can customise web browser to https://
localhost:10000 and entering
Webmin to your taste.” the credentials of any user The welcome screen to webmin shows you how your
that has sudo privileges. It will machine’s resources are currently being used.
use a self-signed SSL
certificate, so you will get an SSL warning. If you’re the left-hand side that contains a wide range of areas
using Webmin on an untrusted network, it’s a good that can be administered. Webmin is module-based,
The clustering feature of idea to set it up with a proper certificate so you can be so the options you see will depend on the modules
Webmin can make
sure that there’s not a man-in-the-middle attack, since you have installed. By picking the modules you need,
administering groups of
that could give attackers complete control over your you can customise Webmin to your taste. The list of
servers as easy as
administering one. server. Once in, you’ll see a web page with a menu on modules is ordered into categories to make it easier to
find the right module for a particular task.
Performing backups
Let’s take a look at one of the most important aspects
of running a system: backups. There are loads of
backup systems available, and if you’ve already got a
Usermin
Usermin is a stripped down version of Webmin designed for
non-root users. It lets people perform all the usual tasks
that they may need to perform for a regular user rather than
the system-wide changes that a root user may need to
make. Usermin follows the same setup as Webmin, but with
far fewer modules, and none of the modules can make
system-wide changes.
For example, a few of the default Usermin modules are:
Disk Quotas where you can view the amount of disk
space you’re currently allowed to use.
SSH Configuration allows you to add authorised keys to
your SSH account.
Scheduled Cron Jobs is used to edit the tasks that the
cron daemon runs at set times.
The intended setup is that both Webmin and Usermin are
on the same system, and any particular user has access to
the one that suits their access level.
112 www.linuxvoice.com
REMOTE CONTROL MASTERCLASS
Virtualmin
Don’t be confused by the name: Virtualmin has little to do
with virtualisation. It’s an extension to Webmin designed for
setting up and running virtual servers in the sense that
Apache uses the term ‘virtual server’, not in the sense of a
server running on a virtual machine. This is where different
users have accounts on the same machine that they can
use to host their own websites, usually with associated FTP
accounts and other such access tools. Unlike a virtualised
server, all virtual servers run on the same distro. We don’t
know who decided to name two similar technologies the
same, but we really wish they hadn’t.
Virtualmin is more specialised than either Webmin or
Usermin, and it’s mostly for people administering large
numbers of websites, especially if each website is being run
by a different person.
system you’re happy with, there’s no reason to change
it. If, however, you don’t, then Webmin’s backup and
restore is one of the easiest to set up, especially for
people who aren’t comfortable on the command line.
The backup options are in the System > Filesystem By using the TAR format for backups, you can be sure that you can restore them even if
Backup module. On the first screen, you just select the Webmin isn’t working.
directory that you want to backup. There’s a box you
can check to store the backup in TAR format, which Using this feature, you can quickly configure a large
will make it easy to use with other tools should you number of servers without having to repeat the
wish. On the second screen, you can set a wide variety configuration steps on each machine. A similar, but
of options to make sure your backup is running just slightly more complicated approach can be done with
how you want it. You can automatically transfer the Cluster SSH, as seen on the previous page.
backup to another server via FTP or SSH; you can In the Cluster menu, you’ll see options to copy files,
schedule the backup to take place at a certain time; run commands, update software and more on groups
you can email someone once the backup has of machines at the same time. Before you do that,
completed; and more. Experienced admins will though, you have to connect your current instance of
probably realise that all this is possible via a few Webmin to the machines you want to administer. To
commands, but the point of Webmin isn’t that it do this, go to Cluster > Cluster Webmin Servers and
makes things possible, but that it makes things easy, enter the details of the machines. Once they’re all
and avoids the need to memorise command options if connected, you will see them appear in the lists on the
you don’t want to. various cluster modules. For example, in Cluster >
Webmin is designed for an administrator remotely Cluster Software Packages, you can install the same
managing servers, but it’s actually quite good as a software on a range of servers with just a few clicks.
general computer admin tool as well, and you can use
it to perform day-to-day tasks, for example, installing The main benefit: discoverability
software via your package manager. One big advantage of Webmin for novice system
administrators is that it’s easy to discover what’s
Package management possible. If you’re faced with just a blank command
The package management module is at System > line, it can be hard to work out what you can achieve
Software Packages (there’s also System > Software with which commands. For example, if you don’t
Package Updates for grabbing the latest versions of know how to change groups, man pages are a good
software). Here you can do all the usual package start, but they only work if you know what the
administration tasks like installing new software, commands are. Using Webmin, you just need to
removing software, and even a distribution upgrade. navigate through the menu to System > Users And
There are already graphical front-ends to rpm and Groups, and you can quickly see all the groups, users
apt-get, but Webmin brings them into a centralised and actions. Of course, it’s a good idea to learn the
system that you can use for much of your system commands as well, as they often have more flexibility
maintenance. Any OpenSUSE or Mandriva users will than Webmin as well as the ability to script, but that
already be used to having such a centralised system, doesn’t mean that there’s not a place for a web-based
but it can be quite a novelty to those of us system in your system administration toolkit.
accustomed to different distros.
One advantage of Webmin over standard command Ben Everard is the Ed Sheeran lookalike behind all of Linux
Voice’s tech infrastructure.
line tools is the ability to cluster servers together.
www.linuxvoice.com 113
/DEV/RANDOM/
Final thoughts, musings and reflections
Nick Veitch
was the original editor
of Linux Format, a
role he played until he
got bored and went
to work at Canonical
Bike helmet, because I
instead. Splitter!
find cycling in the morning
Possibly the world’s makes it much easier to
dirtiest tea cup. work at a desk all day.
A
few months ago, my boiler broke. In the
grand scheme of hardships, this is not a
great one, particularly as I have a service
contract: the duly appointed engineer arrived,
limboed under the beams in my attic and
replaced the errant component – he actually had
one in the van, for once. We had a brief
discussion about it, because my boiler breaks
Microsoft may make terrible
about once a year (I must have upset the gods of operating systems and awful web
central heating somehow) and I likened it to the browsers, but its keyboards are
fabled ship of Theseus, as I believe the front surprisingly good.
A vertical mouse, because
cover is the only part which is original. having arthritis sucks.
On this occasion, it was the main circuit board
(the third incarnation, I recall), which apparently
would have cost about £100. It looks like a loose
collection of relays, a few logic ICs and some
power circuitry, with a few sensor circuits thrown
My Linux Setup Ben Everard
in. To be fair, in limited numbers, it probably is
expensive to build. But why in limited numbers?
Linux Voice’s technical editor shares his open plan blandness.
Why do things such as this, and a whole
collection of other devices littering my home, What version of Linux are you graphics working. I tried again with SUSE
have bespoke “brain” circuitry which does the currently using? a year or so later, and that’s when I started
same job? Dishwashers, washing machines, Across my various devices, I use using Linux properly.
microwaves, tumble driers – they all have some Arch, Ubuntu, ChromeOS,
‘brain’ circuit connected to a handful of actuators Cyanogenmod and Android. All of them do What Free Software/open source
and sensors to perform their servile tasks. a particular job really well. can’t you live without?
If you abstract the I/O part, they could VirtualBox. It is absolutely amazing
probably all run comfortably from something And what desktop do you for testing things out, and I seem to
mass produced and perhaps ruggedised into the currently use? spend half my life in a virtual machine.
bargain for an attractive fraction of the cost. Why On Arch, it’s a bizarre blend of Mate
not go further and invest in some sort of open and Gnome 3, while on Ubuntu it’s What do other people love but
hardware standard? Imagine a world where all an early build of LXQt that I’ve never quite you can’t get on with?
the brains of all the things were the same! gotten around to upgrading. Nothing’s C++. I program in a handful of
It may be an overspecced part for some ever quite normal on my machines. languages, including some
applications, but the ubiquity would mean object-orientated ones, but for some
everything. So if anyone wants to convince the What was the first Linux setup reason I just don’t like C++. I’m fine with C
appliance makers of the world of open hardware, you ever used? though.
they have my support. And the boiler repairman’s I think it was Slackware, but I only
too – his van is only so big… used it once and couldn’t get
114 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