GET A BETTER UBUNTU DISTRO The latest Ubuntu alternatives tested, so you get a slicker Linux!
VALVE STEAM DECK HANDS-ON PREVIEW The #1 open source mag
BUILD THE
Automate your home the open source way
Get a faster, enhanced Linux kernel by discovering how to compile it yourself
HOW TO
SLACKWARE 15
The oldest distro gets an update – we try it out
JUPITER ACE
Discover the 1980s Forth-based gem
GET ORGANISED!
The powerful tool for research and notes
LXF April 2022
ode your own C Doom-style games Create professional, best-selling ebooks Powerful terminal fuzzy search tools
WELCOME
MEET THE TEAM This issue we’re compiling the Linux kernel from source. We wondered if our experts compile anything from source, or does even the thought of this cause them to run screaming into the night? Jonni Bidwell The records tell of a rogue who, masquerading as a GCC packager, managed to sneak an arcane stanza into the source. The result was that whenever a certain string was input to any program compiled by this tainted GCC (including new versions of GCC)… ah well, that would be telling!
Nick Peers I’m perfectly happy to compile stuff from source so long as the instructions are clear and legible so I don’t have to think too hard about it. However, if an up-to-date snap, flatpak or AppImage exists, I’ll always take the lazy option and choose that.
Les Pounder I don’t compile much from source: a project found on GitHub, or an emulator for an old computer. The last serious project I compiled 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.
Michael Reed 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 For me, this question just hits the spot! I’m all in for building things from source, whether it’s another HotPicks candidate or something for myself (or both). And this includes the Linux kernel. Naturally, I avoid compiling large projects such as LibreOffice or Firefox because it may take far too long on my humble desktop machine.
www.techradar.com/pro/linux
Kernel of truth Compiling the kernel from source was always a key moment in many Unix courses. After all, there was a time when everyone who wanted to seriously learn how to admin a system would need to learn this skill. Not that it’s that complex a thing to do – you just need the right files, tools and a modicum of time. Rightly so, modern Linux distros have neatly hidden away this complexity with just outliers such as Gentoo (see LXF276) or Linux from 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 you need to know about building your own kernel, the benefits and tweaks you can make, and looks at trimming the kernels and if you really need to. It’s handy that we’re also covering Linux from Scratch so you can put your knowledge into action! If you prefer your kernels to be pre-compiled then we’re looking at the best Ubuntu alternatives in this issue’s Roundup. The quality 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. For makers and coders we add more features to our basic Wolfenstein game, take a deep-dive into the Mira Chromecast-like protocol and kick off another new series looking at that stalwart language Perl. So enjoy!
Neil Mohr Editor neil.mohr@futurenet.com
Subscribe & save! On digital and print – see page 16
April 2022 LXF287 3
Contents REVIEWS
Intel Core i5 12400
19
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.
SUBSCRIBE NOW! Page 16
BUILD THE KERNEL
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
24
Our PCGamer friends bagged a hands-on hardware preview of the Steam Deck before the big launch at the end of February. Here’s what they learnt…
FLIRC Pi Zero Case
41
Les Pounder keeps his cool with a case for his beloved Raspberry Pi Zero 2 W. Will it beat the heat of a benchmark?
4 LXF287 April 2022
ROUNDUP
Ubuntu alternatives
IN-DEPTH
26
The ever-curious Michael Reed investigates Ubuntu progenies and finds that they each have their own take on a how a desktop should work…
Linux From Scratch – part two
48
Aaron Peters takes us deeper into the Linux From Scratch process, as we get our personal Linux distro up and running from scratch, straight from the source!
www.linuxformat.com
CONTENTS TUTORIALS
Pi USER Raspberry Pi news
TERMINAL: Fuzzy search
40
52
Introduced by PJ Evans. Coolest Projects goes Global so everyone can take part, the Pi gets beta network installs and the 64-bit Pi OS comes out of beta.
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.
FLIRC Pi Zero Case
ZOTERO: Organised research
41
Les Pounder keeps his cool with a case for his beloved Raspberry Pi Zero 2 W. Will it beat the heat of a benchmark?
Build a news ticker
42
EMULATION: Jupiter Ace
Les Pounder constructs his own homage to the famous Times Square news ticker, this time scaled for ants!
Inside casting protocols
54
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.
58
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!
44
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 easier relationships (of the data sort, mind).
Mojolicious web scraping
ASSISTANT: Home automation
92
Mark Gardner helps retrieve and parse HTML and XML from websites with a few lines of Perl and the Mojolicious framework.
3D world collision detection
LIBREOFFICE: Ebook publishing
94
LXF SERVER: Online classes
REGULARS AT A GLANCE 6
Linux malware increases by 35 per cent during 2021, there’s a nasty Polkit exploit you need to patch and governments are once again after your encrypted stuff.
Kernel watch Answers
Back issues
16
62
TOP OF THE FOSS
Get hold of previous Linux Format editions.
10 11
14
We mess up our PDF coverage, again! More people pile into the loss of the DVD, both positive and negative, are we shilling for Apple, and what of creative coverage?
www.techradar.com/pro/linux
Subscriptions
72
David Rutland moodles along with classroom management software on the Linux Format virtual private server and starts his own online course.
Get your monthly Linux dose and save cash!
Logging system monitoring, fixing a dead network with Mint, logging shutdown issues, discovering manuals and how best to create emergency boot USB sticks.
Mailserver
68
Seeking to chalk up a best seller, Michael Reed goes further into the intricacies of publishing a book from his Ubuntu desktop and using online print services.
Enhance your gaming world by adding collision detection and custom objects, as Andrew Smith throws barrels at you.
News
64
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.
Overseas subscriptions
63
Get Linux Format shipped around the globe.
HotPicks
81
Alexander Tolstoy is too busy to enjoy a relaxing holiday by the quiet and peaceful Black Sea. He’s got his hands full with collecting amazing FOSS like Weather Widget 2, Fancontrol GUI, Wine, DaedalOS, FreyrJS, Chmod-CLI, Rescuezilla, Warble, SpaceHuggers, Efiboots and Ehh.
Next month
98
Charitable characters
76
The Emmabuntüs collective enlightens Jonni Bidwell as to its kind and open source efforts, helping to distribute second-hand computers to communities in need.
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% Malware aimed directly at Linux systems increased drastically last year. uring 2021 malware targeting Linux devices increased by 35 per cent. The majority of malware instances involved IoT (Internet of Things) devices caught up in DDoS (distributed denial of service) attacks. IoT devices encompass a range of gadgets. Many of them are internet-connected and run some form of Linux distribution. People who buy a smart fridge, for example, may not know the security implications, which makes them attractive targets for hackers looking to create DDoS attacks, as they ‘recruit’ a large number of low-powered devices to perform such attacks. According to a Crowdstrike report (https:// bit.ly/lxf287crowdstrike), XorDDoS, Mirai and Mozi malware were involved in over 22 per cent of Linux threats in 2021, and there were 10 times the amount of Mozi malware observed in 2021 compared to 2020. Linux-powered IoT devices are “low-hanging fruit for threat actors,” according to Crowdstrike, because of “using hardcoded credentials, open ports or unpatched vulnerabilities.” With the number of internet-connect smart devices growing every year (there’ll be an estimated 30 billion IoT devices on the internet by 2025 according to Statista’s report at https://bit.ly/ lxf287statista), these attacks are likely to grow. The more compromised devices an attacker can add to their botnet, the more powerful attacks using the botnet will be. XorDDoS is another type of malware that saw a 123 per cent increase in 2021. It’s a Linux Trojan that uses SSH brute-forcing attacks to
D
6 LXF287 April 2022
Crowdstrike highlighted a worrying rise in malware that targets Linux devices in 2021.
take over a device. Some variants targeted Docker servers with the open 2375 port, which gave attackers root access to the machine without the need of a password. Meanwhile, Mirai is a form of malware that’s been gaining increasing popularity after its source code was published. It uses brute force attacks against weak protocols like Telnet to gain access to devices. It’s also spawned a growing number of variants that target different protocols. These variants include Sora, IZIH9
IGNORANCE IS NO DEFENCE “This is a concerning trend that highlights the potential danger of having homes full of Internet of Things devices.” and Rekai, each of which saw increased usage in 2021. CrowdStrike discovered an increase of 83 per cent in Rekai samples, for example. This is a concerning trend that highlights the potential danger of having homes full of IoT devices. We’re not suggesting you ditch your Wi-Fi kettle or turn off your smart TV permanently, though. Instead, have a better idea of devices in your home that are connected to the internet, and which represent possible targets to malicious users. Implementing routerlevel security to help protect any device in your home is also worth investing in.
www.linuxformat.com
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to lxf.answers@futurenet.com display issue Q Prickly Is there something I can use to
collect all my LAN data/network/disk space information into a dashboard? I have several computers running (including virtual machines) and I want to send their data to a dedicated server that will show me all the information on one screen. Derrick Long
A
There are a number of ways of collecting this information, depending on what you want to do with it. Based on your brief description of your needs, Cacti (www.cacti.net) would seem to be a good fit. Cacti is a web application, so you’ll need a web server such as Apache installed on one computer on your network, then install Cacti on that. This can be done by downloading a tarball from the web site, or there may be a package for your distro. Using Cacti, or any other web application, means you have the extra work of setting up a web server if you don’t already have one. On the plus side, it also means that Cacti’s information is then available on any computer on your network, requiring only a web browser. The other requirement is that you have the SNMP daemon (see boxout, overleaf) installed and running on each computer you want to monitor. Depending on your distro, this may already be the case.
Cacti can display a range of information from various computers on a single screen.
www.techradar.com/pro/linux
Otherwise, install the relevant package – snmpd for Ubuntu and friends. When you first access the Cacti page on your server, it’ll walk you though some basic setup. Then you can start adding information. Cacti collects information from your computers and stores it in a database, which it can then display in the form of graphs. First you add a device, a computer you want to monitor, then you can pick and choose the items you want to graph. The first tab on the Cacti home page is the console where you do all of this. The next tab is where the graphs are displayed. You can set up different collections (or trees) of graphs, depending on the information you need. You could have a separate tree for each computer, displaying various aspects of that computer. Or you could have, say, a CPU load tree that shows that information for each computer on the network. This enables you to customise the display according to your current needs. Because all the hard work is done by Cacti, adding another device is as simple as making sure snmpd is running on it and adding the graphs you want.
notwork Q Network I’m running Linux Mint 20 and am having real problems with my Ethernet connection dropping out. When I boot up it works fine, but after a period – anything from 10 minutes to 10 hours or,
Neil Bothwick likes turning readers’ woes into wins!
occasionally a couple of days – it loses connection and I have to disconnect the cable and reconnect it. I’ve tried bouncing the network manager and I’ve replaced the cable and network card. The switch is okay because my NAS and Windows PC both use the same switch and are fine. I’ve resorted to using the wireless network, but my connection – even via 5GHz band – rarely gets above 8Mbps whereas Ethernet, when working, gives me 30-35Mbps. I’ve searched the Mint and Ubuntu forums, but nothing seems to work. It used to work fine up until around Mint 19, but I’m pretty sure an OS problem would have been picked up and fixed by now so I’m at a loss. Any ideas how to debug/fix this? Alan Gauld
A
You seem to have covered most of the obvious causes, with one possible exception. You say the switch is working because other devices don’t have the same problem, but are you always using the same port on the switch? It’s possible for an individual port to develop problems, so the first thing to try is swapping the ports for the Linux PC and NAS to see if the problem switches over. You say you changed the network card. Is it the same type, or using the same 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 $ sudo lspci -k
in a terminal. Then create a file in /etc/ modprobe.d with a name ending in .conf containing blacklist MODULENAME
If the issue persists, check the system journal for any error messages about
April 2022 LXF287 11
SUBSCRIBE Save money today!
SUBSCRIBE Sign up today and get your
PowerKick YOUR GIFT! WORTH £50 t,
iss ou Don’t m e now! ib r subsc
wireless charger Product features
he PowerKick wireless power bank T 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 1
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. At linuxformat.com
! DON’T MISS s ar ye Includes 5 & r se U x nu of Li Developer issues
CHOOSE YOUR PACKAGE! 6 MONTHLY PRINT EDITION
PLUS!
SAVE!
Only
20%
£33.75
Six months of Linux Format in print by Direct Debit
6 MONTHLY PRINT + DIGITAL EDITION
PLUS!
NOT FROM THE UK?
Turn to page for more grea63 subscriber t deals!
DIGITAL EDITION ONLY
SAVE!
SAVE!
Only
47%
£46.25
Six months of Linux Format in print and digital by Direct Debit
Only
39%
£27.50
Six issues of Linux Format 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
1) Only available to www.magazinesdirect.com subscribers
PLUS: Exclusive access to the Linux Format subs area!
April 2022 LXF287 17
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. IN BRIEF
Slackware was created by Patrick Volkerding and had its first release almost three decades back, in 1993. This makes the distro one of the two oldest Linux distros that are still actively maintained, with the other being Debian. They say, “If you want to learn Debian, use Debian. If you want to learn Fedora, use Fedora. But if you want to learn Linux, use Slackware.” This still holds true.
ne of the unique aspects that differentiates of users who are still using Slackware, and continue Slackware from the other distros is its glacial to do so. pace. Even as the distro is actively developed Another important change that helps catapult behind the scenes, it doesn’t put out releases as often as Slackware to the modern Linux desktop is support for the some of the current crop. PAM library. Starting with this release, the distro also So while most modern distros, such as Ubuntu and moved away from ConsoleKit2 to elogind that helps run Fedora, release every six months or so, Slackware follows software that depend on systemd while running on distro the “release when it’s ready” philosophy. No surprise, that doesn’t use it, like Slackware, which still uses its then, that Slackware 15 is the distro’s first major release in custom System V-based init system. over a decade. In fact, the distro last had a stable dot release back in 2016 (v14.2, in case you’re wondering). Into the workshop And what were the devs up to in the meantime? Designed for experienced Linux campaigners, Slackware’s According to the release notes of Slackware 15, they charm is that it’s the most Unix-like Linux distro. It tested over 400 different kernel versions before settling adheres to the Keep It Simple, Stupid (KISS) design on the 5.15 LTS kernel for this release, which will be philosophy, which enables advanced users to build their supported until at least October 2023, and going by Linux desktop or server exactly as per their requirements recent trends, most probably for quite a while longer. without any bloat and unnecessary components. In addition to the excellent hardware support brought Slackware takes pride in helping users exercise complete in courtesy of the 5.15 kernel, including preliminary control over their installation, and everything in the distro, support for Apple’s M1 chip, the distro can now boot on from its installer to package management system is a computers with the UEFI firmware. However, it still doesn’t reflection of its ethos of technical simplicity. support running under SecureBoot, but the release notes As is customary for Slackware, the latest release also hint that it might be supported in the next release. ships with two kernels. There’s the huge kernel that rolls in Another major update is the switch to the KDE 5.23.5, which is the desktop environment’s 25th anniversary edition. Slackware 14.2 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.
O
USABLE SLACKWARE Most Slackware users weren’t running Slackware 14.2 on their machines, and were instead using Slackware’s rollingrelease “-current” branch. This is where all the development takes place, until it’s considered stable enough for a release, at which point it’s split into the development branch for the next release. While it can be considered the equivalent of the Testing branch of most
22 LXF287 April 2022
other distros, and isn’t advisable for production servers, it’s become a popular method for powering desktops among Slackware users. Then there’s Slackel that uses the latest software from Slackware-Current, and combines them with the userfriendly tools from the Salix project. Salix is based on Slackware’s stable releases and has been dormant for quite a while.
However the distro has produced some custom tools that Slackel has borrowed to give new users a pleasant experience, straight from installing the distro to the dependency resolving graphical package-management tools. Other desktop-friendly Slackware derivatives include Absolute Linux, Zenwalk, both of which have put out releases based on Slackware 15.
www.linuxformat.com
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… SPECS CPU: AMD Zen 2, 2.4–3.5GHz Core: four cores, eight threads GPU: AMD RDNA 2, 1–1.6GHz GPU units: Eight RAM: 16GB LPDDR5, 32-bit quad-channel Storage: 64GB eMMC, 256GB NVMe, 512GB NVMe Display: 7-inch LCD touchscreen, 1,280x800, 60Hz Audio: Stereo speakers, 3.5mm jack, dual mics Comms: Wi-Fi 2.4/5GHz 2x2 MIMO 802.11ac, Bluetooth 5.0, USB Type-C (DisplayPort 1.4 support), microSD UHS-I Battery: 40Whr Size: 298x117x 49mm Weight: 669g
Arch Linux has never looked so good!
24 LXF287 April 2022
he Steam Deck isn’t just a games console. It’s a PC, which means you can plug it into a monitor or TV, hook up controllers or a mouse and keyboard, install Linux or even Windows if you prefer. As with any PC, you can use launchers other than Steam and even take it apart if you want to. But the Steam Deck has some unique features that give it a more streamlined, console-like experience. The new version of SteamOS, Valve’s Linux-based operating system, will be able to seamlessly play games that were built for Windows thanks to the Proton compatibility tool. The system can suspend and resume games, too, and supports some fancy new AMD graphics features. “Launch” in this case doesn’t quite mean you’ll be getting a Steam Deck in your hands on 25 February. On this day Valve will begin emailing everyone who preordered a Steam Deck. “Customers will have three days (72 hours) from receipt of their order email to make their purchase, before their reservation is released to the next person in the queue. The first units will be on their way to customers starting the 28th, and we plan to release new order email batches on a weekly cadence," Valve says. So if you’ve not pre-ordered don’t expect to get your hands on the hardware any time soon.
T
Go Valve or go home
The Steam Deck is currently only available to reserve for the US, UK, Canada and the European Union, but Valve has told us that it wants to make the Deck available to order in more countries when it can. There are no plans to sell the Steam Deck in stores, so buying it from Valve directly will be the only option for the foreseeable future. The price of the Steam Deck depends on which version you want, and there are three different versions
The promise is AAA gaming access, no matter if it supports Linux.
based on storage size. The Steam Deck costs $399 for 64GB; $529 for 256GB; and $649 for 512GB. The more expensive versions of the Steam Deck feature faster NVMe SSD storage, while the cheapest is listed with a 64GB eMMC (embedded multi-media card) storage solution. All three versions will enable you to increase storage space with a MicroSD card, at least.
Tear down
The Steam Deck specifications were revealed by Valve alongside the console itself, which means we know all about what lies beneath the console’s seven-inch screen. The most important thing to note for Linux users is that the Steam Deck runs on an AMD APU, and one we’re yet to see elsewhere. This chip is built around two key AMD architectures: Zen 2 and RDNA 2. The Zen 2 architecture is the same one found in AMD Ryzen 3000 processors. Within the Steam Deck reside four Zen 2 cores, capable of eight threads, ready and waiting for your portable gaming needs. The RDNA 2 architecture is behind the handheld PC’s 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 the faster the MicroSD, the better for optimal game load times.
www.linuxformat.com
ROUNDUP Ubuntu alternatives 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 system is really under strain. To our satisfaction, all the distributions were usable on such a setup, but we would only consider Lubuntu and Bodhi as viable full-time OSes for this machine. Beyond 2GB of memory, the operating system and desktop becomes less of a factor, and substantial applications use a higher percentage of the total memory anyway.
26 LXF287 April 2022
his month, we’re looking at Ubuntu alternatives. These are Linux distributions that use Ubuntu as a base and then add customised functionality. This way of creating a distro makes a lot of sense because it guarantees the stability and massive software base and driver support of Ubuntu, while still giving the developers freedom to customise the experience. Of the five distributions that we’re examining, only one – Lubuntu – is an official Ubuntu flavour, and the other four have been created by independent teams. You might feel some anxiety about stepping away from the standard Ubuntu release, but all of these
T
distributions are quite popular, with substantial user bases. Although the outlook of these distributions is somewhat modern, they aren’t experimental; they’re all ready for day-to-day use as a main setup. We’re setting out to discover if they would be good enough to use as a daily driver, for experienced Linux users such as ourselves or, perhaps, users of other operating systems who might be tempted to switch. We’ll tell you now: they’re all good distributions, and they all put you on the cutting edge of what a desktop Linux distribution has to offer, but they did have different strengths and weaknesses.
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 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 as Totem video player and Evince document viewer, although this distribution seems to have picked up the odd GNOME habit of giving applications generic names such as Files, Videos and Document Viewer. The Bodhi Linux application selection is stripped down to the essentials with more system-configuration tools than actual applications. Perhaps it could have included a few more extras? The choices are appropriate for a distro that bills itself as lightweight such as Leafpad text editor, Ephoto photo manager and Thunar file manager. Chromium is the web browser, and although there are lighter choices out there, they tend to come with their own compromises in fairness. (mumbles in Firefox–ED) The Zorin default application is closer to that of a standard Ubuntu desktop, with no particular concessions to lightweight options. This is fine because this is a distro destined for standard desktop use. The applications are ones such as Nautilus as the file browser. By the same token, the application selection isn’t paired back and it includes extras such as GIMP for image editing, but simple games such as Mahjong, for example, feel unnecessary. Overall though, it’s a selection of high-quality applications that should serve to impress first-time Linuxers if nothing else.
P
Lubuntu provides a good balance of useful programs without being overwhelming. It could likely manage most basic tasks without having to install anything extra.
Linux Mint has a fairly full set of applications on a standard installation that cover most of the major bases for office and general computer use such Firefox, Thunderbird and the LibreOffice office suite. This is another distro that uses GNOME generic application names rather than the full names in some cases. Lubuntu has a selection of applications that sits in the middle in terms of how much stuff it gives you, and there’s a slight KDE connection here even though the programs tend towards lightweight options. PCMan is the file manager, and this springs up almost instantly when launched. VLC isn’t the most lightweight media player, but it’s well known and has a lot of features.
VERDICT POP!_OS 8/10 BODHI 7/10 MINT 8/10 ZORIN OS 8/10 LUBUNTU 8/10 Lubuntu may contain the best balance of default applications, but there were no major faux pas here. The Mint Welcome application can be skipped or worked through to carry out the initial configuration options. There are also some links to beginner’s documentation.
Install and first run Where we find out how smooth the installation is and what it gives you.
ll of the installation sequences stuck close to the Ubuntu standard. They all offered encryption, but the option was slightly hidden in the case of Bodhi and Zorin OS. Some 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 (nonskippable) first-time run greeter repeated some of these questions and information. The Mint Welcome application was a normal-looking application (which we liked) and offered some configuration options. It also popped a reminder about checking for appropriate video drivers. It’s in keeping with the overall minimalism of Lubuntu that the first-time login launches the desktop with no further fanfare, and Bodhi takes the same approach in this regard. On first-time login, Zorin OS features an animation, set to music. This is then followed by an optional feature tour. One good thing about this is that every slide has a link at the bottom that opens up the appropriate settings.
A
www.techradar.com/pro/linux
We appreciate that Ubuntu kicked off the trend of minimalist installation procedures, but we would have liked to see more innovation here, in each case, with perhaps some optional extras that could be installed such as ‘office applications’ or ‘development tools’ and so forth.
VERDICT POP!_OS 7/10 BODHI 6/10 MINT 7/10 ZORIN OS 8/10 LUBUNTU 6/10 Zorin OS ticks the most boxes when it comes to installation, and the feature tour actually does something useful.
April 2022 LXF287 27
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 annoyingly precise about it, isn’t a complete operating system. It is but a kernel. And like the kernel of a seed pod, it requires all the surrounding bits to be useful. A bootloader can happily load a Linux kernel with no init system specified, and it will just sit there. Without userspace applications (for example, systemd in the first instance) telling the kernel what to do it will simply idle. Yet it has the potential to do anything. The kernel includes everything you would think of as being a
L
32 LXF287 April 2022
low-level component of the operating system, as well as some things you might think belong elsewhere. This includes drivers, filesystems, network protocols, schedulers (process and I/O), memory allocators and all kinds of other treasure. In the early days of Linux, users would regularly have to face compiling their own kernels, sometimes to get new hardware support, sometimes to reconfigure their way out of brokenness, and sometimes to improve performance. Users of Linux From Scratch or Gentoo will be familiar with the kernel compilation process, since it’s more
or less mandatory there. But it’s an option for any flavour of Linux, so we thought we’d have a go at making building kernels more accessible. As we’ll discover, the Linux Kernel is huge and complicated. It may be tempting for some to pore over it with a fine-toothed comb, trying to “optimise” it for speed or size. But this is for the most part hopeless, and more likely to result in breakage than anything else. If you want a faster, more responsive kernel, then a better approach is to use one of the many custom efforts that are available.
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 ought to be an umbrella term for the ‘thing’ that’s responsible for everything your computer does after the BIOS/UEFI hands over control to the bootloader. For popular systems such as Windows and macOS it’s easy to lump everything 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 kernel hands over to the initialisation system (for example, systemd or runit). Yet it turns out that every operating system has a kernel. The falsehood that macOS is based on BSD (perpetuated by lazy journos and Mac users who like to claim their OS is more grown up than it is) stems from 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 by Apple in 1997). Darwin has its own kernel called XNU (an acronym for X is Not Unix), which unlike Windows and Linux is a hybrid, as opposed to a monolithic, affair. It’s based on the Mach kernel, originally a research project into microkernels, with BSD functions added (so it’s not a “BSD-based” kernel). The more shiny layers of macOS, namely the Aqua GUI, the Cocoa/Carbon interfaces and various application services, are all proprietary and have nothing to do with BSD.
The kernel is a modular masterpiece that can run everything from old AGP graphics to the Large Hadron Collider.
W
Driving the deal
The XNU kernel has its own driver API called IOKit, and Windows’ kernel has the less imaginitively titled “Windows Driver Model”. Drivers (programs that talk to hardware) are perhaps the easiest component of a kernel to get your head around, in the sense it’s easy to see why they need to be there. The only trouble is, most modern Linux distros have very few drivers baked in to their kernels. Instead, the preferred approach is to include drivers compiled as external modules, which can be loaded early on in the boot process by Udev 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. So the Linux Kernel contains drivers for every bit of hardware supported by Linux. Well, almost. Modern hardware (particularly Wi-Fi and GPUs) often requires firmware to be uploaded to it on every boot, otherwise it won’t work. This firmware is generally not included in distribution’s kernel source packages (since it’s not
www.techradar.com/pro/linux
source code and sometimes proprietary), but rather shipped in a separate linux-firmware package. Since this package is required for all the drivers in the kernel (usually packaged as linux-image-…) to work, we can’t forget its size (lib/firmware occupies over 700MB on our system). Drivers themselves, occupy fairly negligible space (see the box on page 36).
MAINLINING Over the page we’ll look at compiling a trivially modified Ubuntu kernel. Canonical apply patches and backported fixes to their kernels, with the effect that an Ubuntu kernel bearing the version number 5.13.0, say (which we got by running uname -a on our Ubuntu 20.04 VM) may be constitutionally very different from a “mainline” Kernel 5.13 that you would download from https://kernel.org. You might want to build your own mainline kernel, for example if you suspect a bug 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 follow the instructions over the page. What’s even easier is using the pre-packaged mainline kernels produced by the Ubuntu team. First read the blurb at https://wiki. ubuntu.com/Kernel/MainlineBuilds, then follow the link there to the Mainline Kernel Archive. You’ll see that while Ubuntu 21.10 and LTS (if it’s kitted out with the Hardware Enablement stack) are running Kernel 5.13, the current in-development series (confusingly also called “mainline”) is 5.17. We don’t advise trying out these release-candidate (RC) kernels at first. But you may have reason to try the Longterm branch, which currently is 5.15. As of now, this branch is used by Pop!_OS and it’s what the next LTS of Ubuntu will be based on.
A smorgasbord of kernels can be found at https:// kernel.org, from bleeding edgeRCs, to the SLTS 4.4 series.
April 2022 LXF287 33
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 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 laptop – and let’s face it, you probably do – but how often do you just hop over to the sofa to continue enjoying a classic album or the latest must-watch TV series (I’m literally catching up with Buffy – Ed)? With the correct setup, you can make this happen. You can also store your own media on a server and stream it to your TV or other devices. This is where casting methods and media servers come in, but currently the world is a confusing collection of Google Chromecast, Amazon Fire sticks, Apple whatchamacallits and a host of other device-based screen-sharing systems. So let’s delve into the protocols and see how it all works. To do this, you’ll need to set up your software. For the simplest cases, everything is available by default from your distro, but better alternatives keep appearing. You may also be able to tweak things to your preferences, especially when you’re creating your own content. In this article, we’ll present you with our suggestions for your own journey to media mastery.
W
OUR EXPERT Mats Tage Axelsson would love to broadcast about all things Linux 24/7 .We’re sure that it would be must-watch TV.
Stream or cast?
Let’s start by explaining the two main concepts: streaming and casting. To stream media, you send your media from somewhere for others to Once you’ve selected a suitable ‘sink’, you have a corner marker indicating that you’re sharing the screen with other devices.
44 LXF287 April 2022
GNOME Software Displays starts by requesting your shared screen and then identifies “sinks” aka suitable connections.
watch – typically this is a show of some kind. It’s what YouTubers do when they’re broadcasting live. Casting refers to the end user: how you can make your incoming stream go to a specific device (aka a sink). There are different protocols involved with both these activities. Usually, you don’t need to worry about which protocols are used until you have to choose them for your server. Still, if you know and run Linux then, as ever, you have choices. You may be able to improve the quality of your media, or use a package that’s already on your computer. Some of the protocols you hear about will involve specific needs. For example, the RTSP protocol supports video directly from cameras. You can use this protocol for video casting over Wi-Fi. Other protocols that you need to consider are the ones that stream to different sites such as Youtube (RTMPS) or Facebook (WebRTC). Note that you may use one protocol to send your media files as opposed to watching. You can also use the RTSP protocol for a first-person viewer drone. The big problem with RTSP is limited browser support. Having said this, there’s a gstreamer1 plugin in the apt repositories and a Perl server. The main server, though, is the crmtpserver. It’s a compact and efficient way to connect to video-conferencing, surveillance cameras and your smartphone. Apple introduced HLS or HTTP Live Streaming in 2009 to replace Flash from its phones. It’s become extremely popular – so much so that it’s the default for
www.linuxformat.com
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 Scratch” in the title of this article and didn’t run away screaming into the night? Then you were either intrigued by the premise presented in the last issue of Linux Format, or are a very special Linux fan indeed. But as the title says, we’re going to get right to it in this follow-up article. So get ready for the nuts, bolts, and other assorted components of Linux From Scratch. In the sake of efficiency, you should have the following prepared before diving into the following sections: Lots of patience. A steady hand for copying and pasting terminal commands. A love of reading (plain black text on white or grey backgrounds).
D
High bravery levels in the face of compilation errors. An i386- or x86_64-based PC with a modern(ish) distribution installed. Hard disk space to spare. Or even better, a blank partition. Even better still, a spare hard drive. A copy of https://linuxfromscratch.org/ lfs/downloads/stable. This article will follow along with, and frequently reference, the Linux From Scratch (hereafter also LFS) book. Since the LFS book is an actual book, it can’t reasonably be condensed to the size of an article here. So while we’ll highlight some early parts of the LFS build process, when you embark on this you should follow the book exactly. Its authors took great care in putting together some very fine instructions, so take advantage of them.
Preparing the host
Output of the check-versions.sh script showing that everything is working well on the host system.
48 LXF287 April 2022
The first thing you’ll need to do when preparing the /host/ system (in other words, the existing Linux system on which you’ll build LFS) is installing the prerequisite software. This consists primarily of development tools such as the GCC compiler, Make and Patch, as well as the stalwart open source languages Perl and Python. On a recent version of a Debian-based system, the following
command should get you everything you need (note a fair number of these will already be present, but it doesn’t hurt to include them): $ sudo apt install bash binutils bison bzip2 coreutils diffutils findutils gawk gcc grep gzip m4 make patch perl python3 sed tar texinfo xz-utils
Next, check that they’re all the right version. Section 2.2 of the LFS book provides a convenient script that will check to see if all the required versions of software are present, and confirm the ability to build source packages. Once you copy its contents into a text file and add execute permissions, you’ll find all you need to make sure the system is ready with the following command: $ check-versions.sh
If the results of this command (see screenshot, left) indicate all versions are sufficient and the system is able to compile a sample file successfully, your host system is ready. It’s time to prepare your target system.
Target system
The /target/ system in this context is simply a location in the filesystem where
www.linuxformat.com
TUTORIALS TUTORIAL Prey
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 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 search string are displayed. A fuzzy search, on the other hand, performs an approximate search, and instead of identifying exact matches, displays matching results with each keystroke. The fzf utility identifies itself as a general-purpose fuzzy finder. Released under the MIT License, the crossplatform tools can be used across all flavours of Linux.
W
OUR EXPERT Shashank Sharma is a trial lawyer in Delhi and an avid Arch user. He’s always on the hunt for affordable geeky memorabilia.
Installing fzf
Despite the usefulness of the tool, the project isn’t offered as part of the default installation of desktop Linux distributions. However, it’s available in the software repositories of quite a few. The project’s GitHub page provides a list of all the distributions that carry fzf in their software repositories, along with the supported version. Unfortunately, the latest release, version 0.29.0, is offered only in the latest releases of distributions such as Fedora. Manjaro, openSUSE Tumbleweed, Ubuntu, Debian and Arch, while most others carry older versions. If you’re running one of these distributions that offers the latest version, you can use the distro’s software management utility to install fzf. The command sudo apt install fzf can be used to install it on Debian and Ubuntu or derivatives, while sudo dnf install fzf can similarly be used to install it on Fedora.
Fzf has no dependencies at all, so installing using the install script is the easiest way to ensure you end up with the latest version.
Apart from using the software repositories, there are several other ways to install fzf, including using the package manager homebrew. Of course, you can also use Git to clone the project’s directory to your hard disk and then install fzf using the install script: $ git clone --depth 1 https://github.com/junegunn/fzf. git $ cd fzf $ ./install
The fzf tool supports auto-completion and various key bindings. The install scripts asks if you wish to enable these and also offers to edit your ~/.bashrc file. Once enabled, you’ll be able to deploy the following keybindings to invoke fzf:
RELATED PROJECTS You can assess the popularity and usefulness of fzf by the fact that the project maintains a list of related projects on its Github hosted wiki (https://github.com/junegunn/fzf/ wiki/related-projects). This is a collection of other tools and utilities that build on the functionality of fzf to offer an improved CLI experience. Consider the fzf-extras utility (https:// github.com/atweiden/fzf-extras), for instance, which adds additional key
52 LXF287 April 2022
bindings or the fzf-marks (https:// github.com/urbainvaes/fzf-marks) utility, which enables you to quickly create bookmarks to various directories. The page lists projects across many different categories such as Tmux, Vim, Bookmarks and Shell. Many of the listed projects haven’t seen a new release in quite some time, but these are simple tools offering very limited functionality, so don’t let that deter you from trying them out.
You’ll also find several projects under the ‘Similar implementations’ heading. These are projects that provide functionality similar to fzf. Pick (https:// github.com/mptre/pick) is one such project, although it doesn’t have the same degree of documentation as fzf. While fzf is written in Go, you can also try your hand at Skim (https://github. com/lotabout/skim), which is a fuzzy finder with identical feature set, but written in Rust.
www.linuxformat.com
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 assistant. It’s a free tool for not just collecting notes from a variety of sources, but also organising them, sharing them and even using them as citations and bibliographies within your documents. Zotero exists as two primary components: a desktop client and a browser extension, known as a web connector. This component enables you to capture all or part of a web page and add it to your collection. More on how that works shortly. By the time you read this, installing Zotero may be a simple affair using the Zotero-deb wrapper (see https:// github.com/retorquere/zotero-deb) for details, but at time of writing the author was in the process of
Z
OUR EXPERT Nick Peers says Zotero is the answer to his haphazard organisational systems.
GET TO GRIPS WITH ZOTERO 3
5
6
4
1
Navigation pane Organise your reference materials into collections from here, and save advanced searches to create dynamically updated ‘smart’ collections.
List of items Those items that meet your criteria from the navigation pane, tag selector and keyword search are displayed here.
4
Tag selector 2 All tags applied to the items in the middle pane are displayed here. Colour-code tags to give them more prominence.
Search tool Perform quick keyword-based searches of a selected collection or your entire library here. Click the down arrow to change the search criteria.
Create new items Use these buttons to create new items using templates, existing files or from ISBN numbers (and other codes).
Item pane The currently selected item’s details are displayed here, split across four tabs. Info contains metadata for use in citations.
3
54 LXF287 April 2022
$ sudo mv Zotero_linux-x86_64/ /opt/Zotero $ cd /opt/zotero $ ./set_launcher_icon $ ln -s /opt/zotero/zotero.desktop ~/.local/share/ applications/zotero.desktop
Once complete, you should find Zotero has added a shortcut to the Launcher for easy access. Launch Zotero and it’ll open your web browser to www.zotero.org/ start/ where you’ll be invited to install Zotero Connector 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 prompted to create a free Zotero account – see the box (below right) for why this is a good idea and how to get your data backed up and in sync using it.
Research the tool
2
1
transferring the package hosting to the Zotero organisation. In the meantime, head over to www.zotero. org/download/ to download and extract the tarball manually, then type the following commands, which assume you extracted the Zotero_linux-x86_64 directory from the tarball into your Home folder:
5
6
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 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 reference materials into collections – special folders that enable you to split reference materials between say work and family history. You then select a collection inside which you create each reference item. As these libraries grow they can become quickly unwieldy. The search tool at the top provides one way to filter these items, as does the ability to add multiple tags to items, which are displayed at the bottom of the lefthand pane. You can even link related items to each other, so when you select one item, you can quickly access those items too via its Related tab in the righthand pane. Items can be filed into sub-folders – or sub-
www.linuxformat.com
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 that not all home computers came with BASIC. The Jupiter Ace, from the Cambridge-based Jupiter Cantab Limited computer company was an oddity of the era. The Jupiter Ace looked like a cross between a ZX81 and a hot rod and we quite like that. The design of the Jupiter Ace was down to its creators Richard Altwasser and Steven Vickers, who had previously been part of the ZX Spectrum design team. The Jupiter Ace had 2KB of dedicated video RAM, which offered a performance boost 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 money) price tag. Accessories for the Jupiter Ace included 16, 32 and 48KB RAM packs, replacement keyboards and external storage devices. Most users saved their programs directly to cassette using tape recorder, which was a common technique of the era. Instead of running a BASIC interpreter/operating system we’re presented with Forth, a language that we shall get to grips with later (see LXF276 for more on programming the Jupiter Ace in Forth). The Jupiter Ace wasn’t a big seller, with a reported 5,000 units made and even fewer of the Jupiter Ace 4000 being manufactured at around 800 units, which featured a stronger injection-moulded plastic case. This computer may not have had the high sales of Sinclair’s and Commodore’s machines, but it has a special place in the hearts of coders who cut their teeth with Forth.
OUR EXPERT Les Pounder is associate editor at Tom’s Hardware and a freelance maker. He blogs about hacks and makes at bigl.es.
To see the contents of our word (subroutine) we need to use the LIST command. In BASIC we’d provide a line number, but with Forth we have to pass the command the name of our word. For example, LIST lxfloop.
58 LXF287 April 2022
Emulating a Jupiter Ace
The best Jupiter Ace emulator that we could find for our Kubuntu install was xAce, but bear in mind that we experienced a few bugs while exploring the program.
CREDIT: Factor-h, CC BY-SA 3.0, https://commons. wikimedia.org/wiki/File:Jupiter_ACE_(restored).JPG
W
The Jupiter Ace is a cross between a ZX81 and a hotrod, and we love it. Not many were manufactured, so finding a mint unit is a rarity.
We started by downloading the source files from the project’s GitHub page. Git users can either clone the repository from https://github.com/ lawrencewoodman/xAce or download and extract the ZIP file from https://github.com/lawrencewoodman/ xAce/archive/refs/heads/master.zip. Whatever method you choose to take, you’re left with the xAce directory. Next we need to install a few software dependencies. Open a terminal and update your package repositories. $ sudo apt update
Now install the latest version of the gcc C compiler and some extra C development libraries. $ sudo apt install gcc $ sudo apt install libx11-dev $ sudo apt install libxext-dev
Install the build essential library meta package, which installs a list of tools necessary to compile and debug the xAce installer. $ sudo apt install build-essential
www.linuxformat.com
BACK ISSUES
BACK ISSUES
MISSED ONE?
ISSUE 286 March 2022
ISSUE 285 February 2022
ISSUE 284 January 2021
Product code:
Product code:
Product code:
In the magazine Not all VPNs are created equally – find out how to avoid second-rate services and maintain your privacy online with our in-depth feature. We also test five GUI text editors, show how to build a distro from the ground up using Linux From Scratch, emulate an MSX, set up multi-boot USB devices, code a 3D game world, and reveal the tools for managing your passwords from the command line.
In the magazine Stay one step ahead of the nefarious perpetrators of ransomware with our in-depth feature. We bring you tutorials on rock music effects, offline password management and creating a virtual network lab. Discover how to set up a temperature display for your Raspberry Pi and build web services with Go and the Gin framework. We also put five of the best GUI-based backup tools through their paces.
In the magazine Discover how to turn your Raspberry Pi into an allsinging, all-dancing media hub. We put a spotlight on video conversion tools, take you on a tour of Stacer, the one-stop system management tool, and emulate the Oric-1 (thankfully without that keyboard). Discover how to build a Pi-powered NAS and learn more on how the world’s top-500 supercomputers all harness the power of Linux.
ISSUE 283 December 2021
ISSUE 282 November 2021
ISSUE 281 October 2021
Product code:
Product code:
Product code:
In the magazine We pit Ubuntu against Fedora to see which is the better Gnome-based distro. Five filesystems are put through their paces, we show how to run a Ghost blog, code a Galaxian-style shooter in Python, and use Okular to edit PDF files with ease.
In the magazine Linux and Windows can work in perfect harmony – find out how in our eight-page guide. We share files across a network without the need for protocols, emulate the Tandy TRS-80, control the Pi’s GPIO with Scratch, and create our own server.
In the magazine Discover how to customise the Mint 20 desktop with our in-depth feature. We explore virtual private servers, assess open source art programs, build a Pi-powered pinhole camera, recreate pseudo-3D racing games and emulate the Atari 800.
DVD highlights Ubuntu 21.10 and Devuan 4.0 “Chimaera” (both 64-bit only).
DVD highlights Zorin OS 16 Core, Finnix 123, Lakka 3.4 and LibreELEC 10 (sadly all 64-bit).
DVD highlights Mint 20.2 “Uma” and Elementary OS 6.0 “Odin” (both 64-bit).
LXFDB0286
LXFDB0285
LXFDB0283
LXFDB0282
LXFDB0284
LXFDB0281
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
READING IN THE USA?
UK readers 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
From $132 For 13 issues
REST OF THE WORLD From $132 For 13 issues
EUROPE
From €100 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 Part One
HOME ASSISTANT Credit: www.home-assistant.io
Make your home as smart as possible
Don’t miss next issue! Subscribe on page 16
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 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 have we read about hardcoded administrator-level accounts being left enabled on devices? Canonical and Microsoft provide IoT platforms with security in mind. When using commercial smart home/Internet of Things devices it’s important to keep two things in mind. The first one is that of privacy. Would you be happy if a data breach caused your data to be made available to the public? The second matter is that of sustainability. What would happen if the device’s manufacturer decided to discontinue the web service 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 many different protocols. Home Assistant will keep data on your local network wherever possible and can also integrate with third-party cloud products if required. During this article we’ll be installing Home Assistant and then configure it for basic operation. In part two of the series we’ll discuss how to use slightly more advanced parts of the system, such as automations. Installation to both Raspberry Pi and a virtual machine is simple and both will be briefly covered below.
S
OUR EXPERT Matt Holder has been a fan of the open source methodology for over two decades and uses Linux and other tools where possible.
A huge number of smart home manufacturers are supported, including Ikea Tradfri lights, Phillips Hue and the Unifi network controller. Find out more: www. home-assistant. io/integrations.
64 LXF287 April 2022
Pi Machine
The easiest way to install a software image on to a Micro SD card is to use Raspberry Pi Imager. This can be downloaded from www.raspberrypi.org/software. Once downloaded, insert the Micro SD card into your computer and open the tool (this may need to be opened using the sudo command to elevate the permissions the tool uses. Select Home Assistant from the OS section of the tool, select the Micro SD card under the Storage section and then click the Write button. It’s important to select the correct storage
Enter the required details to create the first user account.
device, otherwise the wrong device may be wiped and overwritten with Home Assistant. Now insert the micro SD card into the Raspberry Pi and connect power and Ethernet. Within a few minutes Home Assistant will have booted, ready for configuration.
Virtual Machine
Alternatively, Home Assistant can be installed as a virtual machine (VM). VM images for KVM, VirtualBox and VMWare Workstation can be downloaded from the Home Assistant website (www.home-assistant.io/installation/ linux). Once downloaded, follow the instructions to create the VM. Once the VM has been created, it can be switched on and within a few minutes the system will have booted and be ready for installation. To configure Home Assistant, open your web browser and visit http://homeassistant.local:8123. If this doesn’t work, then visit http://<IP_ADDRESS>:8123 instead. The IP address can be seen by connecting a monitor or TV to the HDMI output of the Raspberry Pi, or by
www.linuxformat.com
TUTORIALS Publishing ebooks
LIBREOFFICE Credit: www.libreoffice.org
Publishing your own slick ebooks
Part Two
Missed Part One? Turn to page 62 to get hold of it
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 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 available as ebooks. This month’s tutorial picks up from where part one left off in LXF286, with a basic formatted ebook, so you don’t need to read part one but we’re assuming that you have some formatted text to work with in LibreOffice.
W
OUR EXPERT Michael Reed is a Linux nerd and a selfpublished author. Guess which one pays the bills.
If you need help when using LibreOffice for your book project, the LibreOffice website has a comprehensive traditional manual. See https:// documentation. libreoffice.org.
68 LXF287 April 2022
Illustrations and other Images
You may want to add images to your book. These could be photographs that relate to the content of the book, other types of illustration such as diagrams, or even graphs or charts. First, we’d recommend copying any images that you intend to use as part of the book into the project directory of the book. LibreOffice does include some simple image-editing facilities, but generally it’s worth loading the images into a dedicated image editor such as GIMP (www.gimp.org) to carry out any required manipulations such as cropping the image or adjusting the brightness. Colour printing is quite a lot more expensive than outputting your book in monochrome, and if you’re making a monochrome print edition then any included images will have to look good in black and white. In the case of an ebook, your images will show up as colour or monochrome, depending on the type of device it’s viewed on. In that case, the best compromise is to at least check the image in monochrome. If you use GIMP to reduce an image to black and white then the option you need is Colours>Desaturate>Colour to Gray..., which can be found in the main menu. For print or ebook publication, 300dpi is roughly the correct resolution to aim for. However, the actual resolution in pixels varies, depending on the size of the image. For example, an image that filled the entire page, including the borders, of a 6x9-inch book would have a resolution of 300 multiplied by six (1,800 pixels) by 300 multiplied by nine (27,00 pixels). That should give you a rough guide, but remember that most images won’t
We adjusted this image so that it doesn’t go over the borders and then added a short caption below it.
cover the entire page. So, a 3:2 ratio photograph, with text above and below, should be fine at around 1,500x1,000 resolution.
Adding the image
So, how do we include an image? Inserting the image is achieved by selecting Insert>Image... This launches a dialog where you can select the image, and Writer will do its best to scale the image so that it fits on the page. Once the image is inside your document, you’ll notice that there are some resize handles around it. The corner handles are the most useful because they maintain the aspect ratio of your image as you resize it. Typically, you’ll want to resize it so that the image doesn’t extend into the border of the page. If you right-click the image, the Rotate or Flip submenu is worth exploring if you think you can make better use of the page by including the image on its side. There are some more advanced options that can be accessed by right-clicking the image and selecting Properties... In the first tab, the Type tab, there are some anchor options that enable you to glue the image to a specific line, paragraph or page. By default, the image will sit in the middle of the page with no text around it, which is a common style for books. If you want to have the text wrap around the image instead, check out options in the Wrap tab of the dialog. To add a caption to the image, right-click it and select Insert Caption... This enables you to both write the caption and choose the numbering style. It’s a shame
www.linuxformat.com
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 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 be skilled in English, maths and the sciences means that as the current crop of youngsters grows to adulthood, you’ll be able to have informed and valuable conversations with them, civilisation will move forward propelled by their sharp intellects, and maybe they’ll even find a cure for our own rapidly ageing frames before it’s too late. For seemingly endless chunks of the past two years, schools were closed, and pupils of all ages were forced to share stifled living space with furloughed parents and siblings for 23 hours every day. (I quite enjoyed it–ED) Learning was remote, with video links, virtual learning spaces, YouTube video lecture sessions, and of course, Google classroom.
E
OUR EXPERT David Rutland believes it’s impossible for a person to be either be overdressed or overeducated. People who know him agree that he is neither.
Google Classrooms
The choice of Google Classroom was a natural one for many schools. It enables teachers to manage multiple classes at once, juggle their timetables, and mark work directly within the browser. Even better, the fundamentals package is completely free. It’s ideal for schools on a budget. The downsides are equally obvious. Educators are introducing children to a predatory, data-slurping megacorp at an early age, and by integrating its tools into the educational environment, teaching them that yes, big tech is their friend.
Read our original VPS features in LXF281 and LXF282 at https://bit.ly/ lxf281lxfserver and https:// bit.ly/ lxf282lxfserver, respectively.
72 LXF287 April 2022
Viewing a user profile while in an admin role gives you plenty of insight into student progress, grades, badges and more.
Few schools have competent IT departments these days, and most take the view that it’s infinitely easier to subscribe to a service such as Google Classroom than to maintain their own education and learning platform. Ignoring – in addition to privacy-related problems – the unfortunate fact that Google has an addiction to killing off its own services on a near-monthly basis. We don’t know how many teachers are among the Linux Format readership, although we suspect there are more than a few school IT specialists. Online learning platforms aren’t limited to schools, and if you have a particular hobby in which you consider yourself an expert, there’s nothing to prevent you from creating a course – or even an entire online school, and administering it from the comfort of your very own VPS (virtual private server). Figure you know more about extreme couponing, frog dissection or dirt polishing? Here’s your opportunity to share that knowledge with the world in a structured and accountable way.
Get in the Moodle
There are hundred of plugins available for Moodle, providing practically everything you could want in a virtual classroom.
Moodle is a free, online learning management system, which enables you to create your own courses, track progress, hand out and mark assignments, and carry out the kind of administration you hazily remember your primary school teacher performing, bleary-eyed on a Monday morning in 1985. Moodle is FOSS, naturally, and was adopted by universities in the days before Google Classroom was even a glint in Larry Page’s eye.
www.linuxformat.com
IN-DEPTH Charitable characters
CHARITABLE CHARACTERS A map showing the 29 computer rooms YovoTogo has set up across Togo.
ltruism and open source often go hand in hand. Through our recent coverage of Perl (see LXF276) we’ve seen that the idea of helping others was intrinsic to both the language’s (and the community’s) development. More generally, anyone who gives their time and expertise to an open source project, whether it’s through code, translation, documentation or polite bug reports, is helping that project.
A
76 LXF287 April 2022
You might think that hacking on your favourite project is probably not going to save the world. But then that all depends on the project. Back in 2016 (see LXF216), we featured Emmabuntüs, a French collective that combined the power of Linux with the charitable efforts of a hardware recycling cadre. Back then it was putting its bespoke spin of Ubuntu (also called Emmabuntüs) on donated and refurbished computers, and sending those machines out into the
world. Both locally, to the Emmaüs communities in France, and through partnership with other organisations, as far afield as Kathmandu, the Ivory Coast and Benin. Nearly six years on and Emmabuntüs is still at it. The only thing that’s changed is that the distribution is now based on Debian. The collective’s latest initiative is a customised USB image for mass repurposing of machines. Thanks to some canny scripting, this makes doing this at
www.linuxformat.com
CREDIT: YovoTogo, JUMP Lab’Orione and Emmabuntüs
The Emmabuntüs collective enlightens Jonni Bidwell as to its kind and open source efforts.
THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET
HotPicks
Alexander Tolstoy is back with another fine collection of open source tools to make more of your time at the Linux coal face.
Weather Widget 2 Fancontrol GUI Wine DaedalOS FreyrJS Chmod-CLI Rescuezilla Warble SpaceHuggers Efiboots Ehh PLASMA EXTENSION
Weather Widget 2 Version: 2.0.4 Web: https://github.com/ blackadderkate/weather-widget-2 his new Plasma extension is the long-awaited 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 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, 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 for using DuckDuckGo. Strangely enough, none of those 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 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 a compact mode and will display just the temperature and the sky conditions. Click it to roll down the graph with all the details. You only need to glance at the expanded screen of Weather Widget 2 to quickly find out what the weather will be doing for the next few days. You can add more locations in the widget’s settings. For example, it makes sense to add the same location twice to compare forecasts from OWM & Met.no. You can also search for locations right from the Weather Widget 2 settings screen, and even provide longitude and latitude manually for greater accuracy.
Find out if it’s shorts or umbrella weather, with the help of the latest version of Weather Widget.
T
www.techradar.com/pro/linux
EXPLORE THE WEATHER WIDGET 2 INTERFACE 4
1 2
5 3
Manage locations Search for your specific location right under the OWM or Met.no location dialog, or provide exact geographical values by hand.
1
Set up familiar units The widget is familiar with either metric or Imperial systems and enables you to choose extra details, such as the units for atmospheric pressure and wind speed.
2
Set the display mode for panels 3 Weather Widget 2 supports three panel modes: horizontal, vertical and compact. No
matter if your panel is thick or thin, the widget will always remain readable. Temperature and pressure curves Quickly assess and keep in mind how the weather is going to develop for your location. No forecast is ever 100 per cent accurate, so why not add two: one from OWM and another from Met.no?
4
Even more useful data Find out the amount of rain, wind speeds and directions, as well as the more classiclooking weather forecast presented as a table.
5
April 2022 LXF287 81
CODING ACADEMY CODING ACADEMY Binary trees
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 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 begin by discussing the basics of binary trees before we start implementing binary trees in Python.
T
OUR EXPERT Mihalis Tsoukalos is a systems engineer and a technical writer. You can reach him at www. mtsoukalos.eu and @mactsouk.
88 LXF287 April 2022
Get to grips with the basic concepts
Strictly speaking, a tree is a directed acyclic graph that satisfies the following three principles. First, it has a root node that’s the entry point to the tree. Second, every vertex, except the root, has only one entry point. Third, a path connects the root with each vertex. A directed graph features edges that have a direction associated with them. A directed acyclic graph is a directed graph that lacks cycles. As already stated, the root of a tree is the first node of the tree. Each node can be connected to one or more nodes depending on the tree type. If each node leads to one and only one node, then the tree becomes a linked list. A leaf node is a node without any children. Leaves are also called external nodes, whereas a node with at least one child is called an internal node. A binary tree is a specific type of tree where underneath each node there exist at most two more nodes. ‘At most’ means that it can be connected to one, two or no other node. The depth of a tree, which is also called the height of a tree, is defined as the longest path from the root node to a leaf, whereas the depth of a node is the number of edges from the node to the root node of the tree. If you create two binary trees based on the same set of elements added in a different order, then you’re going to produce two completely different trees. The simplest way to do that’s by starting from a different root node. So, in general, we don’t know in advance the final shape of our trees. The screenshot (above) shows two sample binary trees. The tree on top is a “good” binary tree because it’s balanced (the term is going to be explained shortly). The tree on the bottom of the image is not a very “good” binary tree.
This figure shows two binary trees: a balanced tree on top and an unbalanced one. Generally speaking, balanced trees are preferred.
Building a tree is simple. The difficult part is deciding what to store in each node. The definition of the node that’s going to be used in this tutorial is as follows: class Node: def __init__(self, val): self.data = val self.left = None self.right = None
The current version of node has tree elements (fields) – the data element that holds the actual value and the left and right elements that hold the pointers to the children nodes. Although the data element needs a value, the left and right fields can both have the None value, when a node is a leaf, or point to only one child. Usually both left and right fields point to other nodes based on the comparison condition (this is how you specify where a new value is going to be stored). You can change the Node definition to suit your needs or your data. What’s important to remember is that Python must be able to compare your data for things to work. Let’s grow ourselves a binary tree.
Building a binary tree
Building a tree is as simple as adding new nodes. Adding a new node to a tree involves finding out whether that value already exists in the tree or not. If not, we need to create a new node and put that new node in the correct place in the tree. The core functionality for adding nodes
www.linuxformat.com
CODING ACADEMY Web scraping Part One
Don’t miss next issue! Subscribe on page 16
PERL
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 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 format, sometimes the code you’re writing needs to scrape the ingredients of that soup apart and parse out meaningful data. Perl’s Mojolicious web framework includes a set of components that make this task easier. Although most Linux distros come with a version of Perl, it helps to have your own installation separate from the system so you’re not tied to a possibly older version that’s required to support operating system tools and other packages. This separate installation can live in your $HOME directory (or wherever you specify) with its own modules that neither require sudo to install nor interfere with those handled by the package manager. The most popular tool for managing separate Perl installations is called Perlbrew. Installation instructions are at https://perlbrew.pl/Installation.html. You can install it with either of the following shell commands, depending on what you already have installed:
S
OUR EXPERT Mark Gardner is a software developer and blogger with over 25 years of IT experience. You can reach him at www.phoenixtrap. com and @markjgardner.
$ curl -L https://install.perlbrew.pl | bash $ wget -O - https://install.perlbrew.pl | bash The map function is designed to transform a list or collection via a function. You could use a for each loop, but the map has the advantage of returning a new list or collection, enabling you to chain other methods or functions, like the -Mojo oneliner does with join().
92 LXF287 April 2022
From there, it’s a matter of initialising perlbrew, installing and switching to the latest version of Perl, installing the cpanm Perl module installer, and finally installing Mojolicious and IO::Socket::SSL. $ perlbrew init $ perlbrew install perl-5.34.0 $ perlbrew switch perl-5.34.0 $ perlbrew install-cpanm $ cpanm Mojolicious IO::Socket::SSL
Let’s say you wanted a list of links to the recent issues available from Linux Format. You can do this with a single Perl command using Mojolicious’ ojo functionexporting module. This might be something you’d put into a shell alias or cron job, not a production tool: $ perl -Mojo -E ‘my $base = l("https://linuxformat.com/ category/new-issue.html"); say g($base)->dom("article h1 > a") ->map( sub{ l( $_->attr("href") )->to_abs($base) } )->join("\n")’
A terse Perl command line using Mojolicious’ single-letter functions. Good for fun one-liners, not so much for readable code.
https://linuxformat.com/linux-format-285.html ... https://linuxformat.com/linux-format-277.html https://linuxformat.com/zero-th-post.html
Let’s break this down into a structured Perl script: #!/usr/bin/env perl use Mojo::URL; use Mojo::UserAgent;
The preamble above starts our script by telling it to use the perl executable from our path, so we don’t have to worry where perlbrew installed things. After that we load the Mojo::URL module for constructing and parsing Uniform Resource Locators and Mojo::UserAgent, which is Mojolicious’ full-featured HTTP and WebSocket client. my $base = Mojo::URL->new('https://linuxformat. com/category/new-issue.html'); my $ua = Mojo::UserAgent->new; my $response = $ua->get($base)->result; die $response->message if $response->is_error;
Enter the new user agent
We save our starting URL in a Mojo::URL object, since we’re going to use it as the base for the relative links we retrieve later from that page. Next we create a new user agent and immediately use it to perform a HTTP GET on that URL. The get() method just returns a Mojo::Transaction::HTTP object representing the transaction taking place; we need to use the result method on it to obtain the actual $response . (There’s also a res method for returning a response; result has the added benefit of throwing an exception if a
www.linuxformat.com
CODING ACADEMY 3D game worlds
PYTHON
Part Two
Credit: https://github.com/jtmfam/Gh0stenstein
Interact with your 3D game environment Missed Part One? Turn to page 62 to get hold of it
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 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 game world we created. As much as this was done to some level of detail, it still left our 3D world looking a little blank and boring. We’ll now focus more on building objects in the game world rather than further explaining the mathematics and mechanics of how the program works. In this article we’re going to populate our 3D generated game world with game objects. We’ll also start adding collision detection so that you (as a player) will have to walk around the objects presented in the game world or be stopped by them. To help us do this we’ll also be modifying parts of the existing code to help build our game world more easily. Modifying the code will also help us to manipulate game objects placed into the game scene more easily.
F
OUR EXPERT Andrew Smith is a software developer for NHS Digital, has a bachelors degree in software engineering and a master’s degree in computer networks.
Installation and setup
Python 3.10 has recently been released, so we’ll install and set up version 3.10 for the benefit of this tutorial. For those who have Python/PyGame already installed, Python 3.8+ should be fine to use with this tutorial. Type the following to install Python 3.10 and PyGame: $ sudo apt-get install python3.10 $ sudo apt-get install python3-pip $ python3.10 -m pip install pygame When creating variable names, make the name meaningful to what is actually there for. This will make things clearer when reading the code.
94 LXF287 April 2022
Check the versions of Python and pygame. Next, git Clone from repository: $ git clone https://github.com/asmith1979/ lxf287_3DWorld/
The whole project has been put into a folder called PythonProjects, which was created before downloading the project. The source code and project can also be retrieved from the Linux Format archive. This tutorial will focus on the source code located in the folder called lxf287_3DWorld\src. If you’ve not already accessed that folder, type cd lxf287_3DWorld
The redbrick texture is used for the walls while the player navigates the 3D world. It’s the third texture to be loaded into the program.
to open the folder and gain access to the Python source code. You’ll see two Python source code files: main.py and main_2.py. The Python file main.py is the Python script file that you’ll be editing and main_2.py contains the full tutorial code. To edit and view the source code you can either use the default text editor installed on your flavour of Linux or something more specific such as Notepad++, PyCharm or VS Code. The choice is up to you. In this tutorial we’ll be using gedit to view and edit the source files. It may be helpful to open two console windows: one for editing/viewing source files; the other for executing the PyGame code.
Adding game objects
From viewing the python file worldManager.py (in the class constructor of WorldManager), you’ll see that a number of game object images have already been loaded into the program. However, for the benefit of the previous tutorial, the game objects were not rendered in the generated game world. The current game objects that have been loaded into the program include: A barrel image A green light image A pillar image The remaining images that are loaded are for the image textures for the walls. The way in which the game
www.linuxformat.com
9000
NEXT MONTH
ESSENTIAL
Pi PROJECTS Everything you need to build awesome projects and physical Pi-based coding and making!
The #1 open source mag Future Publishing Limited, Quay House, The Ambury, Bath, BA1 1UA Email linuxformat@futurenet.com 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, David Rutland, Mayank Sharma, Shashank Sharma, Andrew Smith, Mihalis Tsoukalos, Alexander Tolstoy Cover illustration magictorch.com Raspberry Pi is a trademark of the Raspberry Pi Foundation. Tux credit: Larry Ewing (lewing@isc.tamu.edu) and The GIMP.
LXF288
will be on sale Tuesday 5 April 2022
Easy video sharing
YouTube? More like BooooTube! We bring you the better, easier and more open way to share your videos online.
So random!
Max-out your entropy and keep dev/random topped up with the most random numbers this side of a white-noise generator.
Satellite photography
There’s terabytes of space-based imaging out there – discover how to get it and how to process it, in the name of science!
ADVERTISING Commercial sales director Clare Dove clare.dove@futurenet.com Senior advertising manager Lara Jaggon 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 MD, tech specialist Keith Walker Head of art and design Rodney Dive Design director Brett Lewis Commercial finance director Dan Jotcham Printed by Wyndeham Peterborough, Storey’s Bar Road, Peterborough, Cambridgeshire, PE1 5YS Distributed by Marketforce, 5 Churchill Place, Canary Wharf, London, E14 5HU www.marketforce.co.uk Tel: 0203 787 9001 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 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 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 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 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 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. 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 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.
Future is an award-winning international media group and leading digital business. We reach more than 57 million international consumers a month and create world-class content and advertising solutions for passionate consumers online, on tablet & smartphone and in print.
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. Contents of future issues subject to change – we might been replaced by a machine learning routine.
98 LXF287 April 2022
Future plc is a public company quoted on the London Stock Exchange (symbol: FUTR) www.futureplc.com
Chief executive Zillah Byng-Thorne Non-executive chairman Richard Huntingford Chief financial officer Penny Ladkin-Brand Tel +44 (0)1225 442244