__MAIN_TEXT__

Page 1

2

Celestia 1.6 5 Stellarium 0.20

PLUS!

HOW TO…

D 4 EE OA .0 FR L 20

On test 1 Aladin Sky Atlas 11 3 KStars 3.5 4 SkyChart 4.2

N W TU DO UN UB

GET INTO ASTRONOMY

ENCODE BETTER VIDEO EMULATE THE APPLE MAC LEARN Pi ASSEMBLY CODE

The #1 open source mag

BLAST OFF

WITH LINUX! Everything you need to install Ubuntu, enjoy Linux and get a fresh start in 2021

pages of tutorials & features

67

Transform your photos with photostacking tricks

How new powerful tools are making the command line great again

ANGRY BIRDS

Code your own bird-based clone

DOCKER MADE EASY

Master the container basics and deploy with the best admins

Update to NextCloud 20 on your Raspberry Pi Activate the Linux-powered Robotic Operating System! LXF February 2021

Next-gen terminal


WELCOME

Year of the Linux…? WHO WE ARE We’re looking to blast off with Linux in 2021, so we asked our team of writers what new software, tech or projects they were looking forward to in 2021… Jonni Bidwell According to my inbox, late last night I ordered a significant quantity of Raspberry Pi gubbins. I’ve gotten a soil moisture meter, a temperature and humidity sensor, a mini TFT display and a Pi Zero. So the year will definitely start with some botanically themed adventures, and my houseplants (what sort?–Ed) will grow yet mightier.

Nick Peers 2021 is the year of the self-built Ubuntu 20.04 server, built on a low-powered Celeron J5040 motherboard housed in a four-bay NAS-sized chassis. Migrating everything across from my QNAP TS-251+ is going to be an interesting experience...

Les Pounder In 2021 I’m looking forward to RISC-V, open source CPUs, making their mark. Right now I have a RISC-V devboard and a soldering iron on the way. Did you know that RISC-V can even be used as the brains for a desktop PC! It’s a truly interesting board.

Shashank Sharma I could answer that it would be cool to see Linux ported to the Apple M1 (perhaps next issue–Ed). It’s also what Linus wants, so that’s something. But call me grounded, or materialistic, but I’d love to have a good, wellperforming 10-inch Linux tablet that’s a breeze to work with.

Alexander Tolstoy I hope there will be more Linux-based handhelds in 2021 of reasonable quality and price tags. Existing products such as Pinephone or Librem are all well and good, but we need more mass-market supply of such devices to finally shatter the dominance of Android. That’s what I’m dreaming of!

www.techradar.com/pro/linux

2021 is the year everyone can blast off with Linux! There’s the aging meme – it’s the year of the Linux desktop! – that’s supposedly a call to arms for mainstream consumer Linux adoption. The irony, of course, is that it hasn’t happened, even though Linux is now running pretty much everything else in the world: from your Android phone and tablets, to the fastest supercomputers and large chunks of the internet. The last holdout is the consumer desktop. There are very good reasons why Linux hasn’t had a look-in here. The Microsoft Windows monopoly ensures consumers only ever get to see Windows pre-installed on systems they buy and, of course, there’s human laziness to factor in. You might not like it but Windows works well, and has all the software and games people need. So why would the average punter or even business exert any effort to switch? It’s clear that in all the other areas where Linux has succeeded, there’s been a specific need that open source has fulfilled. Android needed a customisable kernel for mobile hardware. Supercomputers need custom kernels that can run on thousands of cores without extra charges. Internet services have developed out of academic Unix research and development that fits in perfectly with Linux. The Raspberry Pi needed an educationfriendly, low-cost operating system and Linux was there. With the consumer desktop, people just want something that works, is recognisable and runs their software. The late-2000 EeePC fad dabbled with Linux to cut costs, but was ultimately swapped to Windows as people returned them because they couldn’t run MS Office. This sounds awfully negative, but the big picture is that it doesn’t matter. The Linux kernel and supporting ecosystem has developed just fine without the consumer desktop, and will continue equally well having to make do with just the developer desktop, educational desktop, enterprise desktop, enthusiast desktop, high-performance desktop, media-creation desktop, science desktop, sysadmin desktop, the International Space Station desktop and beyond, so enjoy!

Neil Mohr Editor neil.mohr@futurenet.com

Subscribe & save! On digital and print – see p26

February 2021 LXF272    3


Contents REVIEWS

AMD Radeon RX 6800

18

The RX 6800 not only delivers 1440p performance, it also demolishes the RTX 2080 Ti at 4K, discovers Jacob Ridley.

SUBSCRIBE NOW! Page 26

BLAST OFF

WITH LINUX!

Jonni Bidwell’s preflight checks are complete and the LXF Penguin-Heavy spacecraft is ready to embark on its voyage of Linux discovery. More on page 34.

Guix System 1.2.0 

20

Strap in for this wild tour of the distro designed for the uber-geeks with your knowledgeable guide Mayank Sharma.

Microsoft Edge (dev) 

22

Microsoft’s shiny new browser touches down on Linux. Mayank Sharma fires it up for a test drive… or a voyage of discovery?

FerenOS 2020.11 

23

Mayank Sharma discovers one of the best distro options to introduce new users to Linux. It’s time to spread the word!

Amnesia: Rebirth 

24

Management refuses to go into the server dungeon, and for good reason – Leana Hafer has returned a changed woman!

ROUNDUP

Astronomy software 

IN-DEPTH

28

If you’re a novice stargazer but clueless about how to feed your passion, Shashank Sharma knows how you feel and has a few tools to help you get started…

4     LXF272 February 2021

Rise of the robot OS 

42

Mats Tage Axelsson gives you an introduction to the robotics operating system and shows you what components you can use to power your own bots.

www.linuxformat.com


CONTENTS ON YOUR FREE DVD

Pi USER Raspberry Pi news 

Ubuntu 20.04 LTS Bodhi Linux 5.1 Page 96

46

Elementary OS makes a development appearance for the Pi and RPi OS gets a late December update.

RetroPi 4.7.1 

47

Les Pounder loves retrogaming and Raspberry Pi, so with RetroPie and the new Raspberry Pi 400 the question is: will he find his Nirvana?

Run Majaro Arm 

DVD pages 

48

Les Pounder reveals how to get Manjaro Arm up and running on the Raspberry Pi 4 or 400, and start using the GPIO with Python.

Set up a Nextcloud 20 server 

96

Jonni Bidwell takes us back to basics with this month’s LXFDVD, getting your going with the latest Ubuntu Long Term Support release and Bodhi Linux 5.1 for older PCs.

50

TUTORIALS

The latest Nextcloud 20 release is here and Jonni Bidwell shows you how to get it running on a Pi 3, possibly one hosted by Mythic Beasts in the cloud!

TERMINAL: PDF tools 

58

Shashank Sharma does things to PDF files you can only dream of, the dirty man!

HANDBRAKE: Better video encoding  62

CODING ACADEMY Raspberry Pi assembly code 

Nick Peers reveals how to convert your videos into H.264 or H.265 codecs to save drive space and maximise compatibility.

88

John Schwartzman demos using assembly language code for the 64-bit Raspberry Pi to call Linux kernel services and the C runtime library.

Remaking Angry Birds in Python 

GIMP: Photostacking 

68

Combining photos of the same scene using a stacking technique can result in some spectacular results, reveals Mike Bedford.

92

EMULATION: Classic Apple Mac 

The not-angry-at-all Calvin Robinson talks us through creating an open-source replica of the mobile game Angry Birds, entirely coded in Python.

72

Les Pounder goes back to his college days and reveals how to emulate the classic Apple systems he used for work and play.

DOCKER: Starting with containers  76

REGULARS AT A GLANCE News 

6

Red Hat kills CentOS 8 and creates CentOS Stream, Google kills browser frameworks, RISC-V kills power use, no one can kill 32-bit and Vulkan is killing it with ray tracing!

Kernel watch 

10

Jon Masters has the latest developments.

Answers 

12

Trouble with Mint, trouble with Unity, trouble with Snaps, trouble with SD card encryption and trouble with a full system drive.

Mailserver 

16

Is Linux under virus attack? Is the LXFDVD attacking us with viruses? Are our EFI partitions under attack? Can you attack any old file with a text editor?

www.techradar.com/pro/linux

People think of Docker as a server-room only tool, but as Michael Reed demonstrates, home user can use it, too.

Subscriptions 

26

Back issues 

66

Get hold of previous Linux Format editions – but watch out, they’re selling out fast!

HotPicks 

Next-gen terminal tools  81

Alexander Tolstoy hasn’t got time to congratulate President Biden on his record win, he’s far too busy celebrating amazing FOSS like Waterfox, Songrec, Xsuspender, WinApps, Dog, YUView, AFTL, PixelDefence, Micro-racing, Distribyted and Topalias.

DVD pages 

IN-DEPTH 54

Discover the next-gen of terminal tools with David Rutland to transform your command-line life.

96

Jonni Bidwell holds your hand and guides you through using the LXFDVD on your PC.

Next month 

98 February 2021 LXF272     5


Newsdesk

THIS ISSUE: Early end for CentOS Google ups security 32-bit Linux doubts Speedy RISC-V CPU Vulkan adopts ray-tracing

DISTRO DRAMA

Red Hat kills off CentOS eight years early Support for the distribution will no longer last until 2029, and people are seeing red at Red Hat’s move. any CentOS users have been left fuming after Red Hat, the distro’s parent company, announced that it’ll be ending support for CentOS 8 by the end of 2021 – a good eight years earlier than initially promised. In a blog post (which can be read at https:// bit.ly/LXF272CentOS), the company stated that “the future of the CentOS Project is CentOS Stream,” and that once support for CentOS ends in December 2021, CentOS Stream will serve as the “upstream (development) branch of Red Hat Enterprise Linux.” It means that CentOS will no longer be a rebuild of Red Hat Enterprise Linux (RHEL), which for many people was a key selling point. Instead, it’ll be a rolling release Linux distro, similar to Arch. Rather than having fixed releases where major updates are released according to a schedule, rolling-release distros are constantly updated. This is handy for getting hold of significant fixes more quickly, but it can also make for a less stable distro experience. Red Hat has released an FAQ explaining the move (https://centos.org/distro-faq), where it denies that CentOS Stream will now serve as a RHEL beta test platform, claiming that “CentOS Stream will be getting fixes and features ahead of RHEL. Generally speaking we expect CentOS Stream to have fewer bugs and more runtime features as it moves forward in time but always giving direct indication of what is going into a RHEL release.” Still, this hasn’t stopped many users reacting with anger. Head over to the CentOS subreddit

M

6     LXF272 February 2021

(www.reddit.com/r/CentOS) to get a taste of how the community has reacted (at the time of writing, a post titled ‘RIP CentOS, 2004–2020’ and an image showing Red Hat stabbing CentOS in the back are some of the highest rated posts). Much of the anger resolves around how CentOS 8 was supposed to be supported until 2029, and many people and businesses may have deployed the distro on that basis. Others are annoyed that CentOS will no longer be suitable for enterprise workloads with its move to a rolling-release model. Many users are now looking for alternatives, and it hasn’t taken long for a new challenger to emerge. Rocky Linux (https://rockylinux.org) is

CentOS 8 was set to be supported until 2029, but it’ll now reach end of life in 2021, and people aren’t happy. At all.

“MANY USERS ARE NOW LOOKING FOR ALTERNATIVES, AND IT HASN’T TAKEN LONG FOR A NEW CHALLENGER TO EMERGE.” a community-driven enterprise operating system designed to be “100 per cent bug-for-bug compatible with Red Hat Enterprise Linux now that CentOS has shifted direction,” and is being led by Gregory Kurtzer, founder of CentOS. It’s early days for the distribution (there’s no ETA for its release at the time of writing), but Rocky Linux’s intensive development highlights just how strongly the community feels about Red Hat’s contentious move.

www.linuxformat.com


ANSWERS

Answers

Got a burning question about open source or the kernel? Whatever your level, email it to lxf.answers@futurenet.com

screen trouble Q Minty One fine morning I turned on my laptop, fully expecting my trusty Linux Mint 19 Tara to emerge triumphantly on screen, and for brief moments everything looked normal but, alas, no desktop or beautiful GUI ever appeared! The Mint logo appears with the five dots as if loading the system, remains stuck there for more than a minute and a half, then goes into a loop: 1) Screen goes black for 50 seconds 2) Arrow cursor appears for 30 seconds 3) Screen goes black briefly 4) Horizontal blinking underscore appears top left on screen for about 30 seconds 5) Screen goes black for 50 seconds, and the loop starts again This seems to go on indefinitely. I have tried updating the system, but there seems to be no internet connection available, neither via Wi-Fi nor cable. However, the screen works fine from any live DVD, so there’s no problem with the hardware itself. Any idea what causes this problem and what could be done to remedy it? I would like, if at all possible, to fix this without having to reinstall the system. Kaj Gornitzka

A

Ah, the curse of the pretty splash screen. It hides all the activity going

on during boot, which is fine until something goes wrong and you need to see what is going on during boot. When the splash screen appears, press Esc to get rid of it, then you can see what your computer is trying to do and, hopefully, what is failing. As you mention, the hardware would appear to be fine and so this is likely to be a software problem. Did the networking stop working at the same time as the GUI? Did you have any sort of crash or power failure, particularly during a system update? The first thing I would do is check your root filesystem with fsck to see if there is any corruption: use the -f option to force a check. If there is corruption then you’ll need to boot from a live DVD so that you can run fsck on the filesystem while it’s not mounted. The next thing to check is your update history, which you will find in /var/log/ apt/history.log. Do any updates to video or networking drivers coincide with the start of your problems? You sent us the output from running startx as a user, but this is subtly different to how X is started by the display manager at boot. Look in /var/ log/Xorg.0.log for the full log of X trying to start, and pay particular attention to any lines starting with (EE), because these are errors. I suspect there may be an issue with loading a driver. Finally, you can check the systemd journal for any errors since your last boot with this command: $ sudo journalctl -b -p err Drop the -p err to see the full

You can use the systemd journal to find out all sorts about your system – here’s a comprehensive list of reboots.

12     LXF272 February 2021

log since the last reboot. -b with no argument shows the log for the current boot, but you can also see the log for any other session, which is useful if you want to compare what happens now with the situation before

Neil Bothwick is Dr Tux to you! Fixing all problems dead(ish)!

your problem started. To see a list of all your boot sessions, use $ journalctl --list-boots

Each one has an identifier that you can use as an argument to -b to show the log for that boot session. You’re right to not want to reinstall. This never really fixes problems – just makes them go away for a while, and when they come back you still have no idea how to fix them.

of unity Q Lack As a diehard devotee of the Ubuntu Unity interface, I’ve stuck like a leech to v16.04 LTS. However, because its support comes to an end in the near future I investigated 18.04 LTS. I discovered that by adding my ‘favourites’ to the dock in Gnome I could have a Unity-like interface, so I decided to upgrade. It went well. Some few trouble-free weeks went by, including a few updates, and then trouble began. I’m now randomly logged off with no warning other than, sometimes, a 10-second or so lockup. Data in open files is lost, frequently used applications history is erased and, after this happened once during an update, I can no longer update successfully as ‘some files could not be found’. I have reported this as a bug to Canonical but have so far had no reply. This is appalling! I attach a sample ‘important’ section log entry of the latest time this happened, which means little to me apart from implying a desktop error. The problem is more likely to happen after awakening from a suspended state but does also occur after a cold reboot. I’m baffled. Any ideas? The machine is an Acer Aspire E1-571 laptop fitted with an Intel Core i3, 4GB DDR3 RAM and Intel graphics 3000. David Bones

A

Random failures are the worst kind of problem to diagnose, and it’s easy to fall into a trap of seeing a pattern when there is none. The cause is most often down to hardware: overheating, failing

www.linuxformat.com


REVIEWS

AMD Radeon RX 6800 The RX 6800 not only delivers 1,440p performance, it demolishes the RTX 2080 Ti at 4K, too says Jacob Ridley. SPECS GPU: Navi 21 Process: TSMC 7nm Die: 519 mm2 Transistors: 26.8bn Stream units: 3,840 CUs: 60 Ray accels: 60 Clock: 1,815MHz Boost clock: 2,105MHz Memory: 16GB GDDR6, 256-bit Memory speed: 16Gbps Memory bandwidth: 512GB/s TGP: 250W Min PSU: 650W Size: Two-slot

he AMD RX 6800 is the more affordable of the RDNA 2 (AMD’s next-generation GPU) graphics cards launched at the end of 2020, coming in beneath the AMD RX 6800 XT and the RX 6900 XT. There’s plenty to talk about with the RX 6800, and not the least bit how it stacks up versus the only competition it has right now: the Nvidia RTX 3070. This card has a lot to offer in its own right, however. Perhaps the most immediately staggering of its specs is the 16GB of GDDR6 memory. And while the RX 6800 isn’t ‘Big Navi’, per se – that accolade goes to the 80 compute unit (CU) RX 6900 XT – it’s not exactly ‘Little Navi’, either. That title goes to the 20 CU Xbox Series S… or at least until some RDNA 2 makes its way into budget-friendly graphics cards and next-generation APUs. The RX 6800 is fitted with a total of 60 CUs and 3,840 stream processors, which makes it a size above the RX 5000-series GPUs, including AMD’s previous high-end incumbent, the RX 5700 XT, with its 40 CUs.

T

AMD RDNA 2 architecture With a continuation of the 7nm process, RDNA 2 pulls no punches, offering 30 per cent higher frequency for the same power draw as the previous generation, or 50 per cent greater power savings while holding the same frequency. For a clear-cut example of the initial power savings look to the first-generation RDNA top dog: the RX 5700 XT. This first wave card delivers 40 CUs at 225W with a

Heat build-up is not a problem with the RX 6800.

top clock of 1,905MHz. The RX 6900 XT doubles the CUs, all of which run up to 18 per cent faster, for just 33.33 per cent more power. The AMD RX 6800 comes with a Navi 21 GPU that’s separated from the RX 6800 XT by just 12 CUs: the RX 6800 comes with 60 CUs to the RX 6800 XT’s 72. It clocks in with a 1,815MHz game clock, which can boost upwards of 2,105MHz. We see a reduction in TGP from the two 300W higherend cards above it. The RX 6800 runs at 250W TGP, or what AMD calls TBP. Either way, it’s in reference to the total power drawn by the graphics card and not just the GPU alone. This second-generation RDNA gaming architecture at the core of the RX 6800 is more power efficient than ever, incredibly fast, and comes with new exciting hardware blocks in the Ray Accelerators and Infinity Cache. From here AMD’s building out with an eye on maintaining a level of efficiency throughout, and not blowing the entire power budget on a 512-bit bus. A 512-bit bus, AMD explains, is costly and large. That’s also why you won’t see HBM2 memory anywhere near RDNA 2’s hallowed PCB either. Instead, AMD is incorporating a new concept with RDNA 2: Infinity Cache. The result is a cache subsystem that, AMD says, offers an effective bandwidth far exceeding the physical 256-bit one. One that can turn 512GB/s bandwidth into 1,664GB/s. In other words, 3.25x the effective bandwidth of a 256-bit cache. The Infinity Cache is still a sizeable chunk of the Navi 21 die.

What’s the cache?

AMD’s RDNA 2 uses Infinity Cache tech.

18     LXF272 February 2021

It’s the Infinity Cache that stands out as the most important over Ray Accelerators, though we do love shiny things. The Infinity Cache block-on die naturally acts as a performance boon for the RX 6000-series overall. That’s because the RX 6800, while fit to burst with 16GB of GDDR6 memory, only comes with that 256-bit memory bus to access it. That’s 512GB/s in total. To generate more

www.linuxformat.com


REVIEWS Linux distribution

Guix System v1.2.0 Strap in for this wild tour of the distro designed for the uber-geeks with your knowledgeable guide Mayank Sharma. IN BRIEF With its usability chasm of adopting the GNU principle of free software, which is noble but impractical, despite the superiority of the Guix System it will fail to appeal to a large number of average Linux users. See Debian GNU/ Hurd, NixOS.

uix System is a stateless meta distribution whose origins can be traced back to a research paper. The operating system, which has had its 1.2.0 release, is built around the Guix package manager, which is one of the most advanced open source package management systems out there. Guix is a reimplementation of the Nix package manager and Guix System is the operating system equivalent of NixOS. Guix System is a significant departure from the usual Linux distros. For starters, Guix System strives to be a fully programmable OS, and everything from its GNU shepherd init system to its package manager is written in GNU’s Guile Scheme programming language. In fact, the distro also has the distinction of being recognised by the GNU Foundation as a free software project. While it uses the Linux-libre kernel for the time being, developers are chipping away in the background to prepare it for the GNU project’s Hurd kernel.

G

Salute Guix The main highlight of the distro, however, is its Guix package manager, through which it inherits advanced features such as the ability to perform transactional upgrades and roll-backs, and create reproducible build environments. The install, remove, and upgrade operations in Guix are actually a transaction that will essentially only make changes to a system if the operation succeeds. This means that if a transaction is terminated because of a power outage or a clumsy operator, the system will still remain in a perfectly usable state. Furthermore, any of these package transactions can be rolled back. So if a package upgrade was buggy, you can easily roll-back to the previous one that worked well. Another feature that’s pretty impressive is the fact that you can replicate your configuration on another computer without much trouble.

Managing a Guix System is pretty convenient once you get the hang of it, since it’s essentially a rolling release that you can update with a couple of commands. However, the process will take a long time since Guix is a source-based distro and it’ll recompile all of the available package definitions. That said, the distro does have the option of fetching pre-built binaries. These are known as substitutes since you use them instead of building packages locally.

Install and use The best way to comprehend the advantages of Guix is to install a copy of the Guix System distro. It’s available as a compressed installable ISO. The good thing is that the distro has an installer that will guide you through the steps. It is an ncurses-based installer, but still far better than the earlier incarnations of the distro that required you to manually configure the installation using the command line. If you’ve installed a Linux distro, the text-based menus of the Guix System installer shouldn’t pose much of a problem. Note, however, that the installer doesn’t yet have a partitioner so you’ll have to prepare these manually. In any case, first-time users shouldn’t be experimenting with the Guix System outside the safe confines of a virtual environment The penultimate step in the installer asks you to pick one or more desktop environments and offers familiar options including Gnome, MATE, Xfce, Enlightenment and Openbox. The installer then collates all this information inside an editable configuration file that it uses to install the distro. Installation will take a fair bit of time because the libraries and packages will be compiled and installed from source. The exact time will depend on the processing prowess of your computer and the number of packages the installer has to compile. In addition to an installable ISO, the Guix System project, very helpfully, also produces a virtual disk image that you can use with the Qemu emulator to boot into a preinstalled environment. You can use this image to boot into a Guix System installation that uses the Xfce desktop. First-time users are better off getting a taste for Guix using this virtual image instead of attempting to install the system from scratch. Thanks to the Xfce desktop, the distro doesn’t look as alien on the outside as it is on the inside. Irrespective of your experience with Linux, you wouldn’t be able to get much done with your Guix System installation without first reading through its documentation.

Flesh out the bones Once installed with an Xfce desktop, Guix presents numerous usability issues for novice users.

20     LXF272 February 2021

The distro has a barebones set of tools, so you’ll have to flesh it out into a usable desktop. The good thing is that interacting with the Guix package manager isn’t all that

www.linuxformat.com


SUBSCRIBE Save money today!

SUBSCRIBE

TO LINUX FORMAT …and get all these top benefits! Huge savings, the best value for money and early access to issues. Never miss an issue with delivery to your door and straight to your device. Options to have every issue in print, on your Android devices, iOS devices and PC. Print editions come with a DVD packed with the best new GNU/ Linux distros, digital editions enjoy a free digital download! Exclusive access to the Linux Format archive – with 1,000s of DRM-free tutorials, features, reviews and LUD issues.

SUBSCRIBE NOW!

www.magazinesdirect.com/lin/jandps Call: 0330 333 1113 26     LXF272 February 2021

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 Now with 5 & r se U x of Linu Developer issues

CHOOSE YOUR PACKAGE! 6-MONTHLY PRINT ONLY

QUARTERLY PRINT AND DIGITAL

SAVE!

Only

50%

£21.05 6-monthly print   by Direct Debit

QUARTERLY DIGITAL

SAVE!

Only

60%

£17.50

Quarterly print and digital  by Direct Debit

SAVE!

Only

44%

£12.50 Quarterly digital  by Direct Debit

*Terms and conditions: Offer closes 28 February 2021. 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). 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- Friday 9am5pm UK Time or e-mail: 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. Offer ends: 28/02/2021

www.techradar.com/pro/linux

February 2021 LXF272     27

1) Only available to www.magazinesdirect.com subscribers

PLUS: Exclusive access to the Linux Format subs area!


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

Roundup Aladin Sky Atlas Celestia SkyCharts Stellarium

KStars

Shashank Sharma By day Shashank is a New Delhi trial lawyer, but by night he’s an open source vigilante!

Astronomy software If you’re a novice stargazer but clueless about how to feed your passion, Shashank Sharma knows a few tools to help you get started…

HOW WE TESTED… You’ll find these applications in the software repositories of most desktop distributions, even if the featured version is not the latest. Some programs provide Snap packages, and others provide installable binaries for RPM- and DEBbased distributions. We’ll test the programs on the ease of availability and support for different platforms and devices. We’re running these applications on a quad-core machine with 12GB RAM, without a dedicated graphics card, even though some of the tools suggest the use of one for optimum performance. With expansive projects such as these, users will find themselves at sea in the absence of thorough documentation. We’ll rate the projects also on the feature set, and whether or not you can search for objects and look up co-ordinates in the sky. We’re looking for tools that can work on different platforms and support a host of equipment such as telescopes and lenses. We’ll also test the applications on their usability and practical features.

28     LXF272 February 2021

e’re in the era of some of the best space-based storytelling thanks to series such as Star Trek: Discovery, The Mandalorian, The Expanse and many more. Whether it’s because of these, or because you’re naturally curious about and fascinated by the vastness of space, and its constituents such as galaxies, solar systems, planets and more, your Linux distribution can help fuel your passion with many different applications aimed to help you stargaze. The nature of the Roundup format is such that there can be only one winner. For specialised tools such as the ones featured here, this is an especially difficult task. We’ve tested the different applications on a range of subjects, but they’re easy enough to get your

W

hands on, so you should give each of them a fair shake before you settle on one. If nothing else, the experience of working with the different tools will fuel your excitement, much like this author. Already a fan of the night skies, he found his interest revived after being able to track the International Space Station on its merry way. There’s no dearth of open source astronomy software. While you can install any of the applications featured in this month’s Roundup on your current Linux distribution, there are also specialised distributions aimed at budding astronomy enthusiasts. You’ll find a mention of these, as well as alternate applications in the Also consider section at the end of the article.

www.linuxformat.com


Astronomy software ROUNDUP

Features What can you do with and learn from these applications? Stars features are split across uses such as education, visual observation, astrophotography and astronomy enthusiasts. You can use it as a graphical simulation of the night sky from any location on Earth and for any given date and time. Its display includes up to 100 million stars and 13,000 deep-sky objects apart from all the planets in our solar system, and thousands of comets, asteroids and more. You can also study phenomenon that take place over long timescales by adjusting the simulation speeds, and print high-quality sky charts and more. Stellarium is just as impressive with its catalogue of over 600,000 stars and the capability to add additional catalogues to expand the number to 177 million stars. Like KStars, it too has over 80,000 deep-sky objects and boasts of a very realistic Milky Way, sunrise and sunset. You’ll also enjoy looking at nebulae using the tool. Speed up time to track objects across the sky. In addition to constellation labels and lines, you can also toggle constellation art for a spectacular night-sky renderings. You can also toggle various features on/off with keystrokes, such as pressing ‘r’ to enable constellation art, and pressing F3 to open the Search dialog. Like the others, Celestia also comes with a large catalogue of stars, galaxies, planets, moons, asteroids, comets and more. You can also download dozens of add-ons for even more objects. You can also capture high-def images and even record videos in HD resolution. The application gives you the option to specify the aspect ratio and frame rate when recording a video. Its navigation is a little difficult to master, but the tour guide feature can be used to browse to different objects and planets so that you can then

K

Stellarium has an impressive array of features to help you in your stargazing endeavours, but the other programs aren’t all that lacking, either.

orbit around them to learn new things. When you first run SkyChart, it’ll ask you to select your location and observatory. This is used as a point of view for your look into the skies. The program supports various observatories by default and you can download even more. Like Stellarium you can connect telescopes and even record videos of the objects in the skies. Aladin is an academically lead project so while accomplished has a feature set (and documentation) tooled for academia and not home enthusiasts. Its main feature set is viewing HiPS images alongside 20,000+ other collections.

VERDICT CELESTIA 9/10 SKYCHART 8/10 STELLARIUM 10/10 ALADIN SKY ATLAS 7/10 KSTARS 9/10 Aladin’s lack of documentation makes it tricky to navigate for first-time users.

Customisations Kicking things up a notch with even more databases and catalogues. tellarium uses a plugin system that enables you to add artificial satellites, ocular simulation, telescope configuration and more. New solar system objects from online resources can be introduced and you can even add your own deep sky objects, constellations and so on. Access the different plugins and configure them via the Configuration window. The Celestia forum boards maintain a list of all available plugins. Previously, the celestiamotherlode.net website hosted many plugins, but the site has been offline since August 2020, although a GitHub archive is available. Addons for Celestia generally include one or more catalogue files, surface pictures of the objects and their models to properly render their shapes. Armed with these elements, even you can create your own addons, and many such user-contributed addons are available in the forum boards. KStars includes many different catalogues by default, such as the Messier, which is a collection of 110 deep sky objects and New General Catalogue of Nebulae and Clusters of Stars (NGC), which is a catalogue of 7,840 deep sky objects. More catalogues can be downloaded using the Add-on installer. Aladin lags a good way behind the others with only a handful of plugins from 2007-2008 being available. SkyCharts catalogues a

S

www.techradar.com/pro/linux

Adding new catalogues is fairly straightforward in all the tools.

large number of stars and other objects, but displays only a small subset by default. You can enable more data to be visible by clicking Setup>Catalogue. Click the different tabs and select the different objects. You can also download additional catalogues from the projects website, and these range anywhere from a few megabytes to many gigabytes in size.

VERDICT CELESTIA 8/10 SKYCHART 9/10 STELLARIUM 10/10 ALADIN SKY ATLAS 4/10 KSTARS 10/10 The better the supported the app the better the quality of catalogues to use.

February 2021 LXF272     29


BLAST OFF WITH LINUX! Rocketman Jonni Bidwell assures us preflight checks are complete and that the LXF Penguin-Heavy spacecraft is ready to embark on its voyage of Linux discovery.

ew year, new Linux. That’s what you promised yourself, right? Maybe not, but it’s what you and your hardware deserve. It’s never been easier to get started with Linux, and Ubuntu, one of the world’s most popular distros, has never been in better shape. If you don’t believe us, try it out risk free from our DVD. Once you’re convinced, and ready to give your previous operating systems the boot (ill-fitting pun intended), we’ll show you how to install it, use it and get the most out of it. And if you read the above paragraph, smug and aloof that you’ve already got

N

34     LXF272 February 2021

your favourite distro installed, but slightly concerned this feature won’t help your new year, fret not. We’ve got some great tips for tweaking and perfecting your install. We’ll show you how to diagnose and fix problems – even find ones you never knew you had. We’ll also get you set up with automated backups, which if you follow our Nextcloud Pi tutorial (see page 50), could be sent off-site for extra security. Furthermore, you could install the Nextcloud client tool and enjoy Dropboxlike functionality. For local data, we’ll introduce the wonders of the nextgeneration Btrfs filesystem and show you

how to set up your own storage silo by mirroring a pair of (tremendously sized, if you like) drives. Hard drives fail, so this kind of redundancy is good. People do more and more of their computing through a web browser today. So we’ll show you how to set up Firefox for optimal browsing, with high-resolution Netflix, privacy extensions and even video acceleration (if your hardware plays ball). Your older machines need love too, so you can give them a refresh too, with the excellent Bodhi Linux and its stylish Moksha desktop. That’ll keep even the most senior of hardware ticking along for another couple of years.

www.linuxformat.com


Blast off with Linux

Solid foundations Start 2021 off on the right foot with a fresh install of Ubuntu 20.04 LTS, codename Focal Fossa. ou might have already fired the coverdisc and seen what Ubuntu 20.04 has to offer. If not then you should. Hardware compatibility has never been better, the Gnome desktop is in tiptop shape and thanks to Snaps it’s easy to install the latest versions of popular applications. You might already be running Ubuntu and know all this, or using another distro, but we’ve still got some tips for you. Unless you’re wanting to re-install though, in which case you should probably skip on over the page. Whether you’re new to Linux or a long-time user, it’s always nice to start fresh and from a solid foundation. It’s no fun when your home directory fills up and you run out of disk space and can’t log in. And it’s tedious to have to convert a weighty ext4 volume to Btrfs because you want CoW snapshots, too. By setting up an appropriate partition scheme and filesystems at the outset, things are made more simple and scalable.

The default Focal Fossa background. We won’t cover changing the desktop background here because we like wildcats.

Y

Forward planning A separate /home partition won’t necessarily stop you running out of space, but it lessens the likelihood of the OS partition filling up and the OS on there breaking. And if you envision perhaps adding other Linux distros further down the line, then setting up LVM will enable you to easily add and resize partitions, as well as have them span multiple devices. The caveats on dualbooting below only apply to Windows – different flavours of Linux will happily coexist with one another on the same device, and distro-hopping is such fun. It’s tricky to move your OS(es) from a regular partition(s) into an LVM array, but easy to set it up from

the Ubuntu installer. So long as you use the brutal ‘Erase Disk and Install Ubuntu’ option. You’ll find the LVM option (as well as the option to use LUKS encryption, and indeed the experimental option to use ZFS) in the Advanced Features menu in step 3 over the page. We won’t go beyond the rudiments of LVM here, but if you have even the slightest inkling you’ll want to do some partition shuffling further down the line, then it’s worth ticking the box. LVM abstracts away the limitations of regular partitions and devices. So starting at the Physical Volume (PV, actual storage devices) level, multiple drives are grouped together in a Volume Group (VG). Inside the VG are the Logical Volumes (LVs) that you can treat exactly like partitions, even though they may span multiple devices. Flexible though LVs are, it’s important, if you do come to resize them, that you still have to resize the filesystems on there, too. If you shrink an LV before shrinking the filesystem, things will break, just as in the regular case. Fortunately the lvresize command has a handy –resizefs option.

DUELING BANJ-OSES It’s tempting to install Linux alongside Windows, and the Ubuntu installer enables you to do this. The safest way to do dual-boot is to install Linux to a separate drive. Small SSDs are cheap, fast and will boot Ubuntu in a jiffy. Plus, that way you won’t be touching the Windows-bearing drive so it’s highly unlikely the installation will upset it. Windows is pretty fragile with respect to other OSes touching its partitions. But, conversely, it’s reportedly aggressive with respect to overwriting those of other OSes. So even if your install goes smoothly, a wiley Windows Update might take out your Linux drives. If you want to be really safe, unplug (or

www.techradar.com/pro/linux

disable in the BIOS/UEFI) said drives before booting Windows. Obviously you don’t have this luxury if you install to the same drive, which is why we caution against it. You also avoid the hassle of resizing Windows partitions (which you could trust the Ubuntu installer to do, but if you must go this route we’d recommend using Windows own disk management tool to do this). If you have a modern UEFI system, be sure to tell the installer (step 4 over the page) to use the existing FAT32 EFI partition, rather than make another one. You only need one of these per machine, not per drive or OS. You can then choose which OS to boot from the UEFI

settings. Older BIOS systems will have an option to select which drive to boot from, but you can configure GRUB (the Grand Unified Bootloader) to give you a handy menu if you regularly switch.

Use your BIOS or UEFI settings to choose a boot device. Some UEFI implementations are awful and require the use of Efibootmgr when things go awry.

February 2021 LXF272     35


IN-DEPTH Rise of the robots

RISE OF THE ROBOTS Mats Tage Axelsson presents the basics of a robotics operating system and reveals what components can be used…

ssembling your own robot and getting it to walk around will entertain kids of all ages for a good few minutes. However, for robotics to be long-term fun it needs to be a challenge. A common misconception about robotics is that you need a degree to make anything of your own. Having said that, a robot does require many subsystems to operate. There are legs to move, arms to stretch, things to see and react to. Basically, everything we do as humans – except you must design the entire system that can handle all those tasks.

A

42     LXF272 February 2021

This isn’t something you whip up in your man cave on a rainy afternoon. Being free and open source enthusiasts, we know better than to believe we have to cover every detail ourselves. There have been many projects to make robotics an area you can thrive in and help expand, the most successful organisation to date is the Open Source Robotics Foundation (www.openrobotics.org). Out of this has developed the Robotics Operating System (ROS). It’s not an operating system as such, but rather a collection of tools that help you create your version of what a robot should be and do.

The ROS is better described as a robotics framework, but what do you want from the ROS and what do you need to do to get a robot up and running? We’ve already mentioned that many subsystems control different parts of the robot. Your robot will need to navigate, move and interact with its environment. That may include interacting with you and other humans, but that’s for another time. The simplest robot will run around the house exploring – a more advanced version will go to the kitchen and bring you a new beverage. For all this you need sensors, micro controllers and a lot of mechanics…

www.linuxformat.com


Rise of the robots IN-DEPTH It’s important to bear in mind that all these parts must communicate with each other. This is where things can become complex and you need an overall control system. Using ROS, you can declare and define all the nodes (the distinct parts of the system) and how they communicate. Other things included in the ROS framework are simulators and visualising software to help you spot problems and solve them. Knowing what the different pieces of software do requires a fundamental understanding of the architecture. Yet defining a robot as the sum of its components will quickly become complex, so there needs to be a standard method of communication – either within the robot or from outside. This is, in essence, what ROS is for: it establishes the standard communications protocols. Within this standard are certain components that define the overall system: nodes, services and topics. A node is one collection of functions that communicate with other nodes using the ROS client library. This makes it possible to choose between many different solutions for each task, so long as they use ROS to communicate with the other nodes. Nodes will use the other parts of the architecture – topics and services – in different ways, depending on what the information is used for. Topics are places that contain data, which many nodes will need to access. One node will send data to the topic and other nodes can subscribe to the topic. In short, this is a broadcast-type message – information that many nodes may need and one can create. In contrast, services are created so that one node can request information from another node. The first node is the client that requests information from the server.

Component core To run ROS, you need a number of packages. In the core version you’re provided with everything you need to run the actual robot. These packages implement the ROS interfaces, the middleware interface and some specifications for the messages that you need to use for development. The two that you’ll come in contact with the most are the rclcpp and rclpy libraries. They both implement the client libraries; as you may guess, one is for C++ and the other for Python programmers. The client libraries cover the messaging we mentioned earlier. This is where you decide whether your client needs to broadcast to topics or set up a service for other nodes. This is also where you find the message formats so you can add your information for your applications. The documentation

Controlling a turtle across the screen is ideal for learning the fundamentals of robot design.

www.techradar.com/pro/linux

You can create an entire environment in Gazebo. This includes walls, stairs and windows.

shows many useful examples of a service, client, publisher and others. Everything else uses the client libraries, so make sure you understand them. While you run ROS on your machine, you can find all the different message formats through using the various commands. The other parts of the ROS system are specific to different functions. The turtlesim executable demo displays some of the available functions. It shows how to move the robot around. As well as snaps, you can also use virtual machines for your ROS installations. The snap route to a ROS installation is an easy way to see the first examples before you start creating your own code: $ sudo snap install ros-beginner-tutorials With these snaps, you can run all the demos on the ros.org website. The commands are even named according to the activities in the documentation. A ROS installation contains a massive amount of software. All packages are small, but dependencies can be troublesome on your regular machine that you use for

YARP: A SIMILAR FRAMEWORK YARP is the framework for communications within robotics. It can replace the ROS master as a name server. You can also do this the other way around using the YARP as a name server. The name server will support the nodes and protocols across your system. You can also use both in a single system. One reason why you may want to use this is if you have a single unit that requires a separate underlying protocol. Another reason might be because your project is in transition between the two frameworks. These protocols can be used in other fields. For example, if you have a number of Kubernets nodes you can have them share information using either YARP or ROS. The project is fully open sourced and available on https://github. com/robotology/yarp/releases/latest. The project provides ways to install using Debian packages, or they have their own repository at www.icub.org/ubuntu. Naturally, you can always compile from source using their git repository. It requires CMake, cmake-curses-gui and git. This framework also has its own visualisation system and plotting functions. The focus with YARP is to use as much of the standard GNU tools as possible. There is browser port access, so you can use a browser on one machine to check the stat, along with many other aspects. Discover more about the project at: www.yarp.it/git-master/ index.html. YARP has been tested and have language-specific packages for Python, Java, Lua, MathLab and others.

February 2021 LXF272     43


TUTORIALS Run Manjaro

MANJARO

Quickly install Manjaro on the Pi 4 Les Pounder reveals how to get Manjaro Arm up and running on the Raspberry Pi 4 / 400, and start using the GPIO with Python. ention Raspberry Pi and we think Raspberry Pi OS (Raspbian), but there are many more distributions available for the Raspberry Pi. In this tutorial we’ll download and install Manjaro Arm on a Raspberry Pi 4. Manjaro Arm is a 64-bit operating system designed for the Raspberry Pi 3, 4 and 400. We’ll cover how to update our system and install software using the pacman package manager. Finally we’ll learn how to use the GPIO with Python in Manjaro.

M

OUR EXPERT Les Pounder is associate editor at Tom’s Hardware and a freelance creative technologist. He blogs at bigl.es.

YOU NEED A Raspberry Pi 4 or 400 16GB Micro SD card Breadboard 2 x male to female jumper wires 220 Ohm Resistor (REDRED-BLACKGOLD) An LED Code: https:// github.com/ lesp/LXF272Manjaro-Arm/ archive/main. zip

Manjaro Arm Manjaro for Arm CPUs comes in a range of flavours. We chose the XFCE version from https://manjaro.org/ download/#ARM and then downloaded and extracted the image from the archive. To write this to an 8GB or larger blank micro SD card, we used Balena Etcher (www.balena.io/etcher) and followed the simple process of flashing the image to the micro SD card. When the process is complete, eject the micro SD card and insert into the Raspberry Pi 4, then connect your peripherals and finally insert the power to start the boot process. The Manjaro Arm boot process is a little different to Raspberry Pi OS, in that we need to specify our language, localisation and create a standard user account. Take your time here because the installer, while simple to use, has many options that have to be set correctly before we can use Manjaro Arm. On first boot we’re presented with the XFCE desktop. In the bottom left is the application menu, and next to this there are quick launch icons for the file manager, terminal and Firefox browser.

Armed with Pi Updating the system is the first thing to do after installation, and we can do this via the GUI, the icon for which is in the bottom right of the screen. It resembles a shield with a tick. The GUI is split into sections. We can filter applications via their category, and then browse through the list. Click Installed to show the installed software, and click Updates to show any updates for the install. Manjaro Arm is pretty good at alerting us to updates, via the same bottom-right icon. Underneath the GUI is a powerful package manager, pacman, which has nothing

48     LXF272 February 2021

Manjaro Arm comes in many flavours. We chose XFCE because it’s lightweight yet full of the features that we expect from a modern OS.

to do with the video game character. Rather, it’s an exceptionally useful tool to manage packages on our Manjaro Arm system. To use pacman, open a Terminal and ensure that you’re connected to the internet before moving onwards. Before we can install any software we need to update the list of repositories. The -S switch will synchronise packages, -y will download a fresh copy of the master package database from the servers defined in pacman. conf. Finally -u will upgrade all out-of-data packages: $ sudo pacman -Syu

Setting up Python and the GPIO Once completed, the terminal will return control to us and we can now use pacman to install extra software. The first software to be installed is for the GPIO – specifically the Python modules that’ll enable us to use the GPIO. Note that we were unable to find any install candidates for Python 3 and so Python 2 modules are used. Because Python 2 is now end of life, it’s unwise to base any “serious” projects on these modules. Python 2 comes pre-installed, but to ensure that we have every Python module and the means to install future modules we’ll use Pacman to install a series of packages: $ sudo pacman -S python python-pip gvv base-devel python-setuptools

This will take some time, but once completed the next step is to install the GPIO module for Python. Typically this would be RPI.GPIO, but despite having an installation candidate in the Python packaging tool, pip,

www.linuxformat.com


TUTORIALS Host Nextcloud

NEXTCLOUD

Host Nextcloud 20 on a Raspberry Pi Nextcloud 20 is here and Jonni Bidwell shows you how to get it running on a Raspberry Pi, possibly one hosted by Mythic Beasts ary an issue of Linux Format goes by without us mentioning Nextcloud, the open source private cloud. And that’s because it’s fantastic, and there’s a lot that you can do with it. Now Nextcloud 20 is here and we’re going to talk about it again. Out of the box it makes it possible for you to securely host your own Dropbox-like storage for you and your friends’ files and photos. Even better, it’s light enough that you can comfortably provide for a handful of users (as long as they don’t all use it at the same time) on a Raspberry Pi 3. There are FOSS mobile applications, a desktop client and a lovely web interface, so accessing and synchronising your data is easy. Add the News app and you’ll finally solve the problem of how best to collate your RSS feeds since Google Reader expired, Odin rest its soul. Add the Notes app in case Google Keep goes the same way. If you’re willing to brave some extra configuration (and perhaps some beefier hosting), you can access a collaborative, web-based LibreOffice install in the form of Collabora Online Development Edition. The latest incarnation of Nextcloud brings yet more

N

OUR EXPERT Jonni Bidwell and his Pi Zero single-handedly caused the great Google outage of December 14, 2020. Who knows what he’ll get up to this year?.

collaboration tools and further develops its federation features, whereby users of different Nextcloud instances can interact with one another.

Storage alternatives This is all well and good, but perhaps you don’t want to rely on your Pi’s SD card to store your precious files, or maybe you don’t want to be relying on your home internet connection (because home ISPs, like technical editors, are agents of mischief and chaos). No problem, with the ISP Mythic Beasts you can rent a Pi 3 (for around £5/month or, for a fraction more on a commitment-free per second basis) which netboots and has its root filesystem hooked into its own data platters. Then if you want to pay for a vanity domain name you can, and if you don’t it’s simple to get set up with a free subdomain from the likes of DuckDNS, our favourite dynamic DNS provider. It’s possible to run everything without a registered domain name. However, your users will see certificate warnings if you choose this approach, so it’s only suitable for internal use. There’s no need to spend

Don’t forget to do the Nextcloud security scan, which will ensure your server is kept safe. It’ll warn you about potential issues with your SSL configuration and more.

The welcome animation is plenty reward for getting Nextcloud set up. Subsequent screens have links to handy documentation.

50     LXF272 February 2021

www.linuxformat.com


IN-DEPTH Next-gen terminals

Next-gen terminals

Discover the next-gen terminal tools with David Rutland that will transform your command-line life. or most Linux Format readers, the terminal is where the action happens. Sure, you probably chose your distro based on a mix of aesthetics and the tools with which it comes packaged, but when it comes down to it, most of the real work gets done on a black screen with a monospace font. . Why? Linux is a command-line based system, and generally it’s a lot quicker and more efficient to type a line or two into   BASH than it is to use a mouse to conjure a monolithic GUI from the depths of your SSD. The difference may well be seconds – and you could be using those seconds to get work

F

54     LXF272 February 2021

done. Or to make a cup of tea. Terminals were never designed to be beautiful. Their output is often difficult to scan, and if there happens to be any non-Linux person lurking nearby with a tray of biscuits, there’s a very real danger that you’ll be arrested as a hacker in your local Starbucks. We’re now in the third decade of the 21st century, and terminal tools don’t need to   be ugly, and they don’t need to frighten passers-by, either. It’s now easier than ever to be superproductive in the shell and to work efficiently, too. We’ve rounded up a few essential tools to replace or augment what we already use.

www.linuxformat.com


Next-gen terminals IN-DEPTH

he cat command concatenates files and displays the output to your shell. It can work with all text-based files, and is simple to use. For instance, if you want to view the contents of three html files in your present working directory, you would type cat 1.html 2.html 3.html and the contents would be displayed for you. Alternatively, you can use it to check the contents of just one file: cat 1.html . It’s simple, it’s fast and there’s no need to worry that you’ve accidentally made changes to any of the file contents because you didn’t open it. We’ve been using cat for years for everything from CSS style sheets to ebooks. But it’s white text. Even if you have another colour selected to display the output, it’ll be uniformly that one colour. It’s difficult to read and to find what you’re looking for at a glance. Did you put the correct closing tags on your HTML? You’ll need to pull on your glasses and count lines to find out, or fire up a GUI-based code editor, such as Brackets which has syntax highlighting. Or you could use bat, which first appeared in September 2020 and uses exactly the same syntax as cat. It has syntax highlighting built in and line numbers to help you orient yourself in a lengthy document of series of files. Checking out code is easy because the syntax highlighting is baked in for most programming and markup languages, and will paint strings, functions and operations with different hues, meaning that you’ll never get lost in a document again. The default colour scheme is sensible and easy to read, but it’s far from the only one on offer, and running bat --list-themes will list all of the colour options available to you. Changing the theme is as simple as typing bat --theme=TwoDark . You’re not limited to this author’s presets either. If you have a set of colours in mind that are close to your heart and easy on the eyes, you can define your own. Bat functions perfectly well as a standalone tool and accepts the same arguments as cat, but it also plays nicely with other commonly used and essential software. Find results can be displayed with bat, and it integrates with git to show modifications with respect to the index. Piping a log tail through bat is a pleasure. Bat is available for most distros and can be found here: https://github.com/sharkdp/bat.

T

Making use of du and df Keeping a close eye on your disk space isn’t quite as vital as it used to be. You may have started out with a 20MB hard drive back in 1996, but the chances are good that you’re now rocking something in the terabyte range. It’s a difficult number to even attempt to comprehend, and many users will be able to go through entire life (or at least their computer’s life) without ever needing to worry about running out of space. Sometimes, though, it’s nice to look at the numbers, and it’s always good to know what resources are at your disposal. To date, you’ll probably have been using the df command to give you an idea of your free space. Running df will give you 20 or so lines of text, including the names of all your devices, and their mount points, along with the space they have available, in use,

www.techradar.com/pro/linux

and free – in 1k blocks, which isn’t particularly useful. By default, df will also list any snaps you have installed in their own containers. It’s a useful tool and becomes more useful if you run it with the -h flags , which stands for human and will give you the figures in the most appropriate unit: usually gigabytes and terabytes for large drives, and megabytes for programs. If you need to find out how much space a given directory is taking up on the disk, you’ll be used to running du. For instance, if you want to know the details of the hugo folder, you would type du hugo , and prepare to receive a list of all the files within the hugo directory along with their sizes – again in kilobytes. It’s a lot more useful than ls because du will drill right down into the directory tree to give the sizes of everything.

Displaying disc space stats via duf.

THE BENEFITS OF USING DUF “Running the program will give you a colour-coded graphical representation of how your disk space is being used.” Adding the -s and -h tags will produce a summary in appropriate units. Both du and df are tools for everyday usage, but like cat, they’re often not the easiest outputs to read and extract information from. If you want your disk usage information to be digestible with a single glance, you need duf, which is the Swiss army knife of shell-based disk usage visualisation tools. Running the program anywhere on your system and without arguments will give you easyto-read, beautifully laid-out tables in your terminal, together with a colour-coded graphical representation of how your disk space is being used. Mount points are in blue text while the actual figures for available space are either red, orange, or green. It’s an at-a-glance traffic light system that can instantly show you where space issues are likely to arise. The top table will always show your local drives, and if you have any network drives mounted, these will be further down, followed by special devices. If you supply arguments, duf will only list specific devices and mount points. You can also hide certain

February 2021 LXF272     55


TUTORIALS TUTORIALS Edit PDFs

TERMINAL

Manipulate and work with PDF files

Shashank Sharma breaks down the different things you can do with PDF files, apart from reading and creating them from the blackness of a terminal. ccording to the statistics released by Adobe as part of the 25th anniversary of PDF in 2018, more than 200 billion PDF files were accessed using Adobe products in 2017. In the years since, and taking into account non-Adobe products, the sheer number of PDF files accessed in a year, or even on a daily basis is practically incalculable. The trusted and popular document format started its journey as a proprietary format at Adobe in 1993, and was released as an open standard in 2008. Today, there are a large number of graphical and command-line utilities that you can use to not only read, but also manipulate PDF files. Here, we’ll discuss everything from splitting large PDF files into smaller ones, or merging multiple small files into a single PDF file. We’ll also discuss how to churn multiple image files into a PDF document and shrink the size of a PDF file. We’ll reveal how to run OCR on your PDF files, edit metadata of PDF files, extract text, or images out of PDF files and more!

A

OUR EXPERT Shashank Sharma is a trial lawyer in Delhi and an avid Arch user. He’s always on the hunt for pocket friendly geeky memorabilia.

Creating a PDF from image files

You can only use uppercase letters to define ‘handles’ in pdftk. You can, however, use a single letter or use them in combination to define ‘handles’. For instance, you can use A, B, D, Z, TT or ASD as your ‘handles’.

It’s a common practice to use your cellphone camera to digitise documents. Unless you’re using dedicated scanner apps, you’ll end up with image files. You can convert these image files into PDFs using the popular ImageMagick suite. ImageMagick is a suite of command-line applications and utilities you can use to perform various operations on image files. Whether it’s creating GIF images, collage, or otherwise editing your images, all operations can be performed using one of the included utilities. The most popular of these is convert, which can be used to edit, crop, resize, flip, blur and perform myriad other operations on image files. However, the convert can also be used to stitch multiple image files into a PDF: $ convert image1.png image2.png image3.png output. pdf

The simple command expects a series of image files and the output file format as arguments. While this works well if all your image files are the same size – have the same resolution and DPI – if your images are taken from various sources, such as screenshots of your

58     LXF272 February 2021

desktop, taken using your camera phone or a DSLR, say, then you’ll end up with a PDF file where each page is of a different size. You can overcome this problem by specifying the page size, and other parameters with the convert command: $ convert image1.png image2.png image3.png -page A4 output.pdf You can similarly use the -quality and -resize command options with the convert command to affect

the final PDF file. The exact command will depend on your input files. However, using ImageMagick for this purpose can take some time if you have a large number of input files, and results in large PDF files. If you want to keep the size of the final PDF small then you can use img2pdf. It’s not available by default in most distributions, but is available in the software repositories. Once installed, you can stitch multiple image files into a single PDF and also specify the page size of the resultant file with the following command: $ img2pdf a.png b.png c.jpg --pagesize A4 -o filename. pdf The --pagesize command option expects a case-

insensitive value, and in addition to manually specifying the length and breadth of the page, also supports various sizes such as A4, Legal, Letter, A3 and A5. You can also do other cool things such as turn the page from the default portrait to landscape, by using the ^T option along with –pagesize : $ img2pdf a.png b.png c.jpg --pagesize legal^T -o landscapists Here, we’ve use the --pagesize option to create a legal-sized PDF file, but we’ve also added ^T at the end.

This informs img2pdf to create a landscape output file. Refer to the man page for img2pdf for details about the different command options, such as creating a border around images in the PDF file or resizing images to fit the page size.

Reducing PDF files Most email services, such as Gmail, Yahoo and others restrict the size of attachments. What happens if you need to share a large PDF file with your peers? One option is to upload the content to services such as Google Drive or DropBox, but you can alternatively

www.linuxformat.com


TUTORIALS Video conversion Credit: https://handbrake.fr

HANDBRAKE

Optimise your videos and free up HDD space Nick Peers reveals how to convert your videos into H.264 and H.265 codec formats to help save drive space and maximise playback compatibility. ooking to convert videos into a universal format guaranteed to play on just about any device? Then you need a video converter capable of encoding your video in the universal H.264 or H.265 codec, wrapped up in a MP4 file container. You could use the codec’s own command-line tool, but that becomes unwieldy when you realise just how much finetuning’s required to compress your video to a small enough file without making it unwatchable. What you need is a point-and-click solution in the form of Handbrake (https://handbrake.fr). The program gives you full control over your video conversions via a more user-friendly graphical front end. However, its vast array of options and tabs can make it confusing for beginners. Never fear: read on for our exhaustive stepby-step guide to the whole process.

L

OUR EXPERT Nick Peers has converted countless videos using Handbrake over the past decade. What work-life balance?

Handbrake: master your codec settings 6

1 2

5 3

4

Codec Your main choice here is between H.264 (x264) and H.265 (x265). The latter is superior, but less compatible – and much slower.

1

Framerate In the vast majority of cases, set this to Same as source, and with Constant Framerate selected.

2

Preset 3 Use this slider to trade-off between final video quality and size, over encoding performance. If encoding takes too long, nudge it to fast or faster.

62     LXF272 February 2021

Codec-specific options These options vary depending on the codec you’ve chosen. Take the time to set Tune to match your video type.

4

Quality settings Select Constant Quality and use the RF slider to find the best balance between image quality and file size.

5

Preview Click this button to open a preview window to test your Filters and Video settings on a 45-second clip.

6

As per usual, Handbrake can be installed through Ubuntu Software – but it’s not the latest version. To ensure you’re running Handbrake 1.3, open Terminal and issue the following commands: $ sudo add-apt-repository ppa:stebbins/handbrakereleases $ sudo apt-get update

Two versions are available: a GUI and a CLI. We’ll be focusing on the GUI in this tutorial, so install it thus: $ sudo apt-get install handbrake-gtk

Handbrake off! Launch Handbrake from the Show Applications menu. Step one is to open your source: this can be a single video file, all the files in a selected folder, a disc image (such as an ISO file) or a DVD. Wait while Handbrake scans the file or folder for supported content (most file types) and generates a list of titles. Handbrake will display a summary of the first matching title in the list, complete with a video preview to help you identify it. Click the Title drop-down to see what titles have been added if you selected a folder, ISO file or disc. You can identify each one by its length as shown in the Title field and preview picture. If the preview doesn’t tell you much, click the Preview button at the top and use the slider to choose a different thumbnail from the video, which should help identify it. To the right of the Title field is the Range field. By default, the entire file is selected for encoding, but you can encode just a specific part: chapters, seconds or individual frames depending on just how precise you want to be. You’ll need to identify these breakpoints with the help of another tool – Ubuntu’s Videos program can help you identify both chapters and seconds, but to identify individual frames you’ll need to install VLC via the Software Store (choose the Snap version) and then install the Time extension (https://addons.videolan. org/p/1154032).

Make use of Presets Beneath the Title and Range fields you’ll see a Presets drop-down. Presets make Handbrake manageable on a day-to-day basis, and basically collect all the settings configured in the tabs. This enables you to easily switch between customised settings depending on what you’re

www.linuxformat.com


BACK ISSUES

BACK ISSUES

MISSED ONE?

ISSUE 271 January 2021

ISSUE 270 December 2020

ISSUE 269 November 2020

Product code:

Product code:

Product code:

In the magazine Discover how you can get Linux up and running on your laptop and mobile devices! We also explore the chat tool Jami, provide essential tips for Firefox, use a Raspberry Pi as your daily driver and reveal how to become a package maintainer.

In the magazine Get up to speed on how hackers operate – then turn their tactics against them. We also show how to build a powerful Linux gaming system, put together an audio library, emulate the Atari ST and code a classic card game in Python. We also get our hands on the Raspberry Pi 400!

In the magazine We explain how to stream your videos, music and photos from a home server, review power-user distros, set up a livestreaming session, code Naughts and Crosses in Python, get creative with the Pi camera, and work collaboratively with NextCloud.

LXFDB0271

LXFDB0270

LXFDB0269

DVD highlight Pop!_OS 20.04 LTS and Fedora 33 (both 64-bit).

DVD highlight Kali Linux 2020.3 (64-bit only)

Digital download highlights 4MLinux 34 and Enso OS 0.4 distros (both 64-bit only).

ISSUE 268 October 2020

ISSUE 267 September 2020

ISSUE 266 Summer 2020

Product code:

Product code:

Product code:

In the magazine Use FOSS to make your home and office much smarter, check out maths tools in our Roundup, stay organised with MindForger, code a 2D shooter in Python, recreate the Doctor Who theme in synthesiser simulator Amsynth, and play Doom on a Pi!

In the magazine Learn how to protect your stuff with our ultimate guide to backing-up; discover open source gaming engine Godot; get the low-down on LibreOffice 7.0’s new features, and learn how to schedule tasks in the terminal. Plus privacycentric distros rated!

In the magazine We see what’s new in the latest version of Mint, narrow down the best IDE for your programming adventures, show you how to code the arcade classic Pong, manage tasks using Zenkit To Do, and speak about the Open Mainframe Project with John Mertic.

Digital download highlights Kali Linux 2020.3 and Parrot 4.10 distros (both 64-bit only).

Digital download highlights Endeavour OS 15 and KaOS 2020.07 (both 64-bit only).

Digital download highlights OpenSUSE 15.2 (64-bit) and Grml 2020.06 (32- and 64-bit versions).

LXFDB0268

LXFDB0267

LXFDB0266

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 66     LXF272 February 2021

www.linuxformat.com


TUTORIALS Photo stacking Credit: www.gimp.org

GIMP

Enhance your photos by stacking them Combining multiple photos of the same scene using a stacking technique can result in some spectacular results, reveals Mike Bedford. he principle of photo stacking is to take multiple shots of the same scene and then combine them to produce a single image. As we’ll see, there are plenty of reasons you might chose to do exactly that. You might have come across the concept of photo stacking before, because it’s the basis of high dynamic range photography, commonly referred to as HDR. As we saw in LXF257, this technique is used in scenes with very light and very dark areas because normal photography isn’t capable of recording large differences in brightness in a single shot. Before looking at the processing, we’ll provide some advice on taking the sequence of photos – something that applies to all types of photo stacking. A key requirement is that all the shots capture the same scene. If you don’t manage that it’s not necessarily a deal-breaker, but if the individual photos don’t match up then the processing will be more involved. For good results, you’ll need to use a tripod so your camera or phone doesn’t move between each shot. This is especially difficult to achieve with those forms of

T

OUR EXPERT Mike Bedford likes to exercise both the left- and right-hand parts of his brain, so using technology to create artistic effects is perfect!

By combining three differently exposed shots of this archaeological lime kiln, a single HDR image has been created that shows details in both the light and dark areas.

68     LXF272 February 2021

photo stacking where you need to adjust the settings between shots. The good news is that tripods don’t necessarily cost a fortune, and while a £2 spider type tripod won’t be too sturdy, proper tripods start at less than £10. For optimum results, if your camera supports one, you might also chose to use a cable release or a wireless remote control to further minimise movement. Before taking a look at our first type of photo stacking, we’ll explain how to correct the registration between shots if they don’t line up correctly. Our main emphasis is a manual approach to photo stacking using layers in a photo manipulation package such as GIMP. Here you’ll be importing each image as a different layer in GIMP. With the exception of the first one, as you import each layer, make it partially transparent and move it around while zoomed in, so that it lines up with the others that are already aligned. Finally, adjust the Opacity setting back to 100 per cent. Alternatively, there are automated tools for doing this – see Automated Approaches box (page 70) – and there are GIMP plugins available to help with this stage.

Focus stacking Our first reason for stacking photos is to achieve a good depth of field or, to use a less-technical term, to ensure that all parts of the image are in focus, irrespective of their distance from the camera. In normal photography, the depth of field can be improved by selecting a small aperture if your camera or phone offers this functionality. However, this only goes so far. We discovered this while attempting to capture scenes in a bluebell wood. With a viewpoint close to the ground so some of the bluebells would be quite prominent, it wasn’t possible, however small the aperture, for the flowers in the foreground right through to the trees in the background to all be in focus. Macro photography – that’s photographing small objects, which invariably means shooting at a very close range – poses similar problems and is probably the most common reason for focus stacking. In cases like these the solution is to take several photos, each focused at a different distance, and to combine them. In the simplest of cases it might be necessary to take only two shots – one with the

www.linuxformat.com


TUTORIALS Apple Mac emulation Credit: https://basilisk.cebix.net

BASILISK II

Emulate classic Apple computers Les Pounder goes back to his distant college days and reveals how to emulate the Apple desktop machines that he used for work and play. pple Computers was founded on 1 April, 1976, by college dropouts Steve Jobs and Steve Wozniak. From these humble beginnings we now have a brand that is just as much about style and design as it is computing prowess. Apple Computers’ first computer was the Apple I. In 1977 the Apple II was released and it soon found its niche in US schools. After this we saw the Apple Lisa (1983), a merging of the Apple II aesthetic with what would become the Macintosh range of machines. Sadly Lisa was a flop, but in 1984 we saw the introduction of the Macintosh range with the Macintosh 128. This small machine changed the fortune of Apple and it started a range of Macintosh machines that exists to this day, in the form of the iMac. In this tutorial we’ll take a look at the classic era of Apple Machines.

A

OUR EXPERT Les Pounder is associate editor at Tom’s Hardware and a freelance creative technologist. You can read his blog at bigl.es.

An Apple a day

HyperCard has a text-based language – HyperTalk. Click Objects>Button Info>Scripts to edit the HyperTalk code to quickly add features. The syntax is easy to read and is more akin to reading instructions than code.

The Macintosh Classic design existed over multiple generations of Apple desktops.

There are many ways to emulate an Apple machine, and one of the most popular is to use Basilisk II which is an emulator for Apple machines using the Motorola 68000 series CPUs. This was the pre-OS X era, an era where this author was at college and using System 7.5 OS and Netscape Navigator to go online. To install Basilisk II on our Ubuntu machine we downloaded the latest release from https://launchpad.

Creating a Hardfile gives us a virtual hard drive on which to install the OS. We only need 500MB for a power system.

net/ubuntu/bionic/+package/basilisk2, then opened a terminal in our Downloads folder and installed the package using the following: $ sudo dpkg -i basilisk2_0.9.20120331-4_amd64.deb

Once installed, open the Basilisk II application: $ BasiliskII

We immediately see the Basilisk Settings page which has a series of tabs used to group settings by function. Go to the Memory/Misc tab and in the ROM file setting instruct the program where to find a ROM file for the Mac that we’d like to emulate. Typically, these ROMs are obtained by dumping them from real hardware, but they’re available online. Remember that ROMs are under copyright. Point the ROM file setting to your ROM and then set the RAM, model and CPU type for your emulation. The next step is to go to Volumes and click Create. Navigate to a folder where you wish to create a Hardfile – this is a hard drive image saved as a single file. Name the file as you wish (we chose harddrive), and set the size of the drive in MB before clicking OK. Remember that in the System 7.5 era of computers, a 1GB drive was still a dream to most users. Around 512MB is plenty for an install. After clicking OK the hard drive is created, and we have an unmounted volume to install software. What we need now is a System 7.5 install CD. Again, these are copyrighted. If you have the CD then you can create an

CREDIT: Danamania, CC BY-SA 2.5, https://commons.wikimedia.org/wiki/File:Macintosh_Classic_2.jpg

72     LXF272 February 2021

www.linuxformat.com


TUTORIALS Docker insights Credit: www.docker.com

DOCKER

Getting to grips with Docker People think of Docker as a server-room only tool, but as Michael Reed demonstrates, the platform has a lot to offer the general user, too. his month’s tutorial will hopefully show you that Docker is nothing to be afraid of, and once it’s installed you can start doing some cool stuff using just a handful of commands. You can use it for hosting your own servers, but it’s also handy for quickly summoning up an isolated shell for experimentation. For the uninitiated among you, let’s get into what Docker is and why it’s such a useful tool for all Linux users. Docker manages so-called containers. These containers are sandboxed processes that seem, to the applications and services within them, to be complete Linux systems. So far, this might sound like we’re describing virtual machines (VMs), but there are important differences between containerisation and virtualisation. In the case of virtualisation, the virtualiser emulates the hardware of an entire computer, and this is resource intensive. With containerisation, a process contains the applications and services, and is separated from the rest of your system. By employing the features of the CPU and the Linux kernel, the host system is protected from whatever’s going on inside the container. You’re typically running the container as a normal user rather than as the system super-user, despite the fact you’re doing things like editing system files and installing Linux packages within the container. This approach takes a lot of the stress out of experimenting with servers and other projects, because containers mean you don’t have to make any changes to your host system. Docker containers are fast to deploy and use as well. If you know the right command, you could set up a shell in a fresh container and have it up and running in a few seconds. Beyond security and speed of deployment, there are other advantages of containerisation such as performance benefits. Imagine an application, perhaps a server, that requires around, at peak, 500MB of RAM to run. If this is running inside a virtual machine, the virtualiser has to emulate an entire computer running an operating system of its own. However, when using a Docker container instead of a virtual machine, the memory overhead would consist of merely the application itself along with its dependencies and a small amount for the container.

T

OUR EXPERT Michael Reed has been playing around with Linux since first trying Slackware back in 1996.

Go to https:// hub.docker.com, click Explore and check out the fascinating array of premade images. The Hub is organised into categories, so you should be able to find anything that you’re looking for, or perhaps, you’ll come up with some crafty ideas you’d never considered before?

76     LXF272 February 2021

The WordPress installation page. Docker is an excellent environment for hosting a content management system (CMS) such as WordPress.

The final important Docker concept we’re going to cover here is that of packaging images. You can customise the environment inside a container and install software, as with any other Linux environment, and then package it. This makes it possible to make a useful setup available to other people, via the cloud or file downloads, and then it can be deployed, by them, with a single command. But before we get onto the heady heights of doing that (and we will), let’s play around with Docker itself…

Getting started with docker Start by installing Docker using the package management tools of your chosen Linux distribution ( sudo apt install docker in Ubuntu Linux, for example). We can test the Docker installation with a simple command sequence: docker run hello-world Hopefully, you’ll be greeted with a welcome message informing you that your Docker installation is working. If you receive a message about not being able to connect to the Docker daemon at this point, don’t worry. We found that most distributions don’t add the basic user to the docker group, and we’ll do that now. Note, that you can skip this step if you want to, but if you do, you’ll have to use Docker as a super-user for most operations. The actual procedure might vary between distros, but this sequence works fine with Ubuntu and Fedora,

www.linuxformat.com


THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET

HotPicks

Alexander Tolstoy feels his heart skip a beat as he looks over another set of gorgeous open source applications!

Waterfox Songrec Xsuspender WinApps Dog YUView AFTL PixelDefence Micro-racing Distribyted Topalias WEB BROWSER

Waterfox Version: g3.0.0 Web: www.waterfox.net ime for a privacy talk. As long as we spend lots of time browsing the web, then that’s largely a web browser talk. Anyone running Linux knows there’s a wide variety of browsers for any taste, but opening the hood reveals a much narrower choice: either the Chromium engine or the much weaker WebKit engine. Thankfully there is a third way: Firefox is a highquality mainstream browser. Mozilla says it cares about privacy, but there are also third parties developed forks of Firefox with enhanced privacy settings. One of the best of these forks is Waterfox, which all Firefox lovers should definitely give a try. The main difference between the original and its scion is that the latter strips off telemetry, doesn’t ‘phone home’ and limits data collection where possible. Sounds nice, but there are already many other Firefox clones with similar customisations (LibreWolf, say). However, Waterfox has got something else: it removes Mozilla’s control over what extensions you can and can’t run. Waterfox restores the use of (the security flawed – Ed) 64-bit NPAPI plug-ins and enables users to install both web extensions and legacy Firefox add-ons. That said, if an extension/add-on gets rejected by Mozilla, it can still land somewhere else, like the Waterfox-backed add-on store (legacycollector.org). The new generation of Waterfox (g3.x) has kept the promise to retain all those classic compatibility features while switching to the newer Gecko 78 engine. We were impressed with this browser’s performance. With Waterfox, you have access to a well-supported and updated Firefox-like browser that can still run the huge heritage of legacy Firefox add-ons. With titles like ClassicThemeRestorer, you can make Waterfox look like an early Firefox 3.x application, knowing it’s up-to-date under the bonnet. Web sites often detect Waterfox as an older Firefox ESR release, but Waterfox is not Firefox ESR, it receives security and feature updates from its own update channel. Looking for a customisable and less bloated Firefox? Try Waterfox!

T

www.techradar.com/pro/linux

This ‘less telemetric’ browser has a large and passionate community that provides support for those users who are new to Waterfox.

Exploring the Waterfox interface... 4

1 2

5

3

The familiar interface The interface looks modern, but the browser also supports the XUL and XPCOM add-ons, plus lots of extensions.

1

More add-on options 2 You can install modern-day Mozilla extensions as well as hundreds of legacy addons and extensions that Mozilla has left behind. Waterfox is all for compatibility! New generation of browser offering 3 massive updates Gone are the days of sites telling you that your

Firefox is too old – Waterfox g3.x sports the Gecko 78 engine under the bonnet, which is faster and more feature-complete. Library and sync are available Waterfox provides the same level of access to the usual Firefox features, including downloads, history and bookmarks. Firefox Sync also works here!

4

Main menu with more browser features Access current web page settings and tools, customise the browser’s behaviour, manage log-ins and passwords from this menu.

5

February 2021 LXF272     81


CODING ACADEMY CODING ACADEMY Assembly language

ASSEMBLY LANGUAGE

The code

Get it from linuxformat. com/archives and on the DVD

Get coding on the Raspberry Pi 64-bit

John Schwartzman demos using assembly language code for the 64-bit Raspberry Pi to call Linux kernel services and the C run-time library. earning assembly language won’t make you a faster programmer (slower, more likely). However, it just might make you a better programmer. By learning just what a processor can and can’t do, you’re on the way to a deeper understanding of computer science. Assembly language is a low-level language. It’s specific to a particular processor. You use it to program a specific processor at the hardware level. Compilers understand assembly language, because that’s what they use to create the instructions in high-level languages. Take a C++ compiler: it strings together lots of assembly language instructions to do its work. Every kind of program ultimately executes machine language on the computer. Assembly language is simply machine language with mnemonics. Mnemonics are names given to machine language instructions, also known as op codes, so that we don’t have to remember hundreds of numeric values. It enables us to write a program using identifiers such as ADD, SUB and MOV. Raspberry Pis can run in 32-bit mode (AArch32) or 64-bit mode (AArch64) depending on the OS. In this tutorial we’ll look at AArch64 and install a small 64-bit desktop machine on the Pi. The Pi is a Reduced Instruction Set Computer (RISC) that performs smaller and faster operations than a Complex Instruction Set Computer (CISC) like the Intel x86_64.

L

OUR EXPERT John Schwartzman is a long-time engineering consultant to business and government. He also teaches computer science at a local college.

Making use of the kernel We’re using Linux and so the assembly language we write will use Linux kernel services. Even when we use the C library (glibc), the library methods we call will, in many cases, be thin wrappers around the Linux kernel services. It’s become obligatory to introduce every new programming language with a program that prints “Hello, world!” to the console, so we’ll start there. The screenshot (above) shows the program, hello.c and the screenshot (facing page) shows hello.asm, its AArch64 assembly language equivalent. At the command line in your hello working directory, type make release . Make invokes the gcc assembler to create the object file (hello.obj) from the hello.asm file and the LD GNU linker to create the executable (hello)

88     LXF272 February 2021

Hello.c is the obligatory first program in C.

from the object file. It also uses the GCC C compiler to build and link hello.c into the executable file a.out (assembler output). The command make clean will remove all of the build artifacts from the working directory. The screenshot (page 90) shows the makefile for hello. Each project in this series has a similar makefile and all rely on the bash shell script named maketest.sh in the parent directory. There is also a makefile in the parent directory that will make or clean all of the child projects at once. Execute a.out and hello and satisfy yourself that they do produce the same output. $ make release // Build the program as -o hello.obj hello.asm # assemble ld hello.obj -o hello # link gcc hello.c # compile and link C version (a.out) $ ./a.out // Run the C executable $$$ Hello, world! $ ./hello // Run the ASM executable Hello, world!

The outputs are the same. Let’s examine hello.asm. We start with some constant definitions in lines six through 10. The program has two sections: one for code ( .section .text ) and the other for read-only data ( .section .rodata ). Our code starts at the label _start (line 15). We load some of the processor’s registers in preparation for calling the Linux kernel. This is known as marshaling our arguments. A register is like a fast memory location that’s built

www.linuxformat.com


CODING ACADEMY Angry Birds

PYTHON

Remaking Angry Birds in Python The not-angry-at-all Calvin Robinson talks us through creating an opensource replica of the mobile game Angry Birds, entirely coded in Python. ngry Birds is a cult classic. Released for iPhone and iPad devices in 2009 and later for Android and other SmartPhone devices, Angry Birds has sold over 12 million copies worldwide. Like all good ideas, the gameplay mechanics behind Angry Birds are incredibly simple. The player controls a catapult that flings birds across the screen at a pile of blocks protecting enemy pigs. If a pig falls to the ground, or collides directly with a bird, they die. The aim of the game is to kill all the pigs before running out of birds. The player has a limited reference guide to adjust the direction of their throw – a parabola of sorts. Gravity and prediction play a large part in the success rate of this game. It’s incredibly addictive and therefore become massively popular. Angry Birds The Movie was released in 2016, followed by a TV series, and a whole heap of merchandise. What began as a little mobile game has become a household name. We’re going to have a go at programming our own version of this renowned video game in Python, as part of out retro game-building series. So far, we’ve built a lunar landing module game, a side scrolling platformer, Pac-Man, Pong, the Game of Life, Godot, a bunny shooter, Snap!, Noughts and Crosses and a racing car game. Now it’s time to build something physics based, with our first foray into a mobile game.

A

OUR EXPERT Calvin Robinson is a former assistant principal and computer science teacher with and a degree in computer games design and programming.

Try creating more content for the level. Adjust the x- and y-coordinates in the following code, where x=1000 and y=130 and each box is 100x100 in size: box = make_sprite(43, “images/ boxCrate_ double. png”,(1000, 130),self.space)

Get hold of Python We’ll need Python3 installed for this, along with a couple of modules to make life easier: Arcade and Pymunk. If you’re using a Debian-based distribution run sudo aptget update to get your package repository lists up to date, then sudo apt get install python3 pip3 to install Python and Python’s package manager. Once done, run pip3 install arcade pymunk to download and set up the modules we’ll need for this game. We are going to need images for this game. We’ve uploaded a folder to the Linux Format Archive and included a copy on the disc that came with this issue. Place these pictures into a folder called images and ensure that is in the same parent directory as your Python file. Create a new Python file angrybirds.py in your favourite text editor or Python IDLE. If using a text

92     LXF272 February 2021

Our game is set up and good to go. As you can see, the upset avian has been replaced with by cross blob, but the principle’s the same.

editor, remember to run the program with python3 angrybirds.py in Terminal when we move on to testing. If you’re using the Python IDLE, you only need to hit F5 to save and run when you want to test out the game. We’ll also be using PILL for image transparency. In effect, PILL enables the transparency layer of PNGs to be used in Python. Pillow tends to be installed by default, but if not, pip3 install pill ought to do the trick. Now that we have everything installed and ready to go, let’s begin coding. We’ll start as usual, by setting up our modules: import os import math import arcade import pymunk import timeit from PIL import Image

We’ve imported some basic Python modules: OS, Maths and Timeit, as well as the ones we mentioned earlier. The former modules will enable us to import images and use them as sprites, and also to calculate the physics used to move our bird, other creatures and objects in the game.

www.linuxformat.com


On the disc

DOWNLOAD YOUR DVD Get

code and DVD images at: www.linuxformat.com /archives

Discover the highlights from this month’s packed DVD!

START HERE USING THE LXFDVD

Using Linux for the first time can be very confusing. It’ll most likely be unlike anything that you’ve operated before, especially if you’re used to Microsoft Windows or Apple macOS. Generally our DVDs are designed to be run directly, which is to say that when you first power on your PC (or Mac, see below) it should ‘boot’ from the DVD – so before Windows or macOS even starts to load – with Linux running directly from the DVD. This trick is known as a Live Disc. It enables you to try out the various versions of Linux without having to install or change anything on your PC. Just remove the DVD, restart your PC and it’ll be exactly as you left it. While many systems will boot from a DVD when it finds one, many will not. See below for the standard process for enabling booting from a DVD on various desktops and laptop PCs. The alternative option is to locate the ISO file on the DVD and write this to your own USB thumb drive and attempt to run that. We recommend using Etcher from https://balena.io/etcher that’s available for Windows, macOS and Linux. Good luck!

FERAL FELINES MIN SPECS: 2GHZ CPU >> 4GB RAM >> 25GB DISK

Ubuntu 20.04.1 es, we know, Ubuntu 20.10 is out (and it won’t be that long until 21.04 is released, but remember we write from long in the past Covid-covered mid-December). Still, if you’re looking for a swift, stable OS that you can keep relying on till 2025, then this is it. With this August point release the usual huge package upgrade post-install will be a little less huge. If you have the bandwidth though, do check for a second point release. Also on the cards will be the HWE (hardware enablement) packages, which will suit people with modern hardware. Hybrid graphics (the scourge of laptop users) should work much better with this release. If you have such hardware you can right-click an application and choose to run it on the dedicated GPU for extra power. If you have a fancy GPU (desktop or laptop) then the bundled version of the multimedia FFMPEG library has all the bits required to use it for speedy video (de) compression. If you’re feeling adventurous, there’s an option to install using the ZFS filesystem, though this should still be considered experimental. A great deal of kinks in the Gnome desktop (which Ubuntu re-adopted with 17.10)

Y

BOOT THE DISC

Many PCs should boot automatically if they’re turned on with a disc in the drive. If not, many offer an early Boot Menu accessed by tapping a key while powering up from cold: F9 (HP), F12 (Dell, Lenovo), F8 (Amibios) or F11 (Award BIOS). Alternatively, use the BIOS/UEFI to adjust the boot order to start with the optical drive. Again, this is accessed by tapping a key during power up, usually Del but sometimes F1 or F2. Some new UEFI PCs require access via Windows: holding Shift select its Restart option. If you’re still having problems using the DVD then visit www.linuxformat.com/ dvdsupport Mac owners: Hold the C key while powering on your system to boot from the disc.

96     LXF272 February 2021

64-bit

have been ironed out so you should find version 3.36 to be smooth, responsive and not at all the resource glut that naysayers would have you believe it to be. In this edition Snaps continue to take centre stage. This means you don’t have to mess around with PPAs or whatever if you want newer software than the traditional Ubuntu repositories provide. So the latest versions of popular applications like Blender, Spotify and VSCode are just a click away. Traditionalists needn’t worry though. Apt and ye olde repositories are still there. And a lot of software is still only available in this form, and some is available as both. If you’re coming from a previous version of Ubuntu, you’ll enjoy the new, bold Yaru theme. Like Neapolitan ice cream it comes in three flavours, though these are Light, Standard and Dark as opposed to the pink, yellow and brown hues suggested by that poor analogy. Apparently lots of people have problems relating to corrupt installation media, so Ubuntu now checks its integrity before booting. This will take some time and can be skipped with Ctrl-C, but you should let it complete, at least once. Ubuntu integrates with Google’s groupware suite or Microsoft Exchange (if you really want it to), but it also works beautifully with the open source Nextcloud. Which you would rather use after seeing what it’s capable of (entirely replacing centralised, proprietary cloud services) in our Pi tutorial. Honestly we still don’t know why you’re still reading, just go try it already! The feline in Focal Fossa is Felicity. Find more focal-themed wallpapers at Unsplash, a royalty free archive.

IMPORTANT NOTICE!

DEFECTIVE DISCS: For basic help on running the disc or in the unlikely event of your Linux Format coverdisc being in any way defective, please visit our support site at www.linuxformat.com/dvdsupport. Unfortunately, we’re unable to offer advice on using the applications, your hardware or the operating system itself.

www.linuxformat.com


9000

POWER-UP

YOUR VMs Orchestral (Virtual) Machines in the Docker is a terrible pun but here we are… we look at VM orchestration.

LXF2e7on3

will b ay sale Tuesd 9 February 2021

The #1 open source mag Future Publishing Limited, Quay House, The Ambury, Bath, BA1 1UA Email linuxformat@futurenet.com EDITORIAL Editor Neil “my shed’s Santa’s grotto” Mohr Technical editor Jonni Bidwell Art editor Efrain Hernandez-Mendoza Operations editor Cliff “mmm, Pringles” Hope Group editor in chief Graham Barlow Senior art editor Jo Gulliver Editorial contributors Mats Tage Axelsson, Mike Bedford, Neil Bothwick, Matthew Hanson, Jon Masters, Nick Peers, Les Pounder, Michael Reed, John Schwartzman, Shashank Sharma, Calvin Robinson, 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. Ubuntu is a trademark of Canonical Limited. We are not endorsed by or affiliated with Canonical Limited or the Ubuntu project.

ADVERTISING Media packs are available on request 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 Linux Format is available for licensing. Contact the Licensing team to discuss partnership opportunities. Head of Print Licensing Rachel Shaw licensing@futurenet.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 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 Chief content officer Aaron Asadi Editorial director William Gannon Brand director Andy Clough Head of art & design Rodney Dive 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.

Open source game engines Gaming is big business and occasionally fun too. Discover how you can get started with the best game engines around.

Do the Samba It’s back-to-basics time as we cover network shares using Samba and Active Directory domain control.

Interrogate satellites Look at them up there, orbiting around us like the Sun shines out their antennas. Let’s find out what they’re transmitting.

Disclaimer All contents © 2021 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: Here’s to having a better new year in 2021. We are committed to only using magazine paper which is derived from responsibly managed, certified forestry and chlorinefree 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.

Switch to the ZFS With zetabytes of storage you need the right file system to help you out, but is the ZFS right for you? We have all the answers… Contents of future issues subject to change, much like our waist measurements after Christmas dinner.

98     LXF272 February 2021

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 Rachel Addison Tel +44 (0)1225 442244

Profile for Future PLC

Linux Format 272 (Sampler)  

You can subscribe to this magazine @ www.myfavouritemagazines.co.uk

Linux Format 272 (Sampler)  

You can subscribe to this magazine @ www.myfavouritemagazines.co.uk