Linux Format 265 (Sampler)

Page 1

3

5

Krusader 2.7.2 Ranger 1.9.3

0OOKS £5 EB

4

4Pane 6.0 2 Dolphin 20.04 Midnight Commander 4.8.24

EE FR

1

OF

TESTED: FILE MANAGERS

PLUS!

HOW TO…

!

SOLVE LINUX PROBLEMS SYSTEM MONITORING CREATE EBOOKS

3.7GB

DOWNLOAD Linux Lite Pop!_OS

The #1 open source mag

NEXT-GEN DISTROS Discover the powerful and friendly new stars of the Linux world! Endless OS 3.8 • Fedora 32 • Mint 20 • Pop!_OS 20 • Solus 4.1

FREE!

Worth £50

pages of tutorials & features

57

4 top ebooks

Over 700 pages

Build a Pi-based stop motion animation box

OpenUK

Amanda Brock on influencing governments for the good of open source

ARDUINO EMULATION

Don't buy more kit, run software simulations!

OPEN SOURCE PHONES

Enjoy privacy and freedom with the Purism Librem 5

Hack Google Stadia onto the Raspberry Pi Start coding with your own Pac-Man clone


Newsdesk

THIS ISSUE: European Parliament supports FOSS Tux powers SpaceX mission Lenovo embraces Linux GNOME patent case

OPEN SOURCE SOFTWARE

Open source to sweep across Europe European Parliament moves to strongly recommended all software development to be FOSS first. n 14 May the European Parliament moved to endorse a number of budgetary reports. This included strongly recommending that all software developed either for or by EU institutions should be released under a free and open source licence. This effectively means all IT solutions for EU bodies will first need to be assessed against using open source solutions and the results reported back to the Budgetary Control Committee of the Parliament on a yearly basis. Last issue, we reported how the Dutch Parliament has passed a law that software for government is required to be open source first and even the Munich City coalition has passed to push again for open source software use. This latest development would see all software created for the EU Parliament having to be open source unless a strong reason for being closed source can be demonstrated. Despite the opposition of certain right-wing parties, the budgetary reports were pushed through with the backing of the European Pirate Party. “From now on, the open source ecosystem has a stepping ground for offering open source solutions and the Pirates will gladly play the role of the guardians and will try to solve and highlight any attempt to bypass this strong recommendation. It’s a really important step to remove vendor lock-ins in the Parliament,” says Pirate vice-president of European Parliament Marcel Kolaja. More at https://bit.ly/lxf265eu. This demonstrates how the efforts of lobbyists influence government policies, and coincides with

O

6     LXF265 August 2020

this issue’s interview with Amanda Brock and her role at OpenUK. The organisation aims to gather support within the UK government for greater open source development. The Covid-19 pandemic highlights how important it is for governments to reliably call upon the cooperation of its citizens in tracking and eliminating virus threats with advanced tracking software. While making such software open source enables validation and analysis of the privacy issues of an app, it can’t stop governments from developing less-than-ideal solutions and then legislating for them to be used.

Public money, public code. It just makes sense, right?

“FROM NOW ON ,THE OPEN SOURCE ECOSYSTEM HAS A STEPPING GROUND FOR OFFERING OPEN SOURCE SOLUTIONS” The UK’s Covid-19 app is set to store data centrally, with a remit to retain all data with no option for users to opt out. So even though the software is MIT licenced its implementation is far from ideal. You can find a basic analysis at Privacy International (https://bit.ly/lxf265app) 1. The charity has also taken an in-depth look at the difficulties of tracking entire populations of humans: see https://bit.ly/lxf265covid 2. 1. https://privacyinternational.org/long-read/3752/coronavirus-tracking-uk-what-we-know-so-far 2. https://privacyinternational.org/long-read/3792/covid-contact-tracing-apps-are-complicated-mess-what-you-need-know

www.linuxformat.com


MAILSERVER

Mailserver

Write to us at Linux Format, Future Publishing, Quay House, The Ambury, Bath BA1 1UA or lxf.letters@futurenet.com.

WRITE TO US Do you have a burning Linuxrelated issue that you want to discuss? Write to us at Linux Format, Future Publishing, Quay House, The Ambury, Bath, BA1 1UA or email lxf.letters@ futurenet.com.

Buyer beware Would it help people to tell them that they can buy cheap Linux distros on eBay? They cost a couple of quid, which is nothing. Will you be doing more emulator articles in the future?

The Bionic Beaver will be with us, supported, for a good while yet.

Ian Learmonth

Neil says… I’m sure there are some eBay vendors who are genuine and are offering up-to-date, legitimate release of Linux distros on DVD or USB sticks, but I can’t help getting the feeling the most are just after making a quick buck with some old tat they threw together. Worse than that, you could be buying something dangerous or that doesn’t work at all. Why are you after a physical version of the distro? I’m intrigued? You’d be much better off working out how to download the latest build from the distro’s servers and donating some money to them. As for emulators I’m hoping to kick off a series on emulators in the next issue or so time.

32-bit is just resting I’ve been a user of Ubuntu for probably 10 years and a reader of your fine mag for five. I’ve just read your editorial of the September 2019 issue with its headline “Escape Ubuntu?”. I’m not a geek, I don’t run a business and I’m not a programmer. Instead, I just prefer using open source

Try and support your favourite distros.

10     LXF265 August 2020

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

deadly sins Q Seven I just converted a laptop with Windows 7 to Linux Mint 19.2 to bring new life to it. In the process I substituted the old internal HDD with a new SSD and installed Linux as the only OS of the disk. I then inserted the old Windows 7 disk into a USB external box to occasionally run applications not available on Linux. Basically I need the official iTunes application to manage paid songs downloaded for my iPhone. I tried sudo update-grub , but it’s not enough – the external disk never appears in the Grub menu at startup. Note that the Windows 7 OS on the HDD is fully functional (I can boot it if I change the boot priority from BIOS). Also, if I run Mint, the USB HDD NTFS filesystem is correctly mounted. Do you have some hints to make the external USB HDD dual boot with grub? Thanks a lot in advance. Keep going with your awesome mag. Alberto Caielli, Italy

A

I’m not entirely sure, but I think that the update-grub command these days should see your USB drive, so long as it’s mounted and the os-prober package is installed. If not then you can try and manually create an entry for the

Windows 7 partitions are a little bit simpler than Windows 10.

12     LXF265 August 2020

Windows drive in /etc/grub.d, but this can turn into a laborious process. Each entry in here will generate a stanza in /boot/grub/ grub.cfg when update-grub is run. So have a look at that file to see (vaguely) what you’re aiming for. One problem is that USB device ordering isn’t persistent, so you may not be able to run the (hd0,msdos1) syntax described below reliably. You can use UUIDs, but this requires getting your head around the search syntax in the config file. It’s worth experimenting from the Grub prompt (press C at the Grub boot menu with your USB disk plugged in) to see what Grub can access. First, see if the external disk shows up in the output of ls . You should see a device such as (hd1). (hd0) will almost certainly be an internal drive, as well as partitions on there such as (hd1, msdos1). To confuse the novice user, device labels start at 0 and partitions start at 1. If the drive doesn’t show up, try loading the USB mass storage module with insmod usbms and then trying again. You may also need to load a module for the USB interface, so you can also try insmodding (is that a real verb?–Ed) ehci as well. This all might go nowhere, or end up with all your device names being changed or disappearing, but don’t worry – everything will go back to how it was when you reboot.

Jonni Bidwell does not have all the answers

If you can access the drive, then chainloading Windows 7 from Grub should be quite straightforward: insmod ntfs insmod chain chainloader (hd1, msdos0)+1

If that works (and if it doesn’t this Gentoo wiki page has a few hints https://wiki.gentoo.org/wiki/GRUB2/ Chainloading) then “all” you need to do is incorporate that into a file in /etc/grub.d, (the 40_custom file is provided for this purpose). Start the stanza with menuentry “Windows 7” {

and then use the three commands above (or whatever else you used to get it working), and don’t forget the closing brace. Run grub-update and you should have access to Windows 7. Hooray?

the tunes on Q Get I’ve just switched back to Microsoft for compatibility of hardware/ DJing software, but would dearly love to use Linux for this as I’ve been running it for some years now. I’ve sent you some specs of a PC that I hope to build very soon – the best I can afford right now – for use as a DAWS (digital audio workstation). I’ve been using Mixxx until recently (I love this program), but I recently upgraded my DJ controller and don’t want to map it all out as I understand it’s a laborious process and I don’t really know what I’m doing! So I’m back to using Traktor software on a Native Instruments S3 controller. I also now dabble in Ableton Live from time to time. Short of running Windows in a virtual box which, would probably struggle to cope with the demands of the software, can you suggest any workarounds or setups that would enable me to use Linux in the DAWS with this software/ hardware? Note: I’m considering a separate SSD/HDD setup just for Linux within the PC and I have used Ubuntu Studio before. But it just kept freezing and crashing, so once bitten... Jason

www.linuxformat.com


REVIEWS Smartphone

Purism Librem 5

Yes, it’s an open source smartphone for the privacy- and security-conscious user, but is it easy to operate, asks Christian Cawley… SPECS

OS: PureOS CPU: NXP i.MX 8M quad-core 1.5GHz Cortex A53, 64-bit Arm GPU: Vivante GC7000Lite Mem: 3GB SSD: 32GB eMMC Screen: 5.7-inch, 720×1,440 IPS Baseband: Gemalto PLS8 or Broadmobi BM818 GPS: Teseo LIV3 GNSS Comms: 802.11n dual-band, Bluetooth 4 Ports: USB C (data, charge, DisplayPort), 3.5mm audio, microSD Camera: 13 MP LED flash (rear), 8MP (front) Sensor: 9-axis LSM9DS1 Battery: 3,500mAh, replaceable Size & weight: 150x75x 15.5mm, 230g

nnounced in 2017 as a crowdfunder that was impressively supported, Purism’s Librem 5 is a smartphone take on the Librem laptops. The device is equipped with kill switches and other privacy-enhancing measures, and has been positioned as the company’s solution to forced obsolescence, digital surveillance and the lack of a genuine Linux smartphone. The Librem 5 was released in late 2019 and was shipped to some but not all of its early supporters, and those who received the smartphone noted it sported fewer features than originally advertised. Review devices were suspicious by their absence, until six months later when we can finally examine the Librem 5 phone. Weighing in at 230g, the Librem 5 is a charcoal grey slab containing a quad-core processor, 3GB of RAM, and 32GB of eMMC storage, expandable to 2TB via microSD. The 5.7-inch 1,440x720px TFT IPS display looks imposing and the bezel is minimal. On the back is a removable cover, revealing the 3,500mAh battery. This can be swapped out with a replacement cell if necessary. Key to the Librem 5’s design is the trio of kill switches. There’s one each for Wi-Fi, mobile internet, and the camera and microphone, and when all three switches are activated the GPS is also disabled. There’s also a smart card reading slot. On the opposite side is the power button and a pair of volume buttons. The nanoSIM and microSD card slot is found alongside. At the base of the phone is the USB-C port, equipped for power, data and DisplayPort. Up top is a 3.5mm “Courage Jack” for headphones. Purism has “no intention” of locking you to a non-standard connector just to hook up some earphones, which is a welcome move by the company.

A

Performance General performance from the Librem 5 is decidedly average. Despite the crisp display and impressive hardware specs, key software is slow, and some basic functions have considerable room for improvement. Telephony, for example, works – but the speaker mode is

The Librem 5 might be too bulky for smaller hands.

16     LXF265 August 2020

The good news, you can make calls!

unusably quiet. The volume buttons make absolutely no difference. Call quality is fine, however. Network connectivity seems acceptable, and the phone swiftly connected to the local Wi-Fi router. Connectivity with other devices was less convincing, however. The boot time is impressive. Compared with an iPhone SE, the Librem 5 boots quickly, reaching the lock screen just ahead of the Apple device. Because it’s a Linux phone, there’s no real way to assess it using popular benchmarking smartphone tools like Antutu, but because the Librem 5 isn’t ready for prime time it would be unfair to benchmark it at this stage.

Battery life A stark reminder of the Librem 5’s beta status is the battery. Despite the hardware modesty compared to a standard iPhone or Samsung, the battery loses power at an almost impressive speed. With the current setup, the charge lasts just three to five hours. At least part of the power conundrum will be tied to the modem vendors chosen (Gemalto and Broadmobi). These are usually deployed in industrial equipment, so while perfectly functional will be harder to optimise for power consumption than other closed-source options. That’s not to say Purism isn’t working on the issue. It’s hired firmware developers to improve both reception and power use, but with the strict “no binary blob” imposed on itself, is rather restricted in its options. Some support was required from Purism to get the Librem 5 up and running. Following an initial successful boot, the phone rapidly lost charge. After several days of charging, it turned out that the phone refuses to charge while powered up. Furthermore, it emitted considerable

www.linuxformat.com


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

Roundup 4Pane Dolphin Krusader Commander Ranger

Midnight

Jonni Bidwell His co-workers have only seen him by video link and have been unable to pinpoint his location

File managers Known to be the subject of many files (most of them classified), Jonni Bidwell is here to show you how to manage yours…

HOW WE TESTED… We tried each file manager in Gnome (running on Ubuntu 20.04) and KDE Plasma running on an up-to-date Arch Linux. You may not want to install Krusader on Gnome, and you may not want to use a terminal file manager at all. But we did a variety of tasks in all of these settings. Searching on our disorganised drives for files, connecting to network servers we didn’t know were still working in the Future Towers basement… all manner of things that only foolhardy file wranglers would dare. We also hunted around for common gripes and remedies, had a long look at Github issues for each project, and even prepared a short quiz on each candidate’s keyboard shortcuts (which we duly failed). Of course, we also did all of the everyday housekeeping that makes up the vast majority of most people’s file manager usage, and hopefully we came to some conclusions that will in some way help most people.

22     LXF265 August 2020

he major desktops all have their own file managers. Gnome has Files (formerly Nautilus), Mint has Nemo, MATE has Caja. These are all excellent at doing bread-and-butter file management, and all have their own unique features, including file labelling, batch renaming, metadata editing, and searches that integrate with the desktop’s indexing. We could compare those, or include them, but then to one degree or another the comparison boils down to desktop philosophy. No one’s going to choose a desktop based solely on its file manager, and no one’s going to install, for example, Files on KDE (because

T

despite dragging in a bunch of Gnome libraries it won’t work quite the same). So here we’ll round up file managers that aren’t beholden (beyond perhaps requiring one of GTK or Qt) to a particular desktop. Be that as it may, we’ve included Dolphin (which historically wins these comparisons) and as we’ll see, can work just fine outside of KDE. We’ve chosen ones that are still actively developed, and we’ve got a mix of orthodox file managers (OFMs, having a dual column layout), classic ones (with a directory tree on the left) and hybrids. Despite this, we look forward to hearing what we should and should not have included.

www.linuxformat.com


File managers ROUNDUP

Features Why these candidates stand out from the file management mob. idnight Commander can, though it requires making oddlooking URI link such as ftp://user@remotehost, to connect to FTP and Samba shares. It can also do SFTP, or the slightly lighter FISH protocol. Indeed the latter was written specifically for Midnight Commander. Krusader adds NFS and WebDAV (for Nextcloud, say), but this is cheating slightly since it does so (like Dolphin) through KDE’s I/O “slaves”. If you add the Google Drive slave and add a Google account in the desktop, then you can access your drive manually in Krusader using the gdrive:// URI, but this option doesn’t appear in the connection dialog. Dolphin can do all of that too. In addition, it has a Network section in its bookmarks, which enables you to browse MTP devices and Windows networks. Midnight Commander’s User menu makes it possible to compress files and directories in a number of ways, and further operations can be added (see later). There’s a neat, but not very well-documented Panelize feature, which enables a panel to be populated with either the results of a search or the output of a program, so that the returned files can be worked on individually. 4panel has a mount menu that can mount network shares and ISO images. Ranger can preview text files in a separate column (or open them in your favourite text editor). Ranger aims for minimalism, recognising that other tools (such as the w3m console browser, an image viewer, and Atool for handling archives) already provide the most requested features and speed. Bulk renaming is ever so handy at times, particularly organising photos. Dolphin can give a bunch of files a uniform,

M

4Pane, Krusader and Ranger (using something like sxiv) all let you preview images inline. You can use ascii art if you want, too. Dolphin’s thumbnails are a little small.

numbered name, just select them and choose a prefix. For more advanced renaming, both Dolphin and Krusader can integrate with Krename. 4pane has its own custom renaming dialog, which can use regular expressions or more human-friendly schemes. Midnight Commander can bulk rename natively, and even recurse into subdirectories, but you’ll need to be brave with regexes to use this. Ranger has a :bulkrename command, which will open a text editor containing the selected filenames. You then input the new names, and thy work will be done. That’s no use if you have lots of files, but there are other tools that can help you there.

VERDICT 4PANE 8/10 MIDNIGHT COMMANDER 7/10 DOLPHIN 9/10 RANGER 7/10 KRUSADER 8/10 If you really want a feature in Ranger then you’ll have to add it yourself. Everything’s in Dolphin from the get-go

Ease of use Is the learning curve akin to scaling Mount Doom? he fact that Midnight Commander and Ranger are terminal applications will write them off for a lot of people. This is a shame, because it’s pretty intuitive to navigate around Midnight Commander and help is always on hand via the F1 key. Ranger is perhaps a harder sell, though if you already know Vim then you’ll be fine and if not, just press ? to access man pages, key bindings or commands. You can input Vimlike commands in Ranger, but it comes configured with Midnight Commander-style shortcuts. Dolphin is the easiest for beginners to get to grips with. It has an Undo function (as does 4Pane), and because it follows KDE’s theme, the toolbar icons are easy to understand, and it’s simple to set up bookmarks to commonly accessed folders or network shares. It can preview files if you set the icons large enough, and has a section for recently accessed files. Krusader supports tabs, but they feel slightly clumsy with the two-pane layout. If you’re familiar with Midnight Commander’s use of the function keys then good news, these work in Krusader. And if you’re not, then they are helpfully displayed along the bottom. The layout might feel a little claustrophobic on a small screen,

T

www.techradar.com/pro/linux

Despite its handy hints on startup, Midnight Commander, or indeed any terminal file manager, is not going to be easy to learn.

since each panel has four or five columns by default. 4Pane evoked memories of Windows 3.1’s File Manager, which will give some people a nostalgic feeling of home. But it’s deceptively powerful. Despite having four panes, the layout doesn’t feel cramped as long as you have enough screen estate, that is.

VERDICT 4PANE 7/10 MIDNIGHT COMMANDER 7/10 DOLPHIN 9/10 RANGER 7/10 KRUSADER 8/10 If you put in the effort, learning the ins and outs of Ranger will pay dividends.

August 2020 LXF265     23


SUBSCRIBE Save money today!

SUBSCRIBE

Sign up today and get your

Eclipse 3-Way USB Charger YOUR GIFT! WORTH £64.95

Don’t miss out,   subscribe now!

Product features Holds 6m of cable High-speed charging Smart-IC Technology Three devices at once No more messy cables

Charge multiple devices at maximum speed with the Eclipse 3-Way USB Charger. This easy-onthe-eye charger is a three-port USB charging hub that keeps 6m of cables neatly wrapped inside when not in use, while providing neat popup access with a gentle press of its top.

SUBSCRIBE NOW!

www.myfavouritemagazines.co.uk/lin/eclipse20

Call: 0344 848 2852 28     LXF265 August 2020

www.linuxformat.com


£9.99 offer p14 Go digital! p21

PLUS: Exclusive access to the Linux Format subs area! 1

! DON’T MISS s ar ye Now with 5 & r se U x of Linu Developer issues

CHOOSE YOUR PACKAGE! 6 MONTH PRINT ONLY

SAVE!

Only

22%

£32.50

6 month print  by Direct Debit (NO GIFT)

ANNUAL PRINT ONLY

PLUS! Only

PLUS!

SAVE!

20%

£67.00 Annual print  by Direct Debit

ANNUAL PRINT AND DIGITAL

Only

SAVE!

£72.00 58% Annual print and digital  by Direct Debit

This offer is only available for new UK subscribers. Gift is subject to availability (MSRP £64.95). Gift colour may vary. Please allow up to 60 days for the delivery of your gift. In the event of stocks being exhausted we reserve the right to replace with items of similar value. You will receive 13 issues in a subscription year. You can cancel your subscription within 14 days of purchase. Payment is non-refundable after the 14-day cancellation period unless exceptional circumstances apply. Your statutory rights are not affected. Prices correct at point of print and subject to change. Full details of the Direct Debit guarantee are available upon request. For full terms and conditions please visit www.bit.ly/magterms. Offer ends 30 September 2020. UK calls will cost the same as other standard fixed line numbers (starting 01 or 02) or are included as part of any inclusive or free minutes allowances (if offered by your phone tariff). Lines are open Tue to Thu 9am to 5pm.

www.techradar.com/pro/linux

August 2020 LXF265     29

1) Only available to MyFavouriteMagazines.co.uk subscribers.

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


NEXT-GEN DISTROS Step right up – LXF’s greatest showman Jonni Bidwell is here to unveil the finest Linux distros around!

ast your mind back 15 years, to that pre-credit crunch optimism of the mid-2000s. Windows users were appalled by Windows Vista, and this new Ubuntu operating system was claiming that it could displace Windows. This, despite being based on Linux (something you needed to have either contributed to yourself or subscribed to an arcane journal such as Linux Format to understand) and thinking that orangeybrown hue was a good desktop colour. Well, Windows may not have been wiped out by Ubuntu. But Linux has developed in leaps and bounds. It’s more

C

30     LXF265 August 2020

useable than ever and key industry players take it much more seriously now. Thanks to Valve and Vulkan, we can play thousands of Windows-only titles on our Linux boxes. More companies than ever are shipping Linux on consumer hardware. Your wireless hardware probably works with it. Best of all, there’s a fine range of distros to choose from. Ubuntu has always been a great place to start, but it’s not to everyone’s taste. Here, we present our pick of the next generation of distros, sure to ruffle a few feathers. Since making Linux easy is very difficult, we’ve got a section on useable distros, including our long-time favourite for beginners: Linux Mint.

Next, we’ll explore some of the bestlooking distros out there that will give you a truly modern desktop. In particular elementary OS, through its Pantheon desktop, is doing the unthinkable by making Linux simple, powerful, and – dare we say – at least a little bit Mac OS-like. Finally, we’ll look at distros that are leveraging the latest in open source technologies. You might not want these technologies (or so it seems by the number of complaints we get about Wayland, Systemd et al.). Or you might not be able to use your favourite software with them easily, but these will shape desktop Linux in the years to come.

www.linuxformat.com


Next-gen distros

Linux milestones

Many battles were fought – and coffee urns emptied – to get distros to where they are today. Here’s a quick recap… inux distributions have come a long way since the good old days. In the beginning, of course, there were no distros (actually in the beginning there was no Linux, and no space-time, then there was a big bang… – Ed). You’d start with the kernel, somehow bootstrap a barebones system, fetch some GNU tools, mess with the make files, compile those packages, install them, realise you’d got your Makefile wrong, tidy up the mess. Rinse, lather, repeat. It was great fun. More often than not you had to get these things on CD or even floppy disk in the post, unless you had access to the internet (or a friend in a computer science department). Then in 1992 came SLS, which inspired Slackware and later frustrated Ian Murdock into creating Debian. Yggdrasil, the first Linux live CD, was launched shortly after SLS, which required a gluttonous 8MB of memory and a gargantuan 100MB of disk space. The first stable version of Debian didn’t appear until 1996, by which time Red Hat Linux was on the scene and all of a sudden people realised there was money to be made with that thar Linux. It’s easy to overlook the contributions of those pioneer distributions, and other giants such as SUSE and Mandrake. And indeed those of lesser-heard ones such as Conectiva (a distant ancestor of Mageia that popularised Linux in South America). There’s a tendency to just focus on Ubuntu as the great humaniser of Linux. By the same token, there’s a tendency to dismiss desktop Ubuntu today as a sideshow to Canonical’s commercial success. Ubuntu continues to do great things for Linux, and is an excellent distribution for beginners and professionals alike. But what happened in the mid-2000s was pretty exciting. Suddenly, here was Linux that anyone could use. It did everything that Windows XP did (except maybe talk to your wireless device). There was an office suite that could mostly open Word documents. Finally, something was standing up to the Microsoft juggernaut… Things are different now. Microsoft’s attitude towards open source has changed and desktop computing isn’t the be-all and end-all it once was. In our LXF262 interview with previous Linux Format editors, they point out there’s no longer the threat to Linux that there used to be. The web is truly OS-agnostic, so there’s no danger of say, your bank not supporting you if you use Linux. We take for granted the ability to watch Netflix or play games, but this would have been unimaginable just a few years ago. Today Intel, Oracle and even Microsoft (sort of) now have their own Linux offerings. A few stand-out distros have emerged that have brought genuine innovation, whether technical or ideological, to the Linux world. So let’s have a look at some of them…

L

www.techradar.com/pro/linux

The Hardy Heron wallpaper (from 2008) was remastered for Ubuntu 20.04.

CHANGING TIMES Today Intel, Oracle and even Microsoft (sort of) now have their own Linux offerings SOLVING PROBLEMS Don’t worry if you think something’s not right with a particular Linux distribution. You’re entitled to a full refund after all. Only kidding. In 2012 even Linus himself raged at OpenSUSE developers when he discovered that adding a printer (on his daughter’s laptop) required the root password. Sometimes there are reasons why things are that way (in 2012 there wasn’t the notion of a privileged local user; it’s handled by systemd these days), sometimes it’s a genuine bug, and sometimes you’re just using it wrong. These days Linus is generally calmer (except perhaps on the subject of L1D cache flushing), and his recently purchased development machine (a Threadripper 3970X which you can read all about on ZDNet at www.zdnet.com/article/look-whats-inside-linustorvalds-latest-linux-development-pc) runs Fedora 32. And we’ll talk about that later on. We’ll also see how elementary OS is tackling unnecessary password requests over the page. There are plenty of ways to get help with Linux, and thanks to its popularity it’s highly likely someone has encountered your issue before you did. So your first act should be to always be to Google (or DuckDuckGo if you prefer–Ed) your problem. Beyond that, head to your distro’s forums and search there. If you still feel like you’ve hit a new issue then describe it as best you can, and check the forum’s guidelines about how to get and attach appropriate log files and hardware informations. Help the community help you.

August 2020 LXF265     31


OPEN BRITANNIA

Linux Format puts on its clean shirt and trousers to go on a VoIP call with Amanda Brock and discuss OpenUK, influencing government policy and how old we all are.

CREDIT: Amanda’s photo (with Kitten Dundee) was taken during lockdown as part of @onthedoorstepcrouchend photography project by Julie Kim Photography, May 2020.

38     LXF265 August 2020

www.linuxformat.com


Amanda Brock INTERVIEW manda Brock is CEO of OpenUK (https://openuk. uk), a new non-profit body focused on promoting Open Technology, but this is a recent appointment in a line of influential positions. She has a CV that includes open source advisory work at the United Nations Technology Innovations Labs, being a European rep for Open Invention Network (the largest defensive patent pool in the world) and being on an Open Projects Advisory for the OASIS Standards Body. She also spent five years as General Counsel for Canonical where she set up the legal function. Part of the reason Amanda is involved in so many projects and initiatives is apparent the moment the VoIP connection kicks in. Even a global pandemic can’t stop Amanda being a connector. She’s someone who enjoys talking to people and pulling others into the world of open source, and given the serendipitous way she caught the open source bug, we’re fortunate Tux tipped the scales of fate in our favour.

A

Linux Format: What made a commercial lawyer get involved with the open world? Amanda Brock: The honest truth is a job. I had joined something called Lawyers on Demand as the sixth lawyer on its books. It’s now a massive organisation – a new model for placing lawyers. I was placed in Canonical for three months. I was meant to go to another contract with Amazon to work on its new electrical retail device, which I’m assuming was the Kindle, but six weeks in, Canonical asked me if I’d like to stay. So first, I got a job in open source and, second, I fitted. I’ve never felt more at home anywhere than I did at Canonical. LXF: Have you always been interested in software and technology? AB: When I was at school, I was told to stay away from computers! When I was in fifth form in Scotland in about 1985-86, they had us coding for a term and, for some reason, not one of my coding programs ran. Ever. They couldn’t work out what it was. We were learning to code in binary; it was madness. I was told that computers just didn’t like me, and I should stay away from them. Later, when I joined Canonical as General Counsel, I contacted my old computer science teacher and he apologised. And my old high school is part of the kids’ competition we’re running this year. They run Ubuntu in the school now! At the time, I took my teacher’s advice, stayed away from computers and became a commercial lawyer. In 1996, I was just

www.techradar.com/pro/linux

joining a law firm as an IP, an intellectual property lawyer and they kept telling me that they were hiring me as an IT lawyer. I kept correcting them. In the end I gave in and joined as an IT lawyer. The firm sent me to Queen Mary University, to the Centre for Commercial Law Studies, where I completed a master’s degree over two years in intellectual property and IT. That included the first internet law course in the UK, and I ended up specialising in ecommerce and internet, and going to work for Dixons. I was on the team that created and managed Freeserve, the ISP. Canonical was my first software company. I like working with software engineers. I particularly liked open source. I got into the whole ethos behind it. LXF: So, why do we need OpenUK? And why do we need it now? AB: When I was first approached about it, my reaction was to say I wasn’t interested, we didn’t need OpenUK. Open is about global communities and that’s one of the things that I like about it, that people all over the world have the freedom to work together. Geography hasn’t been a boundary for people, which is great.

Brexit was the trigger, the risk of isolation, making sure that we’re a strong community and not fractured. I think we have amazing talent in the UK in Open, but that talent has rightly been focused on international projects and we don’t know each other geographically. We want to make sure there’s a cohesive, strong voice influencing government. We’re trying to build that in three ways. One is community, by running an active site with blogs and good social

MAKING THE OPEN SOURCE VOICE HEARD “I think we have amazing talent in the UK in Open, but that talent has rightly been focused on international projects and we don’t know each other geographically” My view shifted when I watched what was happening with Brexit. I joined OpenUK a year ago as a director, then became CEO. Now the European Commission’s Open Source Software (and Open Hardware) Beyond 2020 is finally putting its money where its mouth is, and looking at making open the way forward for the Commission and promoting its use across Europe. It has a report being worked on at the moment by Open Forum Europe. That’s about 400-500,000 Euros being spent on understanding Open better. I realised that the UK was going to get left behind as we exited Europe. We don’t have that same integration into government in the UK that we’ve had from a policy perspective in Europe. I don’t think the UK’s open source, open data and hardware communities’ voices have historically been very strongly heard here.

media, creating events and training, bringing people together and reaching out to people, and building community across the industry. Post Covid-19 there’ll be events. Second, making the UK a great place for Open through our legal and policy committee influencing legislation, public sector and policy. Third is learning. It’s something I’m passionate about. Making sure that we have the right educational tools in place for the next generation to come through understanding Open. We’ve got an impressive board in place. We met for the first time in January and it set our purpose, our vision and our mission. The purpose of OpenUK is “to develop and sustain UK leadership in Open technology”. That includes software, hardware and data. I would bet that we’ll include science formally at some point this year, but I think that makes OpenUK the

August 2020 LXF265     39


BROWSER WARS

2020

As Google Chrome crushes all its browser competition, Neil Mohr   takes an in-depth look at what makes a modern browser tick. e suspect most readers remember with bitterness and rolling of eyes the Browser Wars of the year 2000 (okay, perhaps it’s more like 1995, but we like round numbers). Back when websites were websites, adorned with user-unfriendly “Compatible with Netscape” logos and “Under Construction” animated GIFs, that took an age to load over crawling 56K

W

42     LXF265 August 2020

modems. Entire websites that only worked with a flashy plug-in, and Microsoft breaking standards left, right and centre to gain market share. Great days, if by great you mean awful. You have to hand it to Microsoft – and, indeed, Bill Gates – who foresaw the dominant role the web browser would play in the future, and yet still managed to throw away that market-dominating position to some underdog called Google.

Why does it even matter which web browser we choose? Why has the browser become so powerful? What makes a web browser tick, and is there really any difference between them? All of these questions and more will be answered as we dive inside the web browser, benchmark a bunch of them, and ask Jonni, “Should we be sticking with the browser shoved in front of us by globespanning corporations?” Hint: No.

www.linuxformat.com


Browser wars IN-DEPTH e’re not about to take you back to 1993 and explain the history of the world wide web, aka Web 1.0. That’s done and dusted – thanks, Tim Berners-Lee. We’re jumping straight into the “today” to explore what makes a modern web browser tick, because the differences are vast. The important question to ask is why? What has changed so much over the past 27 years or so that makes modern browsers so complex? To kick things off, and to perhaps whet your appetite, just considering the basic high-level functions of a web browser reveals a corresponding high level of complexity. Part of this is the network connectivity to fetch data via HTTP and associated protocols, before you can even consider displaying anything. Even at this stage in the explanations, what we need to understand is that the world wide web is a precarious stack of standards, piled on top of each other, and transmitted over an international-scale network. If any corporation or nation state decides that it wants to interfere with them, things quickly begin to fall apart. Just take DDoS attacks, or certain countries rerouting all traffic by abusing Border Gateway Protocol (PGP) hijacking. On a more relevant level, if a major browser provider wants to undermine open standards, it certainly can – and definitely has done.

W

Inside a browser

www.techradar.com/pro/linux

Mozilla champions an open internet and Firefox is at the heart of its campaign to get just that. Use it.

Same but different We’re going to largely ignore parts of this model, such as networking, the user interface, browser engine, and data storage. It’s not that they’re unimportant – that’s absolutely not the case – but they’re more openly duplicated between systems. Accessing the TCP/IP networking stack and requesting/sending HTTP is donkey work done by standard libraries. Finesses of a user interface are better left for a critical review or group test. And while we’ll mention browser storage, we’re not going into any deep analysis of it. This leaves us with the two main elements that dictate performance and compliance: the JavaScript engine and the rendering engine. We’re going to focus on the rendering engine because it’s big and complex. But why all the fuss in the first place – isn’t HTML just HTML? As we alluded to, the web and online applications are built on standards; in the case of HTML, it’s the World Wide Web Consortium, aka W3C, that defines the guidelines on what each HTML tag should do. The problem is, as with so many aspects of life,

USER INTERFACE DATA PERSISTENCE

The basic overview of a browser hasn’t changed much since the first ones launched in the mid-1990s, the main additions being support for processing JavaScript and local data persistence. Check out the diagram (see bottom right) to see how a browser is built. Networking: There’s a lot of fetching and carrying with a web browser. HTTP(S) is the core, but there’s FTP for file transfers, SMTP (largely unused) for basic email and DNS to look up URLs and request pages from the web server. Not to mention TCP/IP connections and packet transfers. User Interface You probably take it for granted, but the interactive decorations around the browser and additional features it may offer – such as bookmarks, history, password storage, and more – are all part of the interface. Browser engine This is less obvious than the rest, and refers to the intersection between the user interface element and the rendering and Java engine, while also linking to the data storage element. For maximum confusion, some projects refer to the browser engine, while others talk about the rendering engine. Data storage While this started with cookies, local data storage is far more important in modern browsers for use in local applications. Web Storage provides basic local variables, but Web SQL offers full local database features, with an Index database being a compromise between the two. JavaScript engine The programming language of the web, JavaScript enables interactive websites and dynamic content. While it’s designed to be interpreted, modern browsers use a Just In Time (JIT) compiler compiler that converts the script into machine code on execution/demand. Each major browser uses its own engine, which can offer a performance differential. Rendering engine The core block of any modern browser – we’ll take the majority of our time digging

into how this works, which will involve another block diagram. Effectively, this is two parsers: one processing the HTML and document object model (DOM) elements, and the other parsing the cascading style sheet (CSS) data. From this, a rendering tree is generated, laid out, and painted to the display.

BROWSER ENGINE

RENDERING ENGINE

NETWORKING

JAVASCRIPT ENGINE

UI BACK END

The basic blocks that go into powering a browser.

August 2020 LXF265     43


TUTORIALS TUTORIAL Prey

TERMINAL: NNN

Manage your files Shed your clunky graphical file management habits and let Jonni Bidwell show you the grown-up way to wrangle files ou’d think after this file management extravaganza of an issue (see Roundup, HotPicks) you’d think we’d have had enough. But no, it seems we’re hell bent on having you organise your files (it’s synchronicity, we plan nothing! –Ed) this month. So listen up. Nnn, or n cubed, bills itself as the fastest file manager ever written. It’s based on Noice, so the name is a recursive acronym for Nnn’s Not Noice. We really liked our terminal offering in the Roundup, Ranger, but nnn takes things to the next level. It’s written in C, and aims to have as small a memory footprint as possible. As a result, it’s pretty minimal and won’t be to everyone’s tastes. Heck, it doesn’t even have a configuration file, so if you want to change things you can do so through environment variables, plugins and command line switches. But let’s not get ahead of ourselves. You can install nnn in Ubuntu with:

Y

OUR EXPERT Jonni Bidwell uses vim and i3 on an Eee PC, counting his words using wc, regex marks the spot, but his time management’s not on a par with that of his files.

$ sudo apt install nnn

PLUGINS FOR NNN Nnn is tiny but highly extensible. There are several plugins available in the Git repo (check out the list at https://github.com/jarun/nnn/ tree/master/plugins, which also shows their dependencies), and even a script to install them easily. You can run this script directly (but even though it runs as your user it’s good practice to check it first) with curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/ plugins/getplugs | sh

This will install all the plugins in ~/.config/nnn/plugins. To use them we list them in the NNN_PLUG environment variable, together with a hotkey to invoke them. For example if you’ve got the mediainfo tool installed ( sudo apt install mediainfo ), invoke the mediainf plugin (which requires $PAGER to be set too) with: export PAGER=less export NNN_PLUG='m:mediainf’

then start nnn as normal. Now find a media file, hit ; to enter plugin mode, then hit m and you’ll see media information. You can make these variables persistent by appending them to your ~/.bashrc file. To use multiple plugins, delimit them with semicolons. You can write your own plugins in whatever language you like, but for reasons of purity POSIX-compliant shell scripts are preferred. Have a look at the provided ones to learn the ropes. Some of them are quite fun – who would’ve thought we’d finish this issue reading Gargantua and Pantagruel in a terminal file manager, via Project Gutenberg? (facepalm – Ed)

54     LXF265 August 2020

A logo involving both chess and mathematical notation? Shut up and take… oh, it’s free.

but you’ll get a slightly older version (3.0 if you’re using 20.04, as opposed to the current 3.2). If you want the latest and greatest you’ll find RPMs and DEBs in the releases section of the project’s GitHub at https:// github.com/jarun/nnn and you may as well just install that over the top of the one in the Ubuntu repos. The dependencies won’t change – all it needs is the C library and Ncurses. Check the wiki to see some of the other tools it can integrate with. Firing it up you’ll see that it is indeed fast, and it is indeed somewhat spartan. There’s only a single panel, which you can scroll with the cursors or Vim (or Emacs) navigation. Use the left arrow or backspace to go to the parent directory. If you’re using nnn in a fully fledged desktop environment then opening files (either with the right arrow or enter) will respect your file associations there, via the xdg-open helper. Here are a few handy shortcut keys to get you started, you’ll find the rest by pressing ?: ~ switch to your home directory @ switch to directory you launched nnn from - switch to last visited directory . show/hide dotfiles ! spawn a shell in the current directory Nnn supports up to four contexts, which are like tabs with memory (you can set them up to remember settings and locations). Those are the numbers in the corner, the current context (1 if you’ve just opened nnn) has its number highlighted with a blue background, and other contexts in use are underlined. Switch contexts using keys 1 through 4, you’ll see if you navigate somewhere in context 1, then switch to context 2 and navigate to a different place, then you can hop back and forth using the 1 and 2 keys. You can quit a context by pressing q, which will take you to the previous active

www.linuxformat.com


TUTORIALS Building eBooks Credit: https://sigil-ebook.com

SIGIL

Design and publish your very own eBooks Nick Peers reveals how to turn any creative writing endeavour into a digital book that you can share with friends, family and your adoring public. ver wanted to become a self-published author? Looking for a simple way to create a digital publication – whether book or magazine – that can be read on a variety of devices? The solution lies in creating your book in EPUB format, which formats your book using familiar web languages (XHTML and CSS). The resulting content is dynamic and responsive, meaning it can be viewed on screens both large and small without needing adjustment. The process of putting an EPUB document together from scratch might be daunting, were it not for the likes of Sigil (https://sigil-ebook.com), a powerful but userfriendly eBook editing tool. Even then, its array of features and options might be a little intimidating, which

E

OUR EXPERT Nick Peers dreams of republishing his best work in book (or eBook) format. If only he wasn’t so lazy…

Take the Sigil tour 1

2

3 5

6

Book Browser View, manage and access the individual files that make up the content of your eBook from here.

Formatting tools Select your text in Sigil’s code-editing view and use these buttons to style and format it quickly.

Edit pane Double-click any files inside Text or Styles to edit them. The tabbed view enables you to edit multiple files at once.

File versioning Use the Snapshots tool directly from the toolbar to create multiple versions of the same file.

Preview window Obtain a responsive view of how your book’s content – plus the Table of Contents – is looking.

3

56     LXF265 August 2020

$ git clone https://github.com/Sigil-Ebook/Sigil.git

This will unzip the contents into a folder called Sigil in your home directory. Time to build Sigil: $ mkdir ~/sigil-build $ cd ~/sigil-build $ cmake -G “Unix Makefiles” -DCMAKE_BUILD_ TYPE=Release ../Sigil $ sudo make $ sudo make install

Launch PageEdit This button opens whichever external HTML editor you link to Sigil – PageEdit if you follow our instructions.

2

$ sudo apt-get install build-essential git $ sudo apt-get install cmake $ sudo apt-get install qtbase5-dev qttools5-dev qttools5dev-tools qtwebengine5-dev $ sudo apt-get install python3-dev python3-pip python3-lxml python3-six python3-css-parser python3dulwich $ sudo apt-get install python3-tk python3-pyqt5 python3-html5lib python3-regex python3-pillow python3-cssselect python3-chardet

You’re ready to download the program’s source code:

4

1

is why we’ve done all the hard work for you, uncovering the key tips and techniques you need to create a book that can be easily shared or published digitally. Sigil can be installed through the Ubuntu Software Store, but the ubuntu-focal-universe version is outdated. Instead, be brave and install the latest version from source, which is simpler than you might think. If you’re running Ubuntu 18.04 or later, open a Terminal window and install the following dependencies:

4

5

6

Once installed, Sigil is accessible from the Application Launcher. It’ll open to display a three-paned window: on the left is the Book Browser, which contains all the elements that make up your eBook. You’ll see a series of folders, plus two documents: toc.ncx, which contains your book’s table of contents, and content.opf, which is where your book’s structure is defined (and which can be left untouched). More on all of this later. You’ll also see a series of folders, inside which you’ll find the individual files that make up your content – text (XHTML), styles (CSS), images, fonts and so on – are stored. You’ll see the Text folder contains one precreated element, Section0001.xhtml. This is currently displayed in the middle pane – the editing window – while the right-hand pane displays a real-time preview of your book’s page as you edit it.

www.linuxformat.com


HOTPICKS THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET

HotPicks

Neil Mohr is in the HotPicks seat which has been left nice and toasty– and well disinfected – by Tolstoy, who’ll be back next issue!

Inkscape Worker Birdfont PeaZip Mermaid Zeal Mixxx Stella BZFlag TheSSS Eqonomize

VECTOR DRAWING

Inkscape Version: 1.0 Web: https://inkscape.org ere you to ask an open source user to name three drawing packages, the third one they’d mention would very likely be Inkscape, after GIMP and Krita. However, it’s the only vector graphics package on that list. That makes Inkscape hugely important to the open source world and after 16 years of development it’s just turned the big 1.0. Getting hold of the latest build of Inkscape is about as easy as it comes. Inkscape offers builds in both Flatpak and Snap formats, which are now both widely supported. For Ubuntu users there’s a PPA that you can latch on to and obtain updates from, using sudo add-apt-repository ppa:inkscape.dev/stable sudo apt update sudo apt install inkscape The 1.0 release brings with it a host of low-level performance improvements together with some new high-level features. Core to any drawing package is smooth performance and overall you’ll find this release is the best performing release ever. Its interface has also been designed to work beautifully with HiDPI displays, which arty types (and many others) like to use. To coincide with this is a new theme system that bundles the on-trend Dark Mode, and there’s the option to create custom font directories and icon sets. One of the biggest feature changes is to Inkscape’s core Live Path Effects. There’s a new interface and reorganised toolbox that now enables you to make favourites or search it, together with a host of new effects. Again performance has been greatly improved, especially for node-heavy objects. Other new additions include a split-view canvas to preview as you edit, and pressure control of line widths. The option to vectorise line drawings could come in handy, and there are new fillet and chamfer tools, too. It’s a shame that Inkscape gets overshadowed by GIMP and Krita, but it’s almost inevitable that bitmapbased packages are most people’s primary choice for editing photography and comic-style art, while vector

W

60     LXF265 August 2020

Inkscape offers a professional-level vector drawing experience that’s well worth your time.

Get to know the Inkscape interface 1 2

5 3 4

Themes Overhauled for version 1.0 the Inkscape interface has full theme support–including a dark theme for better contrast–plus you’re able to adjust menu options.

1

Toolbar All your main tools are listed down here, you’re able to tweak this to include the ones you use the most or remove those you don’t.

2

Paths A vital element of any vector package are easy to manipulate paths and controls, version

3

one has had these and the effects you can apply hugely improved. Layers To make manipulating sections of your image easier Inkscape offers the classic Layer system, so you can hide and lock entire sections in one go.

4

Colour A vital element of any drawing tool are comprehensive colour selection, mixing and modes. Inkscape offers full RGB and CMYK colour modes.

5

www.linuxformat.com

CREDIT: Ianp5a CC BY-SA 3.0 https://inkscape.org/~Ianp5a

work has always seemed more complex to get started with. However, if you need to edit scalable vector graphics (SVG) then Inkscape should be your first choice.


TUTORIALS Circuit simulation Credit: www.arduino.cc

ARDUINO

Model and simulate your circuit projects He’s no fake, but Mats Tage Axelsson shows you around the intricacies of simulating your Arduino-based projects for better, error-free results. ou may have considered creating a project using either the Arduino controller range of boards or any of its compatible systems. If you have, but were put off by having to buy new hardware just to try it out, then why not simulate your idea before splashing out the cash? All the software you need is on Linux and you can see what the different boards are capable of beforehand. In this tutorial we’re going to learn what you can do with virtual boards and the right software. You can create all the components and connect them to your board, program the controller and see how it handles it. You have several CLI options including simavr, simulavr and a few others, too. There are many different packages available for designing the circuit. The main software for writing the sketches (what the code is referred to as) is the Arduino IDE. A graphical front-end is Simulide, which also can simulate ordinary circuits. Adding components is straightforward. You can measure voltages and display waves on an oscilloscope in the application. We’ll be looking at how to set up the software in this tutorial, step by step. To choose the correct board you’ll need to have a vision for what your project needs to do. You’ll use an Arduino type board for your projects, and there are many copies available. The Arduino platform is open source.

Y

OUR EXPERT Mats Tage Axelsson is keen to show you how using the Linux operating system can benefit your work and home life.

If you want to have many components available while you design a circuit, there are several online solutions. One of them is Upverter (https:// upverter.com). This site acts as a circuit design program with the added advantage of having many components available and updated continually.

Start small The Arduino Uno board is small and cheap. It makes sense to start learning with this model until you’ve become more experienced. We recommend choosing that one first and move on to larger projects later. The standard way to compile for the Arduino is to write a sketch in the Arduino IDE, which is a Java application. It enables you to handle all the tasks necessary for getting your project to a board. However, you may want to do this using other solutions. You can also rely on the compiler extensions from that package. The extensions are for the gcc suite of programs. You can do this by installing arduino-mk, which depends on arduino-core. These packages are there for people who use the command line for everything.

66     LXF265 August 2020

For successful simulation you’ll need a few more packages. Here, too, you have options. A good one is Simulide, a package that’s easy to set up and start creating your design. Compiling and upload to the simulator involves just a couple of clicks. You’re also able to use the Arduino core package for compiling. When you’re planning a new project, it’s good to test your ideas many times. You could either run cables and power your Arduino, or you can simulate your circuit. If you’re uncertain about which components to use, you can buy one of each, or stick to a simulation. Some uses are also available for more scientific cases. Here, you can use Octave to visualise and analyse your designs. For the music lover there’s also a connection to Pure Data. In this tutorial, you’ll create an Arduino circuit that flashes a light, and try to compile and run a simulation with this circuit. You’ll then have the knowledge to choose the method that best suits your way of working and your requirements.

Board to bits Once you have a board, you can program it using the Arduino IDE. But what can you do when you haven’t decided which board to use? You simulate the board! Either way, you need to start the programming as well as the connection of other components. Running the wires works as with other simulators using SPICE. For several of the tools, the Arduino core function compiles your sketches. The simplest is to choose a device and make a sketch that flashes the light on pin 13. Most, if not all Arduino boards have a built-in LED that correspond to pin 13. It’s the “Hello World” of Arduino boards. It’s also great for making sure that your simulator works before adding more components. More components leads to greater complexity. const int ledPin = 13; // Pin connected to LED void setup() { pinMode(ledPin, OUTPUT); // Set LED pin as output } void loop() { digitalWrite(ledPin, LOW); // Turn on LED

www.linuxformat.com


TUTORIALS System monitoring Credit: www.netdata.cloud

NETDATA

Monitor systems and Docker deployments Even when locked-down Mihalis Tsoukalos can still keep a close eye on all of his Linux systems and Docker images with Netdata. elcome to Netdata, software for distributed real-time performance and health monitoring of UNIX machines. Don’t you dare turn that page! A key advantage of Netdata is that it collects all of its metrics without introducing too much load on to the Linux machine that it runs on. In fact, most of the times you’ll forget that Netdata is running on a Linux machine – it’s only after you look at its impressive visualisations that you’ll remember the software is collecting, processing and visualising all these metrics! Another Netdata advantage is that it carries out real-time monitoring, so you can see what’s happening on the Linux machine at that time. Install Netdata using your package manager. On a Debian or Ubuntu Linux system you can install Netdata by executing apt install netdata . The configuration directory of Netdata is /etc/netdata, but you’ll also find plenty of useful files inside /usr/lib/netdata. By default, Netdata listens to http://localhost:19999, which is the first thing that you should try, to ensure that the Netdata installation was successful. The screenshot (right) shows the initial default screen, which is full of information. If you’re running Netdata on your own Linux machine, take the time to look at the Netdata visualisations. If you want to make Netdata available over your local network or the Internet, then you should change the value of “bind socket to IP” in the /etc/netdata/netdata.conf configuration file to the external IP of the machine and restart Netdata by executing systemctl restart netdata for the change to take effect. You can identify the version of Netdata you’re using by looking at the lower right-hand corner of the Netdata screen. We’re using Netdata version 1.12.0 in this tutorial.

W

OUR EXPERT Mihalis Tsoukalos is a DataOps engineer and a technical writer. He is also the author of Go Systems Programming and Mastering Go, 2nd edition.

Find out more about netdata at www.netdata. cloud and the documentation of netdata at https://docs. netdata.cloud. The GitHub repository of netdata is located at https://github. com/netdata/ netdata and the netdata Docker image can be found at https:// hub.docker. com/r/netdata/ netdata.

Measure the metrics

Netdata can collect and display a plethora of metrics – more than 1,000. The list of metrics includes those on the entire system, the CPUs, the memory, the disks, TCP/IP networking, Systemd, specific applications, users, the firewall, running containers as well as the operation of Netdata itself. The good news is that if you want to monitor something that’s not directly supported by Netdata, you can create you own metric collector using the Netdata

70     LXF265 August 2020

The initial screen of the Netdata web interface, which contains a plethora of information and is divided into three main parts.

plugin API. You can find more about that capability at https://github.com/netdata/netdata/tree/master/ collectors/plugins.d. The plugin API won’t be discussed in much detail in this tutorial. Finally, bear in mind that not every metric will help you solve a specific performance issue you might have. You’ll need to understand the metrics and select the ones that are related to your situation and observe them, before trying to troubleshoot your machines. What you already know is that Netdata reads metrics in real time from the machine that it’s running on and automatically creates visualisations with that data. Logically speaking Netdata can be divided into four components. The first component is the metrics collector whereas the second one is a memory time series database that stores the metrics. Note that the metrics aren’t written on disk, which means they’ll be lost if you reboot your machine or restart Netdata. However, using computer memory speeds things up. The third component is the metrics visualiser and the final component is the alarms notification engine. All these components, when combined, make up Netdata.

www.linuxformat.com


CODING ACADEMY CODING ACADEMY Create a Pac-Man game

PYTHON

The code

Creating Pac-Man style games in Python

Download from linuxformat. com/ archives

Pac-Man has earned its place in video gaming history. Calvin Robinson shows how you create your own version of the iconic arcade title. ac-Man is arguably one of the most famous video game characters in the world. First shooting to fame in 1980 with the release of the arcade version, Pac-Man has seen many iterations, remakes and sequels over the years, but nothing compares to the original. It’s a simple premise, really. Pac-Man is a yellow, disk-shaped, mainly feature-less character, who roams around a 2D environment collecting dots. The player has to collect all the dots in the room without being touched by any of the four enemy characters in the form of ghosts. Pinky, Blinky, Inky and Clyde are brightly coloured to stand out against the black background, being pink, red, cyan and orange, respectively. Pac-Man must avoid the ghosts and collect all the dots to progress to the next level. Pac-Man can only move up, down, left or right, through the maze of dots, but does have some advantages in his arsenal. By collecting large ‘power pellets’ Pac-Mac becomes energised and the ghosts all turn blue, enabling him to eat them on impact. The more blue ghosts you eat, the more points you get. As with all arcade games, the aim of the game is to get the highest score on the leader board. Originally called Puck Man in Japan because of the main character looking like a hockey puck, Pac-Man was renamed for Western audiences to avoid any dodgy naming issues. It’s fun and friendly, and potentially the first ‘inclusive’ video game, what with Pac-Man being designed to appeal to girls as well as boys, and to attract a younger audience.

P

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

Speed up Pac-Man by increasing or decreasing the ‘onkey’ values, at the bottom of our code (x,y). Remember that positive numbers move right or up, and negatives move left or down.

Working in Python Likewise, Python is an incredibly accessible programming language. In LXF262 we used Python to create a Lunar Lander Module game, and in LXF263 we created a side-scrolling game in Python. The original Pac-Man game was released between the two, Lunar Lander being 1979 and the first side-scroller being 1981. Python is perfect for our retro gaming projects. So let’s begin… We will, of course, need Python installed. We’ll use Python 3 for this tutorial. If you’re on a Debian-based

74     LXF265 August 2020

A vector based Pac-Man game developed in Python.

distro you can get set up with sudo apt-get update , followed by sudo apt-get install python3 . We’ll also be taking advantage of a vector graphics module linuxformat.py which can be found at the source code link on our Archives page at www.linuxformat.com/ archives. Once downloaded or copied, ensure linuxformat.py is saved in the same directory as the Python project we’re about to develop. Start a new Python file. Using your favourite text editor create an empty file and save it in the same folder as linuxformat.py, which we’ll be using as a reference module for vector graphics. When it comes to programming, there’s no point reinventing the wheel every time. Start your new document off with a new modular imports: from random import choice from turtle import * from linuxformat import vector

Next, we’ll want to declare and initialise all of our global variables: state = {‘score’: 0}

www.linuxformat.com


9000

CODING ACADEMY Data plotting

JAVASCRIPT

Turn your data plots into visual information Mihalis Tsoukalos explains how to create impressive visualisations with the JavaScript library D3.js and a big pile of data. his month’s coding tutorial is on D3.js, a powerful low-level JavaScript library that can create unique, highly customisable and impressive graphical output based on your data. For reasons of simplicity most of the examples shown here will include the data that will be visualised in the HTML file that contains the JavaScript code. However, D3.js enables you to read data from text files that reside either on your local machine or online. The D3.js (Data Driven Documents) library can be downloaded using a <script></script> tag in the HTML page that contains the JavaScript code. The code processes and creates your visualisations, so there’s no need to download it locally. Additionally, you’re free to read the JavaScript code of D3.js and make any changes or improvements you want to it! There are several advantages to using D3.js. First, it can create professional output on the fly without the need to store PNG and PDF files that you’ll have to embed into HTML code. Second, if you’re reading data from the Internet or from a local file that changes, a page refresh is enough to obtain the new data and automatically update the plots. Third, D3 can create animated and interactive graphics – and there are plenty of visualisations that can benefit from these two features. Finally, if you already know JavaScript, using D3 is straightforward as long as you’re willing to learn its rich API. When creating plots with D3.js, bear in mind that each D3 graph requires an HTML file that contains the DOM tree and the JavaScript code for manipulating the DOM tree and the data. If you’re familiar with JavaScript you might already know that you can organise your JavaScript code using multiple files that you can call using the <script></script> tag. However, this tutorial will put all JavaScript code in a single HTML file.

T

OUR EXPERT Mihalis Tsoukalos is a DataOps engineer and a technical writer. He’s the author of Go Systems Programming and Mastering Go. Get in touch with Mihalis at @mactsouk.

D3.js (https:// d3js.org) is a low-level JavaScript library, which means that you’ll need to write lots of code even for the simplest of the examples. On the other hand, D3.js gives you absolute control over the output.

Drawing the canvas The canvas is the area that you give D3 for drawing. It can be shorter than the browser windows, which is the norm. Note that the coordinates of the upper left corner of the canvas are always (0,0) whereas the coordinates of the bottom left corner are (0, height), whatever the

78     LXF265 August 2020

This shows the output of canvas.html that draws the entire userdefined canvas, which is available to D3.js for plotting its output.

value of the height variable is. The coordinates of the upper right corner are (width, 0), based on the value of the width variable, and the coordinates of the bottom right corner of the canvas are (width, height). The essential JavaScript job that does the job is svg.append(“rect”) .attr(“width”, width) .attr(“height”, height) .attr(“fill”, “orange”);

SVG stands for scalable vector graphics and is an XML-based vector image format. You can learn more about SVG at https://en.wikipedia.org/wiki/Scalable_ Vector_Graphics. Moreover, the size of the canvas is defined by two JavaScript variables: width and height. The names of the attributes for creating a rectangle, which also enable you to create a square, are also “width” and “height”. That rectangle is the canvas, which is going to be painted in orange. Explore the source code of canvas.html for more details. The output of canvas.html can be seen in the screenshot (above). This type of output can be handy when you’re drawing something using D3.js but you can’t see it on your screen. This is because it enables

www.linuxformat.com


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.