Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

LXF - 287 - April 2022

Download as pdf or txt
Download as pdf or txt
You are on page 1of 102

WELCOME

MEET THE TEAM


This issue we’re compiling the Linux
Kernel of truth
kernel from source. We wondered if our Compiling the kernel from source
was always a key moment in many
experts compile anything from source, Unix courses. After all, there was a
or does even the thought of this cause time when everyone who wanted to
them to run screaming into the night? seriously learn how to admin a
system would need to learn this
skill. Not that it’s that complex a
Jonni Bidwell thing to do – you just need the right
The records tell of a rogue who, masquerading files, tools and a modicum of time.
as a GCC packager, managed to sneak an Rightly so, modern Linux distros
arcane stanza into the source. The result was have neatly hidden away this
that whenever a certain string was input to complexity with just outliers such as
any program compiled by this tainted GCC Gentoo (see LXF276) or Linux from
(including new versions of GCC)… ah well, that would be telling! Scratch (see page 48) requiring this step. As always, getting your
hands dirty with such things is a fantastic learning experience. And
Jonni’s here to step you through the process. He reveals everything
Nick Peers you need to know about building your own kernel, the benefits and
I’m perfectly happy to compile stuff from tweaks you can make, and looks at trimming the kernels and if you
source so long as the instructions are clear really need to. It’s handy that we’re also covering Linux from Scratch
and legible so I don’t have to think too hard so you can put your knowledge into action!
about it. However, if an up-to-date snap, If you prefer your kernels to be pre-compiled then we’re looking
flatpak or AppImage exists, I’ll always take the at the best Ubuntu alternatives in this issue’s Roundup. The quality
lazy option and choose that. is astounding. There’s a new series kicking off looking at open home
automation. Our Linux Format server is going to be getting the
ability to host lessons and we add some polish to our ebooks.
Les Pounder For makers and coders we add more features to our basic
I don’t compile much from source: a project Wolfenstein game, take a deep-dive into the Mira Chromecast-like
found on GitHub, or an emulator for an old protocol and kick off another new series looking at that stalwart
computer. The last serious project I compiled language Perl. So enjoy!
from source was before the release of the
Raspberry Pi Pico, which required me to build
the C/C++ examples ahead of release. I still have the nightmares.

Neil Mohr Editor


Michael Reed neil.mohr@futurenet.com
Not wishing to show my age too much, but
when I started with Linux in 1996, you had to
recompile the kernel to save on memory. For
one thing, Red Hat around this time spent
ages checking for every possible CD-ROM
interface on boot if you didn’t!

Alexander Tolstoy
Subscribe
For me, this question just hits the spot! I’m all
in for building things from source, whether it’s
& save!
another HotPicks candidate or something for On digital and print –
myself (or both). And this includes the Linux
kernel. Naturally, I avoid compiling large
see page 16
projects such as LibreOffice or Firefox because it may take far too
long on my humble desktop machine.

www.techradar.com/pro/linux April 2022 LXF287 3


Contents SUBSCRIBE NOW!
Page 16

BUILD THE
REVIEWS

Intel Core i5 12400 19

KERNEL
It’s the new Q6600 of the processor
world, which is also Dave James’ greatest
compliment ever! Discover why this should
be your next desktop CPU.

The kernel is what makes Linux


tick. Jonni Bidwell is happy to
help you tune up those ticks.
The fun starts on page 32!

ArchLabs 2022.02.12 20
Mayank Sharma has a soft spot for new
Arch-based distros, and this time around
he’s found one that tickles his fancy and
has a fine selection of desktops.

UBOS Linux 2022-02-04 21


Mechanisms for simplifying the installation
of popular web tools are like snake oil. Or
so thought Mayank Sharma, until he came
across UBOS…

Slackware 15 22
He’s no masochist… until there’s a new
Slackware release, when Mayank Sharma
puts himself through all kinds of pains to
relive the good ol’ days.

Valve Steam Deck


Our PCGamer friends bagged a hands-on
24
ROUNDUP IN-DEPTH
hardware preview of the Steam Deck before
the big launch at the end of February.
Here’s what they learnt…

Ubuntu alternatives 26 Linux From Scratch – part two 48


FLIRC Pi Zero Case 41 The ever-curious Michael Reed investigates Aaron Peters takes us deeper into the Linux
Les Pounder keeps his cool with a case for Ubuntu progenies and finds that they each From Scratch process, as we get our
his beloved Raspberry Pi Zero 2 W. Will it have their own take on a how a desktop personal Linux distro up and running from
beat the heat of a benchmark? should work… scratch, straight from the source!

4 LXF287 April 2022 www.linuxformat.com


CONTENTS

Pi USER TUTORIALS

Raspberry Pi news 40 TERMINAL: Fuzzy search 52


Introduced by PJ Evans. Coolest Projects Shashank Sharma isn’t one for magic,
goes Global so everyone can take part, the but he’s not averse to using the Accio spell,
Pi gets beta network installs and the 64-bit or its computing incarnation, fuzzy finder,
Pi OS comes out of beta. to find things quickly.

FLIRC Pi Zero Case 41 ZOTERO: Organised research 54


Les Pounder keeps his cool with a case for Always on the look-out for organisational
his beloved Raspberry Pi Zero 2 W. Will it tools, Nick Peers reveals how to bring all
beat the heat of a benchmark? your research materials and notes into a
single, convenient space.
Build a news ticker 42
Les Pounder constructs his own homage EMULATION: Jupiter Ace 58
to the famous Times Square news ticker, Les Pounder nips back to the early 80s and
this time scaled for ants! pays homage to a home computer that
sold less than 6,000 units, despite its
Inside casting protocols 44 go-faster stripes!
Mats Tage Axelsson takes you on a tour of
the Linux tools that will enable you to
stream media between your laptop and
other devices.

CODING ACADEMY

Growing binary trees 88


Mihalis Tsoukalos explains how to construct
and use binary trees for faster searches and ASSISTANT: Home automation 64
easier relationships (of the data sort, mind). Matt Holder, who’s a bit of a clever-clogs
himself, investigates the usage of Home
Mojolicious web scraping 92 Assistant to make your home as smart
Mark Gardner helps retrieve and parse as it can be.
HTML and XML from websites with a few
lines of Perl and the Mojolicious framework. LIBREOFFICE: Ebook publishing 68
Seeking to chalk up a best seller, Michael
3D world collision detection 94 Reed goes further into the intricacies of
Enhance your gaming world by adding publishing a book from his Ubuntu desktop
collision detection and custom objects, as and using online print services.
Andrew Smith throws barrels at you.
LXF SERVER: Online classes 72
REGULARS AT A GLANCE David Rutland moodles along with
classroom management software on the
Linux Format virtual private server and
News 6 Subscriptions 16 starts his own online course.
Linux malware increases by 35 per cent Get your monthly Linux dose and save cash!
during 2021, there’s a nasty Polkit exploit
you need to patch and governments are Back issues 62
TOP OF THE FOSS
once again after your encrypted stuff. Get hold of previous Linux Format editions.

Kernel watch 10 Overseas subscriptions 63


Get Linux Format shipped around the globe.
Answers 11
Logging system monitoring, fixing a dead HotPicks 81
network with Mint, logging shutdown issues, Alexander Tolstoy is too busy to enjoy a
discovering manuals and how best to create relaxing holiday by the quiet and peaceful
emergency boot USB sticks. Black Sea. He’s got his hands full with
collecting amazing FOSS like Weather Widget
Mailserver 14 2, Fancontrol GUI, Wine, DaedalOS, FreyrJS, Charitable characters 76
We mess up our PDF coverage, again! More Chmod-CLI, Rescuezilla, Warble, The Emmabuntüs collective enlightens
people pile into the loss of the DVD, both SpaceHuggers, Efiboots and Ehh. Jonni Bidwell as to its kind and open source
positive and negative, are we shilling for efforts, helping to distribute second-hand
Apple, and what of creative coverage? Next month 98 computers to communities in need.

www.techradar.com/pro/linux April 2022 LXF287 5


Newsdesk
THIS ISSUE: Upsurge of Linux malware Polkit exploit highlighted
Governments target privacy Framework’s firmware open sourced

SECURITY

Linux malware
grows by 35% Crowdstrike highlighted a worrying
rise in malware that targets Linux
Malware aimed directly at Linux systems devices in 2021.

increased drastically last year.

D
uring 2021 malware targeting Linux take over a device. Some variants targeted
devices increased by 35 per cent. The Docker servers with the open 2375 port, which
majority of malware instances involved gave attackers root access to the machine
IoT (Internet of Things) devices caught up in without the need of a password.
DDoS (distributed denial of service) attacks. Meanwhile, Mirai is a form of malware that’s
IoT devices encompass a range of gadgets. been gaining increasing popularity after its
Many of them are internet-connected and run source code was published. It uses brute force
some form of Linux distribution. People who buy attacks against weak protocols like Telnet to gain
a smart fridge, for example, may not know the access to devices. It’s also spawned a growing
security implications, which makes them number of variants that target different
attractive targets for hackers looking to create protocols. These variants include Sora, IZIH9
DDoS attacks, as they ‘recruit’ a large number of

IGNORANCE IS NO DEFENCE
low-powered devices to perform such attacks.
According to a Crowdstrike report (https://

“This is a concerning trend that highlights


bit.ly/lxf287crowdstrike), XorDDoS, Mirai and
Mozi malware were involved in over 22 per cent

the potential danger of having homes


of Linux threats in 2021, and there were 10 times
the amount of Mozi malware observed in 2021

full of Internet of Things devices.”


compared to 2020.
Linux-powered IoT devices are “low-hanging
fruit for threat actors,” according to Crowdstrike,
because of “using hardcoded credentials, open and Rekai, each of which saw increased usage
ports or unpatched vulnerabilities.” With the in 2021. CrowdStrike discovered an increase of
number of internet-connect smart devices 83 per cent in Rekai samples, for example.
growing every year (there’ll be an estimated 30 This is a concerning trend that highlights the
billion IoT devices on the internet by 2025 potential danger of having homes full of IoT
according to Statista’s report at https://bit.ly/ devices. We’re not suggesting you ditch your
lxf287statista), these attacks are likely to grow. Wi-Fi kettle or turn off your smart TV
The more compromised devices an attacker can permanently, though. Instead, have a better idea
add to their botnet, the more powerful attacks of devices in your home that are connected to
using the botnet will be. the internet, and which represent possible
XorDDoS is another type of malware that saw targets to malicious users. Implementing router-
a 123 per cent increase in 2021. It’s a Linux level security to help protect any device in your
Trojan that uses SSH brute-forcing attacks to home is also worth investing in.

6 LXF287 April 2022 www.linuxformat.com


NEWSDESK

SECURITY OPINION

Major Linux exploit found IT’S COOL


Almost every distro is affected by a major vulnerability
– make sure that your systems are patched.

A
serious new vulnerability has been and CentOS, then it’s likely you are), you should
found in polkit’s pkexec application, patch your system immediately. Cyberark, a
which is installed by default in many security firm, has also released the PwnKit- Michael Meeks
Linux distros. Due to its popularity, and the fact Hunter tool for Debian and Ubuntu (https://bit. is general manager at
that it’s used to control system-wide privileges, ly/lxf287pwnkit-hunter) that will help you Collabora Productivity
the vulnerability has resulted in a major security determine if your system is affected.
issue for millions of Linux systems. The fact that this vulnerability has been
Its discovery by researchers at Qualys (you hanging around for so long is worrying, and Collabora Online
can read the announcement at https://bit.ly/ as The Stack reports (https://bit.ly/ (COOL) 21.11 has arrived. It
lxf287qualys) has got a lot of people concerned, lxf287thestack), security researcher Ryan Mallon packs online collaborative
with US National Security Agency (NSA) claims he pointed out the vulnerability back in document-editing goodness
cybersecurity director Rob Joyce writing on 2013. With the vulnerability now more widely into an easy-to-obtain
Twitter (https://bit.ly/lxf287tweet) that the reported, hopefully it’s taken more seriously, and update. We packed another
vulnerability “has me concerned. Easy and other potential vulnerabilities within the default year of rendering and
reliable privilege escalation preinstalled on apps that come with our distributions are interoperability development
every major Linux distribution.” thoroughly investigated. into the LibreOffice
According to researchers, this vulnerability Technology core. COOL
has been included since the first release of itself brings a swathe of
pkexec in May 2009, and any local user can UX improvements.
exploit this vulnerability to obtain full root One piece I worked on is
privileges. It didn’t take long before PwnKit performance: profiling and
exploits using the vulnerability emerged. optimising our client-side
If you’re running a system that’s vulnerable Javascript to make the
(and because pkexec is included in almost all Ubuntu is one of the mainstream Linux distributions that’s experience slick and
major distros such as Ubuntu, Debian, Fedora affected by the PwnKit vulnerability. smooth. Previously, we
thought any interaction
issues were caused by
PRIVACY network latency or by
excessive server-side work.
However, after doing end-to-

US government wants your messages end profiling we found the


browser was the primary
culprit. After persuading it
And the UK government wants to confirm IDs online. not to re-render the DOM on
each web-socket message

S
enators in the US are once again first emerged in 2020, but was dropped thanks we got a big step-change in
pushing for the EARN IT act to be to a vocal backlash from privacy campaigners. slickness. Other big wins
made law. If passed, the act would It’s a shame that a group of senators are once were background document
bring in sweeping internet regulations that again trying to push this through, but hopefully saving, accelerated multi-
some fear would give third-party companies the fact that it’s been defeated before means it user editing, and a mature
and the government access to the private will once again fail. diagramming component.
messages of civilians. It could even lead to Internet users’ privacy in the UK is also under Another improvement
penalties for companies that offer end-to-end threat, with the Conservative government again was exposing some dialogs
encryption, which would affect messaging proposing an online safety bill that would require and our sidebar tool palettes
services like WhatsApp, Signal and iMessage. people to confirm their identity, via documents via JSON. Re-using
The EARN IT act also focuses on Amazon, such as credit cards or passports, when LibreOffice’s welded widgets
with creators of the act accusing the company accessing adult content. The government is gave us faster, ‘web native’
of not properly scanning content it hosts on also threatening websites and social media controls in the browser.
Amazon Web Services. With many websites networks with severe punishments if they host With homeworking the
using AWS, this could mean that large swathes prohibited content. new norm, full-feature
of the internet are scanned by government- While we all want to see a safer internet, document collaboration
approved software such as PhotoDNA, which privacy advocates are concerned about becomes vital. Why not
integrates with law enforcement databases. government overreach on what can and cannot reclaim and secure your
The Electronic Frontier Foundation explains be accessed online, and how people are identified documents with the
the act at https://bit.ly/lxf287earnit. The bill when browsing the internet. latest CODE release?

www.techradar.com/pro/linux April 2022 LXF287 7


NEWSDESK

OPINION LAPTOPS

OLD AND Framework open


UNTRUSTED sources its firmware
Users can change how the modular
The Framework Laptop has a modular design
laptop manages its hardware. that enables you to swap out parts.

F
ramework’s innovative laptop, which firmware covers how the laptop handles low-
Keith Edmunds comes with a modular design that level functionality, according to the Framework
is MD of Tiger Computing Ltd, enables you to swap out and replace team, such as “power sequencing, keyboard
which provides support for various parts, now has open source firmware. and touchpad interfacing, and controlling the
businesses using Linux. As Framework announced in a blog post LEDs in the system.”
(https://bit.ly/lxf287framework), the team It’s great to see Framework open source its
has published its Embedded Controller (EC) firmware, making its laptop a more attractive
It’s mostly a firmware for the Framework Laptop on GitHub purchase for many people. Since its launch, the
straightforward task to find (see https://bit.ly/lxf287embeddedcontroller), device has enjoyed growing support for a range
out what software powers which is based on the chromium-ec EC firmware of distros, with Fedora 35 working out of the
a web server. A simple created by Google for Chromebooks. box with full hardware support for its unique
examination of the returned Framework’s firmware is shared under the features. However, as with all firmware, care
headers will often display BSD 3-clause license that enables anyone to should be taken when modifying it, because it
the version of Apache, and modify, share and repurpose the code. The could damage the device if not done properly.
frequently the version of
PHP, too.
A well-known site that
I recently looked at was
SOFTWARE SOFTWARE
running Apache 2.2 and
PHP 5.4. The headers gave
the exact versions, but
we don’t need them. The
FreeCAD Project LibreOffice 7.3
Apache website states that,
“No further evaluation of
Association formed Community now out
security risks will be New legal non-profit New features in the latest
published for 2.2.x releases”
after December 2017.
association set up in Belgium. version of the office suite.
As for PHP, even the most

A T
recent version of 5.4, 5.4.45, major milestone has been passed for he Document Foundation (TDF) has
was released over six years FreeCAD development, with the non- announced a new version of LibreOffice
ago ,with security support profit FreeCAD Project Association (https://bit.ly/lxf287tdfblog).
ending at the same time. (https://bit.ly/lxf287fpa) being set up in LibreOffice 7.3 Community brings a number of
This website is a high Belgium. The aim of the association is to protect new features and fixes that are primarily aimed
profile e-commerce site, and FreeCAD’s existence as a free, community-owned at making the switch from Microsoft Office to
it’s running software with project, and will help raise funds and act as an LibreOffice much smoother for new users.
known, published official body. It won’t be used to rule over or own Interoperability between the suites has
vulnerabilities. More than FreeCAD, but to help communicate with other been improved, including the performance of
that, it’s telling anyone who projects and third parties. LibreOffice when importing Office files, such as
takes the time to look that FreeCAD (https://freecad.org) is an open- .doc, .docx and .xlsx. Change tracking has been
it’s doing so. source 3D modeller, primarily used for designing changed to better work with Microsoft docs, and
Life is busy. We all have a real-life products and objects. It’s a popular free LibreOffice’s Help tool has been improved, and
to-do list with items on it alternative to AutoCAD for architects, and the again focuses on making the software as
that we’re never going to formation of this association has been warmly welcoming as possible to ex-Office users.
cross off with a permanent received by its users. According to The Document Foundation’s
marker pen. But if you’re blog post, LibreOffice 7.3 Community’s new
responsible for public-facing features were developed by 147 contributors,
Linux systems and you don’t while 641 volunteers have helped create
have a process for ensuring localisations for 155 languages – and the latest
they’re kept up to date… version launched in 120 language versions,
well, you might want to more than any other software, according to
put fixing that a bit FreeCAD is a popular 3D modelling tool that doesn’t cost TDF. You can download the latest version from:
nearer the top. around £2,000 a year, unlike AutoCAD, https://bit.ly/lxf287libreoffice73.

8 LXF287 April 2022 www.linuxformat.com


NEWSDESK

Distro watch
OPINION

TRUST ME?
What’s down the side of the free software sofa?

ABSOLUTE LINUX 15.0


Based on Slackware Linux, this distro now has a new
version available to download. Absolute Linux 15.0
comes with the IceWM window manager, LibreOffice 7.3 Matt Yonkovit
and other popular applications. As the release Head of open source strategy
announcement states (which you can read at https:// and silly hats at Percona
bit.ly/lxf287absolutelinux), this release is “still rock-
solid. Still without systemd,” and will run on “modest”
hardware. It’s worth noting, however, that unlike Recently, the open
Slackware, Absolute Linux is 64-bit only. Absolute Linux 15.0 is a great choice if source community has seen
you like your distros to be lightweight. big questions about security
and safety. First, we had
Log4j that affected tens of
PEPPERMINT OS 2022-02-02 thousands of applications.
Peppermint OS has a new release – the first for over two Then two widely used
years. Focusing on being as user-friendly as possible, Javascript libraries– colors
Peppermint OS 2022-02-02 is now based on Debian 11, and faker – were sabotaged
and comes with the Xfce desktop environment. It also by the maintainer responsible
introduces a new Welcome to Peppermint tool that for them. He claimed he was
offers you a choice of software to help customise the tired of other companies
distro and choose default applications. Meanwhile, profiting from his work.
the new Peppermint Hub replaces the Settings and Over the past 20 years, a
Control Center from previous versions. Find out more Peppermint OS is a Debian-based distro common argument against
at: https://bit.ly/lxf287peppermintos. that’s ideal for beginners. open source has been
that you can’t trust it. The
argument goes: “Open source
is not maintained by a single
TRISQUEL GNU/LINUX 10.0 entity. Malicious things can
A major update of this Ubuntu-based distro is now make it into the source code.
available to download. Now based on Ubuntu 20.04 LTS, Do you really trust the
it’s available in MATE, LXDE and KDE Plasma versions, creators?” This was rekindled
and it supports ARM-based systems, with the release when University of Minnesota
announcement (https://bit.ly/lxf287trisquel) researchers submitted Linux
explaining that this has paved the way to “expand to patches with defective code
other architectures soon, targeting 64-bit ARM and to see if they would get
PowerPC next.” A large number of fixes have also been through the review process.
included – many coming from community feedback. So can you trust open
This distro is recognised by the Free Software Trisquel GNU/Linux 10.0 comes in a source? The answer is yes.
Foundation as being fully libre. variety of desktop environments. While incidents put a spotlight
on issues, these same issues
exist in non-open source
software and services too.
TINY CORE LINUX 13.0 That said, we can do better.
The latest version of this ultra-lightweight distro, First, we need companies
weighing in at just 16MB, has been released. It comes relying on key components to
with an updated Linux kernel, and once again runs contribute to the community.
entirely in memory. As well as the 5.15.10 kernel, this Next, we need to support the
new version updates glibc to 2.34, GCC to 11.2.0 and maintainers and creators of
Binutils to 2.37, with many other libraries receiving critical open source. Finally,
Can you spare 16MB? Then you can get
updates as well. Head over to https://bit.ly/ we need to adopt a stance of
Tiny Core Linux 13.0 up and running.
lxf287tinycorelinux for the full changelog, along trust but verify. When using
with links to download. libraries and components
in your application, know
where they come from and
ensure you’re testing
them regularly.

www.techradar.com/pro/linux April 2022 LXF287 9


NEWSDESK

KERNEL WATCH
OPINION

MEASURE
THE PULSE
Jon Masters summarises the latest happenings in
the Linux kernel, because someone has to…

L
inus Torvalds announced the release The pkexec binary includes a bug in its main
of Linux 5.17-rc4 (Release Candidate function. Every C program has a main function,
4). The RC was named Superb Owl and it’s called with an argument count, and an
Jon Masters has been involved in honour of the US Super Bowl annual array of strings representing the arguments. The
with Linux for more than 22 years. American Football game, which is often first argument to any program is usually the
misspelt. The name is meaningless as name of the program, but POSIX (one of the
I enjoy following technical far as the kernel is concerned, and is only main Unix standards) allows for argc to be zero,
discussions on Twitter. In referenced in a single place, but Linus does with no arguments passed to a program. Polkit
the pandemic era, when we can’t like to use it for running gags. assumes, however, that it’s always called with at
meet up so easily at conferences, There was recent coverage on the Hacker least one argument, so it skips past that entry in
this is a good way to keep in News website claiming 5.17-rc2 had been the list. If the list is empty, pkexec performs an
casual contact with a number of released as I Am Satoshi (a reference to the “out of bounds” access beyond the end of the
folks, as well as to gauge the anonymous Bitcoin creator). That turned out argv argument array.
“pulse” of what’s happening in to be a fake joke commit by kernel developer Beyond the argument array per spec is
the broader community, beyond
Matthew Garrett (@mjg59) that, thanks to a the environment array, the place where the
the Linux Kernel Mailing List
GitHub quirk, could be confused as coming environment variables such as PATH is stored.
(LKML), or any one specific Linux
distro or project list. There are from an official clone of Linus’s tree. pkexec will filter out “dangerous” environment
many talented folks who you can variables that might be used to compromise
interact with directly, including That Polkit vulnerability security, but unfortunately the buggy code in
numerous developers. Another month, another security vulnerability. question enables an attacker to overwrite the
One of those I enjoy following This month’s fun comes in the form of a bug environment, restoring a dangerous entry such
is Alyssa Rosenzweig. She’s in the Polkit library used to manage the as LD_PRELOAD, which can be used to replace
perhaps most famous for her interaction between privileged and non- certain library functions to be used by the more
work leading the Panfrost privileged binary with attacker ones. At that
privileged processes. Polkit (once known as
project, which develops Open
PolicyKit) includes pkexec, which can be used point, it’s game over pretty quickly. As a
Source drivers for Arm’s Mali
GPUs (used in many phones
similarly to sudo to run another binary as a consequence of this bug, and to stop the next, a
and other devices, but with a different user. It’s what powers most of the discussion has started about how to safely
proprietary closed source driver). pop-ups you’ll see on a Linux system when change Linux zero argument behaviour in a
In addition to Panfrost, she’s asked to enter an admin password. manner that doesn’t break compatibility.
known for reverse engineering
the GPU in Apple’s M1 processor
and writing a driver from scratch ONGOING DEVELOPMENT
as part of the Asahi Linux project.
All this, and she also won an
The Linux Plumbers Conference is the a per socket, sysfs attribute interface for
award in 2020 as an Outstanding
premier “by the community, of the applications to perform... provisioning.” It’ll
New Free Software Contributor.
Recently, Alyssa published
community, for the community” event be interesting to see how it plays out, and
another awesome blog post on for those working on the lowest levels of what kinds of features can be enabled by
the Collabora website, titled Linux distributions, the kernel, and related providing the right certificates under Linux.
Writing an open source GPU projects. Fingers are crossed for 2022 to see A flurry of activity has been happening in
driver – without the hardware, in a return to an in-person element, with the the RISC-V community. A proposal to ratify
which she describes the process event slated for 12-14 September in Dublin. the official ABI (Application Binary Interface)
she followed to reverse engineer A call has already gone out for proposals used by the SBI (Supervisory Binary
the Arm Valhall GPUs (Mali-G57 to host microconferences during the event, Interface) management firmware to provide
and G78) by using a combination
and Jorg Rodel has already drafted a certain services to an OS was recently made.
of analysing a (locked down)
proposal covering Confidential Computing. SBI does such things as bring CPUs online,
phone to understand how the
hardware behaves, writing a
David E Box posted updated patches or send messages between CPU cores
driver, and then leveraging a tool implementing support for Intel Software (known as IPIs) to perform certain
known as drm-shim to test that Defined Silicon, which is described as “a housekeeping functions. As part of that
driver prior to being able to post manufacturing mechanism for work, Palmer Dabbelt noticed that the kernel
purchase a laptop featuring the activating additional silicon features. code intended to make calls into the SBI
hardware. It’s yet another really Features are enabled through a license wasn’t being linked correctly and is in the
nice write-up by someone activation process. The SDSi driver provides process of cleaning it up.
who’s making an impact
in the community.

10 LXF287 April 2022 www.linuxformat.com


Answers
Got a burning question about open source or the kernel?
Whatever your level, email it to lxf.answers@futurenet.com
Neil
Bothwick
likes turning
readers’ woes
into wins!

Q Prickly display issue


Is there something I can use to
Otherwise, install the relevant package –
snmpd for Ubuntu and friends. When you
occasionally a couple of days – it loses
connection and I have to disconnect
collect all my LAN data/network/disk first access the Cacti page on your server, the cable and reconnect it. I’ve tried
space information into a dashboard? it’ll walk you though some basic setup. bouncing the network manager and I’ve
I have several computers running Then you can start adding information. replaced the cable and network card.
(including virtual machines) and I want Cacti collects information from your The switch is okay because my NAS and
to send their data to a dedicated server computers and stores it in a database, Windows PC both use the same switch
that will show me all the information on which it can then display in the form of and are fine.
one screen. graphs. First you add a device, a computer I’ve resorted to using the wireless
Derrick Long you want to monitor, then you can pick and network, but my connection – even via
choose the items you want to graph. 5GHz band – rarely gets above 8Mbps
A There are a number of ways of
collecting this information,
The first tab on the Cacti home page is
the console where you do all of this. The
whereas Ethernet, when working, gives
me 30-35Mbps. I’ve searched the Mint
depending on what you want to do with it. next tab is where the graphs are displayed. and Ubuntu forums, but nothing seems
Based on your brief description of your You can set up different collections to work. It used to work fine up until
needs, Cacti (www.cacti.net) would seem (or trees) of graphs, depending on the around Mint 19, but I’m pretty sure an OS
to be a good fit. Cacti is a web application, information you need. You could have a problem would have been picked up and
so you’ll need a web server such as Apache separate tree for each computer, displaying fixed by now so I’m at a loss. Any ideas
installed on one computer on your various aspects of that computer. Or you how to debug/fix this?
network, then install Cacti on that. This can could have, say, a CPU load tree that shows Alan Gauld
be done by downloading a tarball from the that information for each computer on the
web site, or there may be a package for
your distro. Using Cacti, or any other web
network. This enables you to customise the
display according to your current needs.
A You seem to have covered most of
the obvious causes, with one
application, means you have the extra work Because all the hard work is done by possible exception. You say the switch is
of setting up a web server if you don’t Cacti, adding another device is as simple working because other devices don’t have
already have one. On the plus side, it also as making sure snmpd is running on it and the same problem, but are you always
means that Cacti’s information is then adding the graphs you want. using the same port on the switch? It’s
available on any computer on your possible for an individual port to develop
network, requiring only a web browser.
The other requirement is that you have
Q Network notwork
I’m running Linux Mint 20 and am
problems, so the first thing to try is
swapping the ports for the Linux PC and
the SNMP daemon (see boxout, overleaf) having real problems with my Ethernet NAS to see if the problem switches over.
installed and running on each computer connection dropping out. When I boot You say you changed the network card.
you want to monitor. Depending on your up it works fine, but after a period – Is it the same type, or using the same
distro, this may already be the case. anything from 10 minutes to 10 hours or, chipset? If it uses the same driver, you’re
not ruling out the possibility of a software
problem. It sounds like this is a desktop
computer if you’re able to replace the
Ethernet card. Most of them have Ethernet
on the motherboard – is this the case with
yours? If so, have you tried using that? If
you’re not using it, it may be best to disable
it, either in the BIOS or by blacklisting the
module it uses, to prevent any possible
interference. You can see which module it
uses by running
Cacti can $ sudo lspci -k
display a
in a terminal. Then create a file in /etc/
range of
information modprobe.d with a name ending in
from various .conf containing
computers blacklist MODULENAME
on a single If the issue persists, check the system
screen.
journal for any error messages about

www.techradar.com/pro/linux April 2022 LXF287 11


ANSWERS

the network card – the Systemd journal


also contains the early boot messages
A We’re weren’t aware of vimgenius.
com, but it looks good. There’s
When it comes to trying out commands,
as long as you don’t use sudo , you
and the output you could otherwise get no generic site for all common Linux won’t be able to do serious damage to
from dmesg as well as the usual syslog commands that we’re aware of, but most your system by experimenting, although
messages. Run commands are well documented. The creating a different user for such
$ sudo journalctl -b majority of commands include man (short experiments would be wise. Alternatively,
to load all messages since the last boot for manual) pages that are read with the you can install another copy of Linux in
into a pager (less by default), then press man command. Try something like a virtual machine, such as VirtualBox or
/ for search followed by the name of your $ man find GNOME Boxes. Then you can experiment
Ethernet interface. Press n to go to the next to read the man page in a terminal. You to your heart’s content without fear of
matching entry in the journal. You could can also read most man pages in a web breaking your system – although there
also use grep to filter relevant entries: browser by visiting sites like https:// is a school of thought that says breaking
$ sudo journalctl -b | grep eth0 mankier.com or https://linux.die.net. and having to repair your system is the
replacing eth0 with the name of your These provide online version of man best way to learn about it, if not the most
network device. This should show you pages, complete with links. Man pages are pleasant way to learn about it. Using a
all messages, including any relating to a useful reference material, but they’re not virtual machine also means you can install
dropped connection. If the machine has intended to be tutorials. The first place to any extra software you want to try out.
been up for a while and you only want look for such help is the program’s own Another option is to use an online
recent messages, you can use web site. You can find this in Ubuntu and virtual machine, such as those provided
$ sudo journalctl --since -1h other Debian-based distros with the apt at https://distrotest.net. These save the
to show messages from the last hour. Once command, such as trouble of installing a virtual machine
you have a specific error message, you $ apt show findutils | grep Homepage: package and then installing a distro on it,
can plug it into your favourite web search This assumes you know the name of but it’s not the fastest way of doing things,
engine to look for possible solutions. the package. findutils installs the find so it’s probably better for a quick test
command. Once again, there’s a command rather than sustained use.

Q Learning curve
I’m new to Ubuntu Linux and
to obtain that information:
$ dpkg -S /usr/bin/find
We haven’t mentioned booting a live
distro because that involves leaving your
trying to learn its commands and You need to give the full path for a current environment, although you could
concepts, but don’t know how can I get reliable search. You can get that with the run a live distro in a virtual machine, saving
instructions to utilise commands I’ve which command. There, that’s three the installation step. That may well be
learned. I wish there was a website like commands you’ve learned already! the best way to do this because you can’t
vimgenius.com break a live distro – everything resets when
for other Linux you reboot it.
commands as
well, such as find,
grep, locate, etc,
Q Why are we waiting?
Since yesterday, when shutting
but I couldn’t find down the system takes a break of about
anything. Can 90 seconds before finally quitting.
you help? This is on a five-day old installation of
David Roberts openSUSE Tumbleweed.
I have a second Tumbleweed
installation on the same machine which
Reading man pages doesn’t take as long. On my old PC
online can be a lot with verbose booting and shutdown
easier than in a
terminal, thanks to the
there were some rare instances where
addition of hyperlinks a message like “waiting for a stop
and an index. job (service?)” appeared with a timer

A QUICK REFERENCE TO… SNMP


The Simple Network Management daemon to retrieve information about generating graphs of the systems, as
Protocol is a protocol for handling that system. The information available is the case with Cacti, or it may be
information on networked devices. It’s not depends on the system of course. In to raise alerts or take action when
limited to computers – devices such as the case of a computer this can include something isn’t right.
modems, switches and printers support items such as networking details, CPU SNMP is most commonly used for
it too. Any device supporting SNMP runs load, memory usage, process and user information retrieval, but it can also be
an agent: a background program that information, and much more. used to send changes to the monitored
handles queries for information. In the The main use of SNMP is to monitor devices in some instances.
case of Linux systems, this program is devices on a network. A central system There’s an SNMP client program for
snmpd, following the standard of naming can keep an eye on all devices on the Linux that can retrieve information from
daemons with an ending d. network, monitoring various aspects of the command line, but SNMP is usually
An SNMP client program can then the system and acting on the information used as the information-gathering
connect to the devices running the received. This may be a case of component of a larger program.

12 LXF287 April 2022 www.linuxformat.com


ANSWERS

counting up to 90 seconds. I never found


out what caused it. I’ve tried to read the
logs in /var/log but they’re now machine
readable only.
Harold Griffin

A The information is there for you. If


you press Escape during shutdown,
it should dismiss the splash screen and let
you see the output. You should then see
the waiting message similar to your other
machine. This will include the name or
description of the service that’s waiting to
stop. The most common candidate for this
is network shares that can’t unmount
because the network connection has
already closed down. The system log is still
there, although Systemd calls it a journal. It
contains similar information to the
traditional system logs, but it’s indexed to With names like Rescatux and System Rescue, it’s pretty obvious what these distros are for.
make searching for specific data much
faster. Because of this, you read the journal distro that can boot to a console or a convert needs to uncompress each one to
with the journalctl command. minimal desktop, it’s your choice. It process it, at something like four bytes per
$ journalctl -b -1 contains just about everything most people pixel of image data. The problem is that
will show the entire log for the last session. would need for repair and maintenance you’re trying to process all of them at
The -b switch tells it which session to use, tasks. It’s also extensible though the use once. One solution is to convert each
counting back from zero for the current of additional modules, so if you need image to a separate PDF, reducing the
session, so -1 takes you up to the last something not covered by the stock distro, memory requirements, then join those
reboot. You should find the information you such as ZFS filesystem support, it can individual PDFs into a single file. You can
need towards the end of the output. be added. The SystemRescue web site do this with a simple for loop in the shell:
As you now know the name of the contains comprehensive documentation $ for IMG in *.jpg; do
service causing the issue, you can also use on using it as well as what we consider to convert $IMG ${IMG%.jpg}.pdf
$ journalctl -b -1 -xu name.service be one of its killer features: the ability to done
The -u option enables you to display add it to your hard disk and boot menu. pdfunite *.pdf ~/123.pdf
only information for the given service, while A bootable USB stick is very nice, but The for loop converts each JPEG to a
-x gives extra explanatory details. With can you be sure of finding it when things PDF, then pdfunite combines them all into
this information, you should be able to go wrong, and you can’t get online to a single file. You’ll need to make sure that
diagnose the cause of the shutdown download another copy? By copying the there are no other PDF files in the directory
delays and take appropriate action. files from the USB image to your /boot before running this.
directory and adding a stanza to GRUB’s

Q USB just in case


I’m looking for a USB rescue distro
boot menus, you can be confident that
it’ll be there as long as your hard disk
GET HELP NOW!
in case a dual-boot machine fails. It’s remains usable. We’d love to try and answer any questions
using Sparky Linux (rolling) and Windows you send to lxf.answers@futurenet.com, Subscriptions: for magazine issues email help@mymagazine.co.uk
10. Do you have any suggestions for a
solid, simple-to-use option? Ideally, it
Q Too many megapixels
I’ve a folder with JPEG files that
no matter what the level. We’ve all been
stuck before, so don’t be shy. However, we’re
should contain as many tools as possible I want to convert to a single PDF file. I only human (although many suspect Jonni
to cover as sorts of issues. tried to use the command convert but is a robot), so it’s important that you include
Jessie Clark I’m getting these errors: as much information as you can. If
$ convert *.jpg ~/123.pdf something works on one distro but not
A There are two rescue CDs that
we always have available. For
convert-im6.q16: cache resources
exhausted `IMG v01 161.jpg’ @ error/
another, then tell us. If you get an error
message, please tell us the exact message
dealing with boot problems, Rescatux cache.c/OpenPixelCache/4083. and precisely what you did to invoke it.
(www.supergrubdisk.org/rescatux) takes convert-im6.q16: cache resources If you have, or suspect, a hardware
some beating. It definitely satisfies your exhausted `IMG v01 162.jpg’ @ error/ problem, let us know about the hardware.
requirement of being simple to use, being cache.c/OpenPixelCache/4083. Consider installing hardinfo or lshw. These
entirely menu driven. It’ll deal with GRUB and many more lines like this. programs list the hardware on your
and Windows booting issues as well as Larry Moran machine, so send us their output. If you’re
some other options such as resetting unwilling, or unable, to install these, run the
passwords and dealing with (not too)
damaged filesystems.
A The cache resources messages
indicate that you could be running
following commands in a root terminal and
send us the system.txt file too.
The more powerful and general- out of memory. You don’t say what size uname -a > system.txt
purpose system, and the one we these images are, but if they’re multi- lspci >> system.txt
always have available, is SystemRescue megapixel digital camera files they’ll be lspci -vv >> system.txt
(www.system-rescue.org). This is a full huge. JPEG files are compressed but

www.techradar.com/pro/linux April 2022 LXF287 13


Mailserver
MAILSERVER

WRITE TO US Fire them all! We’re open to bribes


I’m writing in about Nick Peers’ article, which and free Apple hardware,
Do you have a appeared in LXF283, December 2021. He discussed shame we never get any.
burning Linux-
PDF editing and mentions opening a PDF using the
related issue
document viewer Evince.
that you want to
discuss? Write Unfortunately, Evince will not always display a PDF
to us at Linux correctly. PDFs generated using Microsoft Office
Format, Future Word (I presume that was the program which Nick
Publishing, Quay used) aren’t always displayed correctly.
House, The Master PDF Editor does display any PDFs correctly
Ambury, Bath, and if opened in LibreOffice Draw and then exported,
BA1 1UA or email the file will now display correctly in Evince.
lxf.letters@ As for filling in forms, Master PDF Editor can do it
futurenet.com.
but it’ll usually be easier using LibreOffice Draw and
there will be no watermark.
I didn’t know you needed to choose “Digital
Signatures” to do it, so I have simply opened the
PDFs and filled the required spaces after opening write up these tutorials…
them and then exported to save.
As for editing in Draw, I’ve edited hundreds of Apple shills?
PDFs and my website link [Cracroft/Cashmere Now the DVD is gone how about printing a list of
Ukulele Group] that has over 300 songs and more places in the UK and USA that sell Linux on ISO DVDs
than 200 on another site [SW Strummers] contain or USB sticks every issue or at least twice a year. And
the editing work I’ve done. Not to all the songs and along with that you might include a short tutorial on
never a great deal of work, but certainly a great making them from Linux on the internet or the links
number of edits. for such instructions for Ubuntu and Fedora?
Sandy Ferguson I’ve always preferred the DVDs that Linux Format
You’d think using provides for usually being without problems and
PDFs would
be easy and
Neil says… having such nice disc covers. My archival collection
straightforward by You sound like you’re a master when it comes to PDF will be sorely lacking from here on out. And then of
now. Nope. manipulation. I think I’m getting the wrong people to course, LEDs and CD/DVD discs you no longer need,
have so many creative possibilities for making
interesting lights and lighting effects.
Apple (of the white cases) has long been on a
quest to stamp out discs because its rival Sony (of
the black cases) along with Phillips invented them.
You folks aren’t taking funding from Tim Cook are
you? There’s been an awful lot of M1 CPU news in
Linux Format lately even though we all suspect the
CPU-of-the-month club (i.e. Apple) will be switching
to RISC-V any day now.
I’m fully expecting Safari on Raspberry Pi running
on disassembled iOS code article from you guys any
issue now. Okay, doing without Linux Format DVDs is
going to be a severe hardship, but I guess we’ll
probably be able to survive s-o-m-e-h-o-w.
Ed Scott
Helpdex

14 LXF287 April 2022 www.linuxformat.com


MAILSERVER

Neil says… this really isn’t a sad


Always a pleasure to hear from you, Ed. My first thought decision at all – hopefully
is to say Duckduckgo it, but then it’d be better to it’s one you can be really
perhaps donate the money to your favourite distro dev happy to have made, even
team? I did spot that Debian maintains a list of world- if circumstances were
wide duplicators that can supply CD/DVD/USBs (www. ultimately forced on you.
debian.org/CD/vendors) and usually not just for Debian. Personally, it’s been
So if you’re missing your shiny unrecyclable discs that some time since I’ve
will outlive us all, you can still get them. made use of the DVD,
I would love to be on the paybook of Apple. I’m sure but I continue to enjoy
my pension would look far, far healthier than it does and read large parts of
stuck on Future’s year-on-year sub-inflation wage the magazine each month
increases. Sadly we are not. Also, if anyone wants to – and still value the
donate a spare Apple M1 that’d be nice, too! And why do physical media! Many
we use Safari when we already have Chrome spying on thanks to you and the
us and making our Pis crawl?! I‘m loving the strong Linux Format team.
conspiracy energy, though! Mike For better or for worse, the
Linux Format DVD is no more.
Good riddance! Neil says…
Just wanted to say I wholeheartedly support the I don’t want to make light of the decision because I
decision to drop the DVD. In an era when most new know for sure that there are people in certain areas who
PCs don’t include a DVD player, and when even a do rely on the DVD to compensate for their lack of
middling home broadband connection like mine can decent broadband speeds – or a broadband connection
download an entire distro in a few minutes, I think at all. It’s annoying that I could never get management
there’s no good reason to continue with this. I hope to consider an opt-in scheme.

LETTER OF THE MONTH


Get creative? aimed specifically at the open source
I would like to know if your organisation multimedia artist.
prints a magazine dedicated solely to open Otilia Chanetsa
source multimedia for artists who are
using the full suite of creative software Neil says…
such as Inkscape, GIMP, Krita, Blender, I’d love to cover more creative elements, but
OpenShot, Audacity and GDevelop and the remit of the magazine is really on the
anything that’s relevant individually or in technical aspect of using FOSS/Linux. So
combination, much like computer arts. we’re limited to just the odd tutorial. Future
In other words, everything open source publishes ImagineFX but that’s just 2D digital
can offer an independent artist, graphic art, while its sister title 3D World covers 3D
designer, games programmer/developer, rendering in the industry.
photographer, film maker and special The market (print mags) for both of these
effects including music that the modern is tiny, so I can’t see there being any room for
art environment now demands. a specific open source-based title. Though it
I find that the content of Linux Format is sounds like the sort of thing a website could
just too general for my interests and only carve a niche out for itself. I do feel your The problem with many creative types is
ever occasionally throws a few crumbs frustration on this. they like getting on using their Apple tools.
shane_collinge@yahoo.com

www.techradar.com/pro/linux April 2022 LXF287 15


SUBSCRIBE Save money today!

SUBSCRIBE
Sign up today and get your

PowerKick
YOUR
GIFT!
wireless charger
WORTH
£50 t, Product features
iss ou The PowerKick wireless power bank
Don’t m e now!
subscrib delivers functionality and convenience.
Its clever suction cups secure the
charger to a smartphone or other
device while charging.
The built-in kickstand props the device
up in either landscape mode for video
viewing or portrait mode for video
conferencing, all while charging.
Indicator lights provide information
on the status of device charging,
as well as the current charge of the
10,000mAh lithium polymer battery.

SUBSCRIBE NOW!
www.magazinesdirect.com/lin/a26b
Call 0330 333 1113 and quote A26B
16 LXF287 April 2022 www.linuxformat.com
Save money today! SUBSCRIBE

PLUS: Exclusive access to 1

1) Only available to www.magazinesdirect.com subscribers


the Linux Format subs area!
1,000s of DRM-free
PDF back issues and
articles! Get instant
access back to issue
66 (May 2005) with
tutorials, interviews,
features and reviews.
!
DON’T MISS At linuxformat.com
ars
Includes 5 ye
r &
of Linux Use
Developer
issues NOT FROM
THE UK?
CHOOSE YOUR PACKAGE! Turn to page
for more gre 63
a
subscriber t
deals!

6 MONTHLY 6 MONTHLY DIGITAL EDITION ONLY


PRINT EDITION PRINT + DIGITAL EDITION

SAVE! SAVE! SAVE!


PLUS! PLUS!
2
Only 0% Only 47% Only
39%
£33.75 £46.25 £27.50
Six months of Linux Format Six months of Linux Format in print Six issues of Linux Format
in print by Direct Debit and digital by Direct Debit in digital by Direct Debit

Terms and conditions: Offer closes 30 April 2022. Offer open to new UK subscribers only. Pricing is guaranteed for the first 12 months and we will notify you in
advance of any price changes. Please allow up to six weeks for delivery of your first subscription issue (up to eight weeks overseas). Your gift will be delivered
separately within 60 days after your first payment has cleared. Gifts only available to subscribers on the UK mainland. Gift not available with a digital subscription.
The full subscription rate is for 12 months (13 issues) and includes postage and packaging. If the magazine ordered changes frequency per annum, we will honour
the number of issues paid for, not the term of the subscription. For full terms and conditions, visit www.magazinesdirect.com/terms. For enquiries please call
+44 (0) 330 333 1113. Lines are open Monday to Friday 9am to 5pm UK time or email help@magazinesdirect.com. Calls to 0330 numbers will be charged at no
more than a national landline call, and may be included in your phone provider’s call bundle.

www.techradar.com/pro/linux April 2022 LXF287 17


EXPLORE THE POSSIBILITIES THAT
LINUX HAS TO OFFER
From open-source software to coding masterclasses and Raspberry Pi
projects, get the most from your machine with this exciting array of expert
tutorials, guides and advice from the minds behind Linux Format magazine.

ON SALE
NOW

Ordering is easy. Go online at:

Or get it from selected supermarkets & newsagents


REVIEWS
Intel Core i5 12400
It’s the new Q6600, Dave James’ greatest compliment ever!

T
he easy approach to this review
SPECS would be to dismiss the Intel Core
Socket: i5 12400 as one of the least-
LGA1700 interesting processors from the 12th Gen
Process: Alder Lake generation of CPUs. Yet if we did
Intel 7 10nm that, we’d be dismissing one of the best
Cores (P+E): mainstream chips ever made.
6+0 The first clue is the Alder Lake
Threads: 12 silicon goodness beneath that broad
Cache: 18MB heatspreader, but there are no hybrid cores
L3, 7.5MB L2, here. Instead, it’s packing six of Intel’s
480KB L1 Performance Core; Efficient cores are
Clock: 2.5GHz nowhere to be seen. This single core
(4.4GHz turbo) performance is right up there with the best
Unlocked: processors around. Intel Thread Director
Complicated tech is scheduled to hit the Kernel 5.17, but
GPU: UHD this processor won’t need it.
Graphics 730, The Core i5 12400 still represents a full Want six of Intel’s
24 EU, 300MHz platform upgrade, mind. It requires a new Performance
Cores? You got it!
(1.45GHz Max), chipset and socket (a really big new
OpenGL 4.5, socket!). The LGA 1700 is a hefty
OpenCL 2.1 component, but is also finally available on boards Even without the Core i5 12400’s overclocking chops,
Memory: 128GB outside of the hyper-expensive, hyper-reality swathe of we’d be hailing this as the best budget CPU for an age.
max, No ECC, Z690 DDR5 boards as the B660 chipset is here, and if Intel has continued its aggressive push into the
2-channel you go for a DDR4 memory-supporting version it’s very mainstream market, aiming to squeeze AMD out of the
Memory speed: affordable. You also get PCIe 4.0 support from the running even when it’s starting to claw back its lead
DDR5 chipset, too, for those speedy new SSDs. right at the very top of the CPU stack, too. Do we really
4800MT/s, And in reality good, low-latency DDR4 kit will still need DDR5 and PCIe 5.0 on a budget build? Not a jot.
DDR4 hand any current DDR5 module its bottom bits thanks Throw in this BCLK overclocking and you’re looking
3200MT/s to super lax timings on even the most expensive, most at a chip reminiscent of the classic Intel Q6600, the old
PCIe lanes: 20 speedy of kits housing the new memory technology. school (Intel Celeron 300A, surely? – Ed) overclocking
(16+4, 2x8+4) heart throb. When you can have the Core i5 12400
Base power: High achiever running at a stable 5.2GHz, it hoses the best of Intel’s
65W In straight CPU performance terms it’s mighty previous generation of CPUs and practically matches
Max power: impressive, too, offering great single core performance the best of this generation.
117W and still pretty meaty multithreaded prowess despite The Intel Core i5 12400 is an outstanding CPU. It’s a
dropping the E-Cores. What really highlights the power £200 processor that belongs in your next budget PC
of the Golden Cove microarchitecture is how the Core i5 build. It offers performance on par with the best of the
12400 compares with the best CPU of the 11th Gen last generation, and when paired with the right board
range. Almost across the board the i5 tops the i9. Only can deliver unprecedented overclocking prowess.
in heavily multi-core focused applications do the extra
two cores of Core i9 11900K come into play.
Alder Lake is rightly castigated as being one hot,
VERDICT
hungry chip design, but in this mainstream form it’s DEVELOPER: Intel
impressively low maintenance. At stock speeds it only WEB: www.intel.com
peaks at 72W, with a paltry 44°C as its maximum PRICE: £200
temperature under our AIO cooler.
One side note: this isn’t a K-series processor – so no FEATURES 10/10 EASE OF USE 9/10
official overclocking – but it does reach 5.2GHz without PERFORMANCE 10/10 VALUE 10/10
breaking a sweat. The rumour is that an oversight in the
CPU microcode gives latent support for base clock Even without the unprecedented overclocking potential
overclocking (BCLK OC). Motherboard manufacturers inside the i5 12400 we’d be heartily recommending that this
are seemingly taking advantage of this and adding in chip forms the basis of your next budget PC build.
non-K series specific settings to their boards with
external clock generators. This isn’t official and it could Rating 10/10
be removed at any point by Intel, but there you go.

www.techradar.com/pro/linux April 2022 LXF287 19


REVIEWS Linux distribution

ArchLabs 2022.02.12
Mayank Sharma has a soft spot for new Arch-based distros,
and this time around he’s found one that tickles his fancy.

O
ver the years, the ArchLabs
IN BRIEF distro has deviated
Originally considerably from its
inspired by origins. It now suits users who
BunsenLabs, want to exploit Arch’s famed
the distro began customisability to build their
to bring over installation from scratch, but with
the concepts some added conveniences to
of the popular minimise the time it takes to
minimalist deploy a pure Arch system.
Debian-based ArchLabs caters to users who
distro on top of aren’t afraid of the command line,
an Arch base. but want to run a desktop distro
However, over without spending a lot of time to
the years the compile everything from scratch.
distro has Unlike some of the other popular ArchLabs has customised all of the desktops it bundles. This is its rendition of the Deepin DE
changed Arch-derivatives, the 64-bit only
considerably distro doesn’t boot into a Live environment. Instead, driven repository, helping them resolve dependencies,
and is best its install-only medium takes users to its text-based before retrieving and building them.
described as a installer dubbed AL-Installer. It’s fairly straightforward to The Arch project doesn’t recommend using AUR
Arch distro for navigate and includes all the conveniences of a modern helper scripts, and instead suggests users build all their
the experienced distro installer, without the bloat. packages manually. However, baph didn’t throw any
Linux user. The installer helps users navigate through the errors, and helped us install everything from office
various installation steps, and offers plenty of options. suites to games without any issues.

SPECS
For instance, the installer includes various popular If we have to be picky, the one issue we’d like to flag
partitioning tools, but also extends the option to doesn’t exist in the distro, but rather in the project –
CPU: 1.4GHz automatically partition the disk, which is useful if you namely documentation. The project has just enough
Mem: 1GB only want ArchLabs as the sole distro on the machine. documentation to help new users familiarise themselves
HDD: 15GB The installer also offers bootloaders, shells and a with the distro, but there’s not enough of it to help first-
Build: range of kernels. There’s the vanilla kernel on which the timers orient themselves with the ways of ArchLabs.
64-bit only developer has applied a few patches. Then there’s the Although ArchLabs is designed for users who’ve
long-term support (LTS) kernel, and a security-focused clocked enough mileage with Linux to be able to find
kernel with patches to mitigate exploits. These will be their way around the distro, we think the project needs
handy if you want to use ArchLabs to host servers or an updated ‘getting started’ guide for the mere fact that
critical applications. If you want to run your ArchLabs it’s metamorphosed into a completely different beast
installation as a regular desktop, you can use the Zen than what it eventually set out to be. The distro has
kernel that’s been optimised for everyday desktop use. been dishing out releases for half a decade now, and has
Similarly, the installer gives the user the ability been covered extensively. However, much of the
to choose from over a dozen different desktop information out there isn’t relevant thanks to the
environments and window managers. There’s distro’s constant evolution.
everything from heavyweight desktops like Gnome, and
Deepin, to lightweight ones like Xfce, and LXQt, and
barebones window managers like Sway and JWM.
VERDICT
DEVELOPER: Nathaniel Maia & Matthew Dobson
Chemical attraction WEB: https://archlabslinux.com
In its first release of 2022, the distro has added a new LICENCE: GPL
custom window manager christened dk. This is
described as a list-based tiling window manager, much FEATURES 8/10 EASE OF USE 9/10
like dwm, bspwm and xmonad. PERFORMANCE 9/10 DOCUMENTATION 7/10
Based on Arch, the distro inherits one of the best
package management systems in the game. It Want an easy-to-install Arch-derivative with minimal
supplements this by rolling in its own Arch User bloat and maximum choice? Then consider ArchLabs.
Repository (AUR) helper script dubbed baph for Basic
AUR Package Helper. AUR Helper scripts enable users Rating 8/10
to search for packages published in Arch’s community-

20 LXF287 April 2022 www.linuxformat.com


Linux distribution REVIEWS

UBOS Linux
Mechanisms for simplifying the installation of popular web tools are like
snake oil. Or so thought Mayank Sharma, until he came across UBOS…

U
BOS is a distro that helps
IN BRIEF reduce the amount of time
As its name required to set up and
states, the maintain common network
UBOS distro is programs and services. Essentially,
designed to put UBOS automates much of the
you in charge. administration, reducing actions
An Arch such as deploying complete web
derivative, the tools, securing the connection with
distro simplifies SSL certificates and more, down to
the rollout and a single command.
management of You can use the distro on a
popular web variety of physical, virtual and cloud
tools. The distro hardware. Deploying it is as simple
is available for as uncompressing the downloaded
64-bit PCs, all image for the target platform, and UBOS can deploy web applications on Tor, complete with a .onion hostname. However, the
editions of the writing it to a USB disk, or attaching documentation suggests this deployment option is currently broken.
Raspberry Pi it to a virtual machine.
including the UBOS is based on Arch Linux, and its impressive Similarly, the distro makes it just as simple to
Zero, as well custom rollout and management utility, ubos-admin, un-deploy the web tools, and also back up all data
as virtual bank on Arch’s famed package management system to from individual tools, or from all the deployed ones,
machines, extend much of these conveniences. Using the utility and restore them just as easily as well.
containers, you can deploy popular content management systems You can also use the distro to check for upgrades to
and cloud. including WordPress, phpBB, Nextcloud and several your web programs. When it finds one, the distro will
others with a single command. automatically display an “upgrade in progress” message
Once the distro is up and running, the ubos-admin on your deployed websites, take a temporary backup,
createsite command takes you through an interactive un-deploy the tools, fetch the upgrades, before
setup process, which involves entering the name of the redeploying the tool after the upgrade, then restore
program you want to deploy. The process shouldn’t tax all the data, and make sure it’s imported properly.
those who are experienced in rolling out network All with a simple ubos-admin update command.
software. The inexperienced can go with the default UBOS does a wonderful job of removing all the
options, which will work for most deployments. deployment and administration complexities.
The installed software can be accessed from Furthermore, its support for traditional as well as single
the IP address of the UBOS device it is installed on. board, and virtual computers, makes the distro suitable
Furthermore, UBOS devices use mDNS to advertise for a wide variety of use cases. The only real drawback
itself on the local network for easier access. is its peculiar mechanism for fleshing out the web
UBOS also offers multiple options to add SSL to your programs, which also means its users can access only
deployed web tool. If you only plan to use the tool inside a handful of supported add-ons. However, the distro
the local network you can secure the connection using a makes sure it offers all the popular and useful ones, to
self-signed certificate. ensure its advantages outweigh the drawbacks.
If your site has an official domain name and a public
IP address, UBOS can just as easily fetch and install a
LetsEncrypt certificate. It’ll also ensure the free
VERDICT
certificate is renewed automatically before expiration. DEVELOPER: Johannes Ernst
WEB: https://ubos.net
Off-centre LICENCE: Personal Public Licence
The one oddity about deploying web tools through
UBOS is fleshing them out. Virtually all web tools enable FEATURES 8/10 EASE OF USE 9/10
users to customise them by adding plugins and themes PERFORMANCE 8/10 DOCUMENTATION 8/10
from within the respective apps’ administration console.
However, when deployed with UBOS, users will have to One of the best ways to deploy and administer popular web
specify the add-ons they want to install during the tools that’s designed to suit a wide number of use cases.
interactive command-line setup process. If you’ve
already deployed your web tool, you can rerun the setup Rating 8/10
process to redeploy the utility with any new accessory.

www.techradar.com/pro/linux April 2022 LXF287 21


REVIEWS Linux distribution

Slackware 15.0
He’s no masochist… until there’s a new Slackware release, when Mayank
Sharma puts himself through all kinds of pains to relive the good ol’ days.
ne of the unique aspects that differentiates
IN BRIEF
of users who are still using Slackware, and continue

Slackware was
O Slackware from the other distros is its glacial
pace. Even as the distro is actively developed
to do so.
Another important change that helps catapult
created by behind the scenes, it doesn’t put out releases as often as Slackware to the modern Linux desktop is support for the
Patrick some of the current crop. PAM library. Starting with this release, the distro also
Volkerding and So while most modern distros, such as Ubuntu and moved away from ConsoleKit2 to elogind that helps run
had its first Fedora, release every six months or so, Slackware follows software that depend on systemd while running on distro
release almost the “release when it’s ready” philosophy. No surprise, that doesn’t use it, like Slackware, which still uses its
three decades then, that Slackware 15 is the distro’s first major release in custom System V-based init system.
back, in 1993. over a decade. In fact, the distro last had a stable dot
This makes the release back in 2016 (v14.2, in case you’re wondering). Into the workshop
distro one of the And what were the devs up to in the meantime? Designed for experienced Linux campaigners, Slackware’s
two oldest Linux According to the release notes of Slackware 15, they charm is that it’s the most Unix-like Linux distro. It
distros that are tested over 400 different kernel versions before settling adheres to the Keep It Simple, Stupid (KISS) design
still actively on the 5.15 LTS kernel for this release, which will be philosophy, which enables advanced users to build their
maintained, with supported until at least October 2023, and going by Linux desktop or server exactly as per their requirements
the other being recent trends, most probably for quite a while longer. without any bloat and unnecessary components.
Debian. They In addition to the excellent hardware support brought Slackware takes pride in helping users exercise complete
say, “If you want in courtesy of the 5.15 kernel, including preliminary control over their installation, and everything in the distro,
to learn Debian, support for Apple’s M1 chip, the distro can now boot on from its installer to package management system is a
use Debian. If computers with the UEFI firmware. However, it still doesn’t reflection of its ethos of technical simplicity.
you want to support running under SecureBoot, but the release notes As is customary for Slackware, the latest release also
learn Fedora, hint that it might be supported in the next release. ships with two kernels. There’s the huge kernel that rolls in
use Fedora. But Another major update is the
if you want to switch to the KDE 5.23.5, which is
learn Linux, use the desktop environment’s 25th
Slackware.” This anniversary edition. Slackware 14.2
still holds true. was a rock-solid release, like all KDE
releases, but it used KDE 4.x desktop,
which was off-putting for many users,
and made the oldest surviving Linux
distro look the part.
The other desktop that ships on
the ISO is the lightweight Xfce 4.16,
which is the latest release from Xfce.
Other important changes from the
point of view of the desktop is
support for the PipeWire server for
handling audio and video streams,
hardware, and the Wayland display Slackware’s installer is replete with throwbacks to the good ol’ days. There’s even an option to
server. This is going to benefit a lot install the LILO bootloader on a floppy disk.

USABLE SLACKWARE
Most Slackware users weren’t running other distros, and isn’t advisable for However the distro has produced some
Slackware 14.2 on their machines, and production servers, it’s become a custom tools that Slackel has borrowed
were instead using Slackware’s rolling- popular method for powering desktops to give new users a pleasant experience,
release “-current” branch. This is where among Slackware users. straight from installing the distro to the
all the development takes place, until it’s Then there’s Slackel that uses the dependency resolving graphical
considered stable enough for a release, latest software from Slackware-Current, package-management tools.
at which point it’s split into the and combines them with the user- Other desktop-friendly Slackware
development branch for the next release. friendly tools from the Salix project. Salix derivatives include Absolute Linux,
While it can be considered the is based on Slackware’s stable releases Zenwalk, both of which have put out
equivalent of the Testing branch of most and has been dormant for quite a while. releases based on Slackware 15.

22 LXF287 April 2022 www.linuxformat.com


Linux distribution REVIEWS

For what it’s worth,


the release notes
promise to deliver
Slackware 15.1
after a far shorter
development cycle.
We aren’t holding
our breath, though.

all the modules, and then there’s the standard generic The distro’s package management tool, slackpkg, can
kernel, which needs an initrd file to load the modules. install packages over the internet. However it lacks the
Using the generic kernel will save some memory, which ability to resolve dependencies. This can give a false sense
makes it ideal for older, under-stocked machines. Back in of achievement to new users, since the tool will install any
the day, Slackware users had to generate their own initrd packages without complaining. It’s only when you run the
from the command line, but the distro has become a little installed application that you’ll receive dependency
accommodating and now ships with a CLI tool that can missing errors. The best solution to this problem is for
build the initrd automatically. users to automate the compilation and installation
Slackware ships as an install-only DVD image that process using a script from SlackBuilds.org. Furthermore,
clocks in at around 3.5GB for 64-bit machines as well as while Slackware itself doesn’t incorporate official tools to
for the older 32-bit machines. The installer is as old school resolve dependencies, some unofficial, community-
as it can get, with ncurses interfaces, and expects you to supported software tools such as slapt-get do.
manually carve a partition for the distro. However, the For the experienced Slackware campaigners, the latest
installer selects adequate defaults, and most users can release debuts a script that helps users rebuild the entire
get through the process without much trouble. distro from source, in order to create a bottoms-up
Slackware still uses the LILO bootloader by default. You customised installation.
can use GRUB as well, but again in typical Slackware- All things considered, a Slackware release is a
fashion, this will take some doing. momentous occasion for the old timers, and Slackware 15
is as good a release as any for the young‘uns to
Inside out experience what the hullabaloo is all about. The distro
While Slackware’s installation lacks the usual bells and runs nicely from within the safe confines of a virtual
whistles of modern distro installers, the process is still machine, which is where we’d suggest new users to install
fairly straightforward. However, although the distro isn’t the distro and fiddle around with its legendary
difficult to install, if you want to do more with it, you’ll configuration prowess.
have to mess around with text files. Finally, if you run into problems, there’s an active and
For starters, the distro doesn’t ship with a graphical helpful community over at LinuxQuestions.org that you
package manager. Even if you want to use its CLI can look to for any sort of hand-holding and fixes.
pkgtools package management system, you’ll first
have to edit a file to select the mirror closest to you.
Next, you’ll have to pull down the GPG keys, refresh the
VERDICT
package lists, and install new ones accordingly. None of DEVELOPER: Patrick Volkerding
this is complicated, and becomes second nature as you WEB: www.slackware.com
spend time with the distro, but will feel odd to Linux users LICENCE: GNU GPL
familiar with the ways of the Ubuntus and Fedoras.
The veterans, though, will appreciate the FEATURES 7/10 EASE OF USE 5/10
improvements to pkgtools, which has several new PERFORMANCE 9/10 DOCUMENTATION 7/10
functionalities, such as file locking to prevent conflicts
between parallel installations and upgrades. The utility Ignore the rating; grab the ISO and fire it up inside a VM to
has also been brought up to date to work with the experience the famed dexterity of the oldest Linux distro.
sensibilities of the modern hardware, in that it now limits
the amount of data it writes to storage devices in order to Rating 7/10
avoid extra writes to SSD devices.

www.techradar.com/pro/linux April 2022 LXF287 23


PREVIEW Portable gaming PC

Valve Steam Deck


Our PCGamer friends got a hands-on preview hardware of the Steam
Deck before the big launch at the end of February. Here’s what they learnt…
he Steam Deck isn’t just a games
SPECS
CPU: AMD Zen
T console. It’s a PC, which means you
can plug it into a monitor or TV, hook
2, 2.4–3.5GHz up controllers or a mouse and keyboard,
Core: four cores, install Linux or even Windows if you prefer.
eight threads As with any PC, you can use launchers
GPU: AMD other than Steam and even take it apart
RDNA 2, if you want to. But the Steam Deck has
1–1.6GHz some unique features that give it a more
GPU units: Eight streamlined, console-like experience.
RAM: 16GB The new version of SteamOS, Valve’s
LPDDR5, 32-bit Linux-based operating system, will be able to
quad-channel seamlessly play games that were built for Windows The promise is AAA
Storage: thanks to the Proton compatibility tool. The system can gaming access, no matter
if it supports Linux.
64GB eMMC, suspend and resume games, too, and supports some
256GB NVMe, fancy new AMD graphics features.
512GB NVMe “Launch” in this case doesn’t quite mean you’ll be based on storage size. The Steam Deck costs $399 for
Display: getting a Steam Deck in your hands on 25 February. On 64GB; $529 for 256GB; and $649 for 512GB. The more
7-inch LCD this day Valve will begin emailing everyone who pre- expensive versions of the Steam Deck feature faster
touchscreen, ordered a Steam Deck. “Customers will have three days NVMe SSD storage, while the cheapest is listed with a
1,280x800, (72 hours) from receipt of their order email to make their 64GB eMMC (embedded multi-media card) storage
60Hz purchase, before their reservation is released to the next solution. All three versions will enable you to increase
Audio: Stereo person in the queue. The first units will be on their way to storage space with a MicroSD card, at least.
speakers, customers starting the 28th, and we plan to release new
3.5mm jack, order email batches on a weekly cadence," Valve says. So Tear down
dual mics if you’ve not pre-ordered don’t expect to get your hands The Steam Deck specifications were revealed by Valve
Comms: Wi-Fi on the hardware any time soon. alongside the console itself, which means we know all
2.4/5GHz 2x2 about what lies beneath the console’s seven-inch screen.
MIMO 802.11ac, Go Valve or go home The most important thing to note for Linux users is that
Bluetooth 5.0, The Steam Deck is currently only available to reserve the Steam Deck runs on an AMD APU, and one we’re yet
USB Type-C for the US, UK, Canada and the European Union, but to see elsewhere. This chip is built around two key AMD
(DisplayPort 1.4 Valve has told us that it wants to make the Deck architectures: Zen 2 and RDNA 2.
support), available to order in more countries when it can. There The Zen 2 architecture is the same one found in AMD
microSD UHS-I are no plans to sell the Steam Deck in stores, so buying Ryzen 3000 processors. Within the Steam Deck reside
Battery: 40Whr it from Valve directly will be the only option for the four Zen 2 cores, capable of eight threads, ready and
Size: 298x117x foreseeable future. waiting for your portable gaming needs.
49mm The price of the Steam Deck depends on which The RDNA 2 architecture is behind the handheld PC’s
Weight: 669g version you want, and there are three different versions graphical grunt. The Steam Deck comes with eight
compute units (CUs) for a total of
512 cores. That’s not a massive
amount – the Xbox Series S comes
with 20 RDNA 2 CUs – but it appears
enough to get by at 720p without too
much hassle.
The 512GB and 256GB models are
both NVMe SSD model, which makes
possible bandwidth upwards of
3,000MB/s. As for the 64GB model,
we’re not quite as convinced as it’ll
be slower, but most of all its slim
capacity is almost unimaginable for a
gaming PC. Perhaps as an indie/retro
machine. All three do offer MicroSD
for further expansion, and we suspect
Arch Linux has never the faster the MicroSD, the better for
looked so good!
optimal game load times.

24 LXF287 April 2022 www.linuxformat.com


Portable gaming PC PREVIEW

Valve’s settled on a 1,280x800 display, through which


you’ll enjoy your games on-the-go. However, the Steam WHAT ABOUT PERFORMANCE?
Deck’s touchscreen, 60Hz LCD panel with 400-nits
brightness isn’t much to write home about. At the time of writing no one has conclusive performance figures,
Finally, the RAM specification is 16GB of quad-channel because the software wasn’t in a final release state. However a
LPDDR5 at 5,500MT/s. This is a big deal for an APU- number of previews did get to test performance across five titles.
powered machine like this. The more memory bandwidth Control on Low preset reached 59 average FPS, Devil May Cry 5 on
the merrier, we say. Medium with FXAA hit 86fps average and Ghostrunner on Medium
reached 81fps. There’s raytracing support via Vulkan dynamic
SteamOS revamped rendering for titles that support it, but expect a hefty performance hit.
SteamOS is now more than seven years old, but the For instance, Ghostrunner performance dropped by almost 40 per
version of it releasing alongside the Steam Deck marks a cent. Another helpful trick is that AMD FidelityFX Super Rendering
major change. Valve is switching from Linux distro Debian will be available in a future OS release, which should help
to Arch, and launching it with a fresh interface that will boost performance on titles that don’t
also make its way to the desktop replacing Big Picture directly support it.
mode. We asked Valve why it’s switching, and the answer
is pretty simple: Arch’s frequent updates enable Valve
to iterate more rapidly.
The Steam Deck’s Guide (...) button pulls
up a quick settings menu that reminiscent
of the Nintendo Switch’s, giving you easy
access to the system brightness and
volume as well as toggles for Wi-Fi and
Bluetooth. Pulling this up seamlessly while
in-game just feels nice. Here the Steam Deck
feels like console hardware – this settings menu
just works.
The Steam button is just as impressive. A press In-game setting
while in-game brings up a menu that’s still in access has that
slick console feel.
development, but gives you access to Steam Input
settings or jumps back to the game’s library page,
where you can browse around the rest of the OS. The continues to refine Proton, plenty of games will
game stays nicely suspended until you go back to it. just work without any specific treatment. Yet there will
For years Steam’s Big Picture interface has given also be ways for developers to optimise their games for
Steam a console experience in the living room, but this the Deck hardware.
update to SteamOS delivers the fundamental benefits of “There will be an API that developers will be able to call
a console experience. It’s quick and easy to navigate that says ‘Is this Steam Deck? If so, use these settings,”
around the interface without falling back to a keyboard said Valve designer Lawrence Yang. He compared it to how
and mouse; you can access hardware settings with the many games already detect some basic information about
push of a button; and games will live happily in suspended your kit, such as monitor resolution, and adjust
animation while you browse the OS and easily resume accordingly. Hopefully, by the time the Steam Deck is
from where you left off. launched for proper, many games will have updates with
It definitely still needs polish, but SteamOS 3 will be settings that are optimised for the device, but the graphics
just as critical for the Steam Deck as its cutting-edge settings will still be there for us to tweak if necessary.
AMD hardware. As a portable PC gaming machine, it really is an
Valve has said that most of the work needed to make impressive device. It’s comfortable, feels great to
the entire Steam library work on the Deck is on its hold, and seems to have the power to play games like
in-house team, not individual game developers. As Valve Death Stranding with decent settings (see above). If
SteamOS really can deliver the compatibility that
Valve’s aiming for, then the Steam Deck is going to
become our go-to system for playing games while
lounging on the couch, and we’re convinced that it’s
going to be the best emulation device ever made. We’ll
have a full review next issue!

DETAILS
DEVELOPER: Valve Software
WEB: www.steamdeck.com
PRICE: 64GB £349, 256GB £459, 512GB £569

The Steam Deck delivers the convenience of a console with


the freedom of a PC. All that’s needed is a sleeker SteamOS.
SteamOS 3.0 has come a long way over the past seven years.

www.techradar.com/pro/linux April 2022 LXF287 25


WE COMPARE TONS OF STUFF SO YOU DON’T HAVE TO!

Roundup
Pop!_OS 21.10 Mint 20.2 Cinnamon Bodhi
Linux 6.0.0 Lubuntu 21.10 Zorin OS 16 Core R4
Michael Reed
likes all of his
alternatives to
be as alternative
as possible.

Ubuntu alternatives
Michael Reed investigates Ubuntu progenies and finds that
they each have their own take on a how a desktop should work…

HOW WE TESTED…

Having installed each


distribution, it was time to start
playing around. This consisted
of using the distribution for a
while to carry out typical
desktop computer tasks such
as browsing the web and
running software such
LibreOffice. We also tried
installing some software using
the package management
facilities of the distribution,
noting any difficulties along
the way.
In addition to the standard
desktop computer tests, we
loaded each of the distributions
up on an old laptop fitted with
2GB of RAM and a 1.66GHz
single core hyperthreaded
CPU, because we were curious
to look for problems when the his month, we’re looking at Ubuntu distributions are quite popular, with
system is really under strain.
To our satisfaction, all the
T alternatives. These are Linux
distributions that use Ubuntu as a
substantial user bases. Although the outlook
of these distributions is somewhat modern,
distributions were usable on base and then add customised functionality. they aren’t experimental; they’re all ready for
such a setup, but we would This way of creating a distro makes a lot of day-to-day use as a main setup. We’re setting
only consider Lubuntu and sense because it guarantees the stability and out to discover if they would be good enough
Bodhi as viable full-time OSes massive software base and driver support of to use as a daily driver, for experienced Linux
for this machine. Beyond 2GB Ubuntu, while still giving the developers users such as ourselves or, perhaps, users of
of memory, the operating freedom to customise the experience. other operating systems who might be
system and desktop becomes Of the five distributions that we’re tempted to switch.
less of a factor, and substantial examining, only one – Lubuntu – is an official We’ll tell you now: they’re all good
applications use a higher Ubuntu flavour, and the other four have been distributions, and they all put you on
percentage of the total created by independent teams. You might feel the cutting edge of what a desktop Linux
memory anyway. some anxiety about stepping away from the distribution has to offer, but they did have
standard Ubuntu release, but all of these different strengths and weaknesses.

26 LXF287 April 2022 www.linuxformat.com


Ubuntu alternatives ROUNDUP

The default
applications
The default loadout helps to shape
the personality of a distribution.
op!_OS comes with a slim selection of essential

P applications for general use such as Firefox as the web


browser and Geany as the email client. There are some
office applications such as LibreOffice, a USB image writer and a
scanner tool. Overall, there’s a GNOME flavour with choices such Lubuntu provides a good balance of useful programs without being overwhelming.
as Totem video player and Evince document viewer, although this It could likely manage most basic tasks without having to install anything extra.
distribution seems to have picked up the odd GNOME habit of
giving applications generic names such as Files, Videos and Linux Mint has a fairly full set of applications on a standard
Document Viewer. installation that cover most of the major bases for office and
The Bodhi Linux application selection is stripped down to the general computer use such Firefox, Thunderbird and the LibreOffice
essentials with more system-configuration tools than actual office suite. This is another distro that uses GNOME generic
applications. Perhaps it could have included a few more extras? application names rather than the full names in some cases.
The choices are appropriate for a distro that bills itself as Lubuntu has a selection of applications that sits in the
lightweight such as Leafpad text editor, Ephoto photo manager and middle in terms of how much stuff it gives you, and there’s a slight
Thunar file manager. Chromium is the web browser, and although KDE connection here even though the programs tend towards
there are lighter choices out there, they tend to come with their lightweight options. PCMan is the file manager, and this springs
own compromises in fairness. (mumbles in Firefox–ED) up almost instantly when launched. VLC isn’t the most lightweight
The Zorin default application is closer to that of a standard media player, but it’s well known and has a lot of features.
Ubuntu desktop, with no particular concessions to lightweight
options. This is fine because this is a distro destined for standard VERDICT
desktop use. The applications are ones such as Nautilus as the file
browser. By the same token, the application selection isn’t paired POP!_OS 8/10 BODHI 7/10
back and it includes extras such as GIMP for image editing, but MINT 8/10 ZORIN OS 8/10
simple games such as Mahjong, for example, feel unnecessary. LUBUNTU 8/10
Overall though, it’s a selection of high-quality applications that Lubuntu may contain the best balance of default applications, but there were
should serve to impress first-time Linuxers if nothing else. no major faux pas here.

The Mint
Welcome

Install and first run application can


be skipped or
worked through
to carry out
Where we find out how smooth the the initial
installation is and what it gives you. configuration
options.
ll of the installation sequences stuck close to the Ubuntu There are also

A standard. They all offered encryption, but the option was


slightly hidden in the case of Bodhi and Zorin OS. Some
some links
to beginner’s
documentation.
would prefer to be dumped into the desktop on a first run, but
we’ve given points for distros that add some setup hand-holding at
this point, particularly if it’s skippable for those who don’t need it.
We liked the way that the Pop!_OS installer gave some layout
and theme configuration options while installation was in progress
along with some tips on the UI. Annoyingly though, the (non- We appreciate that Ubuntu kicked off the trend of minimalist
skippable) first-time run greeter repeated some of these questions installation procedures, but we would have liked to see more
and information. innovation here, in each case, with perhaps some optional extras
The Mint Welcome application was a normal-looking application that could be installed such as ‘office applications’ or ‘development
(which we liked) and offered some configuration options. It also tools’ and so forth.
popped a reminder about checking for appropriate video drivers.
It’s in keeping with the overall minimalism of Lubuntu that the VERDICT
first-time login launches the desktop with no further fanfare, and
Bodhi takes the same approach in this regard. POP!_OS 7/10 BODHI 6/10
On first-time login, Zorin OS features an animation, set to MINT 7/10 ZORIN OS 8/10
music. This is then followed by an optional feature tour. One good LUBUNTU 6/10
thing about this is that every slide has a link at the bottom that Zorin OS ticks the most boxes when it comes to installation, and the feature
opens up the appropriate settings. tour actually does something useful.

www.techradar.com/pro/linux April 2022 LXF287 27


ROUNDUP Ubuntu alternatives

Desktop layout
We assess the
controls that you Linux Mint 7/10 Bodhi Linux 6/10
interact with all day. Green, grey and black are the dominant The Bodhi window manager is called
tones of the default Mint desktop. If you Moksha. It’s billed as a lightweight desktop
ach of the distributions has its don’t like it, themes can be changed for and it’s snappy in operation, but given that

E own take on exactly how the


desktop works, but they’ve all
window borders, icons, controls, mouse
pointer and overall desktop.
it’s a fork of Enlightenment, there’s some
bling in evidence. As you move over icons,
stuck to a fairly conventional layout. In The Cinnamon desktop uses a custom tooltips flash into existence and selected
other words, you should be able to taskbar and application launcher. The items fade in. The default terminal window
make a guess as to roughly how they all launcher has a series of quick-access icons has a textured background, and the cursor
work at first glance. Even though they all on the side, and a search box at the top. fades in and out in a neon glow. It’s a highly
have scope to be customised, we’re The Super key calls up the launcher and configurable environment, but it could
going to focus on the default setup that using it mouse-free in this way was quick be argued that the maze of menus
each distribution offers, noting how and efficient. When an application is and windows for doing this are over-
easy it is to make minor changes. launched it adds itself to the bottom bar complicated and they follow a
When we’re considering the scoring, as an icon. Quick access icons occupy the somewhat unconventional layout.
we want the basic functionality to be same space and are underlined when In the tradition of older Linux desktops,
fast, smooth and intuitive. Beyond that, launched. It’s easy to drag and drop icons the backdrop includes a selector widget
we’re looking for added customisations on to either quick launch area. for choosing between the four virtual
that the developers have made, which The overall arrangement is a hybrid of a desktops. Speaking of which, there are
improve the user experience and full-on Mac-like dock and the traditional quite a few widgets that can be added to
introduce extra features. task switcher bars of yore. It’s the the backdrop. The launcher and taskbar
In each case, if you couldn’t get on traditional desktop layout successfully are fairly standard, but it’s a shame that
with the desktop environment, you modernised for 21st century users. the launcher isn’t searchable.
could install a different one – this is
Linux, after all. However, if that were the
case then you might want to consider
one of the other Ubuntu derivatives
rather than doing the customisation
work yourself.

Community and support


When you run into problems, how easy is it to get help?
hat we want to see are the products of a vibrant looked like a helpful resource, but it does require a signup with

W community such as active forums and a healthy


ecosystem of tutorials.
email verification.
The Lubuntu ‘forum’ is actually the Ubuntu forums, but the
Linux Mint has the benefits of being one of the most popular web front end searches for the ‘Lubuntu’ tag within them, but we’d
Linux distributions in its own right. Although it ploughs its own have preferred a dedicated forum. There’s an active IRC channel,
furrow to an extent, most fixes that work on Ubuntu still work and there’s a fairly traditional manual for Lubuntu on the website.
with Mint, even though you may have to adapt them slightly. The Zorin OS website has a forum and it’s rather active
The official Linux Mint forum is highly active and has many indicating an active community around the distribution. There are
sections. Mint is well known online, and there are plenty of also some brief but useful documents covering topics such as
tutorials to be found without too much effort. installing the distribution and installing games.
The Bodhi website frontpage points users to the official wiki.
This is handy because the Moksha is intricate and non-standard. VERDICT
Pop!_OS has an unofficial forum (https://pop-planet.info/
forums) that has some activity and where you could probably get POP!_OS 6/10 BODHI 6/10
a reply if you found yourself in a jam. The System76 website MINT 8/10 ZORIN OS 7/10
contains some troubleshooting documents for all of its products LUBUNTU 6/10
and some of them cover Pop!_OS issues. However, the main Nothing succeeds like success. Mint is the leader thanks, in part, to its
support channel is the official chatroom. This was active and popularity on the Linux scene.

28 LXF287 April 2022 www.linuxformat.com


Ubuntu alternatives ROUNDUP

Pop!_OS 9/10 Zorin OS 8/10 Lubuntu 7/10


Since the 21.04 release, Pop!_OS The default theme is a frosty white one, Lubuntu offers a desktop that runs on the
has shipped with a custom desktop while the desktop is a customised GNOME LXQt environment, which is a combination
environment called COSMIC that runs on desktop with an icon bar task switcher and of the low-resource LXDE desktop
top of GNOME. There’s a dock with icons launcher along the bottom. An icon in the environment with the QT user interface
on it at the bottom of the screen and bottom-right of that bar offers a traditional toolkit. The default look is grey and blue-
another bar running across the top. The application launcher that’s searchable and themed with the neat, minimalist QT
Super key or dock icon activates the divided into categories. The Super key overall aesthetic. However, there are lot
searchable application launcher, which is launches the standard GNOME switcher/ of different areas where you can set the
more list-based than the GNOME one. launcher combo. theme (QT Theme, GTK theme, LXQT
Going up to the top bar, there’s a There’s no top bar at all, and the overall theme, window manager theme), and we
workplace selector and an application look is similar to the older versions of were left confused about what to change.
launcher. The latter brings up a palette of GNOME, other than the use of icons in the Along the bottom of the screen sits the
applications, with categories, that reminds taskbar. However, this is easy to change if taskbar and application launcher. The
us of Android. On the right-hand side of you fancy a different layout. The Zorin latter is about as traditional as it gets,
this bar there are some status icons, one Appearance application offers quick, icon- being a vertical pop-up menu divided into
of which enables the user to flip into tiled based selections between four basic user categories, but it is searchable. It’s linked
windowing mode, which might be a good interface layouts, and further tabs provide to the Super key, and keyboard-only
stepping off point for people who have access to sensible appearance options searching for applications and cursor
always wanted to try a tiled approach. such as the accent colour and font navigation worked quickly and properly.
COSMIC is a slick desktop that’s more selection. There’s also a reminder that you The other desktops that we tested
than a simple customisation of GNOME, can obtain more of these layouts by buying weren’t slow, but everything seemed a little
while leveraging GNOME’s strengths. the Pro version of the distro. bit snappier in LXQt.

Included extras
What additional elements does each distro have that the others lack?
y default, Pop!_OS offers a recovery partition, which is a Once up and running, it’s possible to use your phone as a

B bootable copy of the installation media. The installer,


when run from this environment, can detect the existing
remote to control media playback and presentations on your
computer. It’s also possible to display phone notifications on your
Pop!_OS installation and carry out a ‘refresh installation’ to repair desktop or vice versa. The features keep coming: there’s easy file
any damage when the installation is damaged. In addition, sharing between phone and desktop, and you can even use your
standard Linux software can be run from within it because phone as a touchpad.
it’s a live environment. Linux Mint has all the basic features, but it doesn’t have much
Zorin OS has facilities for installing and running Windows in the way of what you might call ‘frills’. It does come with a utility
programs on a fresh installation. As such, from the get-go it’s called Warpinator, created by the Mint developers for setting up
possible to right-click .exe or .msi files and select ’Install Windows quick file shares between machines.
Application. You can install WINE on other distros to achieve the
same effect, but on Zorin OS this functionality is set up by default VERDICT
and integrated into the user interface and documentation.
Zorin OS also includes a custom application called Zorin POP!_OS 6/10 BODHI 3/10
Connect for connecting to mobile phones and tablets. It only MINT 6/10 ZORIN OS 7/10
works with Android phones, but the facilities are quite extensive. LUBUNTU 3/10
You start by installing the Zorin Connect app on your phone. You Zorin OS comes with a couple of interesting custom tools. The Lubuntu and
can then pair the phone with Zorin OS. Bodhi developers don’t ship much custom software.

www.techradar.com/pro/linux April 2022 LXF287 29


ROUNDUP Ubuntu alternatives

Adding software
How easy is it to add programs,
and how wide is the selection?
lthough there are many ways to add software to a Linux

A system, we’re only interested here in the GUI methods


that are provided by default by each distribution.
Pop!_OS features a custom shop application that uses
standard repositories or Flathub as its sources. Unfortunately, it
doesn’t include the all-important reviews and ratings of Ubuntu Although there are many ways to add software to a Linux system, here we’re only
Centre. We like to see distribution developers coming up with interested in the GUI methods that are provided by default by each distribution.
original applications, but we’re not sure what extra features the
Pop!_Shop adds over the standard Ubuntu software shop. collection of applications is a bit limited. Beyond that, the more
Zorin OS also draws its potential software pool from the technically minded can use Synaptic.
standard repositories, Snap and Flathub. This time, the shop Lubuntu features a pleasing-looking software centre called
application looks like it might be a customised version of the Discovery. This includes the user ratings and draws software from
standard Ubuntu shop, but it also lacks the reviews and ratings. Snap and the Ubuntu repositories. The KDE package manager is
Neither Zorin nor Pop!_OS includes a front-end for apt itself, but the front end to apt.
Synaptic, a tried and tested GUI tool that links directly to the
Ubuntu repositories, could be installed via their shops. VERDICT
Mint’s software shop may be a variant of the Ubuntu software
shop and includes reviews and ratings. Synaptic is also included POP!_OS 6 /10 BODHI 6/10
for direct connection to the software repositories, a practical MINT 7 /10 ZORIN OS 7/10
combination. Flatpak and Ubuntu repositories are the sources. LUBUNTU 7/10
The Bodhi application store is web-based, but launched via the None of the distributions exceeded the standard Ubuntu experience when it
menus. It features user reviews and ratings, but the ‘curated’ comes to adding software.

Variants offered
A wide selection of variants of a distro
can greatly expand its usefulness.
or each distro on test we’re basing our comparison on its

F main edition, but each one feature has at least one


variant. You might only need a single release, but we
mark more highly for releases that can cover a number of use
cases. You might want to keep the same core distro in different
roles, for example.
Linux Mint has an upgrade cycle and versioning system that’s With looks that are reminiscent of the GNOME 2.x era, Mint MATE Edition ran
detached from the main Ubuntu one, but the releases themselves surprisingly well on a 2011-era netbook fitted with just 2GB of RAM.
are based on Ubuntu LTS versions. Linux Mint refers to its variants
as ‘editions’, and the main edition is based around the Cinnamon Legacy release, a 32-bit release, aims to be even lighter weight.
desktop, a feature-packed, modern desktop inspired by the Meanwhile, Zorin OS releases use their own numbering system,
classic GNOME desktop. There’s also an edition based on the but they’re based on Ubuntu LTS releases, with some lag behind
MATE desktop, a direct continuation of the GNOME 2.x era Ubuntu. We’ve focused on the Zorin Core release, but Zorin Lite is
desktop. For this reason, MATE tends to be a bit lighter on a lightweight release based on the XFCE desktop, and Zorin Pro is
resources, and if you really want to go lightweight there’s an Xfce a premium release with extra desktop layouts and art. The Pro
edition, too. LMDE is Mint, but based on Debian Stable rather than release also includes more software.
Ubuntu. There’s also a 32-bit edition of Mint for legacy CPUs. Lubuntu keeps things simple with both desktop LTS and
Pop!_OS follows the version numbers and release cycle of regular releases that are tied to the Ubuntu equivalent releases.
Ubuntu. Pop!_OS has separate downloads for the regular
installation and one that has the Nvidia drivers preinstalled. VERDICT
There’s also an ISO for a Raspberry Pi version.
Bodhi Linux uses its own numbering system for its rolling POP!_OS 6 /10 BODHI 6/10
releases, but the releases are based on Ubuntu LTS releases. MINT 8/10 ZORIN OS 6/10
Bodhi Linux Standard release gives a minimalist installation, but LUBUNTU 5/10
the AppPack release comes with more applications and the Linux Mint has the most editions covering the greatest number of use cases.

30 LXF287 April 2022 www.linuxformat.com


Ubuntu alternatives ROUNDUP

The Verdict
Ubuntu alternatives
verall, we were impressed with what we saw. All of the

O distributions we’ve considered succeed in offering the


feel of a customised OS experience rather than a
generic Linux build with a standard desktop slapped on top.
They all made the standard Ubuntu desktop look a bit stale in
comparison while benefiting from the rock-solid underpinning
that Ubuntu offers.
We’ve decided to make Pop!_OS the overall winner against
strong competition. We got on well with the COSMIC desktop
environment. It’s bound to be a subjective experience, but the
default aesthetic appealed to us, and we felt that the desktop
workflow, which can largely be carried out from the keyboard,
was fast and efficient. The software selection is slim without
being bare-boned, but between the Ubuntu repositories and 1st Pop!_OS 9/10
Flatpak, it should be possible to install anything else that’s
required with ease. Web: https://pop.system76.com Licence: Free software licences
Like Pop!_OS, Zorin OS made us feel as though we were with some proprietary drivers and codecs Version: 21.10
experiencing the cutting edge of what desktop Linux has to offer. The next generation of desktop Linux.
At the same time, we didn’t run into any technical hang-ups in
use, with not one crash or notable glitch over the testing period. 2nd Zorin OS 8/10
This goes for all five of the distributions, and although you can
sometimes feel that big customisations are asking for trouble, Web: https://zorin.com Licence: Free software licences with
what we encountered seemed stable in each case. proprietary drivers and codecs Version: Zorin OS 16 Core R4
The Lubuntu desktop offers a classic layout coupled with a A cutting-edge desktop with great looks.
smart, understated look. The choice of best distribution for the
low-powered laptop fell to either Lubuntu and Bodhi. We were 3rd Linux Mint 7/10
torn because Bodhi seemed a bit faster, but Lubuntu had the
more modern desktop. Web: https://linuxmint.com Licence: Free software licences
Linux Mint doesn’t have a lot of flash features. Instead, with proprietary drivers and codecs Version: 20.2 Cinnamon
it’s a good, reliable implementation of a rather standard Linux A good, solid Linux desktop.
experience. This shouldn’t count against a distribution, but we
decided to award extra points to distros that had attempted 4th Lubuntu 7/10
to innovate and add extra features beyond what’s normally
expected. Mint is highly recommended, but lacks much of a wow Web: https://lubuntu.net Licence: Free software licences with
factor compared to the other distros on test. some proprietary drivers and codecs Version: 21.10
Just judging on looks, Bodhi is a mix of the slightly old- A pleasing, lightweight option.
fashioned with high-end sparkle thanks to the Enlightenment
legacy behind the Moksha desktop environment. It’s fast and 5th Bodhi Linux 7/10
responsive, but some features such as the textured background
of the terminal make it look like a video game interface, and other Web: www.bodhilinux.com Licence: Free software licences with
visual features felt a bit distracting. It’s a tinkerer’s desktop, if some proprietary drivers and codecs Version: 6.0.0
you’ve got the patience to start making changes. Lightweight with a quirky desktop.

ALSO CONSIDER
Elementary OS (https://elementary.io) is an Ubuntu configured for media creation duties. Ubuntu Budgie uses the
derivative in a similar vein to the ones we’ve looked at and it’s lesser-spotted Budgie desktop as its user interface.
sold on a pay-what-you-like model. We looked at one official The distros we’ve looked at use Ubuntu as their base, but
Ubuntu derivative, Lubuntu, but there are others. Kubuntu is there are plenty of cutting-edge Linux desktops that don’t.
based on KDE as the desktop, with an appropriately alternative EndeavourOS (https://endeavouros.com) is based on Arch
application selection. Ubuntu MATE is Ubuntu with the Mint- Linux and seems to be generating a bit of heat this year.
instigated GNOME 2.0 continuation MATE desktop. Ubuntu Manjaro (https://manjaro.org) is another Arch-based desktop-
Studio is an Ubuntu edition that comes preloaded and pre- orientated derivative and one with a long history of its own.

www.techradar.com/pro/linux April 2022 LXF287 31


BUILD THE
The kernel is what makes Linux tick.
Jonni Bidwell is happy to get his hands
dirty and help you tune up those ticks…

inux, if you want to be low-level component of the operating or less mandatory there. But it’s an option

L annoyingly precise about it,


isn’t a complete operating
system. It is but a kernel. And
system, as well as some things you might
think belong elsewhere. This includes
drivers, filesystems, network protocols,
for any flavour of Linux, so we thought
we’d have a go at making building kernels
more accessible.
like the kernel of a seed pod, it requires schedulers (process and I/O), memory As we’ll discover, the Linux Kernel is
all the surrounding bits to be useful. allocators and all kinds of other treasure. huge and complicated. It may be tempting
A bootloader can happily load a Linux In the early days of Linux, users would for some to pore over it with a fine-toothed
kernel with no init system specified, and it regularly have to face compiling their own comb, trying to “optimise” it for speed or
will just sit there. Without userspace kernels, sometimes to get new hardware size. But this is for the most part hopeless,
applications (for example, systemd in the support, sometimes to reconfigure their and more likely to result in breakage than
first instance) telling the kernel what to do way out of brokenness, and sometimes to anything else. If you want a faster, more
it will simply idle. Yet it has the potential improve performance. Users of Linux From responsive kernel, then a better approach
to do anything. The kernel includes Scratch or Gentoo will be familiar with the is to use one of the many custom efforts
everything you would think of as being a kernel compilation process, since it’s more that are available.

32 LXF287 April 2022 www.linuxformat.com


Build the kernel

Grasp the kernel basics


Just what is a kernel and why is it telling my computer what to do?

hen you think of an operating system (OS) it The kernel

W ought to be an umbrella term for the ‘thing’


that’s responsible for everything your
is a modular
masterpiece that
can run everything
computer does after the BIOS/UEFI hands over from old AGP
control to the bootloader. For popular systems such graphics to the
as Windows and macOS it’s easy to lump everything Large Hadron
Collider.
together thusly. There’s no choice of desktops, no
option to boot to a (real) command line and no real
way to replace core applications (like Explorer and
Finder). On Linux it’s clear that things are much more
modular. The progression from UEFI to bootloader to
kernel to login screen is much more demarkated. If
you’re quick you can even identify the moment the source code and sometimes proprietary), but rather
kernel hands over to the initialisation system (for shipped in a separate linux-firmware package. Since this
example, systemd or runit). Yet it turns out that every package is required for all the drivers in the kernel
operating system has a kernel. (usually packaged as linux-image-…) to work, we can’t
The falsehood that macOS is based on BSD forget its size (lib/firmware occupies over 700MB on
(perpetuated by lazy journos and Mac users who like to our system). Drivers themselves, occupy fairly negligible
claim their OS is more grown up than it is) stems from space (see the box on page 36).
the Darwin OS upon which it’s based. Darwin is open
source and partly BSD-based, but it also borrows from
other OSes (particularly NeXTSTEP, which was bought MAINLINING
by Apple in 1997). Darwin has its own kernel called XNU
(an acronym for X is Not Unix), which unlike Windows Over the page we’ll look at compiling a trivially modified Ubuntu
and Linux is a hybrid, as opposed to a monolithic, affair. kernel. Canonical apply patches and backported fixes to their kernels,
It’s based on the Mach kernel, originally a research with the effect that an Ubuntu kernel bearing the version number
project into microkernels, with BSD functions added (so 5.13.0, say (which we got by running uname -a on our Ubuntu 20.04
it’s not a “BSD-based” kernel). The more shiny layers of VM) may be constitutionally very different from a “mainline” Kernel
macOS, namely the Aqua GUI, the Cocoa/Carbon 5.13 that you would download from https://kernel.org. You might want
interfaces and various application services, are all to build your own mainline kernel, for example if you suspect a bug
proprietary and have nothing to do with BSD. has been fixed upstream (or indeed, if you think that an Ubuntu patch
introduced the bug). That’s easy: just extract the source tree and
Driving the deal follow the instructions over the page.
The XNU kernel has its own driver API called IOKit, and What’s even easier is using the pre-packaged mainline kernels
Windows’ kernel has the less imaginitively titled produced by the Ubuntu team. First read the blurb at https://wiki.
“Windows Driver Model”. Drivers (programs that talk to ubuntu.com/Kernel/MainlineBuilds, then follow the link there to
hardware) are perhaps the easiest component of a the Mainline Kernel Archive. You’ll see that while Ubuntu 21.10 and LTS
kernel to get your head around, in the sense it’s easy to (if it’s kitted out with the Hardware Enablement stack) are running
see why they need to be there. The only trouble is, most Kernel 5.13, the current in-development series (confusingly also called
modern Linux distros have very few drivers baked in to “mainline”) is 5.17. We don’t advise trying out these release-candidate
their kernels. Instead, the preferred approach is to (RC) kernels at first. But you may have reason to try the Longterm
include drivers compiled as external modules, which branch, which currently is 5.15. As of now, this branch is used by
can be loaded early on in the boot process by Udev Pop!_OS and it’s what the next LTS of Ubuntu will be based on.
when the corresponding hardware is detected. Modules
plug straight into the kernel, and for the most part act
as if they were a part of it. Other kernel components can
be ‘modularised’ and loaded on demand too, but certain
low-level systems (for example, the one for loading
modules in the first place), have to be built in. A smorgasbord
So the Linux Kernel contains drivers for every bit of of kernels can be
hardware supported by Linux. Well, almost. Modern found at https://
kernel.org, from
hardware (particularly Wi-Fi and GPUs) often requires bleeding edge-
firmware to be uploaded to it on every boot, otherwise it RCs, to the SLTS
won’t work. This firmware is generally not included in 4.4 series.
distribution’s kernel source packages (since it’s not

www.techradar.com/pro/linux April 2022 LXF287 33


Build the kernel

Compiling a kernel
Get straight to business and build your own Ubuntu-esque kernel

o compile your own kernel using Ubuntu package maintainer’s version. In any event, let’s get hold

T (or any distro that uses Ubuntu kernels, for


example Mint, elementary OS, but not Pop!_
of those sources:
$ apt source linux-image-unsigned-$(uname -r)
OS) the first step is to get hold of the kernel sources. If you’re running the HWE kernel, which you probably
The official channel for vanilla kernel sources is are if you’re running an up-to-date desktop edition of
https://kernel.org, but this isn’t necessarily the best Ubuntu 22.04, then the sources will land in the linux-
place to start. Instead, we’ll use an Ubuntu kernel, which hwe-5.13-5.13.0/ directory. You’ll also be told that the
includes numerous patches and backported features. It HWE kernel package is developed on Git, and that more
also has the advantage of coming with a configuration up-to-date sources can be acquired via:
very close to what you’re currently running (in fact it’s $ git clone git://git.launchpad.net/~ubuntu-kernel/
identical if you have the same version). So if we make ubuntu/+source/linux/+git/focal
only small changes there, then we’d hope the resulting Either way, once we have the sources we may as well
kernel still has all the functionality of the old. disable the source repositories. If you used the Perl
Besides the kernel source files, we also need the command earlier you can do this with:
required build tools. If you’ve ever compiled anything $ sudo mv -f /etc/apt/sources.list{.bak,}
before you’ll probably have all these. But if not, get them Incidentally, the apt source directive will get the
with the following: source code to absolutely any package in the Ubuntu
$ sudo apt build-dep linux linux-image-$(uname -r) (or whatever apt-based distro your using). Neat. We
Using uname like this ensures the build tools you’re didn’t use sudo in the apt command because sources
about to download correspond to the kernel you’re are downloaded to the current directory, which we
running, and that both are new. If you updated your carefully made sure was the home directory. The full
system before this command, you might want to reboot kernel sources are large (1.2GB for Ubuntu 21.10) and
(in case a new kernel was available) and then fetch the apt will fail if there’s insufficient space. If this happens
build tools (and kernel sources). If the command hit Ctrl-C, delete the linux-hwe* files in your home
complains about not being able to find source packages, directory, and try again somewhere with plenty of space.
you may need to uncomment the lines beginning
deb-src in /etc/apt/sources.list for both the main Time to compile
and updates repositories. Alternatively, since we’ve Having successfully downloaded the sources, let’s
got a bit of a Perl flavour going on this issue, this little configure and compile them. When you compile the
snippet will do it for you: Linux kernel, you’re free to include or exclude whatever
$ sudo perl -i.bak -pe “s/^# (deb-src .* $(lsb_release -cs) components you want. Traditionally, these were selected
(-updates)? main restricted$)/\$1/” /etc/apt/sources. from a glorious text-based menu accessed by running
list make menuconfig . Things have moved on now and
Those dependencies are plentiful (and include Java there’s a modern configuration interface. Don’t get too
and LaTeX), but our story is not yet done. The (slightly excited, though – it’s still text based, but now it’s
outdated) Ubuntu wiki at https://wiki.ubuntu.com/ powered by ncurses and has a hacker-style black
Kernel/BuildYourOwnKernel mentions that the previous background. Summon this with:
command doesn’t install everything required. And that $ cd linux-hwe-5.13-5.13.0/
statement is still correct. The following packages should $ make nconfig
fill in any gaps, but if not you’ll be told what’s missing: See? Glorious. Navigate through the menus using
$ sudo apt install libncurses-dev fakeroot kernel- the cursor keys and Enter. Options are selected or
package deselected (or selected to be built as modules) using
You may see a warning about updating kernel-img. Space, but don’t change anything just yet (you can
conf, in which case you should choose to install the always quit, by pressing Escape, without saving and run
the last command again to return). Instead, let’s have a
look at what’s in your kernel.
Everything’s organised into menus, one of which
is Device Drivers which we’ve already talked about.
You’ll also see sections for Memory Management,
Networking, Virtualisation and a few others that all
might be expected to appear in an OS. Sections that
house further options have ---> at the end.
We’ll start by making a single, simple change. Go
to the General setup category. Inside you’ll see lots of
Switching from ZSTD to LZ4 compression reduced the time taken to load the kernel on our virtual confusing options, some of which have been selected
machine, although not by anything significant. according to Ubuntu’s default configuration. The option

34 LXF287 April 2022 www.linuxformat.com


Build the kernel

Compiling kernels
will really put your
CPU through its
paces. Our laptop
got too hot to type
on (now there’s
an excuse for late
copy! – Ed).

to use ZSTD compression, you might recall, became the it breaks because a string value is required here.
default in Ubuntu 20.04. Note this is documented precisely nowhere. Finally
We can find out more about a particular option by let’s build the thing:
highlighting it and pressing F2. Doing this in the kernel $ fakeroot make-kpkg -j “$(nproc)” --initrd --append-
compression mode option tells us something about to-version="+lxf” kernel-image kernel-headers
which compression options work best on what system, Now make a cup of tea because the stock Ubuntu
as well as a considered note about who to contact kernel is rather fully featured. You’ll see files being listed
if certain options don’t work. Let’s switch to LZ4 as they’re being compiled, linked and generated. It’s
compression and see if we can spot a difference. reasonably pleasing to watch, but you may need
another cup of tea. On our XPS13 it took most of a lunch
See what’s on the SLAB hour (Who said you were allowed an hour for lunch!? – Ed)
If you like odd-sounding acronyms, have a look in the to finish up, over the course of which it got rather hot.
Choose SLAB allocator menu (towards the bottom of Even in Covid-free draughty corridors of Future Towers.
the General setup menu). Before you get dragged All going well you should see two .deb packages in
deep into the rabbit’s warren of kernel options, exit by your home directory (not the source directory): one
pressing F9 and make sure you save the configuration. containing the kernel image, and one containing the
You’ll be told it’s stored in a file named .config. headers. We’ve been careful to only do a very trivial
One slight quirk with using the Ubuntu kernel is that modification (so, only changing the compression
it’s configured by default to use Canonical’s Trusted format) for our first outing. And with good reason.
System Keys. Because these aren’t included in the These packages are going to replace the current kernel
kernel sources, the build will fail without some packages on the system. This shouldn’t really be a
intervention. We can either manually disable the keys problem since Ubuntu always has a fallback kernel on
(they’re deep in the Cryptographic Services menu), hand, but we don’t really want our first effort to result
or we can use the helpful Debian scripts: in a kernel panic. See how you fare with:
$ scripts/config --set-str SYSTEM_REVOCATION_KEYS $ sudo dpkg -i linux-*.deb
$ scripts/config --set-str SYSTEM_TRUSTED_KEYS The kernel should be installed as Grub’s new default.
This sets these to blank strings. The config program Check after a reboot with the uname -a command, and
also has a –disable argument, but if you use that here if necessary hold down Shift to bring up a boot menu.

COLONEL KURTZ ADVISES...


Using the Ubuntu (technically Debian) use any other kind of workaround here. our modules, and then (finally) update
tools to build kernels is all well and good. Instead, you can build kernels using the grub with sudo update-grub .
But if you’re just hacking away on a mainline tools and not worry about
kernel for personal usage, you might not packaging them. You can run make
want to go to the bother of packaging it nconfig from the sources directory to
all. And it’s certainly inconvenient to do use the (modern) ncurses configurator.
as we’ve done and replace the current Then once you’ve saved it run make to
kernel packages with custom ones, since build it and sudo make modules_install
those packages will be overwritten as to install the modules. Finally, you’ll want
soon as Ubuntu release a new kernel. to copy the kernel image to /boot with
It’s not recommended to try and build sudo make install .
these packages with different names, Did we say finally? Not quite – we still If you like endless options, settings and frobs all
and it’s likely to break things if you try to need to run sudo depmod to enumerate arranged in an Ncurses interface then you’ll love this.

www.techradar.com/pro/linux April 2022 LXF287 35


Build the kernel

Kernel minification
Perfection is reached not when there’s nothing left to add,
but rather when there’s nothing left to take away…

y this point the chances are you’ve already although perhaps not as large as you might think (see

B had a look around the config menu and have


noticed there’s an awful lot of stuff in there
box, below).
Another reason for removing things is demonstrated
you don’t need. This is probably true, and a lot of by the Linux-libre kernel. Here, drivers that require
people are interested in making the kernel smaller. proprietary firmware or microcode have all been
People building for embedded systems, where removed. As has firmware and microcode itself, which
storage space and memory are scarce, naturally will if you take a look at your /lib/firmware directory (ours
want to pull as much stuff as possible out of the kernel. was over 700MB) adds up to a substantial saving. Of
We’ve mentioned that there isn’t really a performance course, removing firmware files should be done carefully,
or memory hit from having so many unused drivers since any device depending on them will cease to
compiled as modules. However, there is a disk space hit, function. There’s also the annoyance of carefully
removing unneeded files, only for a new linux-firmware
At first glance,
there’s a lot of
package to appear and not only replace them, but add
superfluous yet more unnecessary cruft.
drivers in the
kernel. But Spotting superfluous fireware
you never know
Depending on your hardware it might be easy to see
when you’ll need
tape access… which firmware files you need, or at least which ones
you don’t need. For example, if you don’t have an
AMD graphics card then you can remove the 56MB of
firmware in /firmware/amdgpu, or indeed the 7MB of
bits in /firmware/radeon for older cards. There’s a small
volume of firmware for the Nouveau driver, the open
source offering for Nvidia cards, but it’s not really worth
worrying about at this stage.
To get some idea about which firmware has been
loaded on your system, run journalctl -b to bring up the
journal for the current boot. Press / to instigate a search,

DRIVER FOOTPRINTS
Space (at least the space taken up by the most space (165MB). If you examine there’s plenty else to remove too, but
the kernel) on modern hardware further you’ll see that AMDGPU is the again each component is small and
shouldn’t be a concern. The compressed largest graphics driver at around 20MB. sometimes much more critical than it
kernel image /boot/vmlinuz on our Nouveau, the FOSS driver for Nvidia sounds. So blindly removing swathes of
Pop!_OS system occupies a mere 11MB. cards is by comparison a tiny 3.4MB. So them is likely to end you up with a
And the accompanying modules, found axing whichever of these you don’t need broken, (but undeniably leaner) kernel.
in /lib/modules/5.15…/ occupies is a start to slimming down your kernel.
around 425MB. Any other Ubuntu-based Drivers on Linux are small, you might
system will have similar statistics (unless have noticed. Even AMDGPU is tiny
you’ve been tweaking things already). If compared to the equivalent massive
half a gigabyte is important to you (~450MB) download on Windows. The
(which it might be on old hardware) then difference is that very little of that
recompiling a leaner kernel (with only Windows package is ‘driver’. Most of
the required drivers) would be one way it is firmware, oh and shiny but useless
to achieve that. Naturally, that comes (if not outright annoying) gameware
with the downside that if you ever applications. So in reality removing
acquire different hardware, it won’t drivers one by one is a fairly thankless
work with the slimline kernel. exercise (the kernel configuration
Further investigating in the modules/ interface doesn’t make this easy either). The kernel sources directory gets big once you
directory reveals that the network, media It’s unlikely to liberate more than a start compiling. Here the Intel graphics bits are
and GPU device drivers together occupy couple of hundred megabytes. Of course, occupying half a gigabyte.

36 LXF287 April 2022 www.linuxformat.com


Build the kernel

and search for firmware. On our XPS we found the


following lines (and then some irrelevant matches to do
with UEFI keys):
[drm] Finished loading DMC firmware i915/kbl_dmc_
ver1_04.bin (v1.4)/
ath10k_pci 0000:3a:00.0: firmware ver WLAN.
RM.4.4.1-00157-QCARMSWPZ-1/
So our Intel graphics need to run DMC (nice)
firmware and our wireless chip needs something too.
The latter doesn’t explicitly tell us which firmware file it
needs, but if we look at the output of lspci we can
obtain a model number (QCA6174). And it turns out
there’s a /lib/firmware/ath10k/QCA6174 directory, so
that’s probably what we want.
Again, unless you’re seriously strained for space it’s
not really worth picking your firmware directory apart
like this. At least it wasn’t on our XPS. But we do for each CPU core. This might make your machine Prolific Arch
maintain a growing collection of old hardware, including difficult to work with while it’s all building, but will contributor
Graysky has
the undying Eee PC from 2007. With only 2GB of SSD, certainly speed up compilation time. We’re not using
released some
there can be no wasted bytes. Indeed, such old hardware make-kpkg this time, going instead back to first benchmarks for
doesn’t need any firmware at all. Naturally, we’ve principles. So this approach should work on other distros his modprobed-db
slimmed down the kernel to next to nothing as well. If too. Once the image builds we need to follow the helper utilty.
you’re making a kernel that’s tailored for particular instructions in the Colonel Kurtz Advises box (page 35).
hardware, then a common technique is to build any Let’s assume you’ve done that, and installed your
required drivers into the kernel image as opposed to modules and kernel, run depmod and the like.
building modules. The kernel configuration interface Those steps should build a corresponding initrd
even has its own mechanism for selecting modules (initial ramdisk/ramfs image) and put it in /boot where it
based on what’s currently loaded. can be found by GRUB. If you’re not using GRUB, for
To use this, make sure any hardware you’d like the example you’re on Pop!_OS which uses systemd-boot,
new kernel to support is plugged in and working. then extra work may be required to get the bootloader to
$ make localmodconfig

GIVE MODULES THE HEAVE-HO


This generates a configuration based on the current
kernel configuration together with any currently loaded

“If you’d rather have those drivers


modules. In general, this results in a kernel that still has a
number of extraneous modules, but if you have the

compiled into the kernel, as opposed


patience to iteratively compile, test and remove then
eventually you’ll find your way to kernel bliss. It can be

to as modules, you can use the


taxing to manually load every possible driver, and in
some cases it’s hard to resolve hardware names to

command localyesconfig instead”


module names. It’s particularly frustrating when you
miss a key module (yes, you do need SCSI disk support
believe it or not) and have to rebuild the whole thing.
One tool that can help you with this is Modprobed-db pick up the new kernel. We were pleasantly surprised
(see https://github.com/graysky2/modprobed-db), this all worked almost without a hitch on our Pop!_OS
which keeps a database of all the modules ever loaded laptop. But do study the documentation for the
on the system. This increases the chances that hardware kernelstub utility before going in with all guns blazing.
you haven’t plugged into the system for ages will still Systemd-boot requires the whole kernel to live on the EFI
work with the new kernel. partition, and you don’t want to accidentally fill this up.
As you become more involved with building kernels,
Where to compile your drivers? you’ll grow more and more familiar with the
If you’d rather have those drivers compiled into the configuration interface and where particular options
kernel, as opposed to as modules, you can use the hide. You’ll also find that, contrary to widely misheld
command localyesconfig instead. If a previous belief, Linux does in fact support a huge amount of
configuration from an older kernel exists, you’ll be asked hardware. From HAM radio to steering wheel controllers
about new drivers that have been added to the new (new in 5.15) to ISDN modems (remember them?).
sources. Usually it’s okay to accept the defaults here. There’s also a good amount of weirdness. If you nosey
Once the new configuration is written out we can use a deep enough into the kernel sources themselves then
handy script to see any differences, like so: you can find plenty of interesting stuff. The arch/x86/
$ scripts/diffconfig config.old config purgatory subdirectory for example contains
You should notice a lot of lines in the new file (prefixed VM-specific code. Specifically, purgatory is an object
by +) are now set to negative. Let’s try building our diet- that sits between running kernels (for example, when a
sized kernel with a simple new kernel is about to be loaded). If the process goes
$ make -j$(nproc) wrong the kernel hangs with a friendly “I’m in purgatory”
The nproc incantation (used on the previous page message. It’s possible to disable purgatory, but this
too) ensures compilation is divided into parallel jobs, one won’t absolve you of your sins.

www.techradar.com/pro/linux April 2022 LXF287 37


Build the kernel

Popular patches
Forget trawling through configs – use a pre-rolled patchset to set the rules.

e’re always impressed by Colorado-based others like it) is that multiple nicenesses (niceties?) can

W System76 and its contributions to Linux. Not


only does it make glorious hardware and a
be set automatically. All the user needs to do is start a
systemd service.
fine desktop environment, it’s also put in a lot of
effort tweaking behind-the-scenes kernel settings. Interpreting levels of niceness
This work has culminated in the System76 Scheduler Technically, niceness is distinct from priority, in the
service, which tweaks the kernel’s CFS (Completely sense that processes have a value for both. Priority can
Fair Scheduler) settings for lower latency when on AC take any value from rt (realtime) to -51 (very high
power. You don’t even have to be using Pop!_OS to priority) to 20 (normal priority). By default, user
take advantage of it, but if you are it’ll automatically processes (and most system processes) are given a
prioritise foreground applications, as well as common priority of 20, important system processes have a
desktop processes such as Gnome Shell and Kwin. priority of 0, and really important ones have even lower.
Garuda Linux is making a lot of headlines lately. The If two processes competing for CPU time both have the
slick, eye-candy heavy, Arch-based distro includes a same priority, then the process with the lowest niceness
couple of daemons that ought to improve takes precedence. The Pulseaudio daemon, for example,
by default runs as a user process with a nice level of -11,

PROCESSES PLAYING NICE


so that other user processes don’t make for choppy
audio output.

“If two processes competing


One of the earliest and most popular patchsets
for the kernel is Con Kolivas’ “CK” effort. Starting out

for CPU time both have the same


as a set of tweaks to improve desktop performance,
it evolved to include a series of new CPU schedulers,

priority, then the process with the


culminating in BFS (the middle letter of which stands for
something rude) in 2009. Kolivas has in the past voiced

lowest niceness takes precedence.”


concerns about kernel developers’ lack of interest in the
desktop. But with BFS (and much of his scheduler work)
the intention was never to get it mainlined. It’s not
responsiveness. First there’s Ananicy (ANother Auto general purpose enough for the kernel, and the kernel
NICe daemon), which automatically renices (gives has only one scheduler anyway (the Completely Fair
greater affinity) processes. The idea here (as with any Scheduler, CFS). BFS has since been retired in favour of
scheduling tweak) isn’t to magically give you more MuQSS (Multiple Queue Skiplist Scheduler), which was
speed. Rather, it’s concerned with tweaking priorities so introduced in 2016.
that heavy tasks (like compilation or indexing) don’t If you want to try out MuQSS, you can grab the
interfere with things happening in the foreground. patches directly and apply them to a vanilla source tree
Get Garuda’s Nicing is a feature of the Linux kernel itself, and you (see https://github.com/ckolivas/linux for instructions).
kernel goodness
without the icon
can set program ‘niceness’ manually using the renice Alternatively, MuQSS has been included in various
garishness, with command. However, this needs to be set every time a custom kernels, namely Liquorix (https://liquorix.net)
Linux-TKG process is spawned, so the advantage of Ananicy (and and Linux-TKG. The latter includes a choice of several
schedulers, as well as some patches from Intel’s
performance-focused Clear Linux. Linux-TKG also
enables you to compile the whole kernel with CPU-
native optimisations. You might have noticed the vanilla
kernel has some CPU options (under the Processor
Type and Features) but these only target a particular
family, rather than a given microarchitecture such as
Zen 2 for modern Ryzen processors.
Linux-TKG (see https://github.com/Frogging-Family/
linux-tkg) is included in Garuda Linux, but you can try it
out on any Arch-based distro, or any distro with Arch’s
Pacman package manager installed. In theory it’ll work
anywhere, but this isn’t officially sanctioned. Let’s try
it. You’ll need to install Git and then fetch the sources:
$ sudo apt install git
$ git clone https://github.com/Frogging-Family/linux-
tkg.git
$ cd linux-tkg

38 LXF287 April 2022 www.linuxformat.com


Build the kernel

If you choose Clang (see box, below), you can choose


to enable Link Time Optimisations, but this will use a lot
of memory and take a long time.

Researching Clang
Using Clang requires (at least) the clang, llvm and lld
packages to be installed. And if you’re on Ubuntu 20.04
you’ll have to work around the older (version 10 series)
in the repos. DuckDuckGo is your friend here...
You’ll be asked several more questions, and some of
them have defaults which you should probably stick to
at first. Kernel Timer frequency has been the subject of
some debate over the years, and TKG’s default of
500Hz seems to fit sensibly in the middle of the
Any excuse to feature a Pop!_OS background. They also make bespoke generic kernel default of 250Hz, and the 1,000Hz
scheduler tweaks now setting currently used by some low-latency kernels.
Finally you’ll be asked if you want to run nconfig (or
There’s a helpful installation script which we’ll run in any of the other kernel configuration interfaces) for
a moment, but do read the documentation before doing any final tweaks.
so. There’s also a config file customization.cfg that can Once again now is a good time to make a cup of tea,
influence the script’s behaviour. Like make-kpkg the as kernel sources have to be cloned, patched and
script will build DEB (or RPM if you’re using Fedora) configured. Any kernels generated this way must be
packages which can be installed like any other software. removed manually, but the script can help with that. In
See how you get on with: general, any custom kernel you build as a DEB package
$ ./install.sh install should be easy to remove, but always keep an eye on
You’ll be asked which distro you’re using (there’s a your /boot directory for ancient artefacts. We’d dearly
generic option, but in general if you choose something love to cover more kernel patches, in particular Xanmod,
close to your distro it should work). Next you’ll be asked but it looks like we’ll have to leave these explorations to
which kernel version you want to install. They’re listed you. Do let us know how you get on!
newest first, from the bleeding edge-RCs to the strong
and stable 5.4 series. We figured we’d go for a 5.16
version, because that seemed newer and shinier than
what we were currently running. You’ll then be offered a
choice of CPU scheduler (we chose Project C/BMQ)
and given a choice of compiler.

Tools of the Linux trade


When Linux was announced in 1991 Linus noted that he
had ported GNU Bash and GCC to work with it. He also
noted these tools weren’t part of Linux proper, so as
‘distributions’ started bundling GNU tools with the Linux
Kernel, the GNU/Linux conjunction was born. Today’s
distributions still bundle lots of GNU tools (bash, emacs,
gcc), but also lots of other non-GNU tools. Those other
tools don’t ask to be included in the Linux titlage, and if
they did we would probably mock them. If you use Ubuntu 20.04 you’ll have to do some Apt magick to make Clang 3.5 work.

THE CLANG-ERS
Some distros, such as Alpine and language in which most of the kernel is available. Furthermore, a binary
Android, include very few GNU written) and the GNU C extensions. compiled with Clang can be investigated
components (for example, muslibc and There are technical reasons for using with advanced static and dynamic
Bionic are used, respectively, instead of Clang as opposed to GCC. First, it makes analysis tools from the LLVM suite.
the GNU C library). Most distros still use compilation for different platforms easy. These can help find bugs. And yes, using
GCC to compile their kernels, but for A binary compiled with Clang (in what’s Clang to compile the kernel can result in
many years now it’s been possible to use called the LLVM Intermediate a performance increase. As well as this,
the LLVM/Clang compiler instead. Representation) can target, after being since Linux 5.12 (February 2021) the
Android and ChromeOS do this, and processed by the appropriate LLVM kernel has supported LTO (link-time
so does OpenMandriva. LLVM (the Low backend, multiple architectures. optimisations) with Clang. This exercise
Level Virtual Machine) is a toolchain Currently, building the kernel is only enables the kernel to be optimised as a
based around C++ objects, and Clang is supported for ARM and x86 targets, but whole, instead of in the context of
a frontend to LLVM that supports C (the others (MIPS, RISC-V, PowerPC) are individual source files.

www.techradar.com/pro/linux April 2022 LXF287 39


Pi USER
PJ Evans
cut his teeth on The maker’s Coolest
Projects goes Global!
home computing in
the 80s, and is now
technical director
at The Very Good
Email Company.

PHYSICAL The once US-centric event is opening its doors to


COMPUTING makers from around the world. Yes, that means you!
My name is PJ Evans of House ow named Coolest Projects Global, all to see, to offer inspiration, to get
Sinclair. Well, that was me in the
1980s when I fought against
N this is your chance to have your
maker project revealed to the world
mentoring, to generate excitement and
perhaps to get some merch and prizes!
pretenders to the eight-bit throne this year – and it doesn’t even have to be The event is open to anyone up to 18 years
such as House Commodore or finished to be eligible for entry! The aim of old, working either independently or in groups
those sneaky Welsh Dragons. Coolest Projects is for young people to have of up to five people. The final event in early
Although we may have had our their amazing array of projects showcased for June will be a live online celebration that
differences on colour-clash everyone can join in with. Registration for the
versus brown soupy displays, one event is open until 11 May.
thing we could all agree on was Projects can be registered in the following
that the BBC Micro belonged in categories: Scratch, games, web, mobile apps,
the classroom, despite the fact hardware and advanced programming. Judges
we seethed with jealousy at Elite. will evaluate projects based on their coolness,
However, I was won around by complexity, design, usability and presentation.
the Beeb’s User Port: a simple To find out more and get involved, visit
way of talking with the outside https://online.coolestprojects.org.
world. With the help of my design
technology teacher, my GCSE
project hooked up a BBC to a
brace of relays that could switch Got an idea for a project?
mains electricity. I was amazed Get involved now!
and inspired, showing my blinking CREDIT: Raspberry Pi Foundation
table lamp to anyone who came

Network install 64-bit… finally


by the computer lab.
Sadly, the concept of the user
port disappeared in the 1990s
and I missed its possibilities. The
Arduino came in the 2000s and It’s in beta testing. But 32-bit is still default.
sparked some memories of my
‘80s experiments, but the arrival aspberry Pi has released a new beta riginally released as a beta back in
of the first Raspberry Pi put me
right back in my happy place.
R bootloader for Raspberry Pi 4 and
400 devices that enables a very
O May 2020, Raspberry Pi OS 64-bit
looks and feels the same as the
Suddenly that world was open interesting new feature: OS installation over a venerable 32-bit version, which has remained
again, with physical computing network. And Raspberry Pi is looking for help the default for stability reasons. Discover
projects beyond my imagination testing it out. Network installation essentially more here: www.raspberrypi.com/news/
(and very often capabilities) could runs the Imager in the board’s memory. This raspberry-pi-os-64-bit. Will you be taking the
now be shown and explained means you can download and flash a new OS plunge into 64-bit computing on your Pi?
through the power of the internet. using an Ethernet internet connection. More
Back in the late ‘80s I wrote at www.raspberrypi.com/news/network-
for Crash, the ZX Spectrum install-beta-test-your-help-required.
magazine. The resurgence in
‘small form’ affordable computing
has awakened that passion too
and now I write for The MagPi,
hopefully inspiring others to try
things out and see the computer
and not just a screen and
keyboard, but as part of the
physical world.
Network install in action! Damn you 32-bits!
CREDIT: Raspberry Pi Foundation

40 LXF287 April 2022 www.linuxformat.com


Raspberry Pi case REVIEWS

FLIRC Pi Zero Case


Les Pounder keeps his cool with a case for his beloved
Raspberry Pi Zero 2 W. Will it beat the heat of a benchmark?
ou might be wondering why anyone would need
IN BRIEF
With the sleek
Y a case for a Raspberry Pi Zero. It’s a fair point:
the Raspberry Pi was designed to operate in the
good looks open – something that co-creator Pete Lomas has said at
of an Apple numerous events. However, cases protect the Pi and in
device, FLIRC’s the case of FLIRC’s £13 Raspberry Pi Zero case it also
Raspberry Pi keeps the Pi cool, too. This isn’t FLIRC’s first Raspberry Pi
Zero case has case. FLIRC’s Raspberry Pi 4 case is £16 and has the
the cooling same aesthetic and thermal properties, but the Pi Zero
power to version has sacrificed easy access to the GPIO in favour of
keep even maximum cooling.
an overclocked Originally designed for the first Raspberry Pi Zero, but
Raspberry Pi also compatible with the Raspberry Pi Zero 2 W, FLIRC’s
Zero 2 W cool. It aluminium case has a central core that extends down to
also looks great the System on Chip (SoC) containing the CPU, GPU and Removing the bottom cover enables you to drop the Pi Zero into place
on our keychain RAM. The supplied thermal pad creates a bridge between and then secure the Pi to the cooling core with four screws.
and desk. GPIO the SoC and the core, turning the entire case into one
access is good, large heatsink. Using the case as a heatsink seems to be stressberry. For a baseline we ran stressberry on a
and your micro the done thing, with multiple cases from Akasa and Raspberry Pi Zero 2 W with no case. We saw an idle
SD card is CoolerMaster offering similar passive-cooling solutions. temperature of 34.3°C and under stress the temperature
well hidden peaked at 60.1°C. Placing the Pi Zero in FLIRC’s case,
inside the Put a lid on it we saw 29.5°C at idle and under stress we hit a high of
aluminium case. The case comes with two plastic “lids” that either cover 42.9°C – a difference of 17.2°C. These were good cooling
or enable use of the 40-pin GPIO. Each lid clips on with results and makes FLIRC’s case a strong contender for
four retaining points on the case (gently pry it off with a passively cooled overclocking.
plastic or wood tool to prevent scratches). GPIO access FLIRC’s Raspberry Pi Zero case is almost perfect. It
is decent. We can connect pHATs/HATs, but there’s no has great cooling, GPIO access and all of the ports that we
access to the M2.5 mounting holes so you may have need. Granted, we lose access to the micro SD card but
floppy HATs. You’ll also need to ensure that your pHAT/ really, how often do we swap cards? The included lanyard
HAT doesn’t touch the aluminium case. There are ports may seem trivial, but with the FLIRC case we have a sleek,
for mini HDMI, USB (power and data) and for the and relatively power keychain sized computer that, when
camera, but the micro SD card is trapped inside the used as a USB gadget (direct connection via USB), gives
case. It’s not ideal, but if the card were to stick out then us a Linux computer everywhere we go. The Raspberry Pi
it could easily become lost or damaged. Zero 2 W has the horsepower to be a decent media device
Installing the Pi Zero is simple. Place the thermal pad when used with OSMC for example, and FLIRC is well
on the core, drop the Pi so the pad touches the SoC and known in the Pi community.
then screw in the bottom plastic plate to squeeze the SoC The lack of a micro SD card slot is the only negative we
to the core. To test the thermal properties of the case we can see. We’d like to have ready access, but because this
stress-tested the CPU using the Python-based is destined for our pocket, we fear losing (another) micro
SD card to the washing machine.

VERDICT
DEVELOPER: FLIRC
WEB: https://flirc.tv
PRICE: £13

FEATURES 9/10 EASE OF USE 9/10


PERFORMANCE 9/10 VALUE 9/10
Brushed
aluminium and Great looks, good cooling and access to the GPIO mean that
matte black give FLIRC’s Raspberry Pi Zero case is ideal for all models of Zero.
the case an almost
“Apple” aesthetic,
but this is all Rating 9/10
Raspberry!

www.techradar.com/pro/linux April 2022 LXF287 41


TUTORIALS Build a news ticker

MICRO DOT

Assemble a Micro
Dot pHAT news ticker
Les Pounder builds his own homage to the famous Times Square
news ticker, this time scaled for ants!

ately there’s been a lot of news – some good,

L most of it bad. And to keep up with the


constant series of events and developments
from around the world we constantly check our
devices… but what if a Raspberry Pi could give you the
OUR news headlines every five minutes? This project uses
Pimoroni’s Micro Dot pHAT to scroll the news across the
EXPERT vibrant red displays, keeping you up to date.
Les Pounder Micro Dot pHAT comes as a kit, which means that we
is associate need to solder each of the displays to the pHAT board.
editor at Tom’s Please follow Pimoroni’s instructions before moving on.
Hardware and a The board fits on to the Raspberry Pi using the GPIO,
freelance maker and it should fit to match the outline of the Raspberry Pi Get the latest news direct to your Raspberry Pi using a little Python
for hire. He Zero. When attached, connect your accessories and and Cron magic.
blogs about his power on to the desktop.
adventures and We next import a series of Python libraries. The first
projects at bigl.es. Writing the project code is feedparser, which will read news feed. Next is time,
Open a terminal and run Pimoroni’s installer for the which is used to add a pause to the code. Finally, we
Micro Dot pHAT. Follow the installer’s instructions and import the library for Micro Dot pHAT:
install the example files: import feedparser
$ curl https://get.pimoroni.com/microdotphat | bash import time
Next, using the Python 3 package manager pip, import microdotphat
install the feedparser library: This section of code will generate a flashing NEWS
$ sudo pip3 install feedparser banner. It’ll turn all the LEDs on, then off, then show
Once done, open Thonny, which is found under NEWS, before turning off again. This happens five times,
Programming in the main menu. and so we use a for loop:
We start the Python code by first telling our code for i in range(5):

YOU NEED where to find the Python interpreter. We’ll need this later
when we make the file executable.
We turn on all the LED displays and then pause for
0.1 seconds:
Any Pi #!/usr/bin/env python3 microdotphat.fill(1)
Raspberry microdotphat.show()
Pi OS time.sleep(0.1)
Pimoroni We then clear the LED displays and pause for
Micro Dot another 0.1 seconds:
pHAT microdotphat.clear()
Get the microdotphat.show()
code: time.sleep(0.1)
https:// This code will write NEWS to the display. Note that
github.com/ kerning must be false, otherwise the text will be garbled.
lesp/LXF- microdotphat.write_string('NEWS’, kerning=False)
Micro-Dot- microdotphat.show()
News/ time.sleep(0.1)
archive/ Lastly for the loop we clear the displays:
refs/heads/ Crontab guru is a website that simplifies cron schedule expressions. If microdotphat.clear()
main.zip you’re already a cron guru or an aspiring admin, this is the tool for you. microdotphat.show()

42 LXF287 April 2022 www.linuxformat.com


Build a news ticker TUTORIALS

time.sleep(0.1)
We now move to the main section of code and we
start by specifying the URL of the newsfeed. In this case
it’s the BBC news feed. You’re free to use any other feed,
just make sure that it’s an RSS or XML feed.
newsfeed = feedparser.parse("http://feeds.bbci.co.uk/
news/rss.xml")
Create a list called headlines . We’ll use the list to
store the top five headlines.
headlines = []
To populate the list with headlines we use another for
loop that iterates five times. Each time the loop iterates
it appends (adds) another headline, using the value of
i (an integer between 0 and 4) to obtain the next
headline. Another append is used to add a space (eight
blank characters) between the headlines. This is a hack
to add spaces between headlines as they scroll across. Micro Dot pHAT runs on all models of Raspberry Pi that use the latest Bullseye operating system.
for i in range(5):
headlines.append(newsfeed['entries'][i]['title']) Next we open a terminal, set newsfeed.py to be an
headlines.append(” “) executable file and then copy it to the /usr/bin directory
The next line is a debug step that prints the contents as newsfeed. By doing this we can call the command
of the headlines list to the shell. This enables us to see from anywhere in the filesystem.
Soldering Micro
any problems. $ chmod +x newsfeed.py
Dot pHAT’s
print(headlines) $ sudo cp newsfeed.py /usr/bin/newsfeed six displays
Convert the list of headlines into one long, string. We Run the command to test that it works, and when is a joyous
use join to link all of the list items together. you’re satisfied press Ctrl+C to exit, or just wait for it experience,
news = ' '.join([str(item) for item in headlines]) to end. but take care
These two lines are a hack because one of the $ newsfeed because the
underlying libraries for Micro Dot pHAT has a problem Our last step is to set the command to run every five screens are
with unusual characters. We noticed that ‘%’ and ‘-’ minutes. For this we’ll use a cron job, so we need to edit made of plastic
caused errors, so we replaced them accordingly. We’ve crontab. Open a terminal and type the following. If asked and can be
damaged with
raised an issue on Github and hopefully this’ll be fixed. to choose an editor, choose nano:
a hot soldering
news.replace('-’,' ‘) $ sudo crontab -e
iron. Take your
news.replace('%’,‘pc') Scroll to the bottom and add the following line: time and you’ll
Another debug step prints out the long string stored */5 * * * * newsfeed soon have a
in news . We don’t need this, but it may prove useful to Press Ctrl+X, then Y and Enter to save and exit. retro display!
debug any unusual character issues. Reboot the Raspberry Pi and now every five minutes
print(news) the latest news arrives on your desktop!
We need to know how many characters there are in
the string, so we get the length of the string and store it
in a variable. GETTING MORE FROM CRON
characters = (len(news))
We write the string to Micro Dot pHAT’s buffer, ready Let’s be honest, we don’t use Cron very much. This means that we
for display. almost always forget the syntax, and so a tool such as Cronitor’s
microdotphat.write_string(news, offset_x=0, crontab.guru is very useful. The website explains what each value
kerning=False) relates to and how we can create cron schedule expressions for every
Using the value stored in characters, we add 16 extra scenario. Want a script to run at 00:05 everyday in August? Here you
characters to the value, then multiply the value by 8. go: “5 0 * 8 *” . Need a script to run every hour, use @hourly (non-
This is a hack, based on our results, but it appears to standard, but it works).
loop cleanly. We edited Cron using crontab, specifically calling the -e argument
for i in range((characters+16)*8): to edit the file. But we can also use -l to list the user’s crontab to
Inside the for loop we use the scroll function to scroll standard output, or we can use -r to remove. We can edit the crontab
the contents of the buffer, then use show to see the with our own choice of editor. Use the one that works for you!
scrolling text. A pause of 0.01 seconds creates a Crontab is often overlooked, but it’s remarkably useful. When used
smooth scroll. For a slower scroll set it to a higher value, with a Raspberry Pi we can automate many tasks. Want a robot to
such as 0.02. connect to Wi-Fi and Bluetooth on boot? Then crontab is for you. But
microdotphat.scroll() what if you need a program to launch on the Raspberry Pi desktop?
microdotphat.show() Well, for that we need to use a desktop application shortcut. There’s
time.sleep(0.01) an in-depth guide on Tom’s Hardware (www.tomshardware.com/uk/
Save the code as newsfeed.py, then run to check it. how-to/run-script-at-boot-raspberry-pi who?–ED), which shows
You should see the news flash happen five times, then how to start and kill a script on your Raspberry Pi.
the news stories will scroll across the Micro Dot pHAT.

GET YOUR Pi FILLING HERE Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 43
TUTORIALS Share your media

CASTING

Create your own


Chromecast device
Mats Tage Axelsson takes you on a tour of the Linux tools that will
enable you to stream media between your laptop and other devices.

e all spend an inordinate amount of time

W consuming video and music. Many of these


services are streamed via browsers, but that’s
not always the best way to enjoy it. Another key issue:
where to display it? Sure, you can watch videos on your
OUR laptop – and let’s face it, you probably do – but how
often do you just hop over to the sofa to continue
EXPERT enjoying a classic album or the latest must-watch TV
Mats Tage series (I’m literally catching up with Buffy – Ed)?
Axelsson With the correct setup, you can make this happen.
would love to You can also store your own media on a server and
broadcast about stream it to your TV or other devices. This is where
all things Linux casting methods and media servers come in, but
24/7 .We’re sure currently the world is a confusing collection of GNOME Software Displays starts by requesting your shared screen and
that it would be Google Chromecast, Amazon Fire sticks, Apple then identifies “sinks” aka suitable connections.
must-watch TV. whatchamacallits and a host of other device-based
screen-sharing systems. So let’s delve into the protocols watch – typically this is a show of some kind. It’s what
and see how it all works. YouTubers do when they’re broadcasting live. Casting
To do this, you’ll need refers to the end user: how you can make your incoming
to set up your software. stream go to a specific device (aka a sink). There are
For the simplest cases, different protocols involved with both these activities.
everything is available by Usually, you don’t need to worry about which
default from your distro, protocols are used until you have to choose them for
but better alternatives your server. Still, if you know and run Linux then, as ever,
keep appearing. You may you have choices. You may be able to improve the
also be able to tweak quality of your media, or use a package that’s already
things to your preferences, on your computer.
especially when you’re Some of the protocols you hear about will involve
creating your own content. specific needs. For example, the RTSP protocol
In this article, we’ll present supports video directly from cameras. You can use this
you with our suggestions protocol for video casting over Wi-Fi. Other protocols
for your own journey to that you need to consider are the ones that stream to
media mastery. different sites such as Youtube (RTMPS) or Facebook
(WebRTC). Note that you may use one protocol to send
Stream or cast? your media files as opposed to watching.
Let’s start by explaining You can also use the RTSP protocol for a first-person
the two main concepts: viewer drone. The big problem with RTSP is limited
streaming and casting. To browser support. Having said this, there’s a gstreamer1
stream media, you send plugin in the apt repositories and a Perl server. The main
your media from server, though, is the crmtpserver. It’s a compact and
somewhere for others to efficient way to connect to video-conferencing,
surveillance cameras and your smartphone.
Once you’ve selected a suitable
Apple introduced HLS or HTTP Live Streaming in
‘sink’, you have a corner marker
indicating that you’re sharing 2009 to replace Flash from its phones. It’s become
the screen with other devices. extremely popular – so much so that it’s the default for

44 LXF287 April 2022 www.linuxformat.com


Share your media TUTORIALS

HTML5 video players. Which means you’re using it every Lots of casting software is available, and
time you watch videos on YouTube. Creating (ingesting) one example is LetsView. This application
searches for “sinks” (targets) that support
video content is a bit more problematic because
MiraCast, which tend to be TVs.
encoders are either rare or expensive. However, there
are players available to do this, such as the one at
https://nageru.sesse.net. This project is still in alpha. to share, and then you can view it
Fortunately, you can create video with other protocols. on other machines.
If you’re especially interested in streaming to If you need another option, you
YouTube, you can find both API-samples on GitHub can also compile the code of the
(https://github.com/youtube/api-samples), and OBS MiracleCast project (https://
supports it natively. github.com/albfan/miraclecast).
This is a separate project that’s
One cast to rule them all still working on the Miracast
One of the earliest projects to make streaming over standard to make it Linux
Wi-Fi simple and direct between devices was Miracast. compatible. If you want to try it
The effort led to the Miracast standard. It’s still in use, out, you can download the code
although Android has dropped official support. Despite and compile it yourself.
this, you can use your Android device to stream videos The package has very few
to your smart TV and other devices. Android dependencies and so should
applications that do this are AirDroid, LetsView and compile on all modern systems.
AllCast. Many manufacturers also have added support You can even choose from three
to their software and devices. build systems: Autotools, CMake
The reason Google and Apple dropped support was and Meson. Here’s the short
that they developed their own in-house solution. Efforts version using CMake. Before you
to improve the Miracast standard are still ongoing – this start compiling, make sure you
is why it’s still in use. Many display manufacturers that have the required packages installed.
are also on the market support the standard. $ sudo apt install cmake libglib2.0-dev libudev-dev
On Linux, you can use GNOME Network Displays, libsystemd-dev libreadline-dev check libtool If you try to
which works on other desktop environments despite its Download the MiracleCast package using git (save it download a
name. The software enables you to choose which screen in any directory). library for your
$ git clone git@github.com:albfan/miraclecast.git project and
Git creates the miraclecast directory – move into it apt-get fails
and start the procedure. due to wrong
dependencies,
$ cd miraclecast
you can use the
Create a new build directory for CMake to work from
deb file. The
and move into it. dpkg command
$ $ mkdir build may permit the
$ cd build install, though
Set the environment variable that places MiracleCast you must repair
in the correct places for your system. your system
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. with apt-get
Compile the object files: --fix-broken
$ make install after
you’ve run
To configure your Raspberry Pi to enable the SSH server, use the Install the finished binaries:
‘Interface Option’ in the raspi-config tool. the compile.
$ make install # May require `sudo`: `sudo make install`

JUST SHARING YOUR TERMINAL?


If you’re only showing commands on and for re-running a sequence. There The output of your session is saved
your terminal, using OBS (Open isn’t an extensive list of features for the as a YAML file that you can edit, although
Broadcaster Software) may be overkill. In program, but both playing and recording it takes some skill to do that. On top of
this case, you can use a command line- facilities are available. the file you have the settings containing
only solution. There are several that can As many other help programs like this, font terminal width and importantly a
do it. A competent one is Terminalizer, you can publish directly to their web watermark option. The watermark option
which is written in JavaScript. page. However, you’re not forced to use leaves your logo on the animated Gif,
With Terminalizer you can show all your their web page because there’s already a giving you a chance to promote yourself
actions on a terminal and upload them to built-in Gif generator. A web generator while helping other people learn Linux.
the web. The program is useful both as a that creates a complete player for your You can find Terminalizer at https://
way to show your terminal commands web page is also in the works. terminalizer.com.

STREAM US TO YOUR DOORSTEP Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 45
TUTORIALS Share your media

You can combine these commands with && , but


since only make install requires sudo it’s better to split
Installing them up. Tracking down errors is also easier if you take
compile tools things one step at a time. If everything goes well then
can be a hassle. you now have MiracleCast installed on your system. To
Learn about use it, you have a few more steps to follow. The best way
how you can to continue is to use the utilities in the res/ directory in
use Docker or the source tree.
NixOS to create
$ cd res
a compile
To make this work, you must stop ordinary Wi-Fi –
environment
that doesn’t the shell tool kill-wpa.sh will do this for you. When you’ve
mess up your finished, use the normal-wifi.sh script to restore your
main machine. Wi-Fi connection. Note that this is for experimenting
Cmake exist with MiracleCast. It runs via the command line and you
as a Docker need to be skilled and patient with the options.
image here:
https://github. The Pi cast
com/docker/ To send your media from your mobile to a Raspberry Pi,
buildx#binary-
you just need to install a few more libraries on top of AirDroid Cast requires a PIN to get started. You verify this on your
release. MiraCast-enabled TV. It’s ‘Interface Option’ in the raspi-config tool.
your standard distro. Because it’s Raspberry Pi, Raspian
is the most common so this is the reference. To get
started with an already running Pi, you make sure you your Raspberry Pi. Next, you’ll need more libraries to
have an updated system. compile your image and video viewers. You can pick the
$ sudo apt-get update code up from GitHub. Create a temporary directory for
$ sudo apt-get upgrade the code and cd into it.
To both be able to run the RaspiCast tool and manage $ mkdir viewers && cd viewers
your system remotely, start SSH. You can enable SSH $ git clone https://github.com/HaarigerHarald/omxiv
using the raspi-config tool or using the command line. You’ll be in this directory later in the process to
Check the current state of ssh before you do anything. compile your viewers but first, you can find the libraries
$ systemctl status ssh you need in the README.md file. They may change by
To make ssh start at each new reboot, enable ssh. the time you start your project, but below are the
$ sudo systemctl enable ssh current ones.
The command doesn’t start an inactive service. It $ sudo apt-get install libjpeg8-dev libpng12-dev
creates links that start the system during boot. To start Your git command created a directory, so move into
ssh in the current session, use the start command. it and start the compile. This is not a very big or
$ sudo systemctl start ssh complex compile, but look out for faults.
You have the option to either start, enable or both. $ cd omxiv
Designers wrote For this to keep working, though, you must enable The first make command creates all object files.
RaspiCast to and start the service. Using the raspi-config tool is $ make ilclient
interface directly another way of doing it. The tool will start and enable The second command creates the binaries.
with a Raspberry the service. $ make
Pi, although you
$ sudo raspi-config The third moves the binaries on your system.
can add many
more functions When the tool is running, go to Interface Options, find $ sudo make install
to your Pi. SSH and select Yes. Now you’re set to go with SSH on Thanks to the split of the parts of the compiler, you
can compile on a different computer than the one
you’re going to run it on. This is called cross-compiling,
if the machines have a different architecture. Keep this
in mind if you want to compile more complex code for
your tiny Raspberry Pi.
There’s one more package to install: omxplayer. It’s a
command line player for media, and your remote will
call it to run the media.
$ sudo apt install omxplayer
Now you have everything you need to run media on
your Pi. Next is to make it possible to access it from a
remote system. Before you can continue, you need to
know how to access your Pi. The hostname command
will give you the name to use. Check your hostname.
$ hostname
Looking up the hostname sometimes causes
problems because it needs to be fully qualified. This
means that it contains the top-level domain (.com). So,
just in case, print the IP address.
$ ip a

46 LXF287 April 2022 www.linuxformat.com


Share your media TUTORIALS

The printout will have the localhost address and the


other one that you want in the printout. Now make sure
that you’ve set the password to something more secure
than the default, using raspi-conf or the passwd
command. To use this, you need an app running on your
mobile phone: RaspiCast.
Install RaspiCast on your Android phone. Yes, the
RaspiCast is actually the client calling the Pi. It serves
the media and displays it on the screen connected to
the Pi. Once you have it running, start it and fill in the
form for casting. It’s simply the hostname, username
and password that you’ve set yourself. After you’ve
logged in, you can pick the files you want to play or send
your YouTube session to the Raspberry Pi.
For many video streams, Nageru is a project to combine the video streams into a complete
Home automation broadcast. Note that it’s still in the alpha stage of development.
Most of the standards mentioned in this article are
specifically for media of different kinds. However, a new contribute in your own way. For streaming your own
market has emerged: home automation. Being able to media, there’s a vast array of hardware that make things
connect to household devices such as your lights, easy for you. For more complex projects you’ll have to Look for OBS
heating system and even your fridge using W-Fi has use alpha software to make it work. plug-ins for the
become the norm. When you produce your own show, you will have a specific stream
Sensing new business opportunities, Apple and great partner in OBS Studio. Other solutions exist, so you’re planning.
Google have gone their own way, creating two think twice about what you want to stream before you Many other
proprietary standards. This prompted Amazon to create choose your solution. You could end up putting too content creators
its own standard, knowing that it couldn’t compete with much effort into a very simple task. Sharing the have come
with neat little
the big two. Amazon created Matter as an Open source command line is much easier and lighter than making
tricks to make
project and an open standard. The standard will connect all video and transitions available. Look around before life easier and
all media, entertainment and Internet of Things. you decide which way you want to go. shared them
This project started as project CHIP (Connected At first glance, streaming is all about entertaining for you to use
Home over IP), but has now been renamed Matter. The videos and helping others over the web, but when you and enjoy.
story is long and involves many diverse efforts. The look closer there are more functions to consider. Initially
Zigbee alliance is part of the current group Matter, while it was all about streaming over Wi-Fi without an access
the well-known Zwave is left out. The organisation point, but now more use cases have come to light. Using
handling this is the Connectivity Standards Alliance the same standards in automating your home and
(https://csa-iot.org). Its mission is to join all standards controlling your power consumption and generation is
together, making it easy to integrate many brands in the next step.
your smart home.
Until now, if you wanted to set a home automation
system then you’d need to create an account with a HOME ASSISTANT
cloud company. You would end up having all your house
commands go over the internet, which isn’t ideal. New For the past decade or so, many suppliers of automation hardware
competitors are coming on the market though, which and software have entered the market. This has led to several
can help you get started without constantly relying on standards that you can use to communicate with your devices. The
an external supplier. most common are Zigbee and Zwave.
Zigbee and ZWave aren’t compatible, so you must support both or
Future casts only have half the gadgets in your home automation setup. With a
There are many angles to the streaming world that can solution that can support both out of the box, Home Assistant (see
keep you occupied, whether you’re consuming or p64, serendipity!–ED) can help you with your home automation
producing content – or both! Make sure you balance project. They build and sell a small box that contains a Raspberry Pi
your activities. This way you challenge yourself and Compute Module, and radio hardware to connect to other devices.
Setting up such a system is slightly more complicated than a
regular system, but there is a large number of pre-prepared examples
on their web site and GitHub. The snippets are known as Blueprints
and they define what will trigger a new event and what should happen
after that. You may have a light that you want to turn on when the
motion sensor in a room is triggered. The rules for which device
triggers what action are in the Blueprints that you either need to write
or just tweak from existing ones.
With this system, you can keep all your data and logic inside your
home. This is something that’s uncommon among other products
If you want a media server, there are already pre-built systems that you can find on the market.
you can burn to an SD card directly.

www.techradar.com/pro/linux April 2022 LXF287 47


IN-DEPTH Linux From Scratch

LINUX
FROM
SCRATCH
Part Two
Did you miss
part one? Get
hold of it on
page 62

Like to get your hands dirty?


Aaron Peters is your man, as
we get deep into building Linux.

id you read “Linux From High bravery

D Scratch” in the title of this


article and didn’t run away
screaming into the night?
levels in the face of
compilation errors.
An i386- or x86_64-based PC
Then you were either intrigued by the with a modern(ish) distribution installed. command should get you
premise presented in the last issue of Hard disk space to spare. Or even better, everything you need (note a fair
Linux Format, or are a very special Linux a blank partition. Even better still, a spare number of these will already be present,
fan indeed. But as the title says, we’re hard drive. but it doesn’t hurt to include them):
going to get right to it in this follow-up A copy of https://linuxfromscratch.org/ $ sudo apt install bash binutils bison bzip2
article. So get ready for the nuts, bolts, and lfs/downloads/stable. coreutils diffutils findutils gawk gcc grep
other assorted components of Linux From This article will follow along with, and gzip m4 make patch perl python3 sed tar
Scratch. In the sake of efficiency, you frequently reference, the Linux From texinfo xz-utils
should have the following prepared before Scratch (hereafter also LFS) book. Since Next, check that they’re all the right
diving into the following sections: the LFS book is an actual book, it can’t version. Section 2.2 of the LFS book
Lots of patience. reasonably be condensed to the size of an provides a convenient script that will check
A steady hand for copying and pasting article here. So while we’ll highlight some to see if all the required versions of
terminal commands. early parts of the LFS build process, when software are present, and confirm the
A love of reading (plain black text on you embark on this you should follow the ability to build source packages. Once you
white or grey backgrounds). book exactly. Its authors took great care in copy its contents into a text file and add
putting together some very fine execute permissions, you’ll find all you
instructions, so take advantage of them. need to make sure the system is ready
with the following command:
Preparing the host $ check-versions.sh
The first thing you’ll need to do when If the results of this command (see
preparing the /host/ system (in other screenshot, left) indicate all versions are
words, the existing Linux system on sufficient and the system is able to
which you’ll build LFS) is installing the compile a sample file successfully, your
prerequisite software. This consists host system is ready. It’s time to prepare
primarily of development tools such as the your target system.
GCC compiler, Make and Patch, as well as
the stalwart open source languages Perl Target system
Output of the check-versions.sh script showing that and Python. On a recent version of a The /target/ system in this context is
everything is working well on the host system. Debian-based system, the following simply a location in the filesystem where

48 LXF287 April 2022 www.linuxformat.com


Linux From Scratch IN-DEPTH

you’ll be compiling and installing the software packages.


You’ll then create a Linux-friendly directory structure,
add and edit some configuration files, and at the end
you’ll have a working LFS system. The first step is to
create this location, and you have a number of options:
If you have a spare, unused hard drive in your host
system, this is a great choice.
Alternately, you can create two (or more) new
partitions for it on your host system’s main/only drive.
Finally, you can use other methods such as image
files. In this article, we’re building LFS in a virtual $ sudo mkdir $LFS/sources Setting up the LFS
machine, and so we created a new virtual hard disk to $ sudo chmod a+wt $LFS/sources partition scheme
with the GNOME
house the LFS installation. This will make it easier to Let’s go and fetch the LFS source packages. You can
Disks tool.
create a new dedicated LFS virtual machine later and use either the https://linuxfromscratch.org/lfs/
attach this virtual disk to it. downloads/stable/wget-list to use as input to the wget
Once you’ve decided on the system’s destination, command, grab them all via FTP, or download the .TAR
you’ll need to create two partitions. One will be for boot- archive from one of www.linuxfromscratch.org/mirrors.
related files, for which 200MB will be a good size. The html#files on the LFS website. Once all the packages
second will be the main filesystem (see screenshot, are in hand, run a couple of checks from the directory
above right). Section 2.4 of the LFS book also gives some they reside: one to make sure all the files are there, and
guidance on whether to create a swap partition as well one to evaluate the md5sums:
as other “convenience” partitions (see box, below). If you $ check.sh
intend to use the LFS system as one of your $ md5sum -c md5sums
“production” systems, a swap partition may be a good Move them all to the $LFS/sources directory, and
idea. However if you’re just in this for the experience of we’re almost there. The last things are to fill out the
building the system it may be overkill. target system and set up its primary user. First, we’ll
With a filesystem in place, you’ll move on to create a basic root directory structure, including some
preparing it to house a LFS system. The first thing is to symbolic links. Make sure you run these as root. It’s also
create a shortcut for where your LFS system lives, important to check that the $LFS variable is set for your
specifically a shell variable. This will enable you to easily root user:
reference the location in future commands. You can mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin}
issue the following in a terminal to set it you can also for i in bin lib sbin; do
add it to the .bash_profile files for both your user and ln -sv usr/$i $LFS/$i
root to make sure it’s always set in the future: done
$ export LFS=/mnt/lfs case $(uname -m) in
You can, of course, set its location to wherever you x86_64) mkdir -pv $LFS/lib64 ;;
please. Then use your shiny new variable to create the esac
mount point on your host system, then mount the main mkdir -pv $LFS/tools
LFS partition there: When working with the LFS system, the book
$ sudo mkdir -p $LFS recommends setting up a dedicated user (called lfs) for
$ sudo mount -t ext4 /dev/sdb2 $LFS the task. We’ll create this group and user, assign a
Next, create a /sources/ directory in the LFS space, password, then adjust permissions for it:
which will hold all the working files such as source groupadd lfs
packages and build output. It should be set as “sticky” useradd -s /bin/bash -g lfs -m -k /dev/null lfs
so only the owner can delete files there, which the passwd lfs
following chmod command will do: chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}

ALTERNATE LFS FILESYSTEM LAYOUTS


While the simplest and most /opt: This is recommended if you’re /usr/src: Again related to BLFS, this
straightforward way to set up LFS is with planning on installing a large amount will provide you with room to store and
a single partition, the LFS book does of “ancillary” software, especially if re-use the source packages for that
detail some other partitions you may you’re interested in moving on to project across multiple LFS installations,
want to create and mount to the LFS Beyond Linux From Scratch – BLFS. if you want to torture yourself with this
system, as follows: See the boxout (overleaf). exercise more than once.
/boot: This partition should really be /usr: If you have the need to segregate The upside to setting up these
its own partition, as it is in most modern your binaries out from the rest of the additional partitions is you can share
Linux systems. system proper, then you can create them among multiple LFS installations.
/home: The book recommends this in a different partition for this, which is However, you’ll need to keep them in
its own partition, in order to share it with where most of the LFS packages will mind then when getting those
other installations. end up. installations ready to boot up.

www.techradar.com/pro/linux April 2022 LXF287 49


IN-DEPTH Linux From Scratch

case $(uname -m) in rest of this article also entails. However, we’re at the
x86_64) chown -v lfs $LFS/lib64 ;; point now where we’ll actually start building something.
esac
chown -v lfs $LFS/sources It’s tool time
Finally, log in as the new lfs user, create some We’ll now start building the software that will enable us
settings (the .bash_profile and .bashrc files, specifically) to build the software. LFS requires that you compile
for your upcoming terminal work (section 4.4 of the LFS some of the underlying tools that will make it possible to
book explains these in detail), and add those settings to build the LFS packages on the target system. If it
the current session: sounds confusing, consider that one of the packages is
su - lfs GCC. How could you build GCC from within LFS when a
cat > ~/.bash_profile << “EOF” compiler (GCC) isn’t installed yet? It’s a little meta, but
exec env -i HOME=$HOME TERM=$TERM the gist is we’re using the host system to compile the
PS1='\u:\w\$ ' /bin/bash tools that will let LFS stand on its own.
EOF As with the entirety of the LFS process, it’s important
cat > ~/.bashrc << “EOF” to follow the book closely and take things one step at a
set +h time. So start with the instructions for building Binutils
umask 022 (see section 5.2 of the book). Unpack the source
LFS=/mnt/lfs archive, then create a build directory and switch into it:
LC_ALL=POSIX tar xJvf binutils-2.37.tar.xz
LFS_TGT=$(uname -m)-lfs-linux-gnu cd binutils-2.37
PATH=/usr/bin mkdir -v build
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi cd build
PATH=$LFS/tools/bin:$PATH Building most packages follows the time-honoured
CONFIG_SITE=$LFS/usr/share/config.site Linux compilation commands of ./configure , make
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE and make install . In this case, the LFS book provides
EOF all the necessary config options, which you can study to
source .bash_profile understand in depth or simply paste into the terminal:
Are you tired of entering all these terminal ../configure --prefix=$LFS/tools \
commands yet? Hopefully not, because that’s what the --with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--disable-werror
make
make install -j1
You’ll see lots of terminal output scrolling by during
this – see this exciting stuff in the screenshot (left).
Note how it’s always prudent to keep the book open
side-by-side with your work, which should be no
surprise if you’ve built your own software before. But
provided the process ends and you don’t see anything
that looks like errors, switch over to the $LFS/tools
directory, where you should see some new entries.
Success! You’ve compiled your first LFS package!
The remainder of building the LFS toolchain is
following similar instructions to compile the following:
the GCC compiler, the Linux API headers, and the
The start of a Linux directory structure in the LFS system. development libraries GlibC/Libstdc++. You’ll then

BEYOND LINUX FROM SCRATCH


We mentioned in the prior introduction components and applications to your alfs) aims to automate the process of
that the result of LFS is still a rather LFS installation. Examples include building/assembling LFS installations.
simplistic system. It can carry out some security such as sudo support and CFS (Cross-Linux From Scratch): The
basic functions, and certainly the OpenSSH, editors like the almighty CLFS project (https://trac.clfs.org/)
presence of the ViM editor gives it some Emacs, servers such as Apache or targets better support for cross-
utility. But compared to the highly sendmail, and even GUI desktops like compiling LFS for other architectures,
graphical desktop and robust server GNOME or Xfce. With BLFS, you can such as ARM, PowerPC or Sparc CPUs.
Linux distributions, it’s still a bit create a highly customised and highly HLFS (Hardened Linux From Scratch):
underpowered. optimised everyday system. By installing packages from this project
That’s where Beyond Linux From Other LFS-related projects include: (www.linuxfromscratch.org/hlfs) you
Scratch (BLFS) comes in. This project ALFS (Automated Linux From Scratch): can further secure an “out-of-the-box”
enables you to add more powerful This project (www.linuxfromscratch.org/ LFS system.

50 LXF287 April 2022 www.linuxformat.com


Linux From Scratch IN-DEPTH

move on to chapter six to build some more utilities: the


M4 macro processor, the Ncurses terminal UI toolkit, the
Bash shell, Coreutils, Diffutils, the File utilities. You may
recognise many of these from the list of host system
prerequisites. That’s because we’re now compiling LFS
versions of them.

Build LFS on LFS


Chapter seven marks an exciting change, as you’ll
switch over to the LFS system via chroot . You’ll start
by converting the target system’s ownership to be root
(as you’d expect for a typical Linux system, see section
7.2) and preparing virtual file systems such as /dev
(section 7.3) before entering the target system and
setting up the root user there (section 7.4). You’ll
create important config files such as the hosts,
passwd, and group files among others. This process The final stretch... setting up the /etc/fstab file so your system will boot LFS.
is, by and large, the same as setting up the host and
target environments, with the ability to copy cat (see the sample).
commands from the book in order to populate file Section 9.7 provides details of the default setup
content. Chapter seven ends with building some more process for the Bash shell.
packages before saving the system before launching Section 10.2 will help you set up the /etc/fstab file
into chapter eight, where you’ll build the system proper. (again, the guidance in the LFS book makes these a
These chapters aren’t covered in detail in this article, simple copy-paste-edit process, as shown in the
even though they comprise the bulk of its content. The screenshot (above).
reason why is that working your way through them is In section 10.3 you will, at long last, build the
exactly the same exercise we covered in the above Linux kernel.
sections. Chapter seven entails the creation of a

LAYING THE LINUX GROUNDWORK


number of key files, which you’ll do by copying, pasting,
and revising the text provided in the book, just as you

“LFS requires that you compile some


did while setting up the host and target environments.
And in chapter eight you’ll work your way through

of the underlying tools that will make


building each LFS package in turn through a process
similar to building the toolchain. The only caveat in

it possible to build the LFS packages


chapter eight is that a good number of these sections
come with configuration instructions in addition to the

on the target system.”


build steps. As always, follow the directions carefully!

System configurations
The last part of the book concerns putting the final Section 10.4 highlights GRUB configuration.
pieces in place to make LFS a functioning Linux system. Section 11.1, appropriately titled, “The End," has you
Some of the notable pieces of it are as follows: log the distribution in the /etc/lfs-release and /etc/
Section 9.2 details the installation of the LFS os-release files, which might be considered the
Bootscripts (see below), which sets up the SystemV- equivalent of signing a painting you just finished.
style runtimes, while section 9.6 provides steps for At this point, you can either reboot your system (if
configuring them (for example, the /etc/inittab file). LFS is going to live on the machine on which it was
Sections 9.3 and 9.4 walk you through creation of built), or migrate the system (section 8.2.3 notes that
device-related sub-systems such as Udev. cloning a system is as easy as archiving the root
Section 9.5 guides you through configuring networking directory, moving it to another machine of the same
architecture, extracting, and then adjusting config files
as needed).
Well, how did that feel? The authors of the LFS book
have put together a fantastic learning exercise for the
curious Linux enthusiast. It provides enough hand-
holding to enable those without highly technical
backgrounds to create an LFS system “just to say they
did it.” On the other hand, it also explains everything
along the way, giving studious users insight into the
inner workings of Linux that no graphical installer could
ever provide.
All that’s left is to head over to the LFS website and
add yourself to the counter (www.linuxfromscratch.org/
The LFS-Bootscripts package, as a directory listing at left with cgi-bin/lfscounter.php). So what are you waiting for,
corresponding descriptions at right. that last package to finish compiling?

www.techradar.com/pro/linux April 2022 LXF287 51


TUTORIALS
TUTORIAL

FZF
Credit: https://github.com/junegunn/fzf

Rapid fuzzy finder


Shashank Sharma isn’t one for magic, but he’s not averse to using the
Accio spell or its computing incarnation, fuzzy finder, to find things quickly.

hen looking for files on the desktop, you may

W often rely on the search feature of your


favourite file manager. The conventional
searching approach is to apply an exact search, so that
only files or directory that are a perfect match to the
OUR search string are displayed. A fuzzy search, on the other
hand, performs an approximate search, and instead of
EXPERT identifying exact matches, displays matching results
Shashank with each keystroke.
Sharma The fzf utility identifies itself as a general-purpose
is a trial lawyer fuzzy finder. Released under the MIT License, the cross-
in Delhi and an platform tools can be used across all flavours of Linux.
avid Arch user.
He’s always on Installing fzf
the hunt for Despite the usefulness of the tool, the project isn’t Fzf has no dependencies at all, so installing using the install script is
affordable geeky offered as part of the default installation of desktop the easiest way to ensure you end up with the latest version.
memorabilia. Linux distributions. However, it’s available in the
software repositories of quite a few. The project’s Apart from using the software repositories, there are
GitHub page provides a list of all the distributions that several other ways to install fzf, including using the
carry fzf in their software repositories, along with the package manager homebrew. Of course, you can also
supported version. Unfortunately, the latest release, use Git to clone the project’s directory to your hard disk
version 0.29.0, is offered only in the latest releases of and then install fzf using the install script:
distributions such as Fedora. Manjaro, openSUSE $ git clone --depth 1 https://github.com/junegunn/fzf.
Tumbleweed, Ubuntu, Debian and Arch, while most git
others carry older versions. $ cd fzf
If you’re running one of these distributions that $ ./install
offers the latest version, you can use the distro’s The fzf tool supports auto-completion and various
software management utility to install fzf. The command key bindings. The install scripts asks if you wish to
sudo apt install fzf can be used to install it on Debian enable these and also offers to edit your ~/.bashrc file.
and Ubuntu or derivatives, while sudo dnf install fzf can Once enabled, you’ll be able to deploy the following key-
similarly be used to install it on Fedora. bindings to invoke fzf:

RELATED PROJECTS
You can assess the popularity and bindings or the fzf-marks (https:// You’ll also find several projects under
usefulness of fzf by the fact that the github.com/urbainvaes/fzf-marks) the ‘Similar implementations’ heading.
project maintains a list of related utility, which enables you to quickly These are projects that provide
projects on its Github hosted wiki create bookmarks to various directories. functionality similar to fzf. Pick (https://
(https://github.com/junegunn/fzf/ The page lists projects across many github.com/mptre/pick) is one such
wiki/related-projects). This is a different categories such as Tmux, Vim, project, although it doesn’t have the
collection of other tools and utilities that Bookmarks and Shell. Many of the listed same degree of documentation as fzf.
build on the functionality of fzf to offer projects haven’t seen a new release in While fzf is written in Go, you can also
an improved CLI experience. quite some time, but these are simple try your hand at Skim (https://github.
Consider the fzf-extras utility (https:// tools offering very limited functionality, com/lotabout/skim), which is a fuzzy
github.com/atweiden/fzf-extras), for so don’t let that deter you from trying finder with identical feature set, but
instance, which adds additional key them out. written in Rust.

52 LXF287 April 2022 www.linuxformat.com


Terminal TUTORIALS

This is how you


Keybinding Function can preview a file
Search the recent command history with fzf without
Ctrl+r opening it. The
based on $HISTFILE
800 line-plus man
Recursively search for the filename page discusses this
Ctrl+t and other features
in the $PWD
in detail.
Recursively search for a directory
Alt+c name under the $PWD, and cd into
the selected directory.
When you run
Working with fzf the git clone
The fzf tool is only a finder so it makes little sense to command, it
invoke it by itself. Instead, you can use it in conjunction makes a copy
of the entire
with other commands such as cd , or to open files in a
Git repository.
text editor such as vim or nano. even use the ssh **<tab> command to select the
For end users
Before we try that, let’s start with something simple. remote host. only interested
Press Alt+c and see the directory lookup in action. This The ** tab-completion works with a large number of in the latest
feature only works with the $PWD. So, if you’re in your commands. Run the complete | grep _fzf command for release, the
~/ directory, you’ll be able to narrow down directories a complete list of all supported commands. better option is
on your ~/Desktop, ~/Documents and so on, but not in By default, fzf starts in extended-search mode, which to run the git
the /media/ directory, for instance. means that you can type space-separated keywords to clone --depth
This opens an interactive prompt and starts narrow down the file or directory you’re looking for. 1 command,
recursively indexing all the directories in the $PWD. However, you can also utilise different techniques to which only
copies the latest
Start typing some words and the results will change improve the search results.
version of the
with each keystroke. When you see one that you want,
files in the
select it and press Enter to change into the directory. Token Example Explanation
repository.
Although you can use up and down arrow keys to string string Searches for string
navigate the search results produced by fzf, the tool also
Performs an exact match for
supports Ctrl+j or Ctrl+n to move down and Ctrl+k or
‘ ‘string items that include the
Ctrl+p to move up through the results. quoted string
You can exit the fuzzy search by pressing Ctrl+c or
hitting the Esc key. In a departure from behaviour for Lists items that start with
most command-line utilities, fzf also boasts of mouse ^string ^LXF LXF by performing a prefix-
exact-match
support, so if you’re more clicking then keystrokes, you
can use the left-click to select and the scroll wheel to Lists files that end in .odt
navigate the fzf generated results. You can also double- .format$ .odt$ format by performing a
click an entry to change into the directory. suffix-exact-match
You can use even use fzf as a replacement for tab- Lists items that don’t
completion. To invoke fzf tab-completion, you must use !string !dhc include dhc by performing
the ** identifier with a command: inverse-exact-match
cd **<tab> List items that don’t start
> !^string ~^LXF with LXF by performing
18/18 inverse-prefix-exact-match
>Books
Lists files that don’t end with
temp
!.format$ !.odt$ .odt format by performing
temp/repo inverse-suffix-exact-match
temp/repo/data
temp/new
DHC While fzf may seem like a straightforward tool to use
DHC/circulars – and it is – don’t let its simplicity fool you. The project
As you can see, here we used the fzf-tab-completion is incredibly versatile in its use and offers myriad
with the cd command, which opens the interactive capabilities to improve your CLI experience.
search prompt and provides a list of matching One such useful feature is the preview, which enables
directories. As you type in keywords, fzf will narrow you to preview a file as soon as you select it, without
down matching results. This makes changing directories opening it first. This works by opening a preview in an
easy because you don’t have to write long path names, additional pane on your terminal window using an
or repeatedly use the Tab key to perform completion. external tool such as cat or less to preview the contents
You can easily select a directory, even 10 levels deep, of a file. To begin, make sure to read the man page to get
with a handful of keystrokes at the most. a better sense of the tool’s capabilities. You must also
You can also use the ** tab-completion with the kill check out the wiki on the project’s GitHub page
-9 command to identify the process you wish to kill, or if (https://github.com/junegunn/fzf) which is home to
you frequently use ssh to connect to remote devices various examples.

ENHANCE YOUR TERMINAL-FU Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 53
TUTORIALS Organise your research

ZOTERO
Credit: www.zotero.org

Store and search


your research notes
Always on the look-out for organisational tools, Nick Peers reveals how to
bring all your research materials and notes into a single convenient space.

otero bills itself as your personal research transferring the package hosting to the Zotero

Z assistant. It’s a free tool for not just collecting


notes from a variety of sources, but also
organisation. In the meantime, head over to www.zotero.
org/download/ to download and extract the tarball
organising them, sharing them and even using them as manually, then type the following commands, which
citations and bibliographies within your documents. assume you extracted the Zotero_linux-x86_64
OUR Zotero exists as two primary components: a desktop
client and a browser extension, known as a web
directory from the tarball into your Home folder:
$ sudo mv Zotero_linux-x86_64/ /opt/Zotero
EXPERT connector. This component enables you to capture $ cd /opt/zotero
Nick Peers all or part of a web page and add it to your collection. $ ./set_launcher_icon
says Zotero is More on how that works shortly. $ ln -s /opt/zotero/zotero.desktop ~/.local/share/
the answer to By the time you read this, installing Zotero may be a applications/zotero.desktop
his haphazard simple affair using the Zotero-deb wrapper (see https:// Once complete, you should find Zotero has added a
organisational github.com/retorquere/zotero-deb) for details, but at shortcut to the Launcher for easy access. Launch Zotero
systems. time of writing the author was in the process of and it’ll open your web browser to www.zotero.org/
start/ where you’ll be invited to install Zotero Connector
GET TO GRIPS WITH ZOTERO for Firefox or any Chromium-based browser with access
to the Chrome Web Store. If you’re using a different
browser, see the Quick Tip (opposite). You’ll also be
3 5 prompted to create a free Zotero account – see the box
6 (below right) for why this is a good idea and how to get
your data backed up and in sync using it.
4
1 Research the tool
After closing your browser, you’ll see that Zotero has
opened in the background. You’ll be prompted to install
the Zotero LibreOffice Plugin, which makes it easy to
link reference materials from Zotero to any LibreOffice
2 document in the form of bibliographies and citations.
If you skip this step now, you can install it later via Edit>
Preferences>Cite (switch to the Word Processors tab).
More on the plugin later.
As the annotated screenshot reveals, the main Zotero
window is split into various panes. Zotero organises your
Navigation pane List of items
1 Organise your reference materials into 4Those items that meet your criteria from
reference materials into collections – special folders
collections from here, and save advanced the navigation pane, tag selector and keyword that enable you to split reference materials between say
searches to create dynamically updated search are displayed here. work and family history. You then select a collection
‘smart’ collections. inside which you create each reference item. As these
Search tool
Tag selector 5 Perform quick keyword-based searches
libraries grow they can become quickly unwieldy.
2 All tags applied to the items in the middle of a selected collection or your entire library The search tool at the top provides one way to filter
pane are displayed here. Colour-code tags to here. Click the down arrow to change the these items, as does the ability to add multiple tags to
give them more prominence. search criteria. items, which are displayed at the bottom of the left-
hand pane. You can even link related items to each
Create new items Item pane
3 Use these buttons to create new items 6 The currently selected item’s details
other, so when you select one item, you can quickly
using templates, existing files or from ISBN are displayed here, split across four tabs. Info access those items too via its Related tab in the right-
numbers (and other codes). contains metadata for use in citations. hand pane. Items can be filed into sub-folders – or sub-

54 LXF287 April 2022 www.linuxformat.com


Organise your research TUTORIALS

collections – to help make them easier to find using a


hierarchy. Items can reside in multiple sub-collections
too – for cross-reference purposes.
Within each library are a series of specialist views:
My Publications is for those who subsequently share
their own materials online with other Zotero users, while
Duplicate Items, Unfiled Items and Bin – that place of
last resort for deleted files – should be self-explanatory.
The middle pane opens with an invitation to access
the ‘Quick Start Guide’ online (you’ll find detailed
documentation at www.zotero.org/support to fill in any
gaps). Going forward, the pane will display the items in
whichever collection or sub-collection selected in the
left-hand pane, while the right-hand pane displays the
contents of the currently selected item.

First reference item


Zotero has templates to cover most types of reference Key fields include Item Type, Title, Author, Publication The information
materials. These include books, magazines, sound and Date. Click inside one to enter information. Clicking you store under
Info doesn’t just
recordings and TV broadcasts, to electronic media, Item Type reveals the options you saw on the More
make items
which include web pages as well as files stored on your menu, in case you change your mind about what type of easier to identify.
PC, all of which can be linked or stored within your material this is. You’ll see that the fields displayed under It’s also used to
library for easy access to the original material. Info change according to the Item Type selected. automatically
You’ll find the tools you need to add items to your Entering all this information by hand is time- generate citations
and bibliographies.
collection are above the middle pane. Press the green + consuming. Thankfully, Zotero can speed up data entry
button to create blank entries with templates to match for certain types of item. Instead of clicking the green +
a certain type of reference material: five example types icon, click the wand button next to it, and you’ll be
appear at the top of the menu – click More to reveal the prompted to enter one of the following reference
full gamut of options. numbers: ISBN (for books), DOI (for digital content –
Select an option from this list and a blank entry will see www.doi.org), PMID (medical) or arXiv ID (scholarly
be added to the middle pane, complete with an icon articles in the sciences). Once entered, hit Enter and
helping to differentiate it from other types. On the right Zotero will search for the relevant item and – if found – If you’d like to
you’ll see four tabs: Info, Notes, Tags, and Related. The pre-fill the item’s details for you. In non-academic use Zotero with
Info tab is key here, as it’s where you enter as little or as circles, the ISBN search is by far the most useful. a browser other
much detail about the item in question. The more detail than Firefox or
you furnish here, the better your citations and Fill in the blanks Chrome, visit
bibliographies will be in due course. After you’ve populated Info, what do the other tabs www.zotero.
org/download/
offer? Tags enable you to attach keyword-based tags to
bookmarklet
the item to find it in future searches and in tag-filtered
to review
views. The Related item is a way of linking this item to instructions
others in your collection. The link is two-way, so this for installing
item will also appear under the other’s Related tab. and using
The Notes tab enables you to record one or more the Desktop
notes of formatted text about the item in question. The bookmarklet.
text can be formatted using the controls at the top of You’ll need a
the pane, and you can paste it from elsewhere – such as Zotero account
passages of the original text (or indeed the entire text to save items
to your online
Tags are a great way to not only generate filtered views of your itself). Information entered here is then indexed by
library.
research items, but also highlight important items using colour. Zotero, making it easy to retrieve later via searches.

ZOTERO SYNC
If you plan on using Zotero across username and password, then click Set Once set up, wait for the initial sync –
multiple devices, share your research Up Syncing. You’ll be able to choose this may be some time depending on
online with others, or want a cloud-based which libraries to sync, whether to sync how big your libraries are. Going forward,
backup of your libraries, then you need a automatically, include full-text content however, if you leave automatic sync
free Zotero account. You’ll be prompted and what level of file syncing to perform. enabled, then the process should be
to sign up after installing the program, Zotero provides 300MB of free space, but largely seamless. If you run into trouble
or navigate to www.zotero.org/user/ you’ll have to either pay for more (from with sync, or wish to wipe your online
register and provide a username, email $20/year for 2GB) or select the WebDAV library and replace it with the contents of
address and password. option to use your own configured server your local library, return to the Sync
Once you’re signed up, navigate to – supply the URL, username and section of Preferences and switch to the
Edit>Preferences>Sync to enter your password before clicking Verify Server. Reset tab to access the options you need.

www.techradar.com/pro/linux April 2022 LXF287 55


TUTORIALS Organise your research

If you find the pane too cramped, click the ‘Edit in a opens a folder to its current location), and access
separate window’ button to open it in a floating window additional options.
Want to – close the window when you’re done. You’ll also find When you click the green + button to add new items,
separate handy shortcuts beneath the edit pane for adding you’ll see options for adding file attachments directly.
your research related items and tags without having to switch tabs. Doing so will either create a simple floating copy of the
material into Once your note has been created, you’ll see it’s filed file or, if it’s a PDF and Zotero is able to find additional
libraries? Make inside the reference item as a separate sub-entry. This metadata for it, you’ll have it wrapped inside an item
use of Zotero’s is also where you can attach files – either simple links or with some or all of the info fields populated.
support for direct copies – such as a PDF of a magazine article, or a You can also store references to web pages within
profiles: open video or sound file. Add these to existing items by right- Zotero. To see how to do this using Zotero’s web
Terminal, type
clicking the item in the middle pane and choosing Add connector, follow the step-by-step guide (below right).
zotero -P and
hit Enter to
Attachment followed by your choice: link to URI
create, select (enables you to link to files hosted online), link to file Organising your collections
and delete (stored on your PC or network) or stored copy of file. As your library grows, what options are there for
profiles. Each This latter option copies the file to the Home/ keeping things in order? The most obvious solution is to
profile has its Zotero/storage directory on your PC. Choosing to store use Zotero’s collections. Although they look like folders,
own settings files in this way guarantees access to them regardless of Zotero would prefer you to think of them like music
and library, what happens to the original, but bear in mind that this ‘playlists’: the items aren’t physically connected to each
enabling you option will quickly consume file space. collection, but simply linked to it via a shortcut.
to keep them After files have been attached, select one and you’ll This means that items can reside in more than one
separate.
see it also has its own space for recording text. If you collection, and by default dragging an item from one
wanted to include the full text from a Word document or collection to another using the left-hand pane results in
PDF, say, you could paste it here so Zotero can index it. it being ‘copied’ to that collection. If you’d rather move –
You can also right-click the file to view it, show it (this or transfer – the link from its current location, hold the
Shift key as you drag it. It also means when you delete
an item from a collection (select it and click Delete)
then it’s merely removed from that collection. To delete
the actual item, right-click it and choose ‘Move Item to
Trash’ instead.
The whole drag-and-drop element of collections can
make them unwieldy. A more elegant way to organise
your items is through the use of saved searches. These
effectively create a ‘smart’ collection, one whose
contents are determined by the parameters of your
saved search, and so which update automatically as
items are added, removed or changed.
To create a smart collection, choose Edit>Advanced
Search. It works like any good search tool: you can set
up multiple parameters, filter results and then once
you’ve viewed the contents of the search and
Notes can be as long or as short as you need them to be – and if space is cramped, make use of determined it fits your needs, click Save Search. Give it
Zotero’s floating editor. a title and you’ll see it appear with a folder icon and

EXPANDING FUNCTI0NALITY
As with all good open-source collections. There’s also a Zotero OCR fields between items, as well as quickly
communities, Zotero is well-supported, plugin for performing automatic text changing an item type.
especially when it comes to expanding recognition on PDFs you’ve scanned in. Finally, you’ll find dozens of plugins for
its capabilities with plugins. Visit You may also want to consider making it easy to integrate Zotero’s
www.zotero.org/support/plugins for an ZoteroPreview for adding a citation citation integration tools with other tools
exhaustive list, then click the link of one preview tab to items, and Zotero and online services, including WordPress.
to visit its homepage and download the . Metadata Import for Calibre for
xpi file to your Downloads folder. importing (and exporting) metadata
Next, open Zotero and click Tools>Add- between the two.
ons. Click Settings and choose ‘Install Perhaps the most useful plugin of all is
Add-on From File…’ Select your .xpi file Zutilo, which adds many time-saving
and then restart when prompted. tools to Zotero, all accessed via its own
Instructions for using the add-on should context menu. After installation, choose
be found on the plugin’s download page. Tools>Zutilo Preferences to configure it
Plugins worth exploring include Zotero and see what’s available (visit https://
Folder Import for importing a group of github.com/wshanks/Zutilo for a
files from a single folder while replicating detailed description of each). Highlights Zutilo adds lots of missing functionality to Zotero and
that structure within Zotero under including copying and pasting multiple should be considered an essential add-on.

56 LXF287 April 2022 www.linuxformat.com


Organise your research TUTORIALS

magnifying glass, which is Zotero’s way of differentiating


it from a regular collection.
Looking to
Manipulating tags visualise your
Over time you’ll probably want to change your tag items in a
system, which will affect all items. You can apply existing chronologically
tags to items one of two ways. If you use the item’s Tags based timeline?
Choose Tools>
tab, then type the tag name to see a list of suggestions
Create Timeline
appear as you type. Better still, use the tag selector
to create a
panel by dragging an item on top of a tag to add that tag timeline based
to it – perfect if you introduce a new tag to your library on items’
and want to quickly apply it to existing items. publication
You may also want to rename tags, remove them or The citations you generate using Zotero’s LibreOffice plugin are dates. You
merge two or more tags together. All of this is done from generated automatically, based on the style you choose. can filter by
the tag selector pane. Right-click a tag to rename it or keyword and
delete it. If you rename it to the same name as an existing ones, reset document preferences and remove also highlight
existing tag, they’ll be merged and all items containing selected citations. keywords
by colour to
either tag updated accordingly. Start by clicking ‘Document Preferences’ to choose
identify trends.
Tags can also be colour-coded – right-click a tag and your citation style and language. Most citations are
choose ‘Assign Color…’ to pick one. Not only will the based on the Chicago Manual of Style, and there are
tag’s name be coloured in the tag selector pane, you’ll three styles to choose from that are based on Chicago:
find items with coloured tags have those colours ‘author-date’, ‘note’ or ‘full note’. The information
highlighted as small squares next to the tag’s title. displayed in the citation will be taken from the Info tab
When adding items from the web or when of whichever clip you select in Zotero, and you can
using identifiers like ISBN, Zotero may apply tags choose to display each citation at the end of a page
automatically. They’re identifiable by being coloured red (footnote) or at the end of the document (endnote).
in the tag tab (user-created tags are blue). These tags Once you’ve chosen your settings, place the cursor
can be hidden from view (click the button next to the where you wish to insert a citation and click the Add/
tag search field), deleted en masse by right-clicking one Edit Citation. Use the search box to locate the clip you’d
and choosing ‘Delete Automatic Tags in This Library’, like to insert, then click to select it and press Enter to
and prevented from being added in the first place (go insert the citation. If you click the Z button in the Search
to Edit>Preferences>General tab). bar and choose Classic View, you’ll open a dialog with
more options for controlling your citation’s look, such as
Add citations to documents adding a page number.
The LibreOffice Writer plugin enables you to use your If you choose the ‘author-date’ citation style, we
items to support your written documents in the form of advise including a bibliography providing more details
citations and bibliographies. After installation, you’ll see about each citation. Click Insert Bibliography at the
five buttons appear on the main Writer toolbar enabling point where you want this to appear in your document,
you to add/edit citations and bibliographies, refresh then click Edit Bibliography to customise it further.

CAPTURE WEB PAGES

Start web capture Set item details Save snapshot


1 Open your web browser and locate 2 The web connector enables you to 3 The item will be added to your Zotero
the web page you’d like to ‘snip’ to Zotero. choose where to save the item. Click the library with key information added, such as
Look at the Zotero button in your browser down arrow button, next to the ‘Saving to’ title and type (web page). You’ll also see
toolbar: if it’s blue, the page can be saved to drop-down to expand the box. From here that inside the item is a ‘Snapshot’. Zotero
Zotero as ‘embedded metadata’, which you can choose where to save the page saves a complete offline copy (images
means all the bibliographic information is within your library, and add relevant included) of the page to your hard drive,
added to Zotero automatically. Click the keywords as tag if applicable. When you’re enabling you to refer back to the item later
button to bring up a tiny pop-up window. finished, click Done to save the item. exactly as it was when you downloaded it.

GET MORE OF OUR TOP RESEARCHSubscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 57
TUTORIALS Jupiter Ace emulation

XACE
Credit: https://github.com/lawrencewoodman/xAce

May the forth be


with the Jupiter Ace
Les Pounder nips back to the early 80s and pays homage to a home
computer that sold less than 6,000 units, despite its go-faster stripes!

e go back to 1982 to discover

W that not all home computers


came with BASIC. The Jupiter
Ace, from the Cambridge-based
Jupiter Cantab Limited computer
OUR company was an oddity of the era.
The Jupiter Ace looked like a cross
EXPERT

wikimedia.org/wiki/File:Jupiter_ACE_(restored).JPG
between a ZX81 and a hot rod and we

CREDIT: Factor-h, CC BY-SA 3.0, https://commons.


Les Pounder quite like that. The design of the
is associate Jupiter Ace was down to its creators
editor at Tom’s Richard Altwasser and Steven Vickers,
Hardware and a who had previously been part of the
freelance maker. ZX Spectrum design team. The Jupiter
He blogs about Ace had 2KB of dedicated video RAM,
hacks and makes which offered a performance boost
at bigl.es. over the ZX Spectrum.
Packing a Z80 CPU running at
3.25MHz and a minimum of 1KB of
RAM, the Jupiter Ace was sold for
£89.99 in 1982 (approximately £277.20
adjusted for inflation). This was much
lower than the Commodore 64’s £350
(an eye-watering £1,078 in today’s The Jupiter Ace is a cross between a ZX81 and a hotrod, and we love it.
money) price tag. Not many were manufactured, so finding a mint unit is a rarity.
Accessories for the Jupiter Ace included 16, 32 and
48KB RAM packs, replacement keyboards and external We started by downloading the source files from the
storage devices. Most users saved their programs project’s GitHub page. Git users can either clone the
directly to cassette using tape recorder, which was repository from https://github.com/
a common technique of the era. lawrencewoodman/xAce or download and extract the
Instead of running a BASIC interpreter/operating ZIP file from https://github.com/lawrencewoodman/
To see the system we’re presented with Forth, a language that we xAce/archive/refs/heads/master.zip.
contents of shall get to grips with later (see LXF276 for more on Whatever method you choose to take, you’re left
our word programming the Jupiter Ace in Forth). with the xAce directory. Next we need to install a few
(subroutine) we The Jupiter Ace wasn’t a big seller, with a reported software dependencies. Open a terminal and update
need to use the
5,000 units made and even fewer of the Jupiter Ace your package repositories.
LIST command.
4000 being manufactured at around 800 units, which $ sudo apt update
In BASIC we’d
provide a line featured a stronger injection-moulded plastic case. This Now install the latest version of the gcc C compiler
number, but computer may not have had the high sales of Sinclair’s and some extra C development libraries.
with Forth we and Commodore’s machines, but it has a special place $ sudo apt install gcc
have to pass in the hearts of coders who cut their teeth with Forth. $ sudo apt install libx11-dev
the command $ sudo apt install libxext-dev
the name of Emulating a Jupiter Ace Install the build essential library meta package, which
our word. For The best Jupiter Ace emulator that we could find for installs a list of tools necessary to compile and debug
example, LIST our Kubuntu install was xAce, but bear in mind that we the xAce installer.
lxfloop.
experienced a few bugs while exploring the program. $ sudo apt install build-essential

58 LXF287 April 2022 www.linuxformat.com


Jupiter Ace emulation TUTORIALS

The final install is cmake, which is used to build


applications from source.
$ sudo apt install cmake
Stay in the terminal and navigate to the xAce
directory. From there we need to run a command that
will create the build files. Note that after cmake there’s a
single space, and a full stop.
$ cmake .
To build the files use make.
$ make
Right now we have the xAce executable file in the
current directory. We can launch it right now, but to
install it system wide we need to install it.
$ sudo make install
To run xAce we need to be in the same directory as
the ace.rom file. This is a copy of the system ROM image
and it’s distributed with xAce. Navigate to the xAce
directory and run the command. Note that we also tried
to pass an absolute reference to the ace.rom file from
another directory, but this didn’t work.
$ xace
The xAce interface is basic, no pun intended. We have The Jupiter Ace uses Forth rather than BASIC. Here we create a new word (subroutine) “lxf” and
a simple terminal-based interface which uses the F-keys when called it’ll print LXF Rulez to the screen.
to reset and load tape images. More on that later, for
now we must – ahem – go Forth! The version of Forth found on the Jupiter Ace is
based on Forth-79 . This version was released in 1979
Programming the Jupiter Ace and came with added syntax checking and control Can’t remember
Okay, it’s time to flex a little BASIC muscle. We’ve done structures. Some less-used Forth “words” (subroutines) the command
this a few times on many different machines but we are omitted, but can be replaced should the need arise. that will make
start as always with the ol’ 10 PRINT project. Wait a So is Forth better than BASIC? That’s debatable. It’s your code work?
moment, the Jupiter Ace uses Forth! As we’ve covered a case of clarity versus speed, because Forth is claimed Forth has the
VLIST command
in multiple issues, BASIC was the de facto means to to run “10 times faster than BASIC”. However, unless
that will list all
write code on your home micro, but Jupiter Ace owners you’re building critical applications then there’s no great of the available
had Forth instead. difference to the end user. words, including
Forth is a procedural programming language created any words that
by Charles H “Chuck” Moore during his time at the US Break the Forth wall we create.
National Radio Astronomy Observatory (NRAO). The So let’s get to grips with Forth and to do that we need to
language was formalised in 1977. The name Forth comes write Hello World! Start the xAce emulator, or you can
from Moore who “considered it appropriate for fourth- use the excellent web emulator at http://em.ulat.es/
generation computers”. machines/JupiterAce if you prefer.
The language is commonly used in astronomical and We start our Hello World! code by defining a word,
space applications, harking back to Moore’s work at the which is a way to give a subroutine a name. In this case
NRAO. Rather than a line-by-line number system as we shall call it lxf.
used in BASIC, Forth uses a structure that feels like a : lxf
sentence, or as some say “a magic spell”. Forth is quite a Press Enter and the word will move to the top of the
memory-efficient means to write code, and in the early screen. Now type the next line to write a string to the
1980s it was favoured quite highly by those eager to screen. Remember the semicolon at the end of the line:
optimise their code. .” LXF Rulez “;

IT’S FIGNITION TIME!


Fignition predates even the mighty hardware. We were lucky to meet with manage that level of keyboard
Raspberry Pi! This single board computer Skidmore on two occasions, in 2011 and athleticism (we couldn’t) then Skidmore
from Julian Skidmore is a full “Z80 style” 2012 and learnt how his DIY kits were offers FIGKeys, an Arduino-compatible
computer (ATMEGA168-20PU to be designed. The kits come with all the shield for Fignition that breaks out a PS2
exact) with 32KB of RAM and video components necessary to build your own keyboard connection.
output. The best thing is that you have to Fignition – all you need to supply are a If you want to make your own
build the computer from scratch, then few soldering tools and a bit of time. computer then for about £35 (much
write code for it using a version of Forth. Once built the Fignition has a rather cheaper than a Jupiter Ace) you can grab
Skidmore borrowed elements of Forth unusual keypad matrix that requires a Fignition and FIGKeys direct from
79, as used on the Jupiter Ace to trim little dexterity and muscle memory in Skidmore. Visit https://sites.google.
down the language for the low-power order to write your code. If you can’t com/site/libby8dev/home for details.

www.techradar.com/pro/linux April 2022 LXF287 59


TUTORIALS Jupiter Ace emulation

The interpreter will say OK if everything is entered


correctly. If there are errors, such as a missing quotation
mark, then an inversely coloured question mark will
prompt you to check your code.
To run our word, we type its name and press Enter.
lxf
Our code works, and prints LXF Rulez , but it could
do better so let’s rework it. Use the lxf word again.
: lxf
Now use the CLS command to clear the screen.
Next, press Enter to send the command to the top of
the screen.
CLS
Now add the string to print and press Enter. Run via DOSBox, Ace32 is a free DOS-based Jupiter Ace emulator that
Remember to look for OK to confirm that everything performs extremely well. Just as long as you don’t mind running an
is correct. emulator inside an emulator…
.” LXF Rulez “;
Run the word again and the screen will blank, then CLS
print our message to the world. Create a new line using CR (Carriage Return). Press
We can print one thing to the screen, which is a small Enter to send the command to the top of the screen.
but useful step. Now let’s create a loop that will iterate CR
10 times. We’ll call it lxfloop (remember to press Enter). Create a loop that will iterate 16 times, then press
: lxfloop Enter to send the command to the top of the screen.
Use the CLS command to clear the screen. Press 16 0 DO
Enter to send the command to the top of the screen. Now add the string to print and press Enter. We don’t
need a semicolon yet.
.” LXF Rulez “
Create a new line using CR and press Enter to send
the command to the top of the screen.
CR
Finally call the end of the loop, and remember the
semicolon before you press Enter.
LOOP ;
Run the word to see the loop in action.
lxfloop

Learn more about Forth


If all this talk of programming in Forth has piqued your
interest then we have two great resources to share. The
first is Starting Forth, a free PDF and online resource
that explains the Forth syntax. The guide features a
series of images, code examples and clear explanations,
and is exceptionally well put together. Grab your free
copy at www.forth.com/starting-forth.
The other resource is more general, in that it
covers all of the Jupiter Ace story. There are guides
to programming and PDFs of the original manuals
The vlist word will print all of the words in the Forth programming vocabulary, which is along with hardware schematics. Head over to
extremely handy when we forget a word. www.jupiter-ace.co.uk to learn more.

YOUR OPTIONS FOR JUPITER ACE EMULATION


In our feature we used xAce, a competent co.uk/ace32.html. Indeed, this is a site code and ideas before committing them
if flawed emulator. But there are that became extremely useful during the to xAce. This online emulator is limited to
alternatives available. writing of this feature. “just” the Forth interpreter, but it does an
If you’d like an offline alternative, it’s If you prefer an online emulator, then excellent job. There are tabs along the
slim pickings for Linux with xAce being something that’s been a theme during top of the site, and under Z80 we can
the only emulator, but if you’re prepared the course of these features is websites swap to a Z80/Z81 or a Tandy TRS 80 –
to run DOSBox then you can give Ace32 a that emulate old hardware. We visited all machines that we’ve featured in Linux
try. In our tests it was considerably more http://em.ulat.es/machines/JupiterAce Format. If you look under 6809 you’ll find
stable than xAce. The download for and used its excellent Jupiter Ace a Dragon 32 emulator, too! Lots of retro
Ace32 can be found at www.jupiter-ace. emulator as our “scratch pad” to test out fun, available on all your devices!

60 LXF287 April 2022 www.linuxformat.com


Jupiter Ace emulation TUTORIALS

hardware. With the Jupiter Ace, you can do this… but


your bank manager won’t be happy (unless you take
out a loan with reasonable repayment terms). Online The xAce
auction sites have Jupiter Aces for sale at well over emulator is
£500! If you want the rarer 4000 model, which features useful, but
the sturdier case, then £850 is your starting point. If you it has an
see a Jupiter Ace going for cheap at a car boot or garage annoying habit
sale then jump on it like there’s no tomorrow. Even 16KB of producing
a series of “z”
RAM packs are £350!
across the
If you really want Jupiter Ace hardware, then there is
screen. We
an alternative in the form of Grant Searle’s absolutely couldn’t find a
astonishing in-depth project that enables you to build way to stop this,
your own Jupiter Ace. Searle has put the work in with but we quickly
this project. There’s a parts list (bill of materials, often discovered that
shortened to BOM), circuit diagram, component layout pressing F12 will
Hello World by Tygrys and Ziutek is an impressive demo for such a and ROM images for you to create your own ROM chips. perform a hard
low-power machine. Ported from the ZX81 original, this demo is simple, If you’re a fan of the Jupiter Ace, then visit Searle’s reset of the
but has plenty of impact.
site (www.searle.wales) and learn everything there is to Jupiter Ace.
know. If you want the thrill of building your own Jupiter
There are games for the Jupiter Ace, but chances are Ace, but aren’t ready for the commitment of Searle’s kit
that many of us have never played them. As with all then The Future Was 8-Bit has the Minstrel 4th Edition
other retro games, the legality of downloading ROM files for just £200 (compared to a real Jupiter Ace this
depends on where you live so check local laws before is a steal.) The Minstrel 4th is a DIY kit and even
downloading. the keyboard is a PCB. More details at
Loading a game with xAce is a multi-step process. www.thefuturewas8bit.com/minstrel4th.html.
First, navigate to where your ace.rom file is and run
the emulator: The legacy of the Jupiter Ace
$ xace Such a limited release means that the Jupiter Ace isn’t
In the terminal window you’ll see a list of options, F3 as well regarded as its more popular rivals. The rarity of
is the option to load a tape image. No dialog will pop up; the machine means it commands a high price and as
rather, we need to specify the name of the file. It’s best such collectors will want one in their collections. The
practice to have your games in the same location as the Jupiter Ace broke the mould – well, maybe not the ones
ace.rom file. Type or paste the name of the ROM image Sinclair used, but by using Forth instead of BASIC we
and press Enter. This will “insert the tape” and then we have an interesting and powerful programming
need to type LOAD to start the game. alternative. The Jupiter Ace looks gorgeous and is a true
Some games have different commands to run them. product of the era. If you can get one cheap, enjoy it,
For example, we played Ace Invaders, which is a fiendish and if not then emulate it!
shoot ‘em up in the style of Space Invaders but with
more fluid controls. Give it a go! To load Ace Invaders we
had to use this command after inserting the tape.
LOAD GR Z FORGET A LOAD GM
We then fought off the evil space aliens by using Z
and X to move, and M to fire.

The Jupitar Ace demoscene


With little RAM and only a Z80 2.25MHz processor you
would be forgiven if you thought that the Jupiter Ace
couldn’t handle a demoscene demo. Think again. Clever
programming always finds a way to squeeze the most
from a limited amount of memory
The demo we found was Hello World, created for the
website https://speccy.pl by Tygrys and Ziutek. It was
written for the Jupiter Ace but required an additional
16KB RAM pack (that’s nearly £1,000 of Jupiter Ace
kit!). This demo sees a big, bold Hello World bounce
around the screen. Sadly, there’s no music but the
90- second demo is still a great achievement. We can’t
find a tape image to play, but the demo can be seen at
www.youtube.com/watch?v=UxgIAPyyI68.
This is the point where we talk about picking up a Forth is the language favoured by the Jupiter Ace and the pair work extremely well together. If
retro machine and enjoying the experience of vintage you fancy a change from BASIC then give Forth a try.

GET YOUR OWN FORTH POWER:Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 61
BACK ISSUES

BACK ISSUES MISSED ONE?


ISSUE 286 ISSUE 285 ISSUE 284
March 2022 February 2022 January 2021

Product code: Product code: Product code:


LXFDB0286 LXFDB0285 LXFDB0284

In the magazine In the magazine In the magazine


Not all VPNs Stay one step Discover how
are created equally – find out how ahead of the nefarious perpetrators to turn your Raspberry Pi into an all-
to avoid second-rate services and of ransomware with our in-depth singing, all-dancing media hub. We
maintain your privacy online with feature. We bring you tutorials on put a spotlight on video conversion
our in-depth feature. We also test rock music effects, offline password tools, take you on a tour of Stacer,
five GUI text editors, show how to management and creating a virtual the one-stop system management
build a distro from the ground up network lab. Discover how to set up tool, and emulate the Oric-1
using Linux From Scratch, emulate a temperature display for your (thankfully without that keyboard).
an MSX, set up multi-boot USB Raspberry Pi and build web services Discover how to build a Pi-powered
devices, code a 3D game world, and with Go and the Gin framework. We NAS and learn more on how the
reveal the tools for managing your also put five of the best GUI-based world’s top-500 supercomputers all
passwords from the command line. backup tools through their paces. harness the power of Linux.

ISSUE 283 ISSUE 282 ISSUE 281


December 2021 November 2021 October 2021

Product code: Product code: Product code:


LXFDB0283 LXFDB0282 LXFDB0281

In the magazine In the magazine In the magazine


We pit Ubuntu Linux and Discover how
against Fedora to see which is the Windows can work in perfect to customise the Mint 20 desktop
better Gnome-based distro. Five harmony – find out how in our with our in-depth feature. We explore
filesystems are put through their eight-page guide. We share files virtual private servers, assess open
paces, we show how to run a Ghost across a network without the need source art programs, build a
blog, code a Galaxian-style shooter for protocols, emulate the Tandy Pi-powered pinhole camera, recreate
in Python, and use Okular to edit TRS-80, control the Pi’s GPIO with pseudo-3D racing games and
PDF files with ease. Scratch, and create our own server. emulate the Atari 800.

DVD highlights DVD highlights DVD highlights


Ubuntu 21.10 and Devuan 4.0 Zorin OS 16 Core, Finnix 123, Lakka 3.4 Mint 20.2 “Uma” and Elementary OS
“Chimaera” (both 64-bit only). and LibreELEC 10 (sadly all 64-bit). 6.0 “Odin” (both 64-bit).

To order, visit www.magazinesdirect.com


Select Single Issues from the tab menu, then select Linux Format.
Or call the back issues hotline on 0330 333 1113
or +44 (0)330 333 1113 for overseas orders.

Quote the Product code shown above and have your credit or debit card details ready

62 LXF287 April 2022 www.linuxformat.com


UK readers
READING IN THE USA? turn to
p16

SUBSCRIBE!
Don’t wait for the latest issue to reach your local store –
subscribe today and let Linux Format fly straight to you.
Faster, cheaper and with DRM-free archive access!

3 GREAT
WAYS TO
SUBSCRIBE
Print, digita
l-only,
and print+d
igital
bundles!

USA REST OF THE WORLD EUROPE


From $132 From $132 From €100
For 13 issues For 13 issues For 13 issues

IT’S EASY TO SUBSCRIBE!


Visit www.magazinesdirect.com/linux-format
Call +44 0330 333 1113
Lines open Monday-Friday, 9am-5pm, UK time

www.techradar.com/pro/linux April 2022 LXF287 63


TUTORIALS Smart home

HOME ASSISTANT
Part One
Don’t miss
next issue!
Credit: www.home-assistant.io Subscribe

Make your home as


on page 16

smart as possible
Matt Holder, who’s a bit of a clever-clogs himself, investigates the
usage of Home Assistant to make your home as smart as it can be.

mart Home and Internet of Things devices

S have been popular for a number of years now.


Unfortunately, the Internet of Things doesn’t
have the best name in terms of security issues, thanks
to poorly coded or secured devices. How many times
OUR have we read about hardcoded administrator-level
accounts being left enabled on devices? Canonical and
EXPERT Microsoft provide IoT platforms with security in mind.
Matt Holder When using commercial smart home/Internet of
has been a fan of Things devices it’s important to keep two things in
the open source mind. The first one is that of privacy. Would you be
methodology for happy if a data breach caused your data to be made
over two decades available to the public? The second matter is that of
and uses Linux sustainability. What would happen if the device’s
and other tools manufacturer decided to discontinue the web service
where possible. that the device relies on?
The sheer number of manufacturers, protocols and
communication methods can make it difficult to use all
of these systems in a cohesive manner. This is where
Home Assistant (www.home-assistant.io) comes in. Its
lengthy tagline is “Open source home automation that
puts local control and privacy first”. This is the perfect
way to describe an amazing project, which ties together
smart home devices from many manufacturers and Enter the required details to create the first user account.
many different protocols. Home Assistant will keep data
on your local network wherever possible and can also device, otherwise the wrong device may be wiped and
integrate with third-party cloud products if required. overwritten with Home Assistant.
During this article we’ll be installing Home Assistant Now insert the micro SD card into the Raspberry Pi
and then configure it for basic operation. In part two of and connect power and Ethernet. Within a few minutes
the series we’ll discuss how to use slightly more Home Assistant will have booted, ready for configuration.
advanced parts of the system, such as automations.
Installation to both Raspberry Pi and a virtual machine Virtual Machine
is simple and both will be briefly covered below. Alternatively, Home Assistant can be installed as a virtual
A huge number
machine (VM). VM images for KVM, VirtualBox and
of smart home
manufacturers
Pi Machine VMWare Workstation can be downloaded from the Home
are supported, The easiest way to install a software image on to a Micro Assistant website (www.home-assistant.io/installation/
including SD card is to use Raspberry Pi Imager. This can be linux). Once downloaded, follow the instructions to
Ikea Tradfri downloaded from www.raspberrypi.org/software. create the VM. Once the VM has been created, it can be
lights, Phillips Once downloaded, insert the Micro SD card into your switched on and within a few minutes the system will
Hue and the computer and open the tool (this may need to be have booted and be ready for installation.
Unifi network opened using the sudo command to elevate the To configure Home Assistant, open your web browser
controller. Find permissions the tool uses. Select Home Assistant from and visit http://homeassistant.local:8123. If this doesn’t
out more: www. the OS section of the tool, select the Micro SD card work, then visit http://<IP_ADDRESS>:8123 instead.
home-assistant.
under the Storage section and then click the Write The IP address can be seen by connecting a monitor or
io/integrations.
button. It’s important to select the correct storage TV to the HDMI output of the Raspberry Pi, or by

64 LXF287 April 2022 www.linuxformat.com


Smart home TUTORIALS

looking at the console output of the virtual machine,


which is running the software.
Enter the required information and choose to create
the account. Once created, on the next screen enter a
name for the installation, select a location on the map
and select the units for temperature. On the third screen
select the level of anonymised information you feel
happy to share with the Home Assistant project. The
fourth and final step of the onboarding wizard shows a
list of devices that have been detected on your network.
Select each one of these that you wish to configure and
then enter the details that are requested. When the
required components have been configured, select the
Finish button to exit the wizard.
Before going any further, let’s take a look at what
we’ve achieved. First, we learned what the Home
Assistant project is and what its goals are. Next ,we’ve
installed the software on either a Raspberry Pi or Virtual
Machine and then we completed the onboarding Select any services that are detected on the network and select them to configure.
process to create a user account and set up items that
have been discovered on the network. Home Assistant.
As will be discussed shortly, extra functionality can
Set a static IP address be added to Home Assistant using integrations as well Home Assistant
The Home Assistant operating system ties a number of as add-ons. Add-ons are docker containers that the can be installed
different things together: the OS itself, the supervisor supervisor looks after and can be provided by the Home on a large
and Home Assistant. The supervisor provides an Assistant core team or any member of the public. number of
platforms
environment to manage the OS, provide updates and Integrations are more tightly linked to Home Assistant
including the
also run containers, which can interact with Home and are provided as part of the core release.
Raspberry Pi,
Assistant. Once familiar with the software, it’s likely that The Backups tab enables snapshots to be taken, Intel hardware
it’ll become a permanent part of your network. Given which can be used to roll back your setup, should and various
this, it’s a good idea to set a static IP address. This can upgrades or certain configuration changes cause the Virtual Machine
be achieved by using the supervisor options. system to break. Finally, the System tab makes it platforms. More
On the left-hand side menu, open the Configuration possible for the Hostname to be changed as well information
tab. Now visit the Add-ons, Backups and Supervisor as IP address settings, and an overview can be seen can be found at
section and then select the System options. Next, select of RAM and disk usage as well as a view of the logs, the link below:
the Change option, which is next to IP address. Choose for troubleshooting purposes. www.home-
assistant.io/
the relevant option (either IPv4 or IPv6) and change the
installation
option from DHCP to static. Enter the relevant details Configure your setup
for the IP address, subnet mask, gateway and DNS We’ll now have a look at some of the other Configuration
server before saving. Once completed, wait a minute or options. Within the Configuration menu many entries
so and then connect to the web interface again, but this can be changed. Devices and Services are where the
time using the new details. details are stored for the entries that were discovered
Navigating back to the Add-ons, Backups and during the onboarding experience (and where items
Supervisor section again, the other tabs on show are added in the future can be found as well).
Add-ons and Backups. Within the Add-ons tab, you’ll Within the Integrations tab a large number of other
see an overview of any installed Add-ons. These add-ons integrations can be set up. Have a look at what’s on
can be installed from the Add-on Store link and cover a offer, to see what can be added to your installation. The
wide range of things, such as AdGuard Home DNS Devices tab can be used to see the items on our
filtering, DHCP servers, MySQL database servers and networks that have been configured. See the boxout for
NodeRed, which can be used to interact with data from details of Devices, Entities and Services (page 65). Areas

DEVICES, ENTITIES AND SERVICES


Home Assistant is an incredibly powerful referring to whether the heating is Chromecast device or the heating could
tool and has a range of different concepts switched on or off, what the target be turned on.
that you’ll need to become familiar with temperature is and what the current Entities have types and are named as
to get the most from the software. temperature is. A Chromecast device will such, TYPE.NAME. A few examples of
Devices represent physical items that have an entity associated with it, which these types are binary_sensor that
have been configured on the network – provides media playback. represents a True/False value; sensor
for example, a heating thermostat or a Services are used to send signals to that represents a numerical value; switch,
Chromecast device. Entities represent devices or entities to make changes. For representing something that can be
capabilities of these devices. For example, example, using the correct service a Text- switched on and off; and media_player
a heating thermostat will have entities To-Speech message can be sent to a that provides media playback options.

www.techradar.com/pro/linux April 2022 LXF287 65


TUTORIALS Smart home

enable devices and entities to be grouped in rooms of Another useful section to introduce is the States
your house. page. This is available from Developer Tools and then
The Home Skipping over a number of entries, which will be selecting the States tab. Developer Tools may need to
Assistant discussed in a further article, we come to Dashboards. be switched on from the User settings page (accessed
team provided These dashboards are used to create overview pages by selecting your name on the right-hand side).
information where many types of data can be displayed. Advanced features need to be toggled on. The States
about how People and zones can be used to track users. This tab within Developer Tools enables you to see the values
they use any doesn’t necessarily mean tracking your household’s for all entities. It’s a quick way to see when values
anonymised location using GPS coordinates, but could be used to change. However, the screen can become confusing
information detect if a member of your family’s phone is on your when there are a large number of entries on show.
that you choose
network or not. This could then trigger a notification The next item to talk about are the Lovelace
to send to them.
This can be
to welcome them home. The final section within the dashboards. These will be the dashboards used to
viewed here: Configuration panel enables general options to be display information from your smart home. For example,
www.home- changed, as well as restarting the system and viewing part of the dashboard utilised by the author is an
assistant.io/ log entries. overview of the status of the Raspberry Pi 4, which is
integrations/ On the left-hand menu, the logbook and history running Home Assistant. This is a useful dashboard to
analytics. sections can be used to view changes over time to your look at to determine if the device is overheating or is
entities. The Overview option is used to view the default having regular power supply issues.
Lovelace dashboard. There are a huge number of data types that can be
displayed in a Lovelace dashboard, a sample of this can
be seen in the screenshot (top right).

Edit your dashboard


We’re now going to edit a Lovelace dashboard and then
add some information to it regarding the position of
the sun and adding some useful shortcut buttons. This
will provide an idea of the concepts required to build
your own dashboards, relevant to the devices on your
own network.
Lovelace is the name given to the system within
Home Assistant that can be used to build dashboards.
Multiple dashboards are supported and they can all be
designed in different ways. This is incredibly useful
because it means that layouts can be designed for
different screen sizes.
For example, you could have one dashboard for a
phone and one for a tablet. By default, Home Assistant
will build a dashboard, which contains all items that
have been added to it. A relatively recent update has
meant developers are able to categorise data items. In
this way dashboards become less cluttered because not
all entities are included by default.
To create a new dashboard, head to the Configuration
options, select Dashboards and then click the Add
Dashboard button. Once a title has been added, an icon
selected from the icon picker and other options have
Learn the status
of your Raspberry
been selected accordingly, click Create. Next to the
Pi Status on this dashboard that’s just been created, select the arrow icon
dashboard. or Open button, which will open the new dashboard.

SMARTPHONE APPS
Interacting with Home Assistant via the It’s also possible to design a bedtime photograph, which can then be sent via
web browser is a pleasing experience, routine where a Home Assistant notification to your phone. In addition,
whether using a mobile phone or larger automation will switch off your lights the capability within notifications for
screened device such as a laptop. The when your phone is charging and on the user to be asked a question can be
Home Assistant team and community silent. When a smartphone app has been harnessed, so that the user can easily
also make available apps for iOS devices registered with your Home Assistant send a response back to Home Assistant,
as well as Android. These apps integrate installation the phone’s notification which can then be acted upon.
very well with the phone’s operating system can be utilised by Home Apps can be downloaded from the Play
system and enable the phone’s sensors Assistant. For example, if the doorbell Store or App Store, and once opened a
to be provided to Home Assistant to be rings a Home Assistant registered wizard can be followed to connect to your
displayed in the Lovelace interface. camera can be used to take a Home Assistant server.

66 LXF287 April 2022 www.linuxformat.com


Smart home TUTORIALS

CREDIT: https://imgur.com/b1wdGR7
This dashboard will contain all entities that have
been added to your Home Assistant installation, by
default. To edit the dashboard select the three dots and
click the Edit option. The first time this option is
selected for a dashboard, a message will be shown
asking whether to start with a blank dashboard or not.
Select the option and click Take Control.
At this point you’ll see an empty dashboard, which is
in Edit mode. Dashboards can contain multiple tabs or
views and each tab can have its own name or icon,
which it can be selected from. Tabs can also be set to
have different modes. To edit tab options, click the
pencil next to its name/icon.

Choose your view


The view type options are Masonry, Sidebar or Panel.
These refer to either a system where multiple cards are
spread across the screen; a sidebar that has two
columns, one wider than the other; and panel mode,
which enables one card to be shown on this screen.
The latter is useful for something like a kiosk or tablet
device. Within the tab’s options the badges section can
be used to add small icons at the top of the screen to
display values, such as temperature or switch status.
Finally, the visibility section enables tabs to be
hidden for certain users. Perhaps only power users
should see the battery status of remotes, or maybe
Here’s just a
you’d rather not allow your children to be able to switch followed by Add to Lovelace UI. sample of what
lights on or off. Change the settings as required and The second thing we’ll add are a series of buttons, Lovelace can do.
then select Save. that we can use to quickly visit another website and the
The next step in adding items to the dashboard is to configuration page of Home Assistant. Click the Add
add what are referred to as cards. These cards can Card button and this time select the Horizontal Stack.
contain a single piece of information or multiple entries. Next, select the Button Card. On the options that
If added individually, Lovelace will automatically appear, remove any Entity value which is auto-populated
determine where to place them. To have further control and change the Tap Action to URL. Add the Name of
on where the cards are placed, horizontal stack and Linux Format and in the URL Action box enter ‘www.
vertical stack cards exist, which means cards can be linuxformat.co.uk’.
placed next to each other in the order defined. There’s Note the Hold Action option, which can be used to
also a grid card, which can be used to create a table- set a second action if the button is pressed down for a
style view or cards. longer period of time. When the options have been
Click the Add Card button to design the dashboard. selected click Save. Now edit the last card and add
The designer tool is split into two tabs: By Card and By another button entry using the plus option. This time
Entity. By Card is used to find the sort of card you’d like set the Name field to Configuration, Tap Action to
to display and then when it has been selected, the entity Navigate and Navigation Path to /config. Finally, Save
to be displayed can be added. When using the By Entity the options for the card and then exit the Dashboard’s
section, you’ll first search for an entity and then suitable edit mode by using the cross in the top-right corner.
cards are displayed. Both options achieve the same To experiment with the different view modes, edit the
thing, but accomplish the task from different directions. tab’s settings and change the view mode. Now this has
The first thing that we’ll add to the dashboard is the been completed your dashboard contains a card
position of the sun. With the By Entity tab selected, displaying the position of the sun and a couple of
enter sun into the search box. When Sun is displayed, buttons that can be used to accomplish useful tasks.
select the checkbox next to it and click Continue Buttons can also be used to trigger services and
toggle switches. Cards also exist to graph numerical
information over time, view live camera feeds, display
floor plans with icons overlaid as well as many other
useful tasks.
So we’ve installed Home Assistant, explained
some concepts and demonstrated the concepts
required to build dashboards. In next month’s article
we’ll have a look at some more advanced concepts.
In the meantime, have fun experimenting with this
Our first attempt at designing a Lovelace Dashboard within Home amazing project!

AUTOMATE BUYING LINUX FORMATSubscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 67
TUTORIALS Publishing ebooks

LIBREOFFICE
Credit: www.libreoffice.org

Publishing your
Part Two
Missed Part
One? Turn to
page 62 to get
hold of it

own slick ebooks


Seeking to chalk up a best seller, Michael Reed goes further into
the intricacies of publishing a book from his Ubuntu desktop.

e’re going to take a basic ebook and make

W it shine with the help of images such as


photographs and charts. We’ll also add some
features that are appropriate for non-fiction books, such
as tip boxes, an index and citations within the text.
Finally, we’ll get a bit further into what it takes to upload
your files to services that can print books or make them
EXPERT available as ebooks.
Michael Reed This month’s tutorial picks up from where part one
is a Linux nerd left off in LXF286, with a basic formatted ebook, so you
and a self- don’t need to read part one but we’re assuming that you
published author. have some formatted text to work with in LibreOffice.
Guess which one We adjusted this image so that it doesn’t go over the borders and then
pays the bills. Illustrations and other Images added a short caption below it.
You may want to add images to your book. These could
be photographs that relate to the content of the book, cover the entire page. So, a 3:2 ratio photograph, with
other types of illustration such as diagrams, or even text above and below, should be fine at around
graphs or charts. 1,500x1,000 resolution.
First, we’d recommend copying any images that
you intend to use as part of the book into the project Adding the image
directory of the book. LibreOffice does include some So, how do we include an image? Inserting the image is
simple image-editing facilities, but generally it’s worth achieved by selecting Insert>Image... This launches a
loading the images into a dedicated image editor such dialog where you can select the image, and Writer will do
as GIMP (www.gimp.org) to carry out any required its best to scale the image so that it fits on the page.
manipulations such as cropping the image or adjusting Once the image is inside your document, you’ll notice
the brightness. that there are some resize handles around it. The corner
Colour printing is quite a lot more expensive than handles are the most useful because they maintain the
outputting your book in monochrome, and if you’re aspect ratio of your image as you resize it. Typically,
making a monochrome print edition then any included you’ll want to resize it so that the image doesn’t extend
images will have to look good in black and white. In the into the border of the page. If you right-click the image,
case of an ebook, your images will show up as colour the Rotate or Flip submenu is worth exploring if you
or monochrome, depending on the type of device it’s think you can make better use of the page by including
viewed on. In that case, the best compromise is to at the image on its side.
If you need help least check the image in monochrome. If you use GIMP There are some more advanced options that can be
when using
to reduce an image to black and white then the option accessed by right-clicking the image and selecting
LibreOffice
for your book
you need is Colours>Desaturate>Colour to Gray..., Properties... In the first tab, the Type tab, there are some
project, the which can be found in the main menu. anchor options that enable you to glue the image to a
LibreOffice For print or ebook publication, 300dpi is roughly the specific line, paragraph or page. By default, the image
website has a correct resolution to aim for. However, the actual will sit in the middle of the page with no text around it,
comprehensive resolution in pixels varies, depending on the size of the which is a common style for books. If you want to have
traditional image. For example, an image that filled the entire page, the text wrap around the image instead, check out
manual. including the borders, of a 6x9-inch book would have a options in the Wrap tab of the dialog.
See https:// resolution of 300 multiplied by six (1,800 pixels) by 300 To add a caption to the image, right-click it and select
documentation. multiplied by nine (27,00 pixels). That should give you a Insert Caption... This enables you to both write the
libreoffice.org.
rough guide, but remember that most images won’t caption and choose the numbering style. It’s a shame

68 LXF287 April 2022 www.linuxformat.com


Publishing ebooks TUTORIALS

that there’s no spell-check option in this section,


though. You’ll have to check the spelling of the captions
manually and paste them into the dialog.
In the case of diagrams, it might be worth using a
vector graphic format such as SVG, so that LibreOffice
can scale the image on the fly when exporting. Writer
also has a facility to directly include charts (click
Insert>Chart), and tables can be inserted and edited
within Writer itself (Table>Insert Table...). If you do
choose the bitmap approach for material such as charts
and diagrams, make sure that you use a lossless format
such as PNG, rather than lossy JPEG.
Overall, we found that the image-insertion facilities of
Writer were a bit unpredictable in places. We’d advise
that you insert the image, adjust its size, set the wrap
style, set the anchor options, and then add the caption Indexing is another task that Writer can keep track of for you, saving you time and effort. Keep
as a final step. You can change these things in a different adding interesting topics as you go along.
order, but if you do, don’t expect everything to
automatically update in an entirely expected way. Below the Entry field, the first and second Key fields
enable you to create a section header within the index
Indexing your work to keep similar terms together. Once you click Insert, When you add
Indexing is particularly appropriate for non-fiction the entry will be added to the index. However, you have images to an
books, and it’s something that works best if you try to to right-click the index and select Update to actually ebook, you
get into the habit of doing it while you’re writing. First update it, which you’ll have to remember to do from increase the
things first, add the index itself. Scroll to the end of the time to time. This is a pain, but when you consider that file size. That
document and click Insert>Table of Contents and indexing was once a skilled job in itself, it’s pretty cool isn’t as crucial
Index>Table of Contents or Bibliography... This launches that LibreOffice Writer can handle all of this for you, and as it once was,
a dialog from which you should select Alphabetical an index adds a professional feature to the book. thanks to
high-capacity
Index from the drop-down and then click OK.
devices and fast
While working on the text, if you spot a section that Insert citations internet speeds.
you feel would be a good addition to the index, highlight Citations are notes added to the text that show you’re However,
a single word or short phrase and click Insert>Table of referencing another work. There are many citation if the file is
Contents and Index>Index Entry... This launches a styles, but older textbooks tend to put the name of the unexpectedly
dialog. Add an index entry by clicking Insert, having author followed by the work of the year of publication in large, it might
made sure that the Alphabetical Index is selected on round brackets. Wikipedia has popularised a format be worth
the drop-down. where there’s simply a number in square brackets, with reducing the
Before you do, note that there are some interesting a numbered list at the end of the document. size of source
options in the dialog. You can have an index entry that’s By repeating the first step that we used to create an images in GIMP.
different from the word that you selected in the text by index (Insert>Table of Contents and Index>Table of
changing the Entry field to something different. For Contents or Bibliography...), you can add the
example, pages that mention ‘longitude’, ‘compass’ and bibliography (the list of referenced works) to the end of
‘navigation’ could all be put under the entry ‘navigation’ the book. Simply select Bibliography from the Type
in the index. One thing to watch out for here is that drop-down instead of Alphabetical Index. Select the
there’s no spell-check option within the Insert Index Number Entries option if you prefer to adopt the
Entry dialog. Wikipedia citation style with the square brackets.

THE NUMBERS GAME


The ISBN number is the 13-digit number writing, a single ISBN costs £89 or £164 You can then export it into other
(with barcode) on the back of nearly all for a block of 10. Thankfully, Amazon software, if required. The recommended
professionally published books. Thanks Kindle Publishing and Lulu Publishing will barcode size is 2.00x1.25 inches.
to print-on-demand publishing, you can give you a free ISBN if you publish a
often get away without having one. physical copy of your book with either
However, many traditional book sellers company. Amazon also has its own
such as bookshops won’t sell a book numbering system called ASIN that it
unless it has one, and it does give the uses for ebooks. Magazines (like this one,
impression that your book is a more if you’re reading the print edition) use a
professional product. numbering system called ISSN instead.
Unfortunately, they are expensive, The easiest way of creating an ISBN
particularly if you’re buying them in small barcode for the back of a book is to use Once you’ve created a barcode using the appropriate
numbers. The agency that sells UK ISBN the LibreOffice Barcode extension extension in LibreOffice Draw, you can integrate it
numbers is called Neilsen, and at time of (https://extensions.libreoffice.org). into the back cover of your book.

www.techradar.com/pro/linux April 2022 LXF287 69


TUTORIALS Publishing ebooks

The method for adding citations is similar to adding


index entries, but this time you don’t select any text
For justified before adding the entry. Instead, place the cursor at the
body text, select point where you want to add the citation (Insert>Table
an area of the of Contents and Index>Bibliography Entry...). The
text and click easiest way of working with the dialog that pops up is to
the justified select Document Content under the Bibliography
text icon in the Source heading and then press New. Here, you can add
main toolbar. the details about the source (book, article, website and
Then select
so on). If you’re going to add a lot of citations, it might
the “Update
to Match
be worth investigating Writer’s facilities for using the
Selection” Database module to store and edit the entries.
option under
the “Default Vary the page design
Paragraph Sidebars are useful for adding features like ‘tip boxes’ to You can add special characters such as the copyright symbol using the
Style” box in your text. To insert one, add a text box to your text dialog accessed by clicking Insert>Special Character.
the Styles drop- (Insert>Text Box). When you do this, the mouse cursor
down box. changes to a small cross. Drag this across the area that around the box right-click the box and select
you want your side box to occupy. By default, Writer will Wrap>Edit... Then add positive values of around 0.10
allow normal body text to pass behind the box that CM to the padding fields. If you’re feeling really swish,
you’ve just created. To prevent this, click the box: a new you can add a drop box to the sidebox (Format>Text
toolbar, the Text Box toolbar, will appear under the main Box and Shape>Area...>Shadow).
Writer toolbar. If the side box is on the right-hand side of Within the box, you can use the normal text-
the page, select the Before option in the toolbar, and if formatting facilities of the main Writer toolbar to make
it’s on the left, select the After option. This makes the the title text of the box bold. More advanced formatting
text flow around the box. options are hidden away in the Format>Text Box and
You might like to add a line border around the box. Shape>Text Attributes... menu.
Do this by selecting a line style on the Text Box toolbar. When you add a text box of this sort to the
You can also add a light grey background to the box by document, it’s listed under the Drawing Object category
selecting a colour on that toolbar. To add some padding in Writer’s navigation sidebar.

Footnotes and extras


OTHER PUBLISHING SOFTWARE LibreOffice Writer has a feature to add footnotes to a
page (Insert>Footnote and Endnote>Footnote). This
We’ve used LibreOffice for the text editing and page layout of our inserts the number of the footnote at the cursor. The
book. However, as ever when it comes to Linux, there are many other footnote itself is added to the bottom of the page
publishing options available. underneath a small horizontal line where it’s editable.
LaTeX is a document preparation system that actually predates As you add footnotes to various parts of the document,
Linux. It’s a markup language coupled with various support tools that Writer will update the numbers for you and make sure
output documents in various end-formats. The beauty of LaTeX is that the footnotes stay on the same page as the piece of
that it takes care of all of the typography and page layout for you. So, text that they refer to.
for example, you can insert an image in the text and LaTeX will decide Endnotes are added in the same menu (Insert>
where to place it. Footnote and Endnote>Endnote). In this case, a numeral
If this sort of thing sounds appealing, but you don’t fancy learning is added at the cursor and the endnote text is added at
LaTeX, take a look at LyX (www.lyx.org). LyX is halfway between a the end of the document. Note that the endnote links
word processor and a text editor, and sits on top of the LaTeX system. are like hyperlinks, so that you can jump to the note and
It’s fairly WYSIWYG; elements such as illustrations and bold text are back again by clicking the numeral.
shown on screen along with headings for chapters and sections. The There are a few ways of adding small breaks in the
document is one long page while you’re working on it and you don’t text that aren’t significant enough to justify creating a
even have to work in the same font as the output document. If your new chapter by adding a separator. The simplest of
book has a lot of graphics and sophisticated layouts consider the
desktop-publishing program Scribus (www.scribus.net).

LyX is a great
application that
combines the
benefits of a text
editor, a markup
front end, and a
When you insert a footnote, Writer adds a small number at the cursor
word processor.
position. At the bottom of the page, you can edit the footnote.

70 LXF287 April 2022 www.linuxformat.com


Publishing ebooks TUTORIALS

a PDF) and another file for the cover (usually as a PNG).


As we mentioned last month, the exact dimensions of
the cover vary according to the number of pages in the
book. The Lulu website includes a number of complete
guides that explain all of the specifications (www.lulu.
com/publishing-toolkit).
Amazon is probably the best-known online
bookseller. If you upload the files needed to make a
Kindle-compatible ebook, you can also produce a print
edition from the same files. It’s easy to then make both
editions available on Amazon itself. To get started, you
need an Amazon account and you have to create a sign-
in on the https://kdp.amazon.com site as well. As for
the file specifications, you’ll be glad to know that the
We gave this side box a light grey background, a black border and a guides hosted on the site itself are excellent. Click Help
drop shadow, and made the text flow around it. in the top right corner to begin.
Smashwords (www.smashwords.com) is a publisher
these is a simple horizontal line break, and this can that focuses on selling ebooks. You can sell on the site,
be added by selecting Insert>Horizontal Line. A neat- and Smashwords can make the book available to other
looking double line is the default style, but if you want to services such as Apple Books and Barnes and Noble.
change the look of it, click it and edit the Line style in Broadly speaking, we felt that Lulu is the best service
the Styles>Edit Styles...>Border dialog. This will change for quick and simple publishing of small runs or one-off
all instances of line breaks in the document. book printouts. Amazon has the biggest marketplace
and gives you the best chance of selling some copies.
Publishing services You can also send your own book as a gift to an address
There are two ways of handling the printing of a self- different from your own. Smashwords is the most
published book. You can order a print run or you can use streamlined if you want to distribute fiction ebooks.
POD (Print On Demand). As you can imagine, the cost of There are a lot of romantic books on the site, but
individual books goes down if you order a long print run. perhaps it’s time we had a smash-hit romance novel
If you know you’re going to need a large run then it’s involving Linux in some way. Love in the Time of Unix?
worth doing what you can to bring the price of each Fifty Shades of Green: A Linux Mint Romance?
individual book down. We’ve noticed in the past that the We’ve focused on a novel-type of book with some
companies which specialise in large runs tend to be a illustrations, but of course there are many other types of
bit more finicky about the exact specifications of your publication. Picture books full of colour pages make a
files than most of the POD companies. In addition, they great present for the family or clubs and associations,
often charge a setup fee. but they tend to be rather expensive, often topping the
POD is a more flexible way of working, whereby each £10 mark per copy. A year book is a common type of
book is printed, bound and posted as it’s needed. The project that benefits from colour printing. Hopefully,
only problem is that the cost of each book is slightly we’ve given you the tools to create a book, add
higher. However, it’s not massively expensive and a illustrations and other elements, output the files
typical novel-type book with some monochrome and upload those files to a service that can distribute
illustrations of around a 120 pages should cost less than either the ebook or a print edition or both. Best of luck
£4 per copy using a typical POD service. Both of the with your creation.
POD services we’re looking at here have no setup fees.
Lulu (www.lulu.com) is one of the easiest book
publishing services to use, and it caters for print
and ebook projects. Once you’ve created an account,
there are very few obligations if you want to start self-
publishing. You can think of it as a remote printing and
binding service. For example, in many cases you could
take a public domain book or a manual and run off a
hardcopy for yourself. You’d then order a single copy
which will arrive at your address a couple of days later.
Lulu also has its own marketplace, but it’s not very
well known compared to some of the other online
booksellers. To sell the book on sites other than Lulu,
you need to add the ISBN number to the back and to
the copyright page.
The procedure for uploading the files that make up
the book is fairly similar for all of the POD services. You Services such as Amazon make it straightforward to publish your own book. The Amazon Kindle
upload a file containing the interior of the book (usually Publishing site contains extensive help and tutorials.

GET MORE AMATEUR PUBLISHINGSubscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 71
TUTORIALS LXF Server

MOODLE
Credit: https://moodle.org

Create your own


virtual classroom
David Rutland moodles along with classroom management software
on the LXF virtual private server and starts his own online course.

ducation, education, education. If you were

E around in 1997, you probably remember the


then soon-to-be Prime Minister, Tony Blair’s
top three priorities for his first term in office.
Education is important. Developing young minds to
OUR be skilled in English, maths and the sciences means that
as the current crop of youngsters grows to adulthood,
EXPERT you’ll be able to have informed and valuable
David Rutland conversations with them, civilisation will move forward
believes it’s propelled by their sharp intellects, and maybe they’ll
impossible for a even find a cure for our own rapidly ageing frames
person to be before it’s too late.
either be For seemingly endless chunks of the past two years,
overdressed or schools were closed, and pupils of all ages were forced Viewing a user profile while in an admin role gives you plenty of insight
overeducated. to share stifled living space with furloughed parents and into student progress, grades, badges and more.
People who know siblings for 23 hours every day. (I quite enjoyed it–ED)
him agree that he Learning was remote, with video links, virtual learning Few schools have competent IT departments these
is neither. spaces, YouTube video lecture sessions, and of course, days, and most take the view that it’s infinitely easier to
Google classroom. subscribe to a service such as Google Classroom than
to maintain their own education and learning platform.
Google Classrooms Ignoring – in addition to privacy-related problems – the
The choice of Google Classroom was a natural one for unfortunate fact that Google has an addiction to killing
many schools. It enables teachers to manage multiple off its own services on a near-monthly basis.
classes at once, juggle their timetables, and mark We don’t know how many teachers are among the
work directly within the browser. Even better, the Linux Format readership, although we suspect there are
fundamentals package is completely free. It’s ideal more than a few school IT specialists. Online learning
for schools on a budget. platforms aren’t limited to schools, and if you have a
The downsides are equally obvious. Educators are particular hobby in which you consider yourself an
introducing children to a predatory, data-slurping expert, there’s nothing to prevent you from creating a
megacorp at an early age, and by integrating its tools course – or even an entire online school, and
into the educational environment, teaching them that administering it from the comfort of your very own VPS
yes, big tech is their friend. (virtual private server). Figure you know more about
extreme couponing, frog dissection or dirt polishing?
Here’s your opportunity to share that knowledge with
Read our the world in a structured and accountable way.
original VPS
features in Get in the Moodle
LXF281 and Moodle is a free, online learning management system,
LXF282 at which enables you to create your own courses, track
https://bit.ly/ progress, hand out and mark assignments, and carry
lxf281lxfserver out the kind of administration you hazily remember
and https:// your primary school teacher performing, bleary-eyed on
bit.ly/
a Monday morning in 1985. Moodle is FOSS, naturally,
lxf282lxfserver,
There are hundred of plugins available for Moodle, providing practically and was adopted by universities in the days before
respectively.
everything you could want in a virtual classroom. Google Classroom was even a glint in Larry Page’s eye.

72 LXF287 April 2022 www.linuxformat.com


LXF Server TUTORIALS

If you’ve been following our VPS series from the


start, you will already have the prerequisites set up,
including a domain name along with a bunch of
subdomains, a database, git, and server software such
as Apache. If you’re joining us now, see the Top Tip box
(bottom left) on how to get going.

Installing Moodle
First up, create a new and distinctive subdomain for
your Moodle instance (We chose moodle.lxf.by, because
at this point, we’re pretty much out of clever ideas and
puns), and set a new A record with your registrar’s
DNS to point the new subdomain towards the IP
address of the VPS. You can check that the DNS
changes have propagated using the handy tool at
https://dnschecker.org. Moodle chatrooms are surprisingly good. You can add as many as them as you like – even if you
Once all the ticks are green, ssh into your VPS with are the only participant.
ssh your_name@your.vps.ip.address . Make sure that
you update and upgrade the system with sudo apt GRANT USAGE ON *.* TO moodle@localhost
update and sudo apt upgrade – this is especially IDENTIFIED BY ‘donna29mylove’;
necessary if this is the first time you’ve used your VPS. GRANT ALL privileges ON moodle.* TO moodle@ If you choose to
Now clone the Moodle git repository into your home localhost; set up multiple
directory and switch to the stable branch: FLUSH PRIVILEGES; chatrooms for
git clone -b MOODLE_310_STABLE git://git.moodle. quit; students, make
org/moodle.git Of course, your actual password should be sure that you
Then copy the newly created moodle directory and something other than ‘secretpassword’. Make a complex pay attention
its contents to your webserver directory: one and make a note of it somewhere. to what’s going
on in them.
sudo cp -R moodle /var/www/html/ You’ll need to make sure that when you type in
Bullying isn’t
Next, set the permissions so that any user can read, the URL of your Moodle instance, your Apache server limited to the
write and execute from the directory. knows how to handle the requests, so create a new conf playground, and
sudo chmod -R 0777 /var/www/html/moodle file for Apache. students might
If there’s now a security alarm whooping in your sudo nano /etc/apache2/sites-available/moodle.conf find it useful to
brain, don’t worry too much. You’ll be restricting the In this empty file enter: message their
permissions later on. <VirtualHost *:80> tutor in a less-
Moodle needs a data directory that’s situated ServerName your.domain.or.subdomain.tld formal forum.
outside the webserver directory, but with permissions DocumentRoot /var/www/moodle/
so that the web server user can write to it. Your home </VirtualHost>
directory is as good a place as any, so create the Save and exit nano with Ctrl+o then Ctrl+x. Enable
directory as follows: the new site with
mkdir moodledata. sudo a2ensite moodle.conf
Then change ownership to the web server: And restart Apache
sudo chown -R www-data:www-data moodledata/ sudo service apache2 restart
At this point, you will need to create a database with Lastly (at least for this section of the tutorial), deploy
UTF8 encoding, so sudo mariadb then: SSL certs to protect and reassure your future students.
CREATE DATABASE moodle DEFAULT CHARACTER sudo certbot
SET utf8mb4 COLLATE utf8mb4_unicode_ci; And make sure you select the option to redirect all
Enter each of these commands, which will create request to secure HTTPS access.
a user called moodle and enable it to use your new
moodle database: Moodling through the configuration
CREATE USER moodle IDENTIFIED BY While it’s possible to continue configuring Moodle
‘secretpassword’; through the terminal, the developers have created a

OFFICE TOOLS
It’s tempting to use ‘free’ external better protected if you keep them within Likewise, students (and most of the
resources to augment your class, but your Moodle walled garden. There world) may already be used to Google
almost everything that you could possibly are several plugins that enable this kind Docs. While the Moodle base install does
need is either available through the initial of functionality and either make it enable students to type directly into a
Moodle install or through the plug-ins. possible for you to stream multimedia webpage, it can be expanded to a full
Yes, it’s easy to tell students to watch from within Moodle itself, or integrate online office suite by using plugins to
videos you upload to YouTube or other with wholly hosted or self-hosted integrate with self hosted-office suites,
video hosting sites, but their privacy is solutions elsewhere. including OnlyOffice or LibreOffice.

www.techradar.com/pro/linux April 2022 LXF287 73


TUTORIALS LXF Server

rather nice web-based wizard to do the job for you. It


seems a shame to let it go unused.
Why not imitate Visit the site, and you’ll be redirected to your.domain.
the current or.subdomain.tld/install.php. Select the default
UK higher language, and click through to the next screen where
education you’ll be asked to confirm the web address, the moodle
system and directory (in our case this is /var/www/html/moodle),
make money
and the data directory. If you followed our instructions,
from your
moodledata should be in your home directory. Navigate
students.
Plugins exist to there in the terminal and type pwd to get the full path.
integrate your On the LXF VPS, this is /home/david/moodledata.
Moodle site Select your database type from a list, and click
with payment through to the next screen where you’ll be asked for the
platforms. If database details. These are fairly straightforward. The Selecting an activity to add to a course is as simple as picking one from
you’re truly with database host is localhost; both the database name and a ready-made menu.
the zeitgeist the database user are moodle. The password is what
of the 21st you wrote down earlier. Leave the prefix as it is, and the accounts themselves. As the documentation states,
century, you can
final two fields empty. allowing self-registration increases the probability of
even employ a
After confirming that you accept the terms of the spammers creating accounts in order to use forum
Bitcoin payment
gateway. GPL, Moodle will check that you have all of the required posts and blog entries for spam.
php extensions installed. After this, you have the opportunity to register your
If there any missing, take a note of them, head back site with Moodle. This comes with a few benefits such
over to the terminal and install. The wizard told us we as your site appearing in the Moodle sites directory, and
were missing the gd, intl, xmlrpc, and soap extensions. more importantly, enables your students to receive
We were able to install them in a few seconds by push notifications through the official Moodle app. You
inputting the following: don’t need to register the site, but push notifications are
sudo apt install php7.4-gd php7.4-intl php7.4-xmlrpc a useful tool. It’s up to you.
php7.4-soap The actual configuration is now completed, so jump
and restarting Apache once again. into a terminal and type:
Once the Moodle wizard detects that your server sudo chmod -R 0755 /var/www/html/moodle
environment meets all minimum requirements, a This permission change mean that any user can now
continue button will appear. Click it and after a few read and execute code from the Moodle directory, but
minutes a long HTML page will be generated, listing only the owner – in this case the root user – can write
components and hopefully, with a green success box to it.
after each one. Skim to the bottom, hit Continue again Finally, set up a cronjob as the www-data user:
and create your main administrator account. Only the sudo crontab -u www-data -e
fields with a red exclamation mark are required, so you and add the following to run a script every minute:
can save some time by leaving everything else blank. * * * * * /usr/bin/php /var/www/html/moodle/admin/
You’ll be given the option of setting up your tuition cli/cron.php
site’s front page with basic details such as a name, a
summary, and whether or not users can register Creating courses
Moodle is all about managing learning, and if you’re still
with us this far through the tutorial, then it’s likely that
MOBILE MOODLING you have something you want to teach.
When you log in for the first time, the site is bare.
In a physical school, students are limited to a group of buildings. But You’re presented with an empty dashboard, empty
with distance learning, they could be physically anywhere. While you course overview, and an empty calendar. You’ll see
may hope your bright young minds are sitting quietly in a that there’s one online user – you. Before you start
soundproofed room with good lighting and plenty of stationery, it’s far advertising your virtual wares on Gumtree, you want
more likely they’re hanging around street corners with the other to create some basic courses.
yoofs. Fortunately, teenagers today are almost guaranteed to have a On the left side of the interface, click Site
phone on them at all times – so that they can upload videos or their Administration and then the Courses tab. There are a
delinquency to the ‘tok. range of course-related activities, and the one you want
Moodle has mobile apps for both iPhone and Android, so you can is Add A New Course.
push out assignments, grades and notifications, even as the little There’s a lot to fill in here, and the options can be
blighters spray their tags in the alley behind the Co-Op. expanded and hidden using a series of accordions.
With the app installed, students can contact their course-mates, Apart from the General and Description fields – which
browse course content, see their grades, and upload a range of tell potential students what your course is called, what
attachments. There’s no excuse for not turning in assignments or it’s about, and which enables you to set an eye-catching
responding to urgent messages from course staff. As a course leader, logo for your course – it’s best to leave the rest alone
you’ll have access to the same information you have in your browser. for now.
While the official mobile app available on the relevant app stores, it Choosing Save and Continue makes it possible for
can’t be found on F-Droid. you to add students to the course, and because you
don’t yet have any, proceed to Course Content.

74 LXF287 April 2022 www.linuxformat.com


LXF Server TUTORIALS

Your course is also bereft of content at this point, students can access chats from
but what you do have is a new menu on the left-hand previous days, and who’s allowed in.
side, which shows the name of your course, and has You’ll soon discover that whatever
submenus showing participants, badges, competencies, activities you want to add are simple
grades and four topic folders. This is the default that and easy to set up.
was set up during the Add course stage. In the event that Moodle’s built-in
On the right-hand side, below the gear icon, press activities aren’t enough for you,
‘Turn editing on’ to see more options appear for each take a look at the many plug-ins
section. As with many academic activities, the obvious that are available for download at
choice is the correct one and so click Add an activity https://moodle.org/plugins.
or resource.
A pop-up will appear, showing the types of resources Managing students
and activities that can be added. There are forums, You now have a course set up to
surveys and quizzes, books, assignments, labels, your satisfaction, and in all honesty,
lessons, and many more. it’s probably a lot better than ours,
which was set up in a few hours. If
A suitable textbook you allowed students to self enrol
As the bulk of our education took place in the 1990s, via email then congratulations – you
we thought that it appropriate to give our students an now have a virtual class full of bots
out-of-date science text – choosing The Sceptical that are busy spamming the
Chymist by Robert Boyle – available from the archive at chatroom with exhortations to
Project Gutenberg (gutenberg.org/ebooks/22914). try Viagra on the cheap, Cialis,
The book name and description need to be added buckets full of sketchy nootropics,
manually, as do the individual chapters. Text and and hot singles people in your area just waiting to meet Mobile apps for
images can be pasted in using an interface which will you. The usual suspects, then. Moodle mean that
your students are
be intuitive to anyone who has used WordPress. You To add students manually, head back to Site
never more than a
can choose whether your students can mark it as Administration, then users, and Add User. Once again, push notification
complete by themselves. you’ll be invited to create a skeleton profile for them. away from the
Next, we considered that a quick quiz might be Once this is done, they can easily be enrolled on to virtual classroom.
appropriate – to discover whether our pupils found the courses. Clicking a student’s profile in the administrator
choice of a 17th century natural philosophy textbook role grants complete access to their information. If you
germane to a 21st century education. need to know how often they look at the course
Selecting Add an activity or resource from within material, their grades, or what their IP address is, this
topic 2 we were again invited to give a title and is the place to do it. You can even log in as them –
description for our quiz, then configure further options which is a level of functionality we don’t think even
including time limits, submission dates, layout, grading Google provides.
and question behaviour. Clicking the quiz title while still As well as monitoring individual students, from site
in editing mode enables you to set individual questions administration, you can set the theme, change grade
and the appropriate answers. boundaries for automatic marking, view the histories
For topic 3, we created a chatroom for students to of students, grades, courses and classes, and almost
discuss their thoughts on The Sceptical Chymist by anything else you could do in a real school environment
Robert Boyle. By this point you should find the creation – short of carving obscene stickmen into the top of a Badges can be
of course activities starting to become second nature. wooden desk, that is. an inspiration
There are the title and description fields again, along to pupils, and
awarding them
with when the chat room will be active, whether or not A+ for Moodle for random
Yes, we know the national curriculum has moved away achievements
from the old-style alphabet grade system and on to a can keep
1–9(+?–ED) model, but this is our school, and we’re students
giving Moodle an A+. motivated and
Moodle, which we bet you didn’t know was an coming back
acronym for Modular Object-Oriented Dynamic for more – even
Learning Environment, has been knocking around if their initial
since 1999, and has been honed and refined to the motivation has
point where it’s functionally perfect and almost faded. It works
for Duolingo and
infinitely adaptable.
it can work for
It has everything you need to manage online classes
you, too. You
whether you’re a traditional learning environment or you can create your
just fancy starting up a theoretical wickerwork own badges
workshop for fun. And remember: those that can, do. using the
If you’ve used WordPress or any other CMS, you should be almost Those that can’t... edit magazines (and fire troublesome Open Badge
instantly at home with Moodle. contributors – Ed). Factory plugin.

LEARN THE MEANING OF SUFFERINGSubscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 75
IN-DEPTH Charitable characters

CHARITABLE
CHARACTERS
A map showing the 29
computer rooms YovoTogo
has set up across Togo.

CREDIT: YovoTogo, JUMP Lab’Orione and Emmabuntüs

The Emmabuntüs collective enlightens Jonni Bidwell


as to its kind and open source efforts.

ltruism and open source You might think that hacking on your world. Both locally, to the Emmaüs

A often go hand in hand.


Through our recent coverage
of Perl (see LXF276) we’ve
favourite project is probably not going to
save the world. But then that all depends
on the project.
communities in France, and through
partnership with other organisations, as
far afield as Kathmandu, the Ivory Coast
seen that the idea of helping others Back in 2016 (see LXF216), we featured and Benin. Nearly six years on and
was intrinsic to both the language’s Emmabuntüs, a French collective that Emmabuntüs is still at it. The only thing
(and the community’s) development. combined the power of Linux with the that’s changed is that the distribution is
More generally, anyone who gives their charitable efforts of a hardware recycling now based on Debian.
time and expertise to an open source cadre. Back then it was putting its bespoke The collective’s latest initiative is
project, whether it’s through code, spin of Ubuntu (also called Emmabuntüs) a customised USB image for mass
translation, documentation or polite on donated and refurbished computers, repurposing of machines. Thanks to some
bug reports, is helping that project. and sending those machines out into the canny scripting, this makes doing this at

76 LXF287 April 2022 www.linuxformat.com


Charitable characters IN-DEPTH

I visited in France, not all of them do computer recycling,


because they lack the required skills or staffing.
Sometimes our volunteers can help with that. For
example, Yves in the Emmaüs premises of Dijon
has been refurbishing computers with Emmabuntüs
since I first met him.”
However, the work isn’t over when a machine is sold.
Indeed, sometimes machines aren’t sold at all. “If we
take this example, the computers refurbished by Yves
are sold by Emmaüs, and he takes care of the technical
CREDIT: YovoTogo

part, the sale and the after-sales. On the other hand,


sometimes computers are donated in the name of our
collective in Dijon. In this case the donor doesn’t want
us to sell them, so we give these computers to people
recommended by Emmaüs.”
Claude and Patrick from the collective hard at work refurbishing boxes. You can read more about Yves’ journey at https://
emmabuntus.org/yves-the-journey-of-a-humanist. We
scale much less time-consuming. Join us as we find out should note that the Emmabuntüs collective, while
more about that and all the other great work the strongly aligned with Emmaüs values, isn’t officially
Emmabuntüs Collective do. allied with the movement. Collectif Emmabuntüs’ goal –
“to help associations in their transition to a more ethical
Origin story digital world through refurbishing under GNU/Linux” –
The name Emmabuntüs comes from the international is nonetheless something we can all get behind. It’s
Emmaüs movement (see www.emmaus-international. been doing that since 2012, and the collective has
org), which is focused on tackling homelessness and joined forces with other organisations across the globe
poverty; and Ubuntu, which the distro was originally to further its goal.
based on. There are Emmaus charity shops in the UK, In our previous feature we mentioned some of these,
but the movement began in France. including YovoTogo (https://yovotogo.fr) and JUMP
Patrick from the Emmabuntüs collective explains: Lab’Orione (https://jump-lab-orione.tg). Both of these
“The Emmaüs movement is a secular movement that organisations help set up computer rooms in colleges,
was created by the French priest Abbé Pierre, a former lyceums and community centres. Emmabuntüs
resistance fighter and former member of parliament, to provided technical support as well as financial aid of
help the poor and homeless people notably during the 12,000 euros (via the Lilo search engine, the default
1954 great cold wave. Emmabuntüs search engine), enabling the opening of
“If your readers are not familiar with his efforts, we new computer rooms in the Savannah and Kara regions
encourage you to watch the beautiful film on the early (see map, left). This brings the total number of computer
days of the movement, Hiver 54, l’abbé Pierre. In 1963, rooms in the region to 29, and the total number of
the movement became international, and there are now computers to 765. Collectively, this gives some training
more than 350 groups around the world. They all adhere to around 25,000 children each year.
to a universal manifesto, adopted in 1969, and share a Last time we also mentioned the Africa-wide Jerry
common goal: to serve before oneself who is less happy project (www.youandjerrycan.org), which is an effort to
than oneself.” build and distribute cheap computers built inside a jerry
So how does repurposing salvaged computers fit can. The Jerry project and Emmabuntüs have been
with the Emmaüs ethos? In the collective’s own words: collaborating for a decade. JerryClan Ivory Coast has
“Recycling in general is an essential activity of the since adopted Emmabuntüs as its reference distro.
Emmaüs communities, and that’s how they make their JerryClans also exist in Chad, Benin and Senegal.
living in France. I’m not sure if it’s the same in other Closer to home, the collective have also assisted
countries. On the other hand, in the communities other organisations in France, including Les Bricos du

DANCE WITH THE DEBIAN


When we last talked to Emmabuntüs, Facile project. “We’d already collaborated Emmabuntus/
the distro was based on Ubuntu. But with DF-Linux (thanks to Yves from our emmabuntus_de_5
Canonical had just announced its plan to collective) for the English version of their for more about
wind down support for 32-bit systems. Debian Beginner’s Handbook.” Emmabuntüs DE5.
This was back in 2016 (remember, “With Arpinux’s help and inspired by The latest release sees
Ubuntu 16.10 was the first 64-bit only the HandyLinux scripts, using the Live- the venerable (but no
release), but the collective was already Build tool, the migration was not too longer really supported) LXDE desktop
planning its migration to Debian 8 hard. Actually it went very well, and since replaced with not one but two offerings:
(Jessie). Never short of knowledgeable then we already released four versions LXQt and Xfce. Such was the success
friends, it teamed up with Arpinux under Debian, and have started to work of this change during testing that it
(a developer of the now-defunct on the future version 12 of Debian was incorporated into the then-stable
HandyLinux distro) as well as the Debian Bookworm”. See https://framagit.org/ Emmabuntüs DE3, with good results.

www.techradar.com/pro/linux April 2022 LXF287 77


IN-DEPTH Charitable characters

Coeur (https://bricosducoeur.org), GiveIT, the cultural charitable repairs and education, see https://
social centers of Couëron and LinuxAzur (a group therestartproject.org) but we haven’t managed to make
advocating free software on the Côte d’Azur, see www. contact… maybe your interview will help us in this
linux-azur.org). Then over in Belgium it’s been working matter.” We sure hope so, and we’d also encourage any
with Amaury from the BlablaLinux (https://blablalinux. fixit-minded readers in the UK to donate their skills to
be) and his open source efforts. Restart and others like them.
As we write, final preparations are underway Collectif Emmabuntüs receives its hardware from a
for the 2022 Jerry Valentin event in Abidjan (https:// few different sources. YovoTogo ships equipment
jerryvalentin.org). We don’t know how that’ll go this donated by Lycée Notre Dame du Roc (www.lycee-
year, but last year’s saw further collaboration between ndduroc.com) and refurbished by Emmabuntüs.
Jerry, Emmabuntüs and the Montpel’libre group That college, like many others, regularly updates its
(https://bit.ly/lxf287dragon). hardware pool. Students constantly needing new
One major obstacle to helping the JerryClans and machines might be seen as a waste of resources, or at
associated efforts (such as Jerry Do-It-Together, times “technological overkill” in the collective’s words.
https://makingsociety.com/2013/07/jerry-do-it- Yet this provides a constant stream of computers for
together-server-connects-makers-africa/) is the cost donation. “It’s just a bargain!”, the collective tells us.
and logistical effort involved in shipping hardware. There “Mickaël and Claude from YovoTogo erase the BIOS
aren’t many (if any) associations that offer charitable passwords, disable the UEFI, and clone these machines
The opening of shipping from France to Africa. So it’s difficult for with Emmabuntüs Debian Edition Free Culture server.”
the Pogno College generously donated or refurbished hardware to get This is a spin of its distribution showcasing libre culture.
computer room there. And easier to help those closer to home. These computers can then be used offline as training
in Togo. Students
all poised to open
Asked if the collective had any plans to start tools in high schools across Togo. You can read more
terminals and operating in the UK, a spokesperson replied, “We’d like about the free culture edition at https://bit.ly/lxf287-
get hacking. to collaborate with The Restart Project (which offers free-culture-edition.

Making the best of donations


Sometimes hardware donations come from larger
companies, for example this is where laptops are usually
sourced. These sort of bulk donations often entail more
work – “parts are often missing, thermal paste must be
changed, more RAM or a new hard disk is needed” – but
this is standard fare for the collective.
As we know from our growing collection of old kit at
LXF Towers though, nothing lasts forever and sooner or
CREDIT: JUMP Lab’Orione

later things start to fail. It’s the same thing for the
collective, but it strives to make use of all that can be
made use of. “If a computer exhibits intermittent
hardware problems, we cannibalise it to repair others,
because we often get computers of the same type, and
we are not in the situation as a private individual who
wants to extend the life of their own equipment.”

AUTOMATIC FOR THE PEOPLE


The first stage of the campaign saw (http://liveusb.info/dotclear). Clonezilla org/how-to-make-an-emmabuntus-
the introduction of the ‘manual’ USB has a scripting mode, but this wasn’t refurbishing-key-with-ventoy). And
key using Clonezilla. However, the quite enough for the refurbishment once you have that you can mass-
collective soon saw there was room for teams, who have to contend with volatile recondition machines about as fast as
improvement: “Clonezilla is a cool tool. It device labels and different storage physically possible. And of course you
has lots of settings though, and you have configurations. So using MultiSystem, a can then clone the USB itself. Many
to navigate through about 20 different USB stick is partitioned with a number USBs make light work.
screens before the cloning operation of clone images and can cater to both
starts.” This can be complicated for BIOS and UEFI systems. It can even
beginners and also prone to errors, configure swap, which isn’t possible
“especially when you’re on your 10th with Clonezilla alone.
refurbishment of the morning,” add the The final evolution is the fully
collective. “Getting through this initial automatic key, which instead uses the
CREDIT: BlablaLinux

part takes about two minutes, then the cross-platform Ventoy (featured in our
actual cloning process only takes last issue). All that’s required is to set up
between two and 10 minutes, depending the partitions, then copy across some Amaury from Blabla
on the machine”. scripts and clones. As you’d expect Linux finds a new
The next stage was the ‘semi- there’s no shortage of tutorials on how home for a good-as-
new PC in Belgium.
automatic’ key that used MultiSystem to make one (see https://emmabuntus.

78 LXF287 April 2022 www.linuxformat.com


Charitable characters IN-DEPTH

Very occasionally, but inevitably, some machines It appears from


received by Emmabuntüs are DOA. Again, the attitude is the stacks of cases
visible that Mikael
very much a positive one in this case. “We cannibalise it from YovoTogo has
also to repair others, because for the computer industry his work cut out
this hardware was doomed to end up in landfill anyway. for him.
But this situation is very rare, because we usually
receive computers from high schools or from

CREDIT: YovoTogo
corporations which are buying from big brands like HP,
Dell or IBM. Those components are very reliable, which
is less true with those sold to individuals.”
The minimum system requirements for Emmabuntüs
Debian Edition 4 are 1GB of RAM and 80GB of disk
space. No doubt some readers will be keen to tell us
Linux can work on even more constrained hardware. The USB re-use campaign began in earnest in August
Be that as it may, Xfce and LXQt (the two desktop 2020 and also featured BlablaLinux (mentioned above)
environments featured on Emmabuntüs) both work and Tugaleres.com (a generalist site promoting Linux,
well with this amount of memory, and if people want environmentalism and more). The goal was to “federate
the machines to be useful offline, then a modicum of initiatives for reuse in order to provide Linux computers
storage will surely help. free of charge, or at low cost, to poor people, schools,
The first edition (based on Ubuntu 10.04) could etc.” Team Emmabuntüs is more than adept at getting
run on 256MB machines, but that was a long time ago. its distro on to PCs, having been at this game for some
As the collective explains: “Within the frame of our time. But no matter how quick you are with a mouse, if
collaborations with YovoTogo, JUMP or others we advise you have to install an OS manually on dozens of
them to use computers that are not too old. Our goal is machines, it’ll take a lot of time.
not to make feats by reviving very old computers, but Besides helping with the scripting, and creating a
rather to refurbish computers having the longest life series of videos about the key (see https://bit.ly/
expectancy, especially those sent to Africa.” The lxf287-youtube-usb-key) Amaury from BlablaLinux has
collective, and the organisations it partners with,

DEALING WITH DONATED KIT


share a common goal: “To reuse these systems to
train the youth of these countries and to open them

“Parts are often missing, thermal


up to a free and ethical digital world.”
Many of these machines end up in classrooms where

paste must be changed, more RAM


there often isn’t even a reliable power connection, let
alone reliable internet connectivity. Indeed some

or a new hard disk is needed.”


schools didn’t even have a connection to the electrical
grid until they got their computer rooms appropriately
kitted out. And now, through the power of Linux (and
libre software generally) thousands of students can be also been sourcing the USB keys themselves. These
trained every year. As the collective says, “This is the are sold at cost price (plus shipping) throughout
purpose of our common actions, like in the Emmaüs Belgium and France. Interestingly, since the easier
movement: helping other people.” Ventoy method has been introduced, demand for
Emmabuntüs’ most recent initiative, in partnership these has lessened, presumably because people
with Debian Facile (https://debian-facile.org) is the can easily make their own.
creation of a self-cloning system image that can be We (being numerologists at heart) asked the team
installed to a USB stick, which in turn can be recycled. how much time the fully automatic USB key saved.
Before we explore this, it’s worth talking about Debian Obviating the Clonezilla configuration stages (see box,
Facile (“Easy Debian”). This is a French association that opposite) saves “at least two minutes”, and then using
promotes Linux via meetings, its forum and its Debian Ventoy (which automatically detects which storage
Beginner’s Handbook (see https://lescahiersdudebutant. device is which) saves a further 30 seconds. This may
arpinux.org/bullseye-en/index.html). not sound like much, but this is per machine being
imaged. “With this method we take between two and 10
CREDIT: Emmaüs Community of Villers-les-Pots

minutes to recondition a machine, versus the 30 to 45


minutes needed to install an ISO.” We spend a lot of
time installing Linuxes at LXF Towers, and those long
waits for progress bars to move to get rather tedious.
In traditional time measures we estimate the key could
save up to four cups of tea if you have a dozen or so
machines to image. Not bad, not bad. In terms of actual
numbers Mickaël and Claude from YovoTogo achieved a
phenomenal refurbishment of 150 machines in two days
using the new tooling.
That’s the sort of productivity we can only dream
about here at Linux Format. Huge thanks to Yves, Patrick
and the rest of the collective for their help putting this
Yves at the Emmaüs computer booth at Villers les Pots, helping others. feature together.

www.techradar.com/pro/linux April 2022 LXF287 79


The home of technology

techradar.com
THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET

HotPicks
Weather Widget 2 Fancontrol GUI Wine
DaedalOS FreyrJS Chmod-CLI Rescuezilla
Alexander Tolstoy
is back with another fine
collection of open source
tools to make more of your
time at the Linux coal face.

Warble SpaceHuggers Efiboots Ehh

PLASMA EXTENSION

Weather Widget 2
Version: 2.0.4 Find out if it’s
shorts or umbrella
weather, with the
Web: https://github.com/ help of the latest
version of Weather
blackadderkate/weather-widget-2 Widget.

his new Plasma extension is the long-awaited

T update of the original Weather Widget created


by Martin Kotelnik. It used to support two data
providers: Open Weather Map (OWM) and the
Norwegian Meteorological Institute public weather
service (Yr.no). However, that older widget hadn’t been EXPLORE THE WEATHER WIDGET 2 INTERFACE
updated for a while, and over time it dropped support
for Yr.no because it changed the API (and was also
renamed to Met.no). Luckily, the project was revived by
a new developer and came back as Weather Widget 2, 4
with Met.no support restored and several improvements
implemented throughout the interface. The extension is
available at https://store.kde.org and can be quickly
installed for any recent Plasma version.
We’re painfully aware of web articles like ‘Top 5
weather apps for Linux’ that anyone can quickly search
1
5
for using DuckDuckGo. Strangely enough, none of those 2
tools give you a good idea of how temperature and the
elements will change during the next two or three days
at your location. This isn’t the case with Weather Widget
3
2. It’s the only weather program that draws the
temperature and pressure curves on the graph and
then enables you to quickly evaluate the (forecasted)
weather development in your location. Elements such
as rain, snow, wind speed and direction are also there
on the same graph (below the curves).
When placed inside a panel, the widget will appear in
Manage locations matter if your panel is thick or thin, the widget
a compact mode and will display just the temperature 1 Search for your specific location right will always remain readable.
and the sky conditions. Click it to roll down the graph under the OWM or Met.no location dialog, or
provide exact geographical values by hand. Temperature and pressure curves
with all the details. You only need to glance at the
4 Quickly assess and keep in mind how the
expanded screen of Weather Widget 2 to quickly find out
Set up familiar units weather is going to develop for your location.
what the weather will be doing for the next few days. 2 The widget is familiar with either metric No forecast is ever 100 per cent accurate, so
You can add more locations in the widget’s settings. For or Imperial systems and enables you to choose why not add two: one from OWM and another
example, it makes sense to add the same location twice extra details, such as the units for atmospheric from Met.no?
to compare forecasts from OWM & Met.no. You can also pressure and wind speed.
Even more useful data
search for locations right from the Weather Widget 2
Set the display mode for panels 5 Find out the amount of rain, wind speeds
settings screen, and even provide longitude and latitude 3 Weather Widget 2 supports three panel and directions, as well as the more classic-
manually for greater accuracy. modes: horizontal, vertical and compact. No looking weather forecast presented as a table.

www.techradar.com/pro/linux April 2022 LXF287 81


HOTPICKS

SYSTEM TOOL

Fancontrol GUI
Version: 0.8
Web: https://github.com/Maldela/fancontrol-gui

his software will be of use for anyone fond of Right from

T manual fan speed controls. That’s a bit of a


niche subject since in most cases you don’t
the very start,
Fancontrol-GUI
need to intervene and change the default settings. shows the list of
However, configuring cooling fans in a custom-built sensors with
computer enclosure sometimes bears fruit, such as their live values, but even more valuable features can be Creating custom
better cooling performance and noise elimination. found under the Fans section. Fancontrol profiles
is straightforward
In Linux we have the lm_sensors package, which For each Pwmconfig-supported fan the application
thanks to this great
discovers and registers supported thermal sensors, will display a graph with temperature degrees at X and GUI application.
and also provides some extra utilities like pwmconfig the fan’s RPM at Y. You can manually draw the graph’s
for calibrating fans’ voltage and fancontrol for managing shape by moving its two nodes for minimum and
fans’ rotation speeds. All of the above are CLI utilities, maximum RPM values, respectively. Fancontrol-GUI
but it would be nice to have a GUI program for fan places a white dot on the graph to show you the current
management! That’s why we’re featuring Fancontrol-GUI state of the fan, based on the sensor’s reporting.
in this month’s HotPicks. In fact, this is the only general- The whole process is intuitive and easy to break
purpose graphical front-end for Fancontrol that you can down in a minute! That said, you can happily tame your
use without in-depth knowledge of how things work fan and keep it stalled if the temperature is below the
under the hood. designated value. If your system has several fans – say,
The only prerequisite is to have a detected thermal the main CPU fan with some case-mounted airflow fans
sensor supported by the Linux kernel. Some systems – you can use Fancontrol GUI to re-balance airflow
will need to inject extra kernel modules. among fans or fan groups. Make your Linux cool again!

SOFTWARE EMULATOR

Wine
Version: 7.0 Web: www.winehq.org

t’s cork popping time again, pour yourself support for running

I some wine and sit back on a porch swirling the


glass in one hand – though we may have
Windows games
with Wine. Things
missed some details, that’s typically how Linuxoids like the VKD3d 1.2
write about a new Wine release (not around here!–Ed). support from
So we have Wine 7.0, a major release with lots of Direct3D 12 also
improvements both for games and productivity apps. infuse us with hope that Wine is capable of running even Wine’s new theme
Wine is not a type of emulator that you may found more premier Windows game titles than before, and makes Windows
tools feel more
elsewhere in your applications menu. Instead, it’s an also that you may escape commercial Wine-based
native in Linux.
item in the ‘open with’ context menu for .EXE Windows’ solutions like Crossover and stay happy with pure Wine.
binaries, plus the winecfg utility for changing certain There are a load of other highlights that indicate
Wine settings. improved GPU-accelerated media decoding, better
Another notable feature of Wine 7.0 is the new ‘Light’ Vulkan support and as such, but anyway it’s always
theme, which comes bundled with Wine by default. better to try it in real-life scenarios. Don’t forget that
You’ll still need to enable it manually under Desktop Wine is an inclusive emulator that allows running
Integration in winecfg to make Windows apps look Windows binaries on non-x86 hardware, such as
less ‘90s like. Of course, the main changes of this new Raspberry Pi and lots of other ARM-based devices.
release are under the bonnet. To name a few: better Obviously, a low-spec machine won’t chew heavy
HiDPI displays support, better device handling (eg. games, but it will likely deliver fine performance with
joysticks, multiple displays), the re-written Wow64 office and system apps. Lots of people run Wine just for
architecture, various new features in Direct3D 10 and 11. the sake of having their beloved Notepad++ at hand in
It already shows that most changes reflect the maturing Linux, and so can you.

82 LXF287 April 2022 www.linuxformat.com


HOTPICKS

The built-in
DESKTOP ENVIRONMENT ‘browser’ has
bookmarks for
public demo

DaedalOS pages of other


similar projects.

Version: GIT Web: https://github.com/


DustinBrett/daedalOS

he abundance of open source web applications

T means that sooner or later we’ll be seeing


more of them integrated into complex projects.
A good example is WinXP (LXF280), a mock-up of the
older Redmond-made OS run inside a browser. While see what’s available and working. We can import new
that was just an amusing diversion, the idea of having files into DaedalOS from the host system using drag and
a working desktop implemented as a web site is still a drop, or using the ‘Add file’ item in the context menu.
good idea. There are some viewers and editors for working with
The DaedalOS project is an effort to create a web- text documents, viewing images and PDF files, watching
based desktop environment and make it usable for videos, playing games, and browsing the web.
daily computing. Running your own copy of that The world of DaedalOS integrates many other open
desktop is easy because it involves just three source programs, such as Js-DOS, BoxedWine, the web
commands ( $ yarn && yarn build:fs && yarn dev ) implementation of the SDL library and even the Space
before you can start using your local DaedalOS instance Cadet Pinball game (LXF283). The inclusion of the web-
at http://localhost:3000. The web page has been styled based Dosbox and Wine emulators is a short path for
to look like a classic Windows desktop with a bottom DaedalOS to have more applications running natively
panel for the Start menu, tasks and the clock. The (well, almost). Not just office and media accessories,
wallpaper is animated and the desktop itself supports but also games – from JS-Doom to some fanciers titles
icons, enabling you to clutter it with files and folders. loaded via BoxedWine. DaedalOS left an impression of a
So far DaedalOS falls short of key features that a real promising software for organising a real work place, not
desktop environment usually provides, so let’s instead just a cool thing to tell your friends about.

FreyrJS is a
MUSIC DOWNLOADER versatile, service-
agnostic music
downloader

FreyrJS and manager.

Version: 0.2 Web: https://github.com/


miraclx/freyr-js

e have yet another music downloader for you

W here today! However, let’s step away from the


threadbare Youtube-dl and its numerous front-
ends this time, because FreyrJS was made to support
other music services. Be aware that doing so may and wait until FreyrJS delivers the corresponding files.
breach specific service’s terms and conditions of use, The tool supports versatile ways of pointing to a music
that you will have agreed to. The legality of doing so item, but in most cases a standard HTTP sharing link
could vary as per your region’s laws, too. So you know. will suffice. FreyrJS also accepts shorter link variants for
Even if you have a paid subscription to any of the some providers, provided that you know the item’s ID:
alluded to services, you never have access to your $ freyr <service>:track:6elOutcWOeJrjK4en7kY7
tracks as files. That limits your freedom to enjoy your Replace <service> with the service and track with
music library outside of the official vendor-provided artist , provide an artist’s ID and watch FreyrJS
apps. FreyrJS tries to fix this by communicating with download their discography! We tested FreyrJS with
those services’ APIs and fetching the original music files. some of our favourite music and could obtain lots of
All you need is a valid subscription to at least one of the high-quality M4A files (solely for personal use).
services (required for getting the right URLs for the Moreover, FreyrJS has a number of useful features, like
music), and a Linux machine with NodeJS installed and playlists support and batch file downloading mode.
configured. Start by installing FreyrJS: Place your URLs inside a text file and feed it to the tool:
$ npm install -g miraclx/freyr-js $ freyr -i links.txt
Once that’s done just feed this CLI tool with a Nothing beats the feeling of regaining control over
working URL – either for a song, an album, or an artist – music that you’ve paid for!

www.techradar.com/pro/linux April 2022 LXF287 83


HOTPICKS

You can manage


COMMAND-LINE TOOL read, write or
execute flags with
this compact tool.

Chmod-CLI
Version: 0.2 Web: https://github.com/
Mayowa-Ojo/chmod-cli
espite the fact that Linux-based systems are

D user-friendly these days, we still pay special


attention to command-line tools. One of those
is chmod, a decades-old tool for altering access
permissions for file system objects. It hasn’t changed
much since its initial release in 1971, and therefore some permissions for each of the three blocks: Owner, Group
of the younger Linux audience considers it a little and Other. Just leave marks next to the desired labels
difficult to learn. Chmod operates using modes: read, and watch the corresponding Chmod command syntax
write and execute. To further embarrass impressionable update at the bottom of the terminal window. When
young minds, Chmod supports two ways of setting done, hit Ctrl+C to copy the command to the clipboard
permissions: numeric (or octal) and symbolic. and then press q to quit.
Chmod-cli is a Chmod command helper that’s written Chmod-CLI needs the xclip and xsel packages to be
in Go. This tool attempts to find out what changes you installed to manage the clipboard contents. Once that’s
want to commit and then generates the correct Chmod done you can paste that command against any file or
command for it. directory and change their permissions – if you’re
When it’s launched, Chmod-CLI displays a text-based allowed to, of course!
interface with several sections, for Options, Command We think this tool to be of use to those people who
Mode, Path Type and Permissions. Move across find it hard to keep the Chmod syntax in mind. Simple
sections with Tab, tick options with Enter, and navigate commands like chmod +x are easy to remember, but
between items within a section using the arrow keys. those .rwx files may be not – so why not use Chmod-CLI
The Permissions section enables you to define to make your life easier?

A flash drive
BACKUP AND RESTORE TOOL with Rescuezilla
is something
that every Linux

Rescuezilla administrator
should have
within reach.

Version: 2.3.1 Web: https://github.com/


rescuezilla/rescuezilla

escuezilla is one of the few open source tools

R that can be used instead of an enterprise-level


full-system backup solution. If you’ve ever
dealt with tools such as Acronis True Image, then
Rescuezilla will likely meet your needs, too.
The purpose of this tool is to help you back up the A typical usage scenario involves flashing the
entire hard disk with its partition table and its contents Rescuezilla ISO onto a thumb drive using dd or Etcher,
to a safer place, such as an external hard drive or a use it to boot into the live Rescuezilla environment, plug
network destination. The project advertises itself as a in an external hard drive, and then run the Backup
GUI for Clonezilla, the famous and venerable Linux- wizard. Point it at the source disk (choose the entire
based backup tool with a very basic UI. That’s why we device or select partitions), select the destination disk
intentionally use ‘tool’ instead of application since and you’re good to go. Rescuezilla will then create a
Rescuezilla is also a complete standalone boot compressed image of your source disk, which you can
environment, which constitutes of a slimmed-down use to restore your Linux system
Lubuntu version topped with the Rescuezilla GTK GUI. Rescuezilla supports alien backup images, such as
Technically, it’s a tweaked Lubuntu that comes with the ones created by Clonezilla and Redo Rescue, and
some handy utilities you may want to use when even virtual hard drives (VDI, VMDK, VHD). It’s a
recovering a Linux system (such as GParted). However, remarkably versatile backup/restore solution that we’ve
the main point here is that Rescuezilla handles actual used many times without fault. Whether you’re distro-
jobs for backing data up, verifying copies and restoring hopping or preparing for a risky update on a production
disks from such copies. server, you can trust Rescuezilla.

84 LXF287 April 2022 www.linuxformat.com


Games HOTPICKS

There’s no
WORD GUESSING GAME countdown in
Warble – you have
plenty of time for

Warble your guesses!

Version: 1.1.1
Web: https://github.com/avojak/warble
hose unaware of Wordle may think of it as a

T classic pre-internet game, but that would be a


mistake. This is a new word-guessing game
that takes us to a not-so-distant pandemic past, when
Josh Wardle, a software engineer in Brooklyn, created
Wordle for his girlfriend who loved word puzzles such as Meson and Vala, or go along a shorter path and grab
Spelling Bee and the Daily Crossword published in The it as a Flatpak.
New York Times. Warble has three difficulty levels: Easy and Normal
Wordle involves guessing a hidden word within six present a mystery five-letter word, while Hard invites
attempts. It gives you clues by colouring letters in three you to identify a six-letter word. Warble accepts over
ways: green if that’s a correct letter in the correct 5,600 words (we discovered the complete dictionary
position; yellow if it’s correct but should be at a different in words.txt), which are mostly singular and plural
position, and grey if it is an incorrect letter. Sounds nouns. You’re not restrained with anything in the Easy
cool? Hundreds of thousand of people would agree. level, but there are some restrictions for Normal. In
Warble is an open source implementation of the particular, having green or yellow letters means that
game written to further enrich the elementaryOS your next guess should contain them in valid
AppCenter. This means that the game is built around positions (for example, you can’t repeat a wrong
GTK, Vala, Granite and the rest of the usual eOS guess or discard a green letter). That’s not a deal-
software stack. However, the game is available for any breaker for any person with a good English
other Linux flavour you may fancy regardless of how vocabulary anyway, so we encourage you to give
you go about getting it. You can build the sources using Warble a try. Beware: it’s very addictive.

PLATFORMER GAME

SpaceHuggers
Version: 1.0 Web: https://github.com/KilledByAPixel/
SpaceHuggers

ancy playing a time-killing platformer with capture all the

F a footprint as small as 13kb? We have


one! Actually, there’s a competition at
flags. Bad guys
have two ranks: green soldiers and blue commanders. Most of things you
https://js13kgames.com where you can find some The latter possess extra health and are more see are made of
particles, including
decent and playable games crafted to be that small. dangerous. Shoot them all with a chain gun, throw a
rain, snow, blood,
We picked SpaceHuggers, which is a classic side-view grenade, or just roll over them to inflict melee damage. explosions,
platformer that sees you playing a rebel soldier who Grenades cause a large amount of damage and start weapons and water.
needs to eliminate evil guys and their outposts from a fire, so that if you happen to be too close to the
distant planets. Alien terrain, simulated star field in the explosion, you can get burnt. The solution is to use
sky, several suns... everything looks so beautiful despite the roll feature (press X) for brief invulnerability and
being an low-res indie game! putting out fire. Bots don’t roll – they seem to be
SpaceHuggers fits into a single .html file (it’s 17kb, but quite dumb and slow. In contrast, you have more than
shrinks down to 13kb when zipped), so we were anxious enough weapons and re-spawn takes to complete the
to see how many details fits there. Quite a lot as it turns mission, so it all contributes to the game’s appeal.
out! The game drops you into a Lode Runner-like world We were surprised by the smooth and precise
with ladders, mazes and movable objects. character controls, realistic physics (gravity and
Many terrain tiles can be blown either by shooting or explosions, for example) and variegated level
ramming through. SpaceHuggers has an unlimited structures. Of course, those bots could be a little
number of live-generated levels, so if you’re skilled smarter to make the levels harder to complete, but
enough, you can play it forever. In order to complete a we realise that such an improvement would further
level, you’ll need to find and kill all the bad guys, and increase the game’s size.

www.techradar.com/pro/linux April 2022 LXF287 85


HOTPICKS

Efiboots is the only


BOOT MANAGER decent front-end
to efibootmgr.

Efiboots
Version: 1.0 Web: https://github.com/
Elinvention/efiboots

he boot process of an average modern Linux

T UEFI-enabled system isn’t something you need


to manually adjust. However, thanks to Efiboots
we can have a better insight into the internals of a unique number (BootNum, name, a path to the
typical UEFI system running Linux. corresponding EFI loader, and boot parameters).
Efiboots is a graphical interface to efibootmgr, a Efiboots has buttons for changing the order of entries,
command-line utility that enables you to add, delete, setting the default one and adding/removing entries.
sort and alter EFI boot entries from Linux. Normally, Adding a custom EFI boot entry means that you
those entries point to drives with EFI System Partitions can get rid of a separate bootloader (for example,
(ESP), or EFI-compatible boot loaders, such as Grub2- Grub2-efi). Of course, a few other conditions should
efi, Shim or rEFInd. You may want to delete obsolete be satisfied for that, such as you need to have
entries (for example, those left over from previous Linux Secureboot disabled and preferably have only one
distros that you no longer run) or change the boot order Linux OS on your drive. If that’s feasible, then place
using efibootmgr. This is a powerful tool, but it’s also not the copies of the vmlinuz and initrams files
easy to use. Efiboots tries to make it more user-friendly somewhere inside ESP and create your own custom
by offering a convenient GTK3-style graphical front-end. entry in Efiboots. Enter the path to the loader (such as
Grab the source code from GIT, then open a terminal \efi\linux\vmlinuz.efi) and place boot parameters in
window in its directory and run this command: the next field (say, root=/dev/sda2 initrd=/efi/linux/
$ python3 efiboots initrd.img resume=/dev/sda2 splash=silent init=/
The Efiboots window has several columns and sbin/init ). You should then be able to boot your
displays all available boot entries. Each one has a Linux system even faster than before.

Ehh... what was


COMMAND LINE HELPER that command I
used to manually
add network

Ehh routes a few


months ago?

Version: 1.1.0 Web: https://github.com/


lennardv2/ehh

ost Linux users can recall a number of

M commands and configs settings, and the more


they dive into the world of Linux and open
source software, the more things they need to keep
them in mind. That’s especially true for commands we Here’s an example for adding a user to a group:
all use in Linux terminals. These days there are no signs $ usermod -aG (:group) (:user)
of terminal usage declining. Indeed, the opposite is true If you’ll need to recover that command with the
with more new tools available in the CLI mode, from help of Ehh, look up the list of Ehh entries ( $ ehh ),
weather forecasts to image viewing. It would be nice to and then specify the command index in that list (for
have some sort of a sticky note system for shell example, $ ehh 2 ). Ehh will prompt you to provide
commands – like Bash history but more advanced. And the required arguments and then run that command.
so we came across Ehh, a marvellous tool that adds an Sometimes you’ll want to only look up a command
encyclopedic feature to your terminal. stored by Ehh but not run it. If so, then find out the
Ehh helps you to remember those Linux shell command index, and use the $ ehh get <index>
commands that you tend to forget over time, which is template to see the detailed description of that
absolutely normal for rarely used commands that command. The growing dictionary of Ehh commands
system administrators need to employ from time to may soon make it challenging to find out the exact
time. Ehh suggests that while you’re recalling a index of the desired command. Address it by using
command and its syntax, you create an entry for the Ehh’s search feature: $ ehh ls <search string> .
Ehh dictionary ( $ ehh add ), and fill in its description, Ehh will then return all entries that contain your
alias and usage template using a designated syntax. string in their descriptions.

86 LXF287 April 2022 www.linuxformat.com


CODING ACADEMY
CODING ACADEMY

PYTHON
Working with binary
tree data structures
Mihalis Tsoukalos explains how to construct and use binary trees for
faster searches and easier relationships (of the data sort, mind).

he main benefit of using a binary tree or a tree

T in general is that you can quickly find out if an


element is present or not, compared to
performing a linear search. Trees are also good at
modelling relationships and hierarchical data. Let’s
OUR begin by discussing the basics of binary trees before we
EXPERT start implementing binary trees in Python.

Mihalis Get to grips with the basic concepts


Tsoukalos Strictly speaking, a tree is a directed acyclic graph that
is a systems satisfies the following three principles. First, it has a root
engineer and a node that’s the entry point to the tree. Second, every
technical writer. vertex, except the root, has only one entry point. Third, a This figure shows two binary trees: a balanced tree on top and an
You can reach path connects the root with each vertex. A directed unbalanced one. Generally speaking, balanced trees are preferred.
him at www. graph features edges that have a direction associated
mtsoukalos.eu with them. A directed acyclic graph is a directed graph Building a tree is simple. The difficult part is deciding
and @mactsouk. that lacks cycles. what to store in each node. The definition of the node
As already stated, the root of a tree is the first node that’s going to be used in this tutorial is as follows:
of the tree. Each node can be connected to one or more class Node:
nodes depending on the tree type. If each node leads to def __init__(self, val):
one and only one node, then the tree becomes a linked self.data = val
list. A leaf node is a node without any children. Leaves self.left = None
are also called external nodes, whereas a node with at self.right = None
least one child is called an internal node. The current version of node has tree elements
A binary tree is a specific type of tree where (fields) – the data element that holds the actual value
underneath each node there exist at most two more and the left and right elements that hold the pointers to
nodes. ‘At most’ means that it can be connected to one, the children nodes. Although the data element needs a
two or no other node. The depth of a tree, which is also value, the left and right fields can both have the None
called the height of a tree, is defined as the longest path value, when a node is a leaf, or point to only one child.
from the root node to a leaf, whereas the depth of a Usually both left and right fields point to other nodes
node is the number of edges from the node to the root based on the comparison condition (this is how you
node of the tree. specify where a new value is going to be stored). You
If you create two binary trees based on the same set can change the Node definition to suit your needs or
of elements added in a different order, then you’re going your data. What’s important to remember is that Python
to produce two completely different trees. The simplest must be able to compare your data for things to work.
way to do that’s by starting from a different root node. Let’s grow ourselves a binary tree.
So, in general, we don’t know in advance the final shape
of our trees. Building a binary tree
The screenshot (above) shows two sample binary Building a tree is as simple as adding new nodes. Adding
trees. The tree on top is a “good” binary tree because a new node to a tree involves finding out whether that
it’s balanced (the term is going to be explained shortly). value already exists in the tree or not. If not, we need to
The tree on the bottom of the image is not a very “good” create a new node and put that new node in the correct
binary tree. place in the tree. The core functionality for adding nodes

88 LXF287 April 2022 www.linuxformat.com


Binary trees CODING ACADEMY

can be seen in the next code that’s an excerpt from the Here’s the source
code of tree.py,
insertNode() function of tree.py:
which shows how
if root.data > node.data: to create a binary
if root.left is None: tree and how to
root.left = node insert nodes in it.
else: All this is achieved
by the insertNode()
insertNode(root.left, node) function.
elif root.data < node.data:
if root.right is None:
root.right = node
else:
insertNode(root.right, node)
else:
print("Duplicate:”, node.data)
The previous code is for specifying where to put a
new node, if it does not already exist in the binary tree.
The insertNode() function first specifies whether the
current node is going to go on the left or on the right of
the current node that’s being examined. If the required
link is empty (None), then the new node is linked to that
link directly. Otherwise, insertNode() is called
recursively until we find an existing node that has the
desired/required/appropriate link empty – this is where
we’re going to link the current node. Currently, tree.py
generates no output, but this is going to be fixed in the
next section. The screenshot (right) shows the source
code of tree.py. Root node: 13
Going to insert: [13, 11, 0, 3, 16, 14, 9, 19, 15, 12, 18, 10, 17, 2, 4,
Traversing a tree 6, 5, 8, 7, 1] Linked lists
Storing data won’t be much use unless we learn how to 13 11 0 3 2 1 9 4 6 5 8 7 10 12 16 14 15 19 18 17 are popular
traverse a binary tree, which is thankfully an easy task. in computer
Traversing a tree is fundamental for two tasks: counting Searching tree elements science
the height of a binary tree and finding whether a binary Searching for a tree node is similar to adding a node to because of
tree is balanced or not. The logic of traverse.py can be a tree. The only difference is that if we find the desired their simplicity,
found in the implementation of the traverse() function: element the process ends immediately. The logic of versatility and
ease of use.
def traverse(root): search.py is found in a modified version of the
However, their
if not root: insertNode() function found in both tree.py and
linear search
return traverse.py – the name of the new function is search() . time isn’t
print(root.data, end=” “) Using search.py generates the following output: efficient when
traverse(root.left) $ ./search.py 20 2 we have lots
traverse(root.right) Going to insert: [8, 9, 4, 11, 14, 3, 13, 5, 2, 19, 12, 6, 0, 10, 1, 15, of nodes.
The traverse() function operates recursively, which is a 7, 16, 18, 17]
common practice when working with trees of any kind. Found 2
This function prints the value of the current node, which $ code ./search.py 20 21
is passed as a parameter to traverse() , before visiting Going to insert: [6, 9, 15, 1, 7, 5, 8, 16, 19, 13, 2, 18, 10, 3, 17, 12,
the left and right links of the current node, using 4, 11, 0, 14]
traverse(root.left) and traverse(root.right) , Not found 21
respectively. Running traverse.py generates the In the first program execution, the desired value (2)
following output: was found in the tree whereas in the second case, the
$ ./traverse.py 20 value (21) wasn’t found. Being able to search a tree is

MAKING SENSE OF HASH TABLES


A hash table is a data structure that should produce a uniform distribution of The values found in each bucket are
stores one or more key and value pairs. It the hash values. usually connected using a linked list. This
can store keys of any type and uses a On a hash table with k buckets, the means that after going to the desired
hash function to compute an index into search time is O(n/k) where n is the bucket, we need to search a linked list
an array of buckets or slots, from which a number of keys and k is the size of the sequentially. Additionally, hash tables are
value can be found. Ideally, the hash hash array. Although the improvement not particularly good at keeping data
function will assign each key to a unique looks insignificant, you should realise that sorted. As such, it’s not efficient to use a
bucket. Unfortunately, this rarely for a hash array with 20 buckets, the hash table if you want your data sorted.
happens. Therefore, the most crucial search time is now 20 times smaller than In that case you might use either a linked
feature of the hash function is that it when performing a serial search. list or a tree.

www.techradar.com/pro/linux April 2022 LXF287 89


CODING ACADEMY Binary trees

fundamental – after all, the main reason for


constructing a binary tree is to be able to search it.
There’s no
point in sorting Deleting elements
a binary tree As we’re going to find out, deleting an element from a
because trees tree isn’t always easy because of how trees are
are sorted by constructed. Therefore, deleting a node from a tree is a
default in their
relatively difficult task, especially when you compare it
own way. This
special sorting
with deleting a node from a linked list. In the rare
depends on the instance when the node you want to delete is a leaf, the
way new nodes task is simple. Bear in mind that before deleting a node,
are inserted we should first search for it. This means that node
in the binary deletion is based on node searching.
tree. What’s The logic of delete.py is in the following code excerpt
important is, from the _remove() method :
when possible, if val < node.data:
to have our node.left = self._remove(node.left, val)
binary trees
elif val > node.data:
balanced to
node.right = self._remove(node.right, val)
speed up their
operations. else:
# Do more This screenshot shows the core functions of balanced.py, which checks
This code keeps searching for the node that holds whether a given binary tree is balanced or not. Generally speaking,
balanced trees operate faster than non-balanced ones.
the specified value before deleting it. The screenshot
(below) shows a large part the source code of delete.py.
There are many things happening here. First of all, we a height of 16, and an unbalanced binary tree with 1,000
have a different class named BinaryTree. This is because nodes has a height of only 21 – this mainly happens
when deleting nodes from a binary tree, we might end because the bigger the tree, the larger the number of
up deleting its root node, and so we defined a slightly nodes at each level.
different Python class to support that. Finally, we have
some helper functions starting with an underscore. This Totally unbalanced!
is because these functions are called internally by the A binary tree is considered balanced when the
methods of the BinaryTree class. difference between the longest length from the root
node to a leaf node and the shortest such length is 0 or
How high doth it grow? 1. We’ll go into more depth on this in a moment, but a
Balanced or unbalanced, knowing the height of a binary balanced tree is optimised for speed. Balancing a tree
tree can help you understand the structure of your tree can be a difficult and a slow operation and so it’s better
– the relevant code can be found in height.py. The core to keep your tree balanced from the beginning
functionality of the technique is found in the height() (although this isn’t always possible) rather than trying
and _height() functions. Running height.py generates to balance it after you have created it.
the following output: If a binary tree is balanced, its search, insert and
$ ./height.py 100 delete operations take about log(n) steps, where n is the
Height: 16 total number of elements in the tree. Additionally, the
$ ./height.py 1000 height of a balanced binary tree is approximately
Height: 21 log2(n). This means that a balanced tree with 10,000
What’s interesting from the previous output is the elements has a height of 14, which is remarkably small.
fact that an unbalanced binary tree with 100 nodes has The height of a balanced tree with 100,000 elements
will be 17 and the height of a balanced tree with
1,000,000 elements will be 20. In other words, putting a
significantly large number zz elements into a balanced
binary tree doesn’t change the search speed of the tree
in an extreme way. Put more practically, you can reach
any node in a tree with 1,000,000 nodes in less than
20 steps.
This section is going to present an algorithm for
finding out whether a tree is balanced or not. This
algorithm is included in balanced.py and uses the
height() and _height() functions presented in height.
py. The screenshot (above) shows most of the code of
balanced.py while hiding the unnecessary details.
Here’s a large part Running balanced.py produces the following output:
of the code of $ ./balanced.py 10
delete.py where Height: 5
we implement
Balanced: True
the deletion of an
existing node from $ ./balanced.py 10
a binary tree. Height: 7

90 LXF287 April 2022 www.linuxformat.com


Binary trees CODING ACADEMY

LINKED LISTS
Strictly speaking, a linked list is a structure with a finite set of
elements. Each element uses at least two memory locations: one for
the data and the other for a pointer that links the current element to
Here’s the implementation of the nLeafNodes() method that the next one in the sequence of elements that construct the linked
recursively counts the number of leaf nodes (nodes without any list. This is also known as a singly (or single) linked list.
children) in a binary tree. Linked lists enable you to delete or insert elements at will.
Additionally, all operations that can be performed on any kind of
Balanced: False linked list are simple to understand and easy to code. The logic of a
The previous output shows that even a small binary linked list isn’t going to bother you, make you write too much code or
tree with just 10 nodes can still be unbalanced. With this put restrictions into your code.
in mind, imagine how easy it is for bigger binary trees to The first element of a linked list is called the head whereas the last
become unbalanced. element is often called the tail. A queue is a special kind of a linked list
Balancing a binary tree and keeping it balanced is a where each new element is inserted to one end, which is called the
totally different process that’s beyond of the scope of head of the queue, and removed from the other end, which is called
this tutorial. As a hint, given an existing binary tree, you the tail of the queue. The first thing that you should do when defining
can sort all of these values, pick the middle one and a linked list is keep the head of the list in a separate variable. The head
then start rebuilding it from scratch using that middle is the only thing that you need in order to access a linked list.
value as the root of the binary tree. Although you might
not necessarily end up with a perfectly balanced tree,
you’re going to get a much better-looking and faster You can’t beat a tree when you want to represent
binary tree. hierarchical data – this is a rare case where balancing a
tree is actually going to wipe out its usefulness. They
Counting leafs can also be used for building efficient models for real-
If you recall, a leaf node is one without any children. The life problems. Trees are extensively used in compilers
screenshot (above) shows the important source code of during the parsing phase – this is another case when
leafNodes.py, which is located in the implementation of balancing a tree isn’t helpful because we’re going to
the nLeafNodes() method. Running leafNodes.py destroy existing relations.
produces the following output: Finally, trees can be traversed in the correct order
$ ./leafNodes.py 1000 very efficiently. A major disadvantage of binary trees is
334 that the shape of the tree depends on the order that its
$ ./leafNodes.py 10000 elements were inserted. If the keys of a tree are long or
3285 complex, then inserting or searching for an element
might be slow because of the large number of
Finding the parents comparisons required. Finally, if a tree isn’t balanced,
Imagine that you have a binary tree and you want to then the behaviour of the tree is unpredictable.
find out the parent of a node. This section is going to Although you can create a linked list or an array more
show you how using the code of findParent.py. The quickly than a binary tree, the flexibility that a binary
screenshot (below right) displays all the important tree offers in searching operations might worth the
code of findParent.py. All the work is done by the extra housekeeping.
_findParent() method, which returns two values: the Binary trees aren’t the only available trees. As an
node of the parent and the node of the value that example, we can have a tree where each node has up to
we’re searching for. The code of _findParent() keeps three or four children. Generally speaking, tree nodes
visiting the nodes of the binary tree looking for the don’t usually have too many children. If we find
desired value. ourselves requiring trees with more than four nodes,
If the current node is equal to None, then the desired then we might need to reconsider our approach.
value isn’t found and the method returns (None, None) .
If the value is found, then we return the node of the
parent and the node of the value. In the case that the
value we’re looking for is stored in the Root node, then
the value of the parent node is going to be None.
Running findParent.py produces the following output:
$ /findParent.py 100 3
The core code
Parent of 3 is: 5 of findParent.py,
$ ./findParent.py 10 5 which enables
Root node does not have a parent. you to find out
the parent node
of another node
Advantages and disadvantages with the help of
Despite their usefulness, trees are not a panacea and findParent() and
shouldn’t be used without thinking about it beforehand. _findParent().

GET MORE DEAD-TREE CODING! Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 91
CODING ACADEMY Web scraping
Part One
Don’t miss
next issue!

PERL
Subscribe
on page 16

How to use Mojolicious


for web scraping
Mark Gardner reveals how you can retrieve and parse HTML and XML
from websites with a few lines of Perl and the Mojolicious framework.

o much of the modern web is driven by

S services and front-end interfaces talking to


APIs that it’s easy to lose sight of the fact that
everything is ultimately presented in a soup of HTML
markup. In the absence of a well-structured interface or
OUR format, sometimes the code you’re writing needs to
EXPERT scrape the ingredients of that soup apart and parse out
meaningful data. Perl’s Mojolicious web framework
Mark Gardner includes a set of components that make this task easier.
is a software Although most Linux distros come with a version of A terse Perl command line using Mojolicious’ single-letter functions.
developer and Perl, it helps to have your own installation separate from Good for fun one-liners, not so much for readable code.
blogger with over the system so you’re not tied to a possibly older version
25 years of IT that’s required to support operating system tools and https://linuxformat.com/linux-format-285.html
experience. You other packages. This separate installation can live in ...
can reach him at your $HOME directory (or wherever you specify) with its https://linuxformat.com/linux-format-277.html
www.phoenixtrap. own modules that neither require sudo to install nor https://linuxformat.com/zero-th-post.html
com and interfere with those handled by the package manager. Let’s break this down into a structured Perl script:
@markjgardner. The most popular tool for managing separate Perl #!/usr/bin/env perl
installations is called Perlbrew. Installation instructions use Mojo::URL;
are at https://perlbrew.pl/Installation.html. You can use Mojo::UserAgent;
install it with either of the following shell commands, The preamble above starts our script by telling it to
depending on what you already have installed: use the perl executable from our path, so we don’t have
$ curl -L https://install.perlbrew.pl | bash to worry where perlbrew installed things. After that we
$ wget -O - https://install.perlbrew.pl | bash load the Mojo::URL module for constructing and parsing
From there, it’s a matter of initialising perlbrew, Uniform Resource Locators and Mojo::UserAgent, which
The map installing and switching to the latest version of Perl, is Mojolicious’ full-featured HTTP and WebSocket client.
function is installing the cpanm Perl module installer, and finally my $base = Mojo::URL->new('https://linuxformat.
designed to installing Mojolicious and IO::Socket::SSL. com/category/new-issue.html');
transform a list $ perlbrew init my $ua = Mojo::UserAgent->new;
or collection via $ perlbrew install perl-5.34.0 my $response = $ua->get($base)->result;
a function. You $ perlbrew switch perl-5.34.0 die $response->message if $response->is_error;
could use a for $ perlbrew install-cpanm
each loop, but
the map has the
$ cpanm Mojolicious IO::Socket::SSL Enter the new user agent
advantage of
Let’s say you wanted a list of links to the recent We save our starting URL in a Mojo::URL object, since
returning a new issues available from Linux Format. You can do this with we’re going to use it as the base for the relative links we
list or collection, a single Perl command using Mojolicious’ ojo function- retrieve later from that page. Next we create a new user
enabling you exporting module. This might be something you’d put agent and immediately use it to perform a HTTP GET
to chain other into a shell alias or cron job, not a production tool: on that URL. The get() method just returns a
methods or $ perl -Mojo -E ‘my $base = l("https://linuxformat.com/ Mojo::Transaction::HTTP object representing the
functions, like category/new-issue.html"); transaction taking place; we need to use the result
the -Mojo one- say g($base)->dom("article h1 > a") method on it to obtain the actual $response . (There’s
liner does with ->map( sub{ l( $_->attr("href") )->to_abs($base) } also a res method for returning a response; result has
join().
)->join("\n")’ the added benefit of throwing an exception if a

92 LXF287 April 2022 www.linuxformat.com


Web scraping CODING ACADEMY

connection error occurs.) Lastly, we die with an error The same basic
functionality as the
message if the HTTP response has a 4xx or 5xx HTTP
single command
status code – in other words, is an error. line, but now as
my $link_collection = $response->dom('article h1 > a'); a small script
my @issue_links = @{ $link_collection->map(attr => with explanatory
‘href')->to_array }; variables along
the way.
Finally, we have our web page to parse, and this is
where we turn what we know of its HTML source into
instructions on how to extract specific data. That
dom() method on $response retrieves the body
of the response and turns it into a Mojo::DOM object
representing the Document Object Model of the page.
By passing it a parameter it does double-duty, calling The l() function is equal to the Mojo::URL->new()
Mojo::DOM’s find() method on the passed Cascading call in our longer script. It just saves a bit of typing.
Style Sheets (CSS) selector. In this case, we’re telling it say g($base)->dom("article h1 > a") Perlbrew can
to find all <article> elements containing an <h1> Here we’re using ojo’s g() function to quickly create also switch
element with an immediate child <a> element. That a new Mojo::UserAgent, issue a HTTP GET request, between
grabs just the links to the Linux Format issues while and then produce a response object. The result goes multiple library
ignoring all the other links and other elements of the through the same chain of methods as the more root directories
page, storing it in the $link_collection Mojo::Collection verbose script: parse the DOM , then extract specific within the same
object (which is just a fancy reference to an array with elements based on a CSS selector. This is all preceded perl installation.
some convenient methods added). by Perl’s say function, which acts just like print but Check out the
“perlbrew help
with an extra newline automatically appended:
lib” command
Consult the map() ->map( sub{ l( $_->attr("href") )->to_abs($base) }
and “perldoc
One of those convenient methods is map() , which like )->join("\n")’ local::lib”.
the Perl function of the same name, we use to call code Rather than perform two loops (a map over the
on each element of the collection. Each element is itself dom() method’s resulting Mojo::Collection and a
a Mojo::DOM object, so since we’re interested in the for each over a plain array), here we’re passing an
URLs on each of these links, we look at the href attribute anonymous code reference to Mojo::Collection’s map()
using Mojo::DOM’s attr method. The result is another method to do all the work in one pass. The l() function
Mojo::Collection, so we call the to_array method on it creates a new Mojo::URL for each relative link in the
to turn it into a plain reference to an array of strings, and collection as identified by the href HTML attribute. to_
then dereference it by enclosing the whole thing in @{ } abs() then transforms the relative URL into an absolute
braces. link using the $base we set at the beginning. The
If we stopped here and printed out @issue_links , map() 's resulting collection is then joined by newline
we’d have exactly what was in the HTML source – links characters for output by say in the line above. The only
to the magazine issues relative to the particular page we thing left is a single quote to close the string passed to
started with. We need to take one last step to turn those perl’s -E command line flag.
into full URLs suitable for a web browser: We’ve only scratched the surface of Mojolicious’ web
foreach my $link (@issue_links) { client power, to say nothing of its raison d’être as a full-
my $full_link = Mojo::URL->new($link)->to_ featured framework that scales from rapid prototyping
abs($base); into large-scale MVC (Model-View-Controller) web
print “$full_link\n”; applications. Perl itself is an evolving language with a
} vast library of open source modules that developers
Yes, it’s that $base URL we started with. We loop over stitch together to solve a world of software problems.
@issue_links , setting $link each time, and build a new
Mojo::URL from it. We then turn it into an absolute URL
using $base and then print it out as a string. (The -Mojo MOJOLICIOUS OR DANCER?
one-liner at the beginning did this as a map; we’ve
turned it into a for each loop to highlight each step.) Dancer (https://perldancer.org) is another Perl web framework with
an emphasis on simplicity and modularity. It has many overlapping
The one-liner revisited features with Mojolicious, although it doesn’t include web client tools.
We can now take a fresh look at that single command You have many choices if your Dancer or other application also needs
line and translate its brevity: client functionality, from the HTTP::Tiny module packaged with Perl,
$ perl -Mojo -E ' to the venerable LWP::UserAgent (and modules written to use it such
Let’s start with that -Mojo flag. -M is just Perl’s as WWW::Mechanize), to C library interfaces like Net::Curl::Easy.
flag for loading a module from the command line, We’ve opted for Mojolicious for this article because on its own it has
equivalent to the language’s “use” statement. In a no dependencies outside of the core Perl modules. It’s also built to be
fit of cleverness, the Mojolicious authors named this non-blocking, i.e., enabling code to continue to run even when a
particular module ojo so as to spell out the subroutine isn’t finished, and this extends to Mojo::UserAgent. So you
framework’s abbreviated name. The script itself is can use the latter as a simple blocking client as this article does, and
passed as a string to the -E flag, which enables optional then expand your repertoire to keep multiple connections active at
features such as the say command. once. See “Non-blocking” under the “USER AGENT” section of
my $base = l("https://linuxformat.com/category/new- “perldoc Mojolicious::Guides::Cookbook” for a couple of examples.
issue.html");

www.techradar.com/pro/linux April 2022 LXF287 93


CODING ACADEMY 3D game worlds

PYTHON Part Two


Credit: https://github.com/jtmfam/Gh0stenstein

Interact with your


Missed Part
One? Turn to
page 62 to get
hold of it

3D game environment
Enhance your gaming world by adding collision detection and
custom objects, as Andrew Smith throws barrels at you.

or this tutorial we’re continuing from last

F issue’s Python tutorial. Don’t worry, you’ll have


access to the full code. In the previous
instalment we gave an overview of the mechanics and
mathematics, explaining how the player (featured in
first-person view) could move and navigate around the
OUR game world we created. As much as this was done to
some level of detail, it still left our 3D world looking a
EXPERT little blank and boring.
Andrew Smith We’ll now focus more on building objects in the game
is a software world rather than further explaining the mathematics
developer for and mechanics of how the program works.
NHS Digital, has a In this article we’re going to populate our 3D The redbrick texture is used for the walls while the player navigates
bachelors degree generated game world with game objects. We’ll also the 3D world. It’s the third texture to be loaded into the program.
in software start adding collision detection so that you (as a player)
engineering and a will have to walk around the objects presented in the to open the folder and gain access to the Python source
master’s degree game world or be stopped by them. To help us do this code. You’ll see two Python source code files: main.py
in computer we’ll also be modifying parts of the existing code to help and main_2.py. The Python file main.py is the Python
networks. build our game world more easily. Modifying the code script file that you’ll be editing and main_2.py contains
will also help us to manipulate game objects placed into the full tutorial code.
the game scene more easily. To edit and view the source code you can either
use the default text editor installed on your flavour of
Installation and setup Linux or something more specific such as Notepad++,
Python 3.10 has recently been released, so we’ll install PyCharm or VS Code. The choice is up to you. In this
and set up version 3.10 for the benefit of this tutorial. tutorial we’ll be using gedit to view and edit the source
For those who have Python/PyGame already installed, files. It may be helpful to open two console windows:
Python 3.8+ should be fine to use with this tutorial. Type one for editing/viewing source files; the other for
the following to install Python 3.10 and PyGame: executing the PyGame code.
$ sudo apt-get install python3.10
$ sudo apt-get install python3-pip Adding game objects
$ python3.10 -m pip install pygame From viewing the python file worldManager.py (in the
Check the versions of Python and pygame. Next, git class constructor of WorldManager), you’ll see that a
When creating
Clone from repository: number of game object images have already been
variable names, $ git clone https://github.com/asmith1979/ loaded into the program. However, for the benefit of the
make the name lxf287_3DWorld/ previous tutorial, the game objects were not rendered in
meaningful to The whole project has been put into a folder called the generated game world. The current game objects
what is actually PythonProjects, which was created before downloading that have been loaded into the program include:
there for. This the project. The source code and project can also be A barrel image
will make things retrieved from the Linux Format archive. A green light image
clearer when This tutorial will focus on the source code located in A pillar image
reading the the folder called lxf287_3DWorld\src. If you’ve not The remaining images that are loaded are for the
code.
already accessed that folder, type cd lxf287_3DWorld image textures for the walls. The way in which the game

94 LXF287 April 2022 www.linuxformat.com


3D game worlds CODING ACADEMY

objects are set up in the game world is as follows: Let’s vary things
up with a greybrick
sprite_positions=[
texture used for
(20.5, 11.5, 2), #green light in front of playerstart the walls. It’s the
#green lights in every room fourth texture to
(18.5,4.5, 2), be loaded into
(10.0,4.5, 2), the program.
(10.0,12.5,2),
(3.5, 6.5, 2),
(3.5, 20.5,2),
(3.5, 14.5,2),
(14.5,20.5,2),

#row of pillars in front of wall: fisheye test


(18.5, 5.5, 1), # Add a Pillar to each corner of the game scene
#(18.5, 11.5, 1),
(18.5, 12.5, 1), # Back wall left When modifying
add_sprite(21.5, 1.5, PILLAR_IMAGE) existing projects
#some barrels around the map such as this one,
(21.5, 1.5, 0), # Back wall right try to keep the
(15.5, 1.5, 0), add_sprite(21.5, 22.5, PILLAR_IMAGE) code and images
(16.0, 1.8, 0), consistent to
(16.2, 1.2, 0), # Front Wall Right help keep
things clear.
(3.5, 2.5, 0), add_sprite(1.5, 22.5, PILLAR_IMAGE)
(9.5, 15.5, 0),
(10.0, 15.1,0), # Front Wall Left
(10.5, 15.8,0), add_sprite(1.5, 1.5, PILLAR_IMAGE)
]
As much as the above approach displays the correct # Add some barrels to the game scene
game object in the correct position as specified above, it add_sprite(10.0, 10.0, BARREL_IMAGE)
can be what regarded as a “hard-coded” approach. add_sprite(10.0, 12.0, BARREL_IMAGE)
Replace the above code with the following: add_sprite(10.0, 14.0, BARREL_IMAGE)
sprite_positions=[] Now Save, and execute the code.
This line of code clears all sprites from our collection From now moving around the 3D world, you’ll see
to start again. A more improved and less “hard-coded” that four pillar objects have been added (one at each
approach would to introduce both constant values and corner) and three barrel objects have been added to the
methods so that we don’t have to key in values every centre of the game scene. When you’ve finished moving
time. First, we could define constant values for the around having a look at the newly added objects, press
images which are loaded in. Near the top of main.py Escape and continue with the tutorial.
(after the imports), type in the following code: The first part of code that we added above is used to
LIGHT_IMAGE = 2 act as a reference point for the images that have been
PILLAR_IMAGE = 1 loaded into the program, so instead of typing 0 , we now
BARREL_IMAGE = 0 can type BARREL_IMAGE . Instead of typing 1 , we now
Next, scroll down to after where sprite_positions[] can type PILLAR_IMAGE and instead of typing 2 , we
collections is first declared and type the following code. now can type LIGHT_IMAGE .
def add_sprite(zposin, yposin, image): The code that we implemented following on from this
sprite_positions.append([zposin,yposin,image]) makes use of the above as we created a small function
After entering the above code, press the Enter key a called add_sprite, that takes in three arguments
couple of times and type in the following code: (z-position, y-position and image).
def build_world_add_sprites(): The add_sprite function is then used in the function

ADDING CUSTOM GAME OBJECTS


It’s possible to create your own game 2 Load the image into the program in the function build_world_add_sprites()
objects and add them to the game WorldManager class constructor in in main.py:
program by following these steps. WorldManager.py (hint: look at how other add_sprite(21.5, 1.5, PILLAR_IMAGE)
1 Create an image, in PNG file format objects are loaded in): This code is given just as an example.
that’s 64x64 pixels using an image- load_image(pygame.image.load("pics/ Adopt naming conventions based on the
editing tool such as GIMP (hint: base it items/barrel.png").convert(), False, object that you’re creating to add into the
on an existing image from \src\pics\ colorKey = (0,0,0)) game world. It’s also important to keep
items). Once the image is created, it 3 Add a constant name and value for the image sizes to 64x64 pixels, which is
should be in the location \src\pics\ image created (example BOX_CRATE = consistent with other images destined for
items so that it can be loaded in by 3) in main.py. the game, so that all game object images
the program. 4 Now add the game object to the appear at the same size.

www.techradar.com/pro/linux April 2022 LXF287 95


CODING ACADEMY 3D game worlds

we then create called build_world_add_sprites() which


sets up the objects in our 3D world. By using this
Instead of approach it’s clearer which objects we’re adding to the
scrolling 3D world and in what order, because we now have
through source names to describe the various game objects.
code in the IDE,
So far we’ve added a pillar to each corner of the
use the editor’s
game scene and also added three barrels to the centre
search facility
(usually Ctrl+F) of it. If you haven’t already done so, save and then
to find what execute the program to see the results.
you’re looking
for, such as Game object collision
a variable or The game objects in our 3D world can’t interact with the
function name player, so now we need to add code to detect a collision
between player and a game object. We’ll add collision
detection for the barrel objects in the game scene. Our modified game scene including pillars and barrels, which have
First we’ll add a function called spriteCollision that been added using the function build_world_add_sprites().
will be used to detect if there’s been a collision between
the player and game object in the 3D world. After the position of the player, the direction and where the
function build_world_add_sprites(), type the following: intended position for the player will be (where the player
def spriteCollision(currentPositionIn, is moving to).
projectedPosition): The overall purpose of the function is to detect a
# Returns True if collision, Fale if no collision collision between a barrel and the player. If there’s a
retValue = False # Return False by default collision, the function returns the value of True and if
there’s no collision the function returns a False value.
# Get Player position You may notice that the first argument passed in is a list
player_x_pos = currentPositionIn[0] that contains the x-position (or z-position) of the player,
player_y_pos = currentPositionIn[1] y-position of the player, player direction-x and player
direction-y. This saves us from having to add more
# Get Camera direction arguments to the function individually.
player_cam_dirx = currentPositionIn[2] Because there’s more than one game object in our
player_cam_diry = currentPositionIn[3] 3D world, a for loop has been implemented to examine
each of the game objects one at a time, to see if a
collision has occurred with the player. Each time a sprite
for sprite in sprite_positions: object is examined, the position and type of sprite
# Extract sprite details image is also collected. This also helps to detect if a
sprite_x_pos = sprite[0] collision has occurred.
sprite_y_pos = sprite[1]
sprite_type = sprite[2] Roll out the barrel(s)
The first part of our collision detection focuses on the
# Collision detection on approach to barrels player approaching the barrel objects when the game
if player_x_pos <= (sprite_x_pos+1.0) and player_y_ program starts (the first if statement). To limit the
pos >= (sprite_y_pos-0.2) and player_y_pos <= (sprite_y_ number of objects (in this case, the barrels), the sprite_
pos+0.2) and sprite_type == BARREL_IMAGE and type has been used as a filter for the game objects and
player_cam_dirx < 0.0: is set to BARREL_IMAGE . This helps collision
retValue = True detection between the player and barrel objects to
else: not become confused with other game objects in the
# Collision detection on return from barrels game scene.
if player_x_pos >= (sprite_x_pos-2.0) and The camera direction is also taken into account. At
player_y_pos >= (sprite_y_pos-0.2) and player_y_pos <= the start of the program, the camera direction value
(sprite_y_pos+0.2) and sprite_type == BARREL_IMAGE when approaching the barrels is less than 0.0, so this
and player_cam_dirx > 0.0: has been implemented into the if statement to detect
The latest versions retValue = True collision when the player approaches the barrel objects,
of Python (3.10) when the game is launched.
and PyGame (2.1.0)
return retValue The second if statement is very similar to the first
are installed,
as seen in the The function that’s just been implemented, one, apart from that it detects if the camera direction is
Terminal window. spriteCollision, takes in as arguments the current above 0.0. This is a situation where the player has
walked past the barrel objects and turns around to fully
come back towards them again. The camera direction
value will be above 0.0 so this has been put into the
second if statement. If either of the if conditions is
true, then a True value is returned to identify a collision
has occurred.
To make use of this function we now need to plug it
in to the main game code, which we’ll need to alter the
main game loop for. In main.py, find the following code:

96 LXF287 April 2022 www.linuxformat.com


3D game worlds CODING ACADEMY

PYGAME – MAIN LOOP


In every PyGame program there’s a main loop that’s used to process
the program until it’s ended. Items processed in the loop include user
input, which could be from a mouse, keyboard or keypad. It could also
include logical decisions to process the game program and to also
process and render the graphics to the screen. Let’s take a brief look
at the game loop used in our game program:
...
while(True):
testclock.tick(60)
wm.draw(screen)
frameTime = float(testclock.get_time()) / 1000.0 # frameTime is
the time this frame has taken, in seconds
Another modified game scene including the three barrel objects that # t = time.Clock()
have been added in the function build_world_add_sprites(). #text = f.render(str(testclock.get_fps()), False, (255, 255, 0))
#screen.blit(text, text.get_rect(), text.get_rect())
… weapon.draw(screen, testclock)
pygame.display.flip()
if keys[K_UP]: ...
# move forward if no wall in front of you Usually the main game loop is set to end on a Boolean condition,
and in this case the loop ends when a False value is provided. The first
# Move forward and back on z-axis part of the while loop in our game program deals with the frame rate
# Get the move value and rendering the graphics on to the screen. Following on from this,
moveX = wm.camera.x + wm.camera.dirx * user input is dealt with which in regards to this game program mainly
moveSpeed covers keyboard input. From reading the code and looking out for the
keyboard controls, you’ll find that when the Escape key is pressed, a
# Move only if not collided with a wall False value is returned.
if worldMap[int(moveX)][int(wm.camera.y)]==0:

... completely taken into account. This can be further


Under the last if statement, implement the following corrected in the function that we’ve created called
code, remembering to indent by four spaces: spriteCollision. In the for loop, the first part of the if
# Collision Detection with game sprites statements both contain code such as (sprite_y_pos-
spriteCollisionDet = spriteCollision([wm.camera.x, 0.2) . The decimal value shown can be altered to add to
wm.camera.y, wm.camera.dirx, wm.camera.diry], the collision detection width of the barrel object.
moveX) In this tutorial, we’ve shown how to add game
objects to our 3D game world and how to implement
if spriteCollisionDet == False: collision detection between objects and player. Further
wm.camera.x += wm.camera.dirx * moveSpeed features could be added such as a player’s name and
energy level, sound, or an options menu could
.. implemented before the game starts to play. Your
Now that we’ve implemented the above code, every imagination is your only limit!
time the Up key is pressed, the collision to detection
algorithm is activated to check to see if there’s a
collision between the player and the barrel objects in
the game scene. If you haven’t already done so, save
what you’ve implemented so far and execute the
program to see what happens.

Test the collision code


When the program is launched, choose one of the
barrels to approach and walk directly up to it. You
shouldn’t be able to pass it immediately, but will now
have to go around the barrel itself due to the collision
detection algorithm that we’ve recently implemented. In
addition, when you walk past the barrel objects and turn
around to walk back towards them, you should still be
made to go around them.
Even though the collision detection algorithm works, Here, the player is standing next to a barrel but is unable to move past it, because of the collision
it’s not perfect because the full width of the barrel isn’t detection algorithm. Unstoppable force, meet immovable object!

LET LXF COLLIDE WITH YOU! Subscribe now at http://bit.ly/LinuxFormat


www.techradar.com/pro/linux April 2022 LXF287 97
NEXT MONTH

ESSENTIAL
The #1 open source mag

Future Publishing Limited,


Quay House, The Ambury, Bath, BA1 1UA
Email linuxformat@futurenet.com

Pi PROJECTS
EDITORIAL
Editor Neil Mohr
Kernel editor Jonni Bidwell
Art editor Efrain Hernandez-Mendoza
Operations editor Cliff Hope
Group editor in chief Graham Barlow
Group art director Jo Gulliver
Editorial contributors
Mats Tage Axelsson, Neil Bothwick, Mark Gardener,
Matthew Hanson, Matthew Holder, Jon Masters,
Nick Peers, Aaron Peters, Les Pounder, Michael Reed,

Everything you need to


David Rutland, Mayank Sharma, Shashank Sharma,
Andrew Smith, Mihalis Tsoukalos, Alexander Tolstoy
Cover illustration magictorch.com

build awesome projects


Raspberry Pi is a trademark of the Raspberry Pi Foundation.
Tux credit: Larry Ewing (lewing@isc.tamu.edu) and The GIMP.
ADVERTISING

and physical Pi-based


Commercial sales director Clare Dove
clare.dove@futurenet.com
Senior advertising manager Lara Jaggon

coding and making!


lara.jaggon@futurenet.com
Head of commercial – Technology Dave Randall
dave.randall@futurenet.com
Account director Andrew Tilbury
andrew.tilbury@futurenet.com
INTERNATIONAL LICENSING
Head of Print Licensing Rachel Shaw
Linux Format is available for licensing and syndication.
To find our more contact us at licensing@futurenet.com
or view our content at www.futurecontenthub.com.
NEW SUBSCRIPTIONS & BACK ISSUES
Web www.magazinesdirect.com
UK 0330 333 1113 World +44 (0) 330 333 1113
EXISTING SUBSCRIPTIONS
Web www.mymagazine.co.uk
UK 0330 333 4333 World +44 (0) 330 333 4333
Subscription delays: Disruption remains within UK
and International delivery networks. Please allow up to
7 days before contacting us about a late delivery to
help@magazinesdirect.com
CIRCULATION
Head of newstrade Tim Mathers
PRODUCTION AND DISTRIBUTION
Head of production UK & US Mark Constance
Production project manager Clare Scott
Senior ad production manager Jo Crosby
Digital editions controller Jason Hudson
THE MANAGEMENT

LXF288
MD, tech specialist Keith Walker
Head of art and design Rodney Dive
Design director Brett Lewis
Commercial finance director Dan Jotcham
will be on sale Printed by Wyndeham Peterborough, Storey’s Bar
Road, Peterborough, Cambridgeshire, PE1 5YS
Tuesday Distributed by Marketforce, 5 Churchill Place, Canary
Wharf, London, E14 5HU www.marketforce.co.uk
Tel: 0203 787 9001
5 April Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
GNU/Linux is abbreviated to Linux throughout for brevity. Where applicable code

2022 printed in this magazine is licensed under the GNU GPL v2 or later. See www.gnu.
org/copyleft/gpl.html. All copyrights and trademarks are recognised and respected.
Disclaimer All contents © 2022 Future Publishing Limited or published under
licence. All rights reserved. No part of this magazine may be used, stored,
transmitted or reproduced in any way without the prior written permission of the
publisher. Future Publishing Limited (company number 2008885) is registered in
England and Wales. Registered office: Quay House, The Ambury, Bath BA1 1UA. All
information contained in this publication is for information only and is, as far as we
are aware, correct at the time of going to press. Future cannot accept any

Easy video sharing responsibility for errors or inaccuracies in such information. You are advised to
contact manufacturers and retailers directly with regard to the price of products/
services referred to in this publication. Apps and websites mentioned in this
publication are not under our control. We are not responsible for their contents or any
other changes or updates to them. This magazine is fully independent and not

YouTube? More like BooooTube! We bring you the better, affiliated in any way with the companies mentioned herein.
If you submit material to us, you warrant that you own the material and/or have
the necessary rights/permissions to supply the material and you automatically grant

easier and more open way to share your videos online. Future and its licensees a licence to publish your submission in whole or in part in
any/all issues and/or editions of publications, in any format published worldwide and
on associated websites, social media channels and associated products. Any
material you submit is sent at your own risk and, although every care is taken, neither
Future nor its employees, agents, subcontractors or licensees shall be liable for loss

So random!
or damage. We assume all unsolicited material is for publication unless otherwise
stated, and reserve the right to edit, amend, adapt all submissions. All contents in
this magazine are used at your own risk. We accept no liability for any loss of data or
damage to your systems, peripherals or software through the use of any guide.
Notes: No space Tux this issue, it was poo pooed.

Max-out your entropy and keep dev/random topped up with the We are committed to only using magazine paper derived from
responsibly managed, certified forestry and chlorine-free
manufacture. The paper in this magazine was sourced and
most random numbers this side of a white-noise generator. produced from sustainable managed forests, conforming to
strict environmental and socioeconomic standards. The
manufacturing paper mill and printer hold full FSC and PEFC
certification and accreditation.

Satellite photography Future is an award-winning international media group and


leading digital business. We reach more than 57 million
There’s terabytes of space-based imaging out there – discover international consumers a month and create world-class
content and advertising solutions for passionate
consumers online, on tablet & smartphone and in print.
how to get it and how to process it, in the name of science!

Rust and Linux


It’s the new go-to language for Linux and rock-solid, memory
secure code. We get you started on coding open source tools. Future plc is a public
company quoted on the
London Stock Exchange
Chief executive Zillah Byng-Thorne
Non-executive chairman Richard Huntingford
!ǝǣƺǔˡȇƏȇƬǣƏǼȒǔˡƬƺȸ Penny Ladkin-Brand
(symbol: FUTR)
www.futureplc.com Tel +44 (0)1225 442244
Contents of future issues subject to change – we might been replaced by a machine learning routine.

98 LXF287 April 2022


9000 9001

You might also like